Examples of DocStruct


Examples of ugh.dl.DocStruct

   * ================================================================
   */
  private String getMetadataFromDigitalDocument(MetadataLevel inLevel, String metadata) {
    if (this.dd != null) {
      /* TopStruct und FirstChild ermitteln */
      DocStruct topstruct = this.dd.getLogicalDocStruct();
      DocStruct firstchildstruct = null;
      if (topstruct.getAllChildren() != null && topstruct.getAllChildren().size() > 0) {
        firstchildstruct = topstruct.getAllChildren().get(0);
      }

      /* MetadataType ermitteln und ggf. Fehler melden */
 
View Full Code Here

Examples of ugh.dl.DocStruct

  public DocStruct ChangeCurrentDocstructType(DocStruct inOldDocstruct, String inNewType) throws DocStructHasNoTypeException,
      MetadataTypeNotAllowedException, TypeNotAllowedAsChildException, TypeNotAllowedForParentException {
    // inOldDocstruct.getType().getName()
    // + " soll werden zu " + inNewType);
    DocStructType dst = this.myPrefs.getDocStrctTypeByName(inNewType);
    DocStruct newDocstruct = this.mydocument.createDocStruct(dst);
    /*
     * -------------------------------- alle Metadaten hinzufügen --------------------------------
     */
    if (inOldDocstruct.getAllMetadata() != null && inOldDocstruct.getAllMetadata().size() > 0) {
      for (Metadata old : inOldDocstruct.getAllMetadata()) {
        boolean match = false;

        if (newDocstruct.getPossibleMetadataTypes() != null && newDocstruct.getPossibleMetadataTypes().size() > 0) {
          for (MetadataType mt : newDocstruct.getPossibleMetadataTypes()) {
            if (mt.getName().equals(old.getType().getName())) {
              match = true;
              break;
            }
          }
          if (!match) {
            try {
              newDocstruct.addMetadata(old);
            } catch (Exception e) {
              Helper.setFehlerMeldung("Metadata " + old.getType().getName() + " is not allowed in new element "
                  + newDocstruct.getType().getName());
              return inOldDocstruct;
            }
          } else {
            newDocstruct.addMetadata(old);
          }
        } else {
          Helper.setFehlerMeldung("Metadata " + old.getType().getName() + " is not allowed in new element "
              + newDocstruct.getType().getName());
          return inOldDocstruct;
        }
      }
    }
    /*
     * -------------------------------- alle Personen hinzufügen --------------------------------
     */
    if (inOldDocstruct.getAllPersons() != null && inOldDocstruct.getAllPersons().size() > 0) {
      for (Person old : inOldDocstruct.getAllPersons()) {
        boolean match = false;
        if (newDocstruct.getPossibleMetadataTypes() != null && newDocstruct.getPossibleMetadataTypes().size() > 0) {
          for (MetadataType mt : newDocstruct.getPossibleMetadataTypes()) {
            if (mt.getName().equals(old.getType().getName())) {
              match = true;
              break;
            }
          }
          if (!match) {
            Helper.setFehlerMeldung("Person " + old.getType().getName() + " is not allowed in new element "
                + newDocstruct.getType().getName());
          } else {
            newDocstruct.addPerson(old);
          }
        } else {
          Helper.setFehlerMeldung("Person " + old.getType().getName() + " is not allowed in new element "
              + newDocstruct.getType().getName());
          return inOldDocstruct;
        }
      }
    }
    /*
     * -------------------------------- alle Seiten hinzufügen --------------------------------
     */
    if (inOldDocstruct.getAllToReferences() != null) {
      // TODO: get rid of Iterators, use a for Loop instead
      for (Iterator<Reference> iterator = inOldDocstruct.getAllToReferences().iterator(); iterator.hasNext();) {
        Reference p = iterator.next();
        newDocstruct.addReferenceTo(p.getTarget(), p.getType());
      }
    }

    /*
     * -------------------------------- alle Docstruct-Children hinzufügen --------------------------------
     */
    if (inOldDocstruct.getAllChildren() != null && inOldDocstruct.getAllChildren().size() > 0) {
      for (DocStruct old : inOldDocstruct.getAllChildren()) {
        if (newDocstruct.getType().getAllAllowedDocStructTypes() != null && newDocstruct.getType().getAllAllowedDocStructTypes().size() > 0) {

          if (!newDocstruct.getType().getAllAllowedDocStructTypes().contains(old.getType().getName())) {
            Helper.setFehlerMeldung("Child element " + old.getType().getName() + " is not allowed in new element "
                + newDocstruct.getType().getName());
            return inOldDocstruct;
          } else {
            newDocstruct.addChild(old);
          }
        } else {
          Helper.setFehlerMeldung("Child element " + old.getType().getName() + " is not allowed in new element "
              + newDocstruct.getType().getName());
          return inOldDocstruct;
        }
      }
    }
    /*
     * -------------------------------- neues Docstruct zum Parent hinzufügen und an die gleiche Stelle schieben, wie den Vorg?nger
     * --------------------------------
     */
    inOldDocstruct.getParent().addChild(newDocstruct);
    int i = 1;
    // TODO: get rid of Iterators, use a for Loop instead
    for (Iterator<DocStruct> iter = newDocstruct.getParent().getAllChildren().iterator(); iter.hasNext(); i++) {
      if (iter.next() == inOldDocstruct) {
        break;
      }
    }
    for (int j = newDocstruct.getParent().getAllChildren().size() - i; j > 0; j--) {
      KnotenUp(newDocstruct);
    }

    /*
     * -------------------------------- altes Docstruct vom Parent entfernen und neues als aktuelles nehmen --------------------------------
View Full Code Here

Examples of ugh.dl.DocStruct

  }

  /* =============================================================== */

  public void KnotenUp(DocStruct inStruct) throws TypeNotAllowedAsChildException {
    DocStruct parent = inStruct.getParent();
    if (parent == null) {
      return;
    }
    List<DocStruct> alleDS = null;

    /* das erste Element kann man nicht nach oben schieben */
    if (parent.getAllChildren().get(0) == inStruct) {
      return;
    }

    /* alle Elemente des Parents durchlaufen */
    for (DocStruct tempDS : parent.getAllChildren()) {
      /*
       * wenn das folgende Element das zu verschiebende ist dabei die Exception auffangen, falls es kein nächstes Kind gibt
       */
      try {
        if (parent.getNextChild(tempDS) == inStruct) {
          alleDS = new ArrayList<DocStruct>();
        }
      } catch (Exception e) {
      }

      /*
       * nachdem der Vorg?nger gefunden wurde, werden alle anderen Elemente aus der Child-Liste entfernt und separat gesammelt
       */
      if (alleDS != null && tempDS != inStruct) {
        alleDS.add(tempDS);
      }
    }

    /* anschliessend die Childs entfernen */
    for (Iterator<DocStruct> iter = alleDS.iterator(); iter.hasNext();) {
      parent.removeChild(iter.next());
    }

    /* anschliessend die Childliste korrigieren */
    // parent.addChild(myStrukturelement);
    for (Iterator<DocStruct> iter = alleDS.iterator(); iter.hasNext();) {
      parent.addChild(iter.next());
    }
  }
View Full Code Here

Examples of ugh.dl.DocStruct

  }

  /* =============================================================== */

  public void KnotenDown(DocStruct inStruct) throws TypeNotAllowedAsChildException {
    DocStruct parent = inStruct.getParent();
    if (parent == null) {
      return;
    }
    List<DocStruct> alleDS = new ArrayList<DocStruct>();

    /* alle Elemente des Parents durchlaufen */
    // TODO: get rid of Iterators, use a for Loop instead
    for (Iterator<DocStruct> iter = parent.getAllChildren().iterator(); iter.hasNext();) {
      DocStruct tempDS = iter.next();

      /* wenn das aktuelle Element das zu verschiebende ist */
      if (tempDS != inStruct) {
        alleDS.add(tempDS);
      } else {
View Full Code Here

Examples of ugh.dl.DocStruct

  public void deleteAllUnusedElements(DocStruct inStruct) {
    inStruct.deleteUnusedPersonsAndMetadata();
    if (inStruct.getAllChildren() != null && inStruct.getAllChildren().size() > 0) {
      // TODO: get rid of Iterators, use a for Loop instead
      for (Iterator<DocStruct> it = inStruct.getAllChildren().iterator(); it.hasNext();) {
        DocStruct ds = it.next();
        deleteAllUnusedElements(ds);
      }
    }
  }
View Full Code Here

Examples of ugh.dl.DocStruct

        DigitalDocument dd = pp.getDigitalDocument();
        Fileformat ff = new XStream(inPrefs);
        ff.setDigitalDocument(dd);
        /* BoundBook hinzufügen */
        DocStructType dst = inPrefs.getDocStrctTypeByName("BoundBook");
        DocStruct dsBoundBook = dd.createDocStruct(dst);
        dd.setPhysicalDocStruct(dsBoundBook);
        /* Inhalt des RDF-Files überprüfen und ergänzen */
        checkMyOpacResult(ff.getDigitalDocument(), inPrefs, myFirstHit, verbose);
        // rdftemp.write("D:/PicaRdf.xml");
        return ff;
View Full Code Here

Examples of ugh.dl.DocStruct

     * zusätzliche Opac-Details ## ##################################################### ####################################################
     */

    private void checkMyOpacResult(DigitalDocument inDigDoc, Prefs inPrefs, Element myFirstHit, boolean verbose) {
        UghHelper ughhelp = new UghHelper();
        DocStruct topstruct = inDigDoc.getLogicalDocStruct();
        DocStruct boundbook = inDigDoc.getPhysicalDocStruct();
        DocStruct topstructChild = null;
        Element mySecondHit = null;

        /*
         * -------------------------------- bei Multivolumes noch das Child in xml und docstruct ermitteln --------------------------------
         */
        // if (isMultivolume()) {
        if (getOpacDocType().isMultiVolume()) {
            try {
                topstructChild = topstruct.getAllChildren().get(0);
            } catch (RuntimeException e) {
            }
            mySecondHit = (Element) myFirstHit.getParentElement().getChildren().get(1);
        }

        /*
         * -------------------------------- vorhandene PPN als digitale oder analoge einsetzen --------------------------------
         */
        String ppn = getElementFieldValue(myFirstHit, "003@", "0");
        ughhelp.replaceMetadatum(topstruct, inPrefs, "CatalogIDDigital", "");
        if (this.gattung.toLowerCase().startsWith("o")) {
            ughhelp.replaceMetadatum(topstruct, inPrefs, "CatalogIDDigital", ppn);
        } else {
            ughhelp.replaceMetadatum(topstruct, inPrefs, "CatalogIDSource", ppn);
        }

        /*
         * -------------------------------- wenn es ein multivolume ist, dann auch die PPN prüfen --------------------------------
         */
        if (topstructChild != null && mySecondHit != null) {
            String secondHitppn = getElementFieldValue(mySecondHit, "003@", "0");
            ughhelp.replaceMetadatum(topstructChild, inPrefs, "CatalogIDDigital", "");
            if (this.gattung.toLowerCase().startsWith("o")) {
                ughhelp.replaceMetadatum(topstructChild, inPrefs, "CatalogIDDigital", secondHitppn);
            } else {
                ughhelp.replaceMetadatum(topstructChild, inPrefs, "CatalogIDSource", secondHitppn);
            }
        }

        /*
         * -------------------------------- den Main-Title bereinigen --------------------------------
         */
        String myTitle = getElementFieldValue(myFirstHit, "021A", "a");
        /*
         * wenn der Fulltittle nicht in dem Element stand, dann an anderer Stelle nachsehen (vor allem bei Contained-Work)
         */
        if (myTitle == null || myTitle.length() == 0) {
            myTitle = getElementFieldValue(myFirstHit, "021B", "a");
        }
        ughhelp.replaceMetadatum(topstruct, inPrefs, "TitleDocMain", myTitle.replaceAll("@", ""));

        /*
         * -------------------------------- Sorting-Titel mit Umlaut-Konvertierung --------------------------------
         */
        if (myTitle.indexOf("@") != -1) {
            myTitle = myTitle.substring(myTitle.indexOf("@") + 1);
        }
        ughhelp.replaceMetadatum(topstruct, inPrefs, "TitleDocMainShort", myTitle);

        /*
         * -------------------------------- bei multivolumes den Main-Title bereinigen --------------------------------
         */
        if (topstructChild != null && mySecondHit != null) {
            String fulltitleMulti = getElementFieldValue(mySecondHit, "021A", "a").replaceAll("@", "");
            ughhelp.replaceMetadatum(topstructChild, inPrefs, "TitleDocMain", fulltitleMulti);
        }

        /*
         * -------------------------------- bei multivolumes den Sorting-Titel mit Umlaut-Konvertierung --------------------------------
         */
        if (topstructChild != null && mySecondHit != null) {
            String sortingTitleMulti = getElementFieldValue(mySecondHit, "021A", "a");
            if (sortingTitleMulti.indexOf("@") != -1) {
                sortingTitleMulti = sortingTitleMulti.substring(sortingTitleMulti.indexOf("@") + 1);
            }
            ughhelp.replaceMetadatum(topstructChild, inPrefs, "TitleDocMainShort", sortingTitleMulti);
            // sortingTitle = sortingTitleMulti;
        }

        /*
         * -------------------------------- Sprachen - Konvertierung auf zwei Stellen --------------------------------
         */
        String sprache = getElementFieldValue(myFirstHit, "010@", "a");
        sprache = ughhelp.convertLanguage(sprache);
        ughhelp.replaceMetadatum(topstruct, inPrefs, "DocLanguage", sprache);

        /*
         * -------------------------------- bei multivolumes die Sprachen - Konvertierung auf zwei Stellen --------------------------------
         */
        if (topstructChild != null && mySecondHit != null) {
            String spracheMulti = getElementFieldValue(mySecondHit, "010@", "a");
            spracheMulti = ughhelp.convertLanguage(spracheMulti);
            ughhelp.replaceMetadatum(topstructChild, inPrefs, "DocLanguage", spracheMulti);
        }

        /*
         * -------------------------------- ISSN --------------------------------
         */
        String issn = getElementFieldValue(myFirstHit, "005A", "0");
        ughhelp.replaceMetadatum(topstruct, inPrefs, "ISSN", issn);

        /*
         * -------------------------------- Copyright --------------------------------
         */
        String copyright = getElementFieldValue(myFirstHit, "037I", "a");
        ughhelp.replaceMetadatum(boundbook, inPrefs, "copyrightimageset", copyright);

        /*
         * -------------------------------- Format --------------------------------
         */
        String format = getElementFieldValue(myFirstHit, "034I", "a");
        ughhelp.replaceMetadatum(boundbook, inPrefs, "FormatSourcePrint", format);

        /*
         * -------------------------------- Umfang --------------------------------
         */
        String umfang = getElementFieldValue(myFirstHit, "034D", "a");
        ughhelp.replaceMetadatum(topstruct, inPrefs, "SizeSourcePrint", umfang);

        /*
         * -------------------------------- Signatur --------------------------------
         */
        String sig = getElementFieldValue(myFirstHit, "209A", "c");
        if (sig.length() > 0) {
            sig = "<" + sig + ">";
        }
        sig += getElementFieldValue(myFirstHit, "209A", "f") + " ";
        sig += getElementFieldValue(myFirstHit, "209A", "a");
        ughhelp.replaceMetadatum(boundbook, inPrefs, "shelfmarksource", sig.trim());
        if (sig.trim().length() == 0) {
            myLogger.debug("Signatur part 1: " + sig);
            myLogger.debug(myFirstHit.getChildren());
            sig = getElementFieldValue(myFirstHit, "209A/01", "c");
            if (sig.length() > 0) {
                sig = "<" + sig + ">";
            }
            sig += getElementFieldValue(myFirstHit, "209A/01", "f") + " ";
            sig += getElementFieldValue(myFirstHit, "209A/01", "a");
            if (mySecondHit != null) {
                sig += getElementFieldValue(mySecondHit, "209A", "f") + " ";
                sig += getElementFieldValue(mySecondHit, "209A", "a");
            }
            ughhelp.replaceMetadatum(boundbook, inPrefs, "shelfmarksource", sig.trim());
        }
        myLogger.debug("Signatur full: " + sig);

        /*
         * -------------------------------- Ats Tsl Vorbereitung --------------------------------
         */
        myTitle = myTitle.toLowerCase();
        myTitle = myTitle.replaceAll("&", "");

        /*
         * -------------------------------- bei nicht-Zeitschriften Ats berechnen --------------------------------
         */
        // if (!gattung.startsWith("ab") && !gattung.startsWith("ob")) {
        String author = getElementFieldValue(myFirstHit, "028A", "a").toLowerCase();
        if (author == null || author.equals("")) {
            author = getElementFieldValue(myFirstHit, "028A", "8").toLowerCase();
        }
    this.atstsl = ProzesskopieForm.createAtstsl(myTitle, author);

        /*
         * -------------------------------- bei Zeitschriften noch ein PeriodicalVolume als Child einfügen --------------------------------
         */
        // if (isPeriodical()) {
        if (getOpacDocType().isPeriodical()) {
            try {
                DocStructType dstV = inPrefs.getDocStrctTypeByName("PeriodicalVolume");
                DocStruct dsvolume = inDigDoc.createDocStruct(dstV);
                topstruct.addChild(dsvolume);
            } catch (TypeNotAllowedForParentException e) {
                e.printStackTrace();
            } catch (TypeNotAllowedAsChildException e) {
                e.printStackTrace();
View Full Code Here

Examples of ugh.dl.DocStruct

    }

    /*
     * get the topstruct element of the digital document depending on anchor property
     */
    DocStruct topElement = dd.getLogicalDocStruct();
    if (this.myPrefs.getDocStrctTypeByName(topElement.getType().getName()).isAnchor()) {
      if (topElement.getAllChildren() == null || topElement.getAllChildren().size() == 0) {
        throw new PreferencesException(myProzess.getTitel()
            + ": the topstruct element is marked as anchor, but does not have any children for physical docstrucs");
      } else {
        topElement = topElement.getAllChildren().get(0);
      }
    }

    /*
     * -------------------------------- if the top element does not have any image related, set them all --------------------------------
     */
    if (topElement.getAllToReferences("logical_physical") == null || topElement.getAllToReferences("logical_physical").size() == 0) {
      if (dd.getPhysicalDocStruct() != null && dd.getPhysicalDocStruct().getAllChildren() != null) {
        Helper.setMeldung(myProzess.getTitel()
            + ": topstruct element does not have any referenced images yet; temporarily adding them for mets file creation");
        for (DocStruct mySeitenDocStruct : dd.getPhysicalDocStruct().getAllChildren()) {
          topElement.addReferenceTo(mySeitenDocStruct, "logical_physical");
        }
      } else {
        Helper.setFehlerMeldung(myProzess.getTitel() + ": could not found any referenced images, export aborted");
        dd = null;
        return false;
View Full Code Here

Examples of ugh.dl.DocStruct

   * ================================================================
   */
  private String getMetadataFromDigitalDocument(MetadataLevel inLevel, String metadata) {
    if (this.dd != null) {
      /* TopStruct und FirstChild ermitteln */
      DocStruct topstruct = this.dd.getLogicalDocStruct();
      DocStruct firstchildstruct = null;
      if (topstruct.getAllChildren() != null && topstruct.getAllChildren().size() > 0) {
        firstchildstruct = topstruct.getAllChildren().get(0);
      }

      /* MetadataType ermitteln und ggf. Fehler melden */
 
View Full Code Here

Examples of ugh.dl.DocStruct

          myBandnr = "_" + tokenizer.nextToken();
        }
        Prefs myPrefs = p.getRegelsatz().getPreferences();
        try {
          Fileformat gdzfile = p.readMetadataFile();
          DocStruct dsTop = gdzfile.getDigitalDocument().getLogicalDocStruct();
          DocStruct dsFirst = null;
          if (dsTop.getAllChildren() != null && dsTop.getAllChildren().size() > 0) {
            dsFirst = dsTop.getAllChildren().get(0);
          }

          MetadataType mdtPpnDigital = ughhelp.getMetadataType(myPrefs, "CatalogIDDigital");
          MetadataType mdtPpnAnalog = ughhelp.getMetadataType(myPrefs, "CatalogIDSource");
          List<? extends Metadata> alleMetadaten;

          /* digitale PPN korrigieren */
          if (dsFirst != null) {
            alleMetadaten = dsFirst.getAllMetadataByType(mdtPpnDigital);
            if (alleMetadaten != null && alleMetadaten.size() > 0) {
              Metadata md = alleMetadaten.get(0);
              myLogger.debug(md.getValue());
              if (!md.getValue().endsWith(myBandnr)) {
                md.setValue(md.getValue() + myBandnr);
                Helper.setMeldung(null, "PPN digital adjusted: ", p.getTitel());
              }
            }

            /* analoge PPN korrigieren */
            alleMetadaten = dsFirst.getAllMetadataByType(mdtPpnAnalog);
            if (alleMetadaten != null && alleMetadaten.size() > 0) {
              Metadata md1 = alleMetadaten.get(0);
              myLogger.debug(md1.getValue());
              if (!md1.getValue().endsWith(myBandnr)) {
                md1.setValue(md1.getValue() + myBandnr);
                Helper.setMeldung(null, "PPN analog adjusted: ", p.getTitel());
              }
            }
          }

          /* Collections korrigieren */
          List<String> myKollektionenTitel = new ArrayList<String>();
          MetadataType coltype = ughhelp.getMetadataType(myPrefs, "singleDigCollection");
          ArrayList<Metadata> myCollections;
          if (dsTop.getAllMetadataByType(coltype) != null && dsTop.getAllMetadataByType(coltype).size() != 0) {
            myCollections = new ArrayList<Metadata>(dsTop.getAllMetadataByType(coltype));
            if (myCollections != null && myCollections.size() > 0) {
              for (Metadata md : myCollections) {
             
                if (myKollektionenTitel.contains(md.getValue())) {
                  dsTop.removeMetadata(md);
                } else {
                  myKollektionenTitel.add(md.getValue());
                }
              }
            }
          }
          if (dsFirst != null && dsFirst.getAllMetadataByType(coltype) != null) {
            myKollektionenTitel = new ArrayList<String>();
            myCollections = new ArrayList<Metadata>(dsFirst.getAllMetadataByType(coltype));
            if (myCollections != null && myCollections.size() > 0) {
              for (Metadata md : myCollections) {
//                Metadata md = (Metadata) it.next();
                if (myKollektionenTitel.contains(md.getValue())) {
                  dsFirst.removeMetadata(md);
                } else {
                  myKollektionenTitel.add(md.getValue());
                }
              }
            }
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.