Package de.sub.goobi.metadaten

Examples of de.sub.goobi.metadaten.MetadatenImagesHelper


        }
      }

      /* Imagevalidierung */
      if (this.mySchritt.isTypImagesSchreiben()) {
        MetadatenImagesHelper mih = new MetadatenImagesHelper(null, null);
        try {
          if (!mih.checkIfImagesValid(this.mySchritt.getProzess().getTitel(), this.mySchritt.getProzess().getImagesOrigDirectory(false))) {
            return "";
          }
        } catch (Exception e) {
          Helper.setFehlerMeldung("Error on image validation: ", e);
        }
View Full Code Here


          if (!mv.validate(s.getProzess())) {
            error = true;
          }
        }
        if (s.isTypImagesSchreiben()) {
          MetadatenImagesHelper mih = new MetadatenImagesHelper(null, null);
          try {
            if (!mih.checkIfImagesValid(s.getProzess().getTitel(), s.getProzess().getImagesOrigDirectory(false))) {
              error = true;
            }
          } catch (Exception e) {
            Helper.setFehlerMeldung("Error on image validation: ", e);
          }
View Full Code Here

     */
    DigitalDocument dd = gdzfile.getDigitalDocument();
    if (dd.getFileSet() == null) {
      Helper.setMeldung(myProzess.getTitel() + ": digital document does not contain images; temporarily adding them for mets file creation");

      MetadatenImagesHelper mih = new MetadatenImagesHelper(this.myPrefs, dd);
      mih.createPagination(myProzess, null);
    }

    /*
     * 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;
      }
    }

    for (ContentFile cf : dd.getFileSet().getAllFiles()) {
      String location = cf.getLocation();
      // If the file's location string shoes no sign of any protocol,
      // use the file protocol.
      if (!location.contains("://")) {
        location = "file://" + location;
      }
      URL url = new URL(location);
      File f = new File(imageFolder, url.getFile());
      cf.setLocation(f.toURI().toString());
    }

    mm.setDigitalDocument(dd);

    /*
     * -------------------------------- wenn Filegroups definiert wurden, werden diese jetzt in die Metsstruktur übernommen
     * --------------------------------
     */
    // Replace all paths with the given VariableReplacer, also the file
    // group paths!
    VariableReplacer vp = new VariableReplacer(mm.getDigitalDocument(), this.myPrefs, myProzess, null);
    Set<ProjectFileGroup> myFilegroups = myProzess.getProjekt().getFilegroups();

    if (myFilegroups != null && myFilegroups.size() > 0) {
      for (ProjectFileGroup pfg : myFilegroups) {
        // check if source files exists
        if (pfg.getFolder() != null && pfg.getFolder().length() > 0) {
          File folder = new File(myProzess.getMethodFromName(pfg.getFolder()));
          if (folder != null && folder.exists() && folder.list().length > 0) {
            VirtualFileGroup v = new VirtualFileGroup();
            v.setName(pfg.getName());
            v.setPathToFiles(vp.replace(pfg.getPath()));
            v.setMimetype(pfg.getMimetype());
            v.setFileSuffix(pfg.getSuffix());
            mm.getDigitalDocument().getFileSet().addVirtualFileGroup(v);
          }
        } else {

          VirtualFileGroup v = new VirtualFileGroup();
          v.setName(pfg.getName());
          v.setPathToFiles(vp.replace(pfg.getPath()));
          v.setMimetype(pfg.getMimetype());
          v.setFileSuffix(pfg.getSuffix());
          mm.getDigitalDocument().getFileSet().addVirtualFileGroup(v);
        }
      }
    }

    // Replace rights and digiprov entries.
    mm.setRightsOwner(vp.replace(myProzess.getProjekt().getMetsRightsOwner()));
    mm.setRightsOwnerLogo(vp.replace(myProzess.getProjekt().getMetsRightsOwnerLogo()));
    mm.setRightsOwnerSiteURL(vp.replace(myProzess.getProjekt().getMetsRightsOwnerSite()));
    mm.setRightsOwnerContact(vp.replace(myProzess.getProjekt().getMetsRightsOwnerMail()));
    mm.setDigiprovPresentation(vp.replace(myProzess.getProjekt().getMetsDigiprovPresentation()));
    mm.setDigiprovReference(vp.replace(myProzess.getProjekt().getMetsDigiprovReference()));
    mm.setDigiprovPresentationAnchor(vp.replace(myProzess.getProjekt().getMetsDigiprovPresentationAnchor()));
    mm.setDigiprovReferenceAnchor(vp.replace(myProzess.getProjekt().getMetsDigiprovReferenceAnchor()));

    mm.setPurlUrl(vp.replace(myProzess.getProjekt().getMetsPurl()));
    mm.setContentIDs(vp.replace(myProzess.getProjekt().getMetsContentIDs()));

    String pointer = myProzess.getProjekt().getMetsPointerPath();
    pointer = vp.replace(pointer);
    mm.setMptrUrl(pointer);

    String anchor = myProzess.getProjekt().getMetsPointerPathAnchor();
    pointer = vp.replace(anchor);
    mm.setMptrAnchorUrl(pointer);

    // if (!ConfigMain.getParameter("ImagePrefix", "\\d{8}").equals("\\d{8}")) {
    List<String> images = new ArrayList<String>();
    if (ConfigMain.getBooleanParameter("ExportValidateImages", true)) {
      try {
        // TODO andere Dateigruppen nicht mit image Namen ersetzen
        images = new MetadatenImagesHelper(this.myPrefs, dd).getDataFiles(myProzess);
        int sizeOfPagination = dd.getPhysicalDocStruct().getAllChildren().size();
        if (images != null) {
          int sizeOfImages = images.size();
          if (sizeOfPagination == sizeOfImages) {
            dd.overrideContentFiles(images);
View Full Code Here

TOP

Related Classes of de.sub.goobi.metadaten.MetadatenImagesHelper

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.