Skip to content

Commit

Permalink
kitodo#3408 fix checkstyle problems
Browse files Browse the repository at this point in the history
  • Loading branch information
markusweigelt committed Sep 23, 2021
1 parent f43ed0b commit 1125e0d
Showing 1 changed file with 40 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class ProcessDataTab {
this.createProcessForm = createProcessForm;
}


/**
* Set docType.
*
Expand Down Expand Up @@ -199,7 +198,7 @@ void setAllDocTypes(List<SelectItem> allDocTypes) {
}

/**
* Generate process titles and other details.
* Generate process title and tiff header
*/
public void generateProcessTitleAndTiffHeader() {
List<ProcessDetail> processDetails = createProcessForm.getProcessMetadataTab().getProcessDetailsElements();
Expand All @@ -222,34 +221,17 @@ public void generateProcessTitleAndTiffHeader() {
if (Objects.nonNull(parentProcess)) {

// get title of workpiece property "Haupttitle" from chosen title record process
currentTitle = parentProcess.getWorkpieces().stream().filter(property -> "Haupttitel".equals(property.getTitle())).findFirst().map(Property::getValue).orElse(currentTitle);
currentTitle = parentProcess.getWorkpieces().stream()
.filter(property -> "Haupttitel".equals(property.getTitle())).findFirst()
.map(Property::getValue).orElse(currentTitle);

} else {
int processesSize = createProcessForm.getProcesses().size();

if( processesSize > 1 ) {
List<TempProcess> ancestors = createProcessForm.getProcesses().subList(1, processesSize);

// get title of ancestors where TitleDocMain exists when several processes were imported
for (TempProcess tempProcess : ancestors) {
ProcessFieldedMetadata processFieldedMetadata = initializeTempProcessDetails(tempProcess);
AtomicReference<String> tempTitle = new AtomicReference<>();
processFieldedMetadata.getChildMetadata().parallelStream().filter(metadata -> TitleGenerator.TITLE_DOC_MAIN.equals(metadata.getKey())).findFirst().ifPresent(metadata -> {
if (metadata instanceof MetadataEntry) {
tempTitle.set(((MetadataEntry) metadata).getValue());
}
});

if (Objects.nonNull(tempTitle.get()) && !tempTitle.get().isEmpty()) {
currentTitle = tempTitle.get();
break;
}
}
}
currentTitle = getTitleFromAncestors();
}
}

String atstsl = ProcessService.generateProcessTitleAndGetAtstsl(processDetails, processTitle, process, currentTitle);
String atstsl = ProcessService.generateProcessTitleAndGetAtstsl(processDetails, processTitle, process,
currentTitle);
// document name is generally equal to process title
tiffHeaderDocumentName = process.getTitle();
tiffHeaderImageDescription = ProcessService.generateTiffHeader(processDetails, atstsl,
Expand All @@ -261,14 +243,44 @@ public void generateProcessTitleAndTiffHeader() {
"editForm:processFromTemplateTabView:processMetadata");
}

private String getTitleFromAncestors() {
int processesSize = createProcessForm.getProcesses().size();

if (processesSize <= 1) {
return null;
}

List<TempProcess> ancestors = createProcessForm.getProcesses().subList(1, processesSize);

// get title of ancestors where TitleDocMain exists when several processes were imported
for (TempProcess tempProcess : ancestors) {
ProcessFieldedMetadata processFieldedMetadata = initializeTempProcessDetails(tempProcess);
AtomicReference<String> tempTitle = new AtomicReference<>();
processFieldedMetadata.getChildMetadata().parallelStream()
.filter(metadata -> TitleGenerator.TITLE_DOC_MAIN.equals(metadata.getKey())).findFirst()
.ifPresent(metadata -> {
if (metadata instanceof MetadataEntry) {
tempTitle.set(((MetadataEntry) metadata).getValue());
}
});

if (Objects.nonNull(tempTitle.get()) && !tempTitle.get().isEmpty()) {
return tempTitle.get();
}
}
return null;
}

/**
* initialize process details table.
*
* @param tempProcess
* whose metadata should be queried
* whose metadata should be queried
*/
private ProcessFieldedMetadata initializeTempProcessDetails(TempProcess tempProcess) {
var metadata = ImportService.initializeProcessDetails(tempProcess.getWorkpiece().getLogicalStructure(), createProcessForm.getRulesetManagement(),
createProcessForm.getAcquisitionStage(), createProcessForm.getPriorityList());
var metadata = ImportService.initializeProcessDetails(tempProcess.getWorkpiece().getLogicalStructure(),
createProcessForm.getRulesetManagement(), createProcessForm.getAcquisitionStage(),
createProcessForm.getPriorityList());
metadata.setMetadata(ImportService.importMetadata(tempProcess.getMetadataNodes(), MdSec.DMD_SEC));
return metadata;
}
Expand Down

0 comments on commit 1125e0d

Please sign in to comment.