Package de.sub.goobi.persistence.apache

Examples of de.sub.goobi.persistence.apache.FolderInformation$GoobiImageFileComparator


  }

  public boolean validate(Fileformat gdzfile, Prefs inPrefs, int processId, String title) {
    ProcessObject process = ProcessManager.getProcessObjectForId(processId);
    ProjectObject project = ProjectManager.getProjectById(process.getProjekteID());
    FolderInformation fi = new FolderInformation(processId, process.getTitle());
    this.title = title;
    String metadataLanguage = (String) Helper.getManagedBeanValue("#{LoginForm.myBenutzer.metadatenSprache}");
    boolean ergebnis = true;

    DigitalDocument dd = null;
    try {
      dd = gdzfile.getDigitalDocument();
    } catch (Exception e) {
      Helper.setFehlerMeldung(Helper.getTranslation("MetadataDigitalDocumentError") + title, e.getMessage());
      ergebnis = false;
    }

    DocStruct logical = dd.getLogicalDocStruct();
    if (logical.getAllIdentifierMetadata() != null && logical.getAllIdentifierMetadata().size() > 0) {
      Metadata identifierTopStruct = logical.getAllIdentifierMetadata().get(0);
      try {
        if (!identifierTopStruct.getValue().replaceAll("[\\w|-]", "").equals("")) {
          Helper.setFehlerMeldung(Helper.getTranslation("MetadataIdentifierError")
              + identifierTopStruct.getType().getNameByLanguage(metadataLanguage) + " in DocStruct "
              + logical.getType().getNameByLanguage(metadataLanguage) + Helper.getTranslation("MetadataInvalidCharacter"));
          ergebnis = false;
        }
        DocStruct firstChild = logical.getAllChildren().get(0);
        Metadata identifierFirstChild = firstChild.getAllIdentifierMetadata().get(0);
        if (identifierTopStruct.getValue() != null && identifierTopStruct.getValue() != ""
            && identifierTopStruct.getValue().equals(identifierFirstChild.getValue())) {
          Helper.setFehlerMeldung(Helper.getTranslation("MetadataIdentifierError") + identifierTopStruct.getType().getName()
              + Helper.getTranslation("MetadataIdentifierSame") + logical.getType().getName() + " and "
              + firstChild.getType().getName());
          ergebnis = false;
        }
        if (!identifierFirstChild.getValue().replaceAll("[\\w|-]", "").equals("")) {
          Helper.setFehlerMeldung(Helper.getTranslation("MetadataIdentifierError") + identifierFirstChild.getType().getName()
              + " in DocStruct " + firstChild.getType().getName() + Helper.getTranslation("MetadataInvalidCharacter"));
          ergebnis = false;
        }
      } catch (Exception e) {
        // no firstChild or no identifier
      }
    } else {
      Helper.setFehlerMeldung(Helper.getTranslation("MetadataMissingIdentifier"));
      ergebnis = false;
    }
    /*
     * -------------------------------- PathImagesFiles prüfen --------------------------------
     */
    if (!this.isValidPathImageFiles(dd.getPhysicalDocStruct(), inPrefs)) {
      ergebnis = false;
    }

    /*
     * -------------------------------- auf Docstructs ohne Seiten prüfen --------------------------------
     */
    DocStruct logicalTop = dd.getLogicalDocStruct();
    if (logicalTop == null) {
      Helper.setFehlerMeldung(title + ": " + Helper.getTranslation("MetadataPaginationError"));
      ergebnis = false;
    }

    this.docStructsOhneSeiten = new ArrayList<DocStruct>();
    this.checkDocStructsOhneSeiten(logicalTop);
    if (this.docStructsOhneSeiten.size() != 0) {
      for (Iterator<DocStruct> iter = this.docStructsOhneSeiten.iterator(); iter.hasNext();) {
        DocStruct ds = iter.next();
        Helper.setFehlerMeldung(title + ": " + Helper.getTranslation("MetadataPaginationStructure")
            + ds.getType().getNameByLanguage(metadataLanguage));
      }
      ergebnis = false;
    }

    /*
     * -------------------------------- auf Seiten ohne Docstructs prüfen --------------------------------
     */
    List<String> seitenOhneDocstructs = null;
    try {
      seitenOhneDocstructs = checkSeitenOhneDocstructs(gdzfile);
    } catch (PreferencesException e1) {
      Helper.setFehlerMeldung("[" + title + "] Can not check pages without docstructs: ");
      ergebnis = false;
    }
    if (seitenOhneDocstructs != null && seitenOhneDocstructs.size() != 0) {
      for (Iterator<String> iter = seitenOhneDocstructs.iterator(); iter.hasNext();) {
        String seite = iter.next();
        Helper.setFehlerMeldung(title + ": " + Helper.getTranslation("MetadataPaginationPages"), seite);
      }
      ergebnis = false;
    }

    /*
     * -------------------------------- auf mandatory Values der Metadaten prüfen --------------------------------
     */
    List<String> mandatoryList = checkMandatoryValues(dd.getLogicalDocStruct(), new ArrayList<String>(), metadataLanguage);
    if (mandatoryList.size() != 0) {
      for (Iterator<String> iter = mandatoryList.iterator(); iter.hasNext();) {
        String temp = iter.next();
        Helper.setFehlerMeldung(title + ": " + Helper.getTranslation("MetadataMandatoryElement"), temp);
      }
      ergebnis = false;
    }

    /*
     * -------------------------------- auf Details in den Metadaten prüfen, die in der Konfiguration angegeben wurden
     * --------------------------------
     */
    List<String> configuredList = checkConfiguredValidationValues(dd.getLogicalDocStruct(), new ArrayList<String>(), inPrefs, metadataLanguage,
        project);
    if (configuredList.size() != 0) {
      for (Iterator<String> iter = configuredList.iterator(); iter.hasNext();) {
        String temp = iter.next();
        Helper.setFehlerMeldung(title + ": " + Helper.getTranslation("MetadataInvalidData"), temp);
      }
      ergebnis = false;
    }

    MetadatenImagesHelper mih = new MetadatenImagesHelper(inPrefs, dd);
    try {
      if (!mih.checkIfImagesValid(title, fi.getImagesTifDirectory(true))) {
        ergebnis = false;
      }
    } catch (Exception e) {
      Helper.setFehlerMeldung(title + ": ", e);
      ergebnis = false;
    }

    /*
     * -------------------------------- Metadaten ggf. zum Schluss speichern --------------------------------
     */

    try {
      List<String> images = fi.getDataFiles();
      if (images != null) {
        int sizeOfPagination = dd.getPhysicalDocStruct().getAllChildren().size();
        int sizeOfImages = images.size();
        if (sizeOfPagination != sizeOfImages) {
          List<String> param = new ArrayList<String>();
          param.add(String.valueOf(sizeOfPagination));
          param.add(String.valueOf(sizeOfImages));
          Helper.setFehlerMeldung(Helper.getTranslation("imagePaginationError", param));
          return false;
        }
      }
    } catch (InvalidImagesException e1) {
      Helper.setFehlerMeldung(process.getTitle() + ": ", e1);
      ergebnis = false;
    }

    try {
      if (this.autoSave) {
        process.writeMetadataFile(gdzfile, fi.getMetadataFilePath(), inPrefs, project.getFileFormatInternal());
      }
    } catch (Exception e) {
      Helper.setFehlerMeldung("Error while writing metadata: " + title, e);
    }
    return ergebnis;
View Full Code Here


          }
        }
      }
    }
    ProcessObject po = ProcessManager.getProcessObjectForId(processId);
    FolderInformation fi = new FolderInformation(po.getId(), po.getTitle());
    if (po.getSortHelperImages() != FileUtils.getNumberOfFiles(new File(fi.getImagesOrigDirectory(true)))) {
      ProcessManager.updateImages(FileUtils.getNumberOfFiles(new File(fi.getImagesOrigDirectory(true))), processId);
    }
    logger.debug("update process status");
    updateProcessStatus(processId);
    logger.debug("start " + automatischeSchritte.size() + " automatic tasks");
    for (StepObject automaticStep : automatischeSchritte) {
View Full Code Here

    }
    script = script.replace("{", "(").replace("}", ")");
    DigitalDocument dd = null;
    ProcessObject po = ProcessManager.getProcessObjectForId(step.getProcessId());

    FolderInformation fi = new FolderInformation(po.getId(), po.getTitle());
    Prefs prefs = ProcessManager.getRuleset(po.getRulesetId()).getPreferences();

    try {
      dd = po.readMetadataFile(fi.getMetadataFilePath(), prefs).getDigitalDocument();
    } catch (PreferencesException e2) {
      logger.error(e2);
    } catch (ReadException e2) {
      logger.error(e2);
    } catch (IOException e2) {
View Full Code Here

     * --------------------------------
     */
    Fileformat gdzfile;
    Fileformat newfile;
    try {
       this.fi = new FolderInformation(process.getId(), process.getTitle());
      String metadataPath = this.fi.getMetadataFilePath();
      gdzfile = process.readMetadataFile(metadataPath, this.myPrefs);
      switch (MetadataFormat.findFileFormatsHelperByName(this.project.getFileFormatDmsExport())) {
      case METS:
        newfile = new MetsModsImportExport(this.myPrefs);
View Full Code Here

      }
    }

   
   
      FolderInformation fi = new FolderInformation(this.process.getId(), this.process.getTitle());
     
      String processpath = fi.getProcessDataDirectory().replace("\\", "/");
      String tifpath = fi.getImagesTifDirectory(false).replace("\\", "/");
      String imagepath = fi.getImagesDirectory().replace("\\", "/");
      String origpath = fi.getImagesOrigDirectory(false).replace("\\", "/");
      String metaFile = fi.getMetadataFilePath().replace("\\", "/");
      String ocrBasisPath = fi.getOcrDirectory().replace("\\", "/");
      String ocrPlaintextPath = fi.getTxtDirectory().replace("\\", "/");
      String sourcePath = fi.getSourceDirectory().replace("\\", "/");
      String importPath = fi.getImportDirectory().replace("\\", "/")
      Regelsatz ruleset = ProcessManager.getRuleset(this.process.getRulesetId());
      String myprefs = ConfigMain.getParameter("RegelsaetzeVerzeichnis") + ruleset.getDatei();

      /* da die Tiffwriter-Scripte einen Pfad ohne endenen Slash haben wollen, wird diese rausgenommen */
      if (tifpath.endsWith(File.separator)) {
View Full Code Here

     */
    this.myPrefs = ProcessManager.getRuleset(process.getRulesetId()).getPreferences();

    this.project = ProjectManager.getProjectById(process.getProjekteID());
    String atsPpnBand = process.getTitle();
    this.fi = new FolderInformation(process.getId(), process.getTitle());
    Fileformat gdzfile = process.readMetadataFile(this.fi.getMetadataFilePath(), this.myPrefs);

    String zielVerzeichnis = prepareUserDirectory(inZielVerzeichnis);

    String targetFileName = zielVerzeichnis + atsPpnBand + "_mets.xml";
View Full Code Here

   */
  @SuppressWarnings("deprecation")
  protected boolean writeMetsFile(ProcessObject process, String targetFileName, Fileformat gdzfile, boolean writeLocalFilegroup)
      throws PreferencesException, WriteException, IOException, InterruptedException, SwapException, DAOException,
      TypeNotAllowedForParentException {
    this.fi = new FolderInformation(process.getId(), process.getTitle());
    this.myPrefs = ProcessManager.getRuleset(process.getRulesetId()).getPreferences();
    this.project = ProjectManager.getProjectById(process.getProjekteID());
    MetsModsImportExport mm = new MetsModsImportExport(this.myPrefs);
    mm.setWriteLocal(writeLocalFilegroup);
    String imageFolderPath = this.fi.getImagesDirectory();
View Full Code Here

TOP

Related Classes of de.sub.goobi.persistence.apache.FolderInformation$GoobiImageFileComparator

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.