List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.kitodo.production.forms.ProzesskopieForm.java
/** * Metadata inheritance and enrichment./*w w w . j a va 2 s . c o m*/ */ private void updateMetadata() { if (ConfigCore.getBooleanParameter(ParameterCore.USE_METADATA_ENRICHMENT)) { LegacyDocStructHelperInterface enricher = rdf.getDigitalDocument().getLogicalDocStruct(); Map<String, Map<String, LegacyMetadataHelper>> higherLevelMetadata = new HashMap<>(); while (Objects.nonNull(enricher.getAllChildren())) { // save higher level metadata for lower enrichment List<LegacyMetadataHelper> allMetadata = enricher.getAllMetadata(); if (Objects.isNull(allMetadata)) { allMetadata = Collections.emptyList(); } iterateOverAllMetadata(higherLevelMetadata, allMetadata); // enrich children with inherited metadata for (LegacyDocStructHelperInterface nextChild : enricher.getAllChildren()) { enricher = nextChild; iterateOverHigherLevelMetadata(enricher, higherLevelMetadata); } } } }
From source file:org.kitodo.production.services.data.ProcessService.java
/** * Returns the batches of the desired type for a process. * * @param type//from www.ja v a2 s . c om * of batches to return * @return all batches of the desired type */ public List<Batch> getBatchesByType(Process process, BatchType type) { List<Batch> batches = process.getBatches(); if (Objects.nonNull(type)) { List<Batch> result = new ArrayList<>(batches); result.removeIf(batch -> !(batch.getType().equals(type))); return result; } return batches; }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
/** * Creates a new file format. When a new process is created, an empty METS * file must be created for it.//from w ww. j a va 2 s . c om */ public void createNewFileformat() { RulesetManagementInterface ruleset = ServiceManager.getRulesetService() .getPreferences(this.prozessKopie.getRuleset()).getRuleset(); try { Workpiece workpiece = new Workpiece(); IncludedStructuralElement includedStructuralElement = workpiece.getRootElement(); ConfigOpacDoctype configOpacDoctype = ConfigOpac.getDoctypeByName(this.docType); if (Objects.nonNull(configOpacDoctype)) { // monograph if (!configOpacDoctype.isPeriodical() && !configOpacDoctype.isMultiVolume()) { workpiece.getRootElement().setType(configOpacDoctype.getRulesetType()); this.rdf = new LegacyMetsModsDigitalDocumentHelper(ruleset, workpiece); } else if (configOpacDoctype.isPeriodical()) { // journal includedStructuralElement.setType("Periodical"); addChild(includedStructuralElement, "PeriodicalVolume"); this.rdf = new LegacyMetsModsDigitalDocumentHelper(ruleset, workpiece); } else if (configOpacDoctype.isMultiVolume()) { // volume of a multi-volume publication includedStructuralElement.setType("MultiVolumeWork"); addChild(includedStructuralElement, "Volume"); this.rdf = new LegacyMetsModsDigitalDocumentHelper(ruleset, workpiece); } } if (this.docType.equals("volumerun")) { includedStructuralElement.setType("VolumeRun"); addChild(includedStructuralElement, "Record"); this.rdf = new LegacyMetsModsDigitalDocumentHelper(ruleset, workpiece); } } catch (FileNotFoundException e) { Helper.setErrorMessage(ERROR_READING, new Object[] { Helper.getTranslation(OPAC_CONFIG) }, logger, e); } }
From source file:org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNestedImpl.java
private Map<String, Object> managerSubstitutionNodeTemplateProperties(TranslateTo translateTo, Template template, String templateName) { Map<String, Object> substitutionProperties = new HashMap<>(); Map<String, Object> heatProperties = translateTo.getResource().getProperties(); if (Objects.nonNull(heatProperties)) { for (Map.Entry<String, Object> entry : heatProperties.entrySet()) { Object property = TranslatorHeatToToscaPropertyConverter.getToscaPropertyValue(entry.getKey(), entry.getValue(), null, translateTo.getHeatFileName(), translateTo.getHeatOrchestrationTemplate(), template, translateTo.getContext()); substitutionProperties.put(entry.getKey(), property); }/*from w w w.j av a2 s .c o m*/ } return addAbstractSubstitutionProperty(templateName, substitutionProperties); }
From source file:org.kitodo.production.services.data.ProcessService.java
/** * Check if Tif directory exists./* w w w . j a v a 2 s . c o m*/ * * @return true if the Tif-Image-Directory exists, false if not */ Boolean checkIfTifDirectoryExists(Integer processId, String processTitle, String processBaseURI) { URI testMe; if (Objects.nonNull(processBaseURI)) { testMe = getImagesTifDirectory(true, processId, processTitle, URI.create(processBaseURI)); } else { testMe = getImagesTifDirectory(true, processId, processTitle, null); } return fileService.fileExist(testMe) && !fileService.getSubUris(testMe).isEmpty(); }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
/** * Set document type.//from w ww . j a va 2s.com * * @param docType * String */ public void setDocType(String docType) { if (!this.docType.equals(docType)) { this.docType = docType; if (Objects.nonNull(rdf)) { LegacyMetsModsDigitalDocumentHelper tmp = rdf; createNewFileformat(); if (rdf.getDigitalDocument().getLogicalDocStruct() .equals(tmp.getDigitalDocument().getLogicalDocStruct())) { rdf = tmp; } else { LegacyDocStructHelperInterface oldLogicalDocstruct = tmp.getDigitalDocument() .getLogicalDocStruct(); LegacyDocStructHelperInterface newLogicalDocstruct = rdf.getDigitalDocument() .getLogicalDocStruct(); // both have no children if (oldLogicalDocstruct.getAllChildren() == null && newLogicalDocstruct.getAllChildren() == null) { copyMetadata(oldLogicalDocstruct, newLogicalDocstruct); } else if (oldLogicalDocstruct.getAllChildren() != null && newLogicalDocstruct.getAllChildren() == null) { // old has a child, new has no child copyMetadata(oldLogicalDocstruct, newLogicalDocstruct); copyMetadata(oldLogicalDocstruct.getAllChildren().get(0), newLogicalDocstruct); } else if (oldLogicalDocstruct.getAllChildren() == null && newLogicalDocstruct.getAllChildren() != null) { // new has a child, but old not copyMetadata(oldLogicalDocstruct, newLogicalDocstruct); throw new UnsupportedOperationException("Dead code pending removal"); } else if (oldLogicalDocstruct.getAllChildren() != null && newLogicalDocstruct.getAllChildren() != null) { // both have children copyMetadata(oldLogicalDocstruct, newLogicalDocstruct); copyMetadata(oldLogicalDocstruct.getAllChildren().get(0), newLogicalDocstruct.getAllChildren().get(0)); } } fillFieldsFromMetadataFile(); } } }
From source file:org.kitodo.production.services.data.ProcessService.java
private URI getImageDirectory(boolean useFallBack, URI directory, URI imageDirectory) { if (Objects.nonNull(imageDirectory) && useFallBack && !SUFFIX.equals("")) { URI tif = imageDirectory; List<URI> files = fileService.getSubUris(tif); if (files.isEmpty()) { List<URI> folderList = fileService.getSubUris(directory); for (URI folder : folderList) { if (folder.toString().endsWith(SUFFIX) && !folder.getPath().startsWith(DIRECTORY_PREFIX)) { imageDirectory = folder; break; }// ww w . j av a 2s . c o m } } } return imageDirectory; }
From source file:org.kitodo.production.services.file.FileService.java
private URI getDummyImagePath() throws URISyntaxException, IOException { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); URL dummyImage = classloader.getResource("images/dummyImage.tif"); if (Objects.nonNull(dummyImage)) { return dummyImage.toURI(); } else {//from w w w . ja v a 2 s. c om throw new IOException("No dummy image found in resources!"); } }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
private void copyMetadata(LegacyDocStructHelperInterface oldDocStruct, LegacyDocStructHelperInterface newDocStruct) { if (Objects.nonNull(oldDocStruct.getAllMetadata())) { for (LegacyMetadataHelper md : oldDocStruct.getAllMetadata()) { newDocStruct.addMetadata(md); }//from w w w .ja v a2s .c om } }
From source file:org.kitodo.production.metadata.MetadataProcessor.java
/** * alle Seiten des aktuellen Strukturelements ermitteln. *//*from w ww . j a v a 2s . c o m*/ private void determinePagesStructure(LegacyDocStructHelperInterface inStrukturelement) { if (inStrukturelement == null) { return; } List<LegacyReferenceHelper> references = inStrukturelement.getAllReferences("to"); int zaehler = 0; int imageNr = 0; if (references != null) { references.sort((firstObject, secondObject) -> { Integer firstPage = 0; int secondPage = 0; LegacyMetadataTypeHelper mdt = this.myPrefs.getMetadataTypeByName("physPageNumber"); List<? extends LegacyMetadataHelper> listMetadata = firstObject.getTarget() .getAllMetadataByType(mdt); if (Objects.nonNull(listMetadata) && !listMetadata.isEmpty()) { LegacyMetadataHelper page = listMetadata.get(0); firstPage = Integer.parseInt(page.getValue()); } listMetadata = secondObject.getTarget().getAllMetadataByType(mdt); if (Objects.nonNull(listMetadata) && !listMetadata.isEmpty()) { LegacyMetadataHelper page = listMetadata.get(0); secondPage = Integer.parseInt(page.getValue()); } return firstPage.compareTo(secondPage); }); /* die Gre der Arrays festlegen */ this.structSeiten = new SelectItem[references.size()]; this.structurePageNew = new MetadataImpl[references.size()]; /* alle Referenzen durchlaufen und deren Metadaten ermitteln */ for (LegacyReferenceHelper ref : references) { LegacyDocStructHelperInterface target = ref.getTarget(); determineSecondPagesStructure(target, zaehler); if (imageNr == 0) { imageNr = determineThirdPagesStructure(target); } zaehler++; } } /* * Wenn eine Verknpfung zwischen Strukturelement und Bildern sein soll, * das richtige Bild anzeigen */ if (this.imageToStructuralElement) { identifyImage(imageNr - this.imageNumber); } }