Package ugh.dl

Examples of ugh.dl.MetadataType


                }
              }
              field.setWert(myautoren);
            } else {
              /* bei normalen Feldern die Inhalte auswerten */
              MetadataType mdt = ughHelp.getMetadataType(this.prozessKopie.getRegelsatz().getPreferences(), field.getMetadata());
              Metadata md = ughHelp.getMetadata(myTempStruct, mdt);
              if (md != null) {
                field.setWert(md.getValue());
              }
            }
View Full Code Here


            try {
              /*
               * bis auf die Autoren alle additionals in die Metadaten übernehmen
               */
              if (!field.getMetadata().equals("ListOfCreators")) {
                MetadataType mdt = this.ughHelp.getMetadataType(this.prozessKopie.getRegelsatz().getPreferences(),
                    field.getMetadata());
                Metadata md = this.ughHelp.getMetadata(myTempStruct, mdt);
                /*
                 * wenn das Metadatum null ist, dann jetzt initialisieren
                 */
                if (md == null) {
                  md = new Metadata(mdt);
                  md.setDocStruct(myTempStruct);
                  myTempStruct.addMetadata(md);
                }
                md.setValue(field.getWert());
                /*
                 * wenn dem Topstruct und dem Firstchild der Wert gegeben werden soll
                 */
                if (myTempChild != null) {
                  md = this.ughHelp.getMetadata(myTempChild, mdt);

                  md.setValue(field.getWert());
                }
              }
            } catch (NullPointerException e) {
            } catch (UghHelperException e) {

            } catch (MetadataTypeNotAllowedException e) {

            }
          } // end if ughbinding
        }// end for

        /*
         * -------------------------------- Collectionen hinzufügen --------------------------------
         */
        DocStruct colStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct();
        try {
          addCollections(colStruct);
          /*
           * falls ein erstes Kind vorhanden ist, sind die Collectionen dafür
           */
          colStruct = colStruct.getAllChildren().get(0);
          addCollections(colStruct);
        } catch (RuntimeException e) {
          /*
           * das Firstchild unterhalb des Topstructs konnte nicht ermittelt werden
           */
        }

        /*
         * -------------------------------- Imagepfad hinzufügen (evtl. vorhandene zunächst löschen) --------------------------------
         */
        try {
          DigitalDocument dd = this.myRdf.getDigitalDocument();
          DocStructType dst = this.prozessVorlage.getRegelsatz().getPreferences().getDocStrctTypeByName("BoundBook");
          DocStruct dsBoundBook = dd.createDocStruct(dst);
          dd.setPhysicalDocStruct(dsBoundBook);

          UghHelper ughhelp = new UghHelper();
          MetadataType mdt = ughhelp.getMetadataType(this.prozessKopie, "pathimagefiles");

          if (this.myRdf != null && this.myRdf.getDigitalDocument() != null
              && this.myRdf.getDigitalDocument().getPhysicalDocStruct() != null) {
            List<? extends Metadata> alleImagepfade = this.myRdf.getDigitalDocument().getPhysicalDocStruct().getAllMetadataByType(mdt);
            if (alleImagepfade != null && alleImagepfade.size() > 0) {
View Full Code Here

  /**
   * alle Kollektionen eines übergebenen DocStructs entfernen ================================================================
   */
  private void removeCollections(DocStruct colStruct) {
    try {
      MetadataType mdt = this.ughHelp.getMetadataType(this.prozessKopie.getRegelsatz().getPreferences(), "singleDigCollection");
      ArrayList<Metadata> myCollections = new ArrayList<Metadata>(colStruct.getAllMetadataByType(mdt));
      if (myCollections != null && myCollections.size() > 0) {
        for (Metadata md : myCollections) {
          colStruct.removeMetadata(md);
        }
View Full Code Here

   * @throws TypeNotAllowedAsChildException
   */
  private DocStruct ParsenHeftzuordnung(DocStruct dsPeriodicalVolume, String myRight, DigitalDocument inDigitalDocument)
      throws TypeNotAllowedForParentException, MetadataTypeNotAllowedException, TypeNotAllowedAsChildException {
    DocStructType dst;
    MetadataType mdt = this.myPrefs.getMetadataTypeByName("CurrentNo");
    DocStruct dsPeriodicalIssue = null;
    /* erstmal prüfen, ob das Heft schon existiert */
    List<DocStruct> myList = dsPeriodicalVolume.getAllChildrenByTypeAndMetadataType("PeriodicalIssue", "CurrentNo");
    if (myList != null && myList.size() != 0) {
      for (DocStruct dsIntern : myList) {
View Full Code Here

    // myLogger.debug(myLeft);
    // myLogger.debug(myRight);
    // myLogger.debug("---");
    Metadata md;
    MetadataType mdt;

    // J: Zeitschrift
    // V: Band
    // I: Heft
    // Y: Jahrgang
View Full Code Here

      WrongImportFileException {
    // myLogger.debug(myLeft);
    // myLogger.debug(myRight);
    // myLogger.debug("---");
    Metadata md;
    MetadataType mdt;

    // J: Zeitschrift
    // V: Band
    // I: Heft
    // Y: Jahrgang
View Full Code Here

    return ergebnis;
  }

  private boolean isValidPathImageFiles(DocStruct phys, Prefs myPrefs) {
    try {
      MetadataType mdt = this.ughhelp.getMetadataType(myPrefs, "pathimagefiles");
      List<? extends Metadata> alleMetadaten = phys.getAllMetadataByType(mdt);
      if (alleMetadaten != null && alleMetadaten.size() > 0) {
        @SuppressWarnings("unused")
        Metadata mmm = alleMetadaten.get(0);
View Full Code Here

      String prop_doctype = cp.getParamString("validate.metadata(" + i + ")[@docstruct]");
      String prop_startswith = cp.getParamString("validate.metadata(" + i + ")[@startswith]");
      String prop_endswith = cp.getParamString("validate.metadata(" + i + ")[@endswith]");
      String prop_createElementFrom = cp.getParamString("validate.metadata(" + i + ")[@createelementfrom]");
      DocStruct myStruct = inStruct;
      MetadataType mdt = null;
      try {
        mdt = this.ughhelp.getMetadataType(inPrefs, prop_metadatatype);
      } catch (UghHelperException e) {
        Helper.setFehlerMeldung("[" + this.title + "] " + "Metadatatype does not exist: ", prop_metadatatype);
      }
      /*
       * wenn das Metadatum des FirstChilds überprüfen werden soll, dann dieses jetzt (sofern vorhanden) übernehmen
       */
      if (prop_doctype != null && prop_doctype.equals("firstchild")) {
        if (myStruct.getAllChildren() != null && myStruct.getAllChildren().size() > 0) {
          myStruct = myStruct.getAllChildren().get(0);
        } else {
          continue;
        }
      }

      /*
       * wenn der MetadatenTyp existiert, dann jetzt die nötige Aktion überprüfen
       */
      if (mdt != null) {
        /* ein CreatorsAllOrigin soll erzeugt werden */
        if (prop_createElementFrom != null) {
          ArrayList<MetadataType> listOfFromMdts = new ArrayList<MetadataType>();
          StringTokenizer tokenizer = new StringTokenizer(prop_createElementFrom, "|");
          while (tokenizer.hasMoreTokens()) {
            String tok = tokenizer.nextToken();
            try {
              MetadataType emdete = this.ughhelp.getMetadataType(inPrefs, tok);
              listOfFromMdts.add(emdete);
            } catch (UghHelperException e) {

            }
          }
View Full Code Here

            List<DocStruct> pageList = physical.getAllChildren();

            int indexToImport = Integer.parseInt(insertPage);
            DocStructType newPageType = prefs.getDocStrctTypeByName("page");
            DocStruct newPage = doc.createDocStruct(newPageType);
            MetadataType physicalPageNoType = prefs.getMetadataTypeByName("physPageNumber");
            MetadataType logicalPageNoType = prefs.getMetadataTypeByName("logicalPageNumber");
            for (int index = 0; index < pageList.size(); index++) {

                if (index == indexToImport) {
                    DocStruct oldPage = pageList.get(index);
View Full Code Here

            physicaldocstruct = this.mydocument.createDocStruct(dst);

            /*--------------------------------
             * Probleme mit dem FilePath
             * -------------------------------- */
            MetadataType MDTypeForPath = this.myPrefs.getMetadataTypeByName("pathimagefiles");
            try {
                Metadata mdForPath = new Metadata(MDTypeForPath);
                if (SystemUtils.IS_OS_WINDOWS) {
                    mdForPath.setValue("file:/" + inProzess.getImagesTifDirectory(false));
                } else {
                    mdForPath.setValue("file://" + inProzess.getImagesTifDirectory(false));
                }
                physicaldocstruct.addMetadata(mdForPath);
            } catch (MetadataTypeNotAllowedException e1) {
            } catch (DocStructHasNoTypeException e1) {
            }
            this.mydocument.setPhysicalDocStruct(physicaldocstruct);
        }

        if (directory == null) {
            checkIfImagesValid(inProzess.getTitel(), inProzess.getImagesTifDirectory(true));
        } else {
            checkIfImagesValid(inProzess.getTitel(), inProzess.getImagesDirectory() + directory);
        }

        /*-------------------------------
         * retrieve existing pages/images
         * -------------------------------*/
        DocStructType newPage = this.myPrefs.getDocStrctTypeByName("page");
        List<DocStruct> oldPages = physicaldocstruct.getAllChildrenByTypeAndMetadataType("page", "*");
        if (oldPages == null) {
            oldPages = new ArrayList<DocStruct>();
        }

        /*--------------------------------
         * add new page/images if necessary
         * --------------------------------*/

        if (oldPages.size() == this.myLastImage) {
            return;
        }

        String defaultPagination = ConfigMain.getParameter("MetsEditorDefaultPagination", "uncounted");
        Map<String, DocStruct> assignedImages = new HashMap<String, DocStruct>();
        List<DocStruct> pageElementsWithoutImages = new ArrayList<DocStruct>();
        List<String> imagesWithoutPageElements = new ArrayList<String>();

        if (physicaldocstruct.getAllChildren() != null && !physicaldocstruct.getAllChildren().isEmpty()) {
            for (DocStruct page : physicaldocstruct.getAllChildren()) {
                if (page.getImageName() != null) {
                    File imageFile = null;
                    if (directory == null) {
                        imageFile = new File(inProzess.getImagesTifDirectory(true), page.getImageName());
                    } else {
                        imageFile = new File(inProzess.getImagesDirectory() + directory, page.getImageName());
                    }
                    if (imageFile.exists()) {
                        assignedImages.put(page.getImageName(), page);
                    } else {
                        try {
                            page.removeContentFile(page.getAllContentFiles().get(0));
                            pageElementsWithoutImages.add(page);
                        } catch (ContentFileNotLinkedException e) {
                            logger.error(e);
                        }
                    }
                } else {
                    pageElementsWithoutImages.add(page);

                }
            }

        }
        try {
            List<String> imageNamesInMediaFolder = getDataFiles(inProzess);
            for (String imageName : imageNamesInMediaFolder) {
                if (!assignedImages.containsKey(imageName)) {
                    imagesWithoutPageElements.add(imageName);
                }
            }
        } catch (InvalidImagesException e1) {
            logger.error(e1);
        }

        // handle possible cases

        // case 1: existing pages but no images (some images are removed)
        if (!pageElementsWithoutImages.isEmpty() && imagesWithoutPageElements.isEmpty()) {
            for (DocStruct pageToRemove : pageElementsWithoutImages) {
                physicaldocstruct.removeChild(pageToRemove);
                List<Reference> refs = new ArrayList<Reference>(pageToRemove.getAllFromReferences());
                for (ugh.dl.Reference ref : refs) {
                    ref.getSource().removeReferenceTo(pageToRemove);
                }
            }
        }

        // case 2: no page docs but images (some images are added)
        else if (pageElementsWithoutImages.isEmpty() && !imagesWithoutPageElements.isEmpty()) {
            int currentPhysicalOrder = assignedImages.size();
            for (String newImage : imagesWithoutPageElements) {
                DocStruct dsPage = this.mydocument.createDocStruct(newPage);
                try {
                    // physical page no
                    physicaldocstruct.addChild(dsPage);
                    MetadataType mdt = this.myPrefs.getMetadataTypeByName("physPageNumber");
                    Metadata mdTemp = new Metadata(mdt);
                    mdTemp.setValue(String.valueOf(++currentPhysicalOrder));
                    dsPage.addMetadata(mdTemp);

                    // logical page no
                    mdt = this.myPrefs.getMetadataTypeByName("logicalPageNumber");
                    mdTemp = new Metadata(mdt);

                    if (defaultPagination.equalsIgnoreCase("arabic")) {
                        mdTemp.setValue(String.valueOf(currentPhysicalOrder));
                    } else if (defaultPagination.equalsIgnoreCase("roman")) {
                        RomanNumeral roman = new RomanNumeral();
                        roman.setValue(currentPhysicalOrder);
                        mdTemp.setValue(roman.getNumber());
                    } else {
                        mdTemp.setValue("uncounted");
                    }

                    dsPage.addMetadata(mdTemp);
                    log.addReferenceTo(dsPage, "logical_physical");

                    // image name
                    ContentFile cf = new ContentFile();
                    if (SystemUtils.IS_OS_WINDOWS) {
                        cf.setLocation("file:/" + inProzess.getImagesTifDirectory(false) + newImage);
                    } else {
                        cf.setLocation("file://" + inProzess.getImagesTifDirectory(false) + newImage);
                    }
                    dsPage.addContentFile(cf);

                } catch (TypeNotAllowedAsChildException e) {
                    logger.error(e);
                } catch (MetadataTypeNotAllowedException e) {
                    logger.error(e);
                }
            }
        }

        // case 3: empty page docs and unassinged images
        else {
            for (DocStruct page : pageElementsWithoutImages) {
                if (!imagesWithoutPageElements.isEmpty()) {
                    // assign new image name to page
                    String newImageName = imagesWithoutPageElements.get(0);
                    imagesWithoutPageElements.remove(0);
                    ContentFile cf = new ContentFile();
                    if (SystemUtils.IS_OS_WINDOWS) {
                        cf.setLocation("file:/" + inProzess.getImagesTifDirectory(false) + newImageName);
                    } else {
                        cf.setLocation("file://" + inProzess.getImagesTifDirectory(false) + newImageName);
                    }
                    page.addContentFile(cf);
                } else {
                    // remove page
                    physicaldocstruct.removeChild(page);
                    List<Reference> refs = new ArrayList<Reference>(page.getAllFromReferences());
                    for (ugh.dl.Reference ref : refs) {
                        ref.getSource().removeReferenceTo(page);
                    }
                }
            }
            if (!imagesWithoutPageElements.isEmpty()) {
                // create new page elements

                int currentPhysicalOrder = physicaldocstruct.getAllChildren().size();
                for (String newImage : imagesWithoutPageElements) {
                    DocStruct dsPage = this.mydocument.createDocStruct(newPage);
                    try {
                        // physical page no
                        physicaldocstruct.addChild(dsPage);
                        MetadataType mdt = this.myPrefs.getMetadataTypeByName("physPageNumber");
                        Metadata mdTemp = new Metadata(mdt);
                        mdTemp.setValue(String.valueOf(++currentPhysicalOrder));
                        dsPage.addMetadata(mdTemp);

                        // logical page no
                        mdt = this.myPrefs.getMetadataTypeByName("logicalPageNumber");
                        mdTemp = new Metadata(mdt);

                        if (defaultPagination.equalsIgnoreCase("arabic")) {
                            mdTemp.setValue(String.valueOf(currentPhysicalOrder));
                        } else if (defaultPagination.equalsIgnoreCase("roman")) {
                            RomanNumeral roman = new RomanNumeral();
                            roman.setValue(currentPhysicalOrder);
                            mdTemp.setValue(roman.getNumber());
                        } else {
                            mdTemp.setValue("uncounted");
                        }

                        dsPage.addMetadata(mdTemp);
                        log.addReferenceTo(dsPage, "logical_physical");

                        // image name
                        ContentFile cf = new ContentFile();
                        if (SystemUtils.IS_OS_WINDOWS) {
                            cf.setLocation("file:/" + inProzess.getImagesTifDirectory(false) + newImage);
                        } else {
                            cf.setLocation("file://" + inProzess.getImagesTifDirectory(false) + newImage);
                        }
                        dsPage.addContentFile(cf);

                    } catch (TypeNotAllowedAsChildException e) {
                        logger.error(e);
                    } catch (MetadataTypeNotAllowedException e) {
                        logger.error(e);
                    }
                }

            }
        }
        int currentPhysicalOrder = 1;
        MetadataType mdt = this.myPrefs.getMetadataTypeByName("physPageNumber");
        if (physicaldocstruct.getAllChildrenByTypeAndMetadataType("page", "*") != null) {
            if (physicaldocstruct.getAllChildrenByTypeAndMetadataType("page", "*") != null) {
                for (DocStruct page : physicaldocstruct.getAllChildrenByTypeAndMetadataType("page", "*")) {
                    List<? extends Metadata> pageNoMetadata = page.getAllMetadataByType(mdt);
                    if (pageNoMetadata == null || pageNoMetadata.size() == 0) {
View Full Code Here

TOP

Related Classes of ugh.dl.MetadataType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.