Examples of DocStruct


Examples of ugh.dl.DocStruct

    }
  }

  private List<String> checkSeitenOhneDocstructs(Fileformat inRdf) throws PreferencesException {
    List<String> rueckgabe = new ArrayList<String>();
    DocStruct boundbook = inRdf.getDigitalDocument().getPhysicalDocStruct();
    /* wenn boundbook null ist */
    if (boundbook == null || boundbook.getAllChildren() == null) {
      return rueckgabe;
    }

    /* alle Seiten durchlaufen und prüfen ob References existieren */
    for (Iterator<DocStruct> iter = boundbook.getAllChildren().iterator(); iter.hasNext();) {
      DocStruct ds = iter.next();
      List<Reference> refs = ds.getAllFromReferences();
      String physical = "";
      String logical = "";
      if (refs.size() == 0) {

        for (Iterator<Metadata> iter2 = ds.getAllMetadata().iterator(); iter2.hasNext();) {
          Metadata md = iter2.next();
          if (md.getType().getName().equals("logicalPageNumber")) {
            logical = " (" + md.getValue() + ")";
          }
          if (md.getType().getName().equals("physPageNumber")) {
View Full Code Here

Examples of ugh.dl.DocStruct

            metadataBean.createPagination();
        } else {

            Prefs prefs = metadataBean.getMyProzess().getRegelsatz().getPreferences();
            DigitalDocument doc = metadataBean.getDocument();
            DocStruct physical = doc.getPhysicalDocStruct();

            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);

                    // physical page no for new page

                    Metadata mdTemp = new Metadata(physicalPageNoType);
                    mdTemp.setValue(String.valueOf(indexToImport + 1));
                    newPage.addMetadata(mdTemp);

                    // new physical page no for old page
                    oldPage.getAllMetadataByType(physicalPageNoType).get(0).setValue(String.valueOf(indexToImport + 2));

                    // logical page no
                    // logicalPageNoType = prefs.getMetadataTypeByName("logicalPageNumber");
                    mdTemp = new Metadata(logicalPageNoType);

                    if (insertMode.equalsIgnoreCase("uncounted")) {
                        mdTemp.setValue("uncounted");
                    } else {
                        // set new logical no. for new and old page
                        Metadata oldPageNo = oldPage.getAllMetadataByType(logicalPageNoType).get(0);
                        mdTemp.setValue(oldPageNo.getValue());
                        if (index + 1 < pageList.size()) {
                            Metadata pageNoOfFollowingElement = pageList.get(index + 1).getAllMetadataByType(logicalPageNoType).get(0);
                            oldPageNo.setValue(pageNoOfFollowingElement.getValue());
                        } else {
                            oldPageNo.setValue("uncounted");
                        }
                    }

                    newPage.addMetadata(mdTemp);
                    doc.getLogicalDocStruct().addReferenceTo(newPage, "logical_physical");

                    ContentFile cf = new ContentFile();
                    cf.setLocation(filename);
                    newPage.addContentFile(cf);
                    doc.getFileSet().addFile(cf);

                }
                if (index > indexToImport) {
                    DocStruct currentPage = pageList.get(index);
                    // check if element is last element
                    currentPage.getAllMetadataByType(physicalPageNoType).get(0).setValue(String.valueOf(index + 2));
                    if (!insertMode.equalsIgnoreCase("uncounted")) {
                        if (index + 1 == pageList.size()) {
                            currentPage.getAllMetadataByType(logicalPageNoType).get(0).setValue("uncounted");
                        } else {
                            DocStruct followingPage = pageList.get(index + 1);
                            currentPage.getAllMetadataByType(logicalPageNoType).get(0).setValue(
                                    followingPage.getAllMetadataByType(logicalPageNoType).get(0).getValue());
                        }
                    }
                }
            }
            pageList.add(indexToImport, newPage);
View Full Code Here

Examples of ugh.dl.DocStruct

    public void downloadFile() {
        File downloadFile = null;

        int imageOrder = Integer.parseInt(imageSelection);
        DocStruct page = metadataBean.getDocument().getPhysicalDocStruct().getAllChildren().get(imageOrder);
        String imagename = page.getImageName();
        String filenamePrefix = imagename.substring(0, imagename.lastIndexOf("."));
        try {
            File[] filesInFolder = new File(metadataBean.getMyProzess().getImagesDirectory() + currentFolder).listFiles();
            for (File currentFile : filesInFolder) {
                String currentFileName = currentFile.getName();
View Full Code Here

Examples of ugh.dl.DocStruct

   * @see de.sub.goobi.metadaten.copier.MetadataSelector#createIfPathExistsOnly(CopierData,
   *      DocStruct, String)
   */
  @Override
  protected void createIfPathExistsOnly(CopierData data, DocStruct logicalNode, String value) {
    DocStruct subnode = getSubnode(logicalNode);
    if (subnode == null) {
      return;
    }
    selector.createIfPathExistsOnly(data, subnode, value);
  }
View Full Code Here

Examples of ugh.dl.DocStruct

   * @see de.sub.goobi.metadaten.copier.MetadataSelector#createOrOverwrite(CopierData,
   *      DocStruct, String)
   */
  @Override
  protected void createOrOverwrite(CopierData data, DocStruct logicalNode, String value) {
    DocStruct subnode = getSubnode(logicalNode);
    if (subnode == null) {
      try {
        // TODO: after merge of newspaper module the following three
        //       lines can be subsumed as:
        // subnode = logicalNode.createChild(docStructType, data.getDigitalDocument(), data.getPreferences());
View Full Code Here

Examples of ugh.dl.DocStruct

   *
   * @see de.sub.goobi.metadaten.copier.MetadataSelector#findIn(ugh.dl.DocStruct)
   */
  @Override
  protected String findIn(DocStruct supernode) {
    DocStruct subnode = getSubnode(supernode);
    if (subnode == null) {
      return null;
    } else {
      return selector.findIn(subnode);
    }
View Full Code Here

Examples of ugh.dl.DocStruct

     * @throws DAOException
     * @throws SwapException
     */
    public void createPagination(Prozess inProzess, String directory) throws TypeNotAllowedForParentException, IOException, InterruptedException,
            SwapException, DAOException {
        DocStruct physicaldocstruct = this.mydocument.getPhysicalDocStruct();

        DocStruct log = this.mydocument.getLogicalDocStruct();
        if (log.getType().isAnchor()) {
            if (log.getAllChildren() != null && log.getAllChildren().size() > 0) {
                log = log.getAllChildren().get(0);
            }
        }

        /*--------------------------------
         * der physische Baum wird nur
         * angelegt, wenn er noch nicht existierte
         * --------------------------------*/
        if (physicaldocstruct == null) {
            DocStructType dst = this.myPrefs.getDocStrctTypeByName("BoundBook");
            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);
View Full Code Here

Examples of ugh.dl.DocStruct

      String prop_metadatatype = cp.getParamString("validate.metadata(" + i + ")[@metadata]");
      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.myProzess.getTitel() + "] " + "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;
        }
      }

View Full Code Here

Examples of ugh.dl.DocStruct

   *
   * @see de.sub.goobi.metadaten.copier.DataSelector#findIn(de.sub.goobi.metadaten.copier.CopierData)
   */
  @Override
  public String findIn(CopierData data) {
    DocStruct currentLevel = data.getLogicalDocStruct();
    MetadataSelector destination = data.getDestination();
    for (int descend = index; descend > 0; descend--) {
      if (!(destination instanceof MetadataPathSelector)) {
        return null;
      }
      int childReference = ((MetadataPathSelector) destination).getIndex();
      currentLevel = currentLevel.getAllChildren().get(childReference);
      destination = ((MetadataPathSelector) destination).getSelector();
    }
    return nextSelector.findIn(currentLevel);
  }
View Full Code Here

Examples of ugh.dl.DocStruct

     * DocStruct rukursiv durchlaufen
     * --------------------------------*/
    DigitalDocument mydocument = null;
    try {
      mydocument = gdzfile.getDigitalDocument();
      DocStruct logicalTopstruct = mydocument.getLogicalDocStruct();
      rueckgabe += getNumberOfUghElements(logicalTopstruct, inType);
    } catch (PreferencesException e1) {
      Helper.setFehlerMeldung("[" + myProzess.getId() + "] Can not get DigitalDocument: ", e1.getMessage());
      logger.error(e1);
      rueckgabe = 0;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.