Skip to content

Commit

Permalink
Merge pull request 'Release v24.11' (!357) from release_24.11 into ma…
Browse files Browse the repository at this point in the history
…ster
  • Loading branch information
Dominick Leppich committed Dec 5, 2024
2 parents ddd0c5a + c237144 commit 15a1d5c
Show file tree
Hide file tree
Showing 30 changed files with 299 additions and 273 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.goobi.workflow</groupId>
<artifactId>workflow-base</artifactId>
<version>24.10</version>
<version>24.11</version>
<relativePath/>
</parent>
<artifactId>workflow-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
Expand Down Expand Up @@ -252,7 +256,7 @@ public static int getProcessCount(String filter, Institution institution) throws
Connection connection = null;
StringBuilder sql = new StringBuilder();
sql.append("SELECT COUNT(1) FROM prozesse left join batches on prozesse.batchID = batches.id ");
sql.append("left JOIN projekte on prozesse.ProjekteID = projekte.ProjekteID ");
sql.append("INNER JOIN projekte on prozesse.ProjekteID = projekte.ProjekteID ");
if (institution != null) {
sql.append("and projekte.institution_id = ");
sql.append(institution.getId());
Expand Down Expand Up @@ -281,7 +285,7 @@ public static List<Process> getProcesses(String order, String filter, Integer st
Connection connection = null;
StringBuilder sql = new StringBuilder();
sql.append("SELECT prozesse.* FROM prozesse left join batches on prozesse.batchID = batches.id ");
sql.append("left JOIN projekte on prozesse.ProjekteID = projekte.ProjekteID ");
sql.append("INNER JOIN projekte on prozesse.ProjekteID = projekte.ProjekteID ");
if (institution != null) {
sql.append("and projekte.institution_id = ");
sql.append(institution.getId());
Expand Down Expand Up @@ -716,7 +720,7 @@ public static String getExportPluginName(int processId) throws SQLException {
}
}

public static final ResultSetHandler<Batch> resultSetToBatchHandler = new ResultSetHandler<Batch>() {
public static final ResultSetHandler<Batch> resultSetToBatchHandler = new ResultSetHandler<>() {
@Override
public Batch handle(ResultSet rs) throws SQLException {

Expand All @@ -731,7 +735,7 @@ public Batch handle(ResultSet rs) throws SQLException {
}
};

public static final ResultSetHandler<List<Batch>> resultSetToBatchListHandler = new ResultSetHandler<List<Batch>>() {
public static final ResultSetHandler<List<Batch>> resultSetToBatchListHandler = new ResultSetHandler<>() {
@Override
public List<Batch> handle(ResultSet rs) throws SQLException {
List<Batch> answer = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private void sortTranslations() {
}

private void sortTranslations(FieldValue value) {
Collections.sort(value.getTranslations(), Comparator.comparing(TranslationInstance::getLanguage));
value.getTranslations().sort(Comparator.comparing(TranslationInstance::getLanguage, Comparator.nullsFirst(Comparator.naturalOrder())));
}

public FieldValue addFieldValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class VocabularyRecordsBean implements Serializable {
private static final long serialVersionUID = 5672948572345L;

private static final String RETURN_PAGE_OVERVIEW = "vocabulary_records";
private static final String RETURN_PAGE_UPLOAD = "vocabulary_upload";

private static final VocabularyAPIManager api = VocabularyAPIManager.getInstance();

Expand All @@ -75,7 +74,7 @@ public class VocabularyRecordsBean implements Serializable {
private Part uploadedFile;
@Getter
@Setter
private boolean clearBeforeImport;
private boolean clearBeforeImport = false;

public String load(ExtendedVocabulary vocabulary) {
this.vocabulary = vocabulary;
Expand Down
88 changes: 67 additions & 21 deletions src/main/java/org/goobi/production/properties/ProcessProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,33 @@
* exception statement from your version.
*/

import io.goobi.workflow.api.vocabulary.VocabularyAPIManager;
import io.goobi.workflow.api.vocabulary.helper.ExtendedVocabularyRecord;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.goobi.beans.Processproperty;
import org.goobi.beans.Step;
import org.goobi.managedbeans.FormInputMultiSelectBean;
import org.goobi.managedbeans.FormInputMultiSelectHelper;
import org.goobi.production.cli.helper.StringPair;

import javax.faces.model.SelectItem;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import io.goobi.workflow.api.vocabulary.VocabularyAPIManager;
import io.goobi.workflow.api.vocabulary.helper.ExtendedVocabularyRecord;
import lombok.extern.slf4j.Slf4j;
import org.goobi.beans.Processproperty;
import org.goobi.beans.Step;
import org.goobi.production.cli.helper.StringPair;

import lombok.Getter;
import lombok.Setter;

import javax.faces.model.SelectItem;

@Slf4j
public class ProcessProperty implements IProperty, Serializable {

Expand Down Expand Up @@ -104,11 +107,18 @@ public class ProcessProperty implements IProperty, Serializable {
@Setter
private String pattern = "dd.MM.yyyy";

@Getter
private FormInputMultiSelectBean normalSelectionBean;
@Getter
private FormInputMultiSelectBean vocabularySelectionBean;

public ProcessProperty() {
this.possibleValues = new ArrayList<>();
this.projects = new ArrayList<>();
this.workflows = new ArrayList<>();
this.showStepConditions = new ArrayList<>();
this.normalSelectionBean = new FormInputMultiSelectHelper(() -> this.possibleValues, this::getSelectedValues, this::setSelectedValues);
this.vocabularySelectionBean = new FormInputMultiSelectHelper(() -> this.possibleValues, this::getSelectedVocabularyRecords, this::setSelectedValues);
}

/*
Expand All @@ -121,13 +131,7 @@ public void setValue(String value) {
this.value = value;
this.readValue = value;
if (Type.VOCABULARYREFERENCE.equals(this.type)) {
try {
ExtendedVocabularyRecord rec = VocabularyAPIManager.getInstance().vocabularyRecords().get(this.value);
this.readValue = rec.getMainValue();
} catch (Exception e) {
log.warn("Unable to retrieve vocabulary record reference \"{}\"", this.value);
this.readValue = "Broken vocabulary reference";
}
this.readValue = readVocabularyMainValueForRecord(this.value);
}
}

Expand Down Expand Up @@ -216,7 +220,7 @@ public List<String> getValueList() {
if (this.value != null && this.value.contains("; ")) {
return Arrays.asList(this.value.split("; "));
} else {
return new ArrayList<>();
return Collections.emptyList();
}
}

Expand All @@ -229,8 +233,50 @@ public void setValueList(List<String> valueList) {
this.readValue = value;
}

private List<SelectItem> getSelectedValues() {
return new LinkedList<>(
getValueList().stream()
.map(value -> new SelectItem(value, value))
.toList()
);
}

public List<String> getMultiVocabularyReferenceList() {
return getValueList().stream()
.map(this::readVocabularyMainValueForRecord)
.toList();
}

private String readVocabularyMainValueForRecord(String ref) {
if (StringUtils.isBlank(ref)) {
return "";
}
try {
ExtendedVocabularyRecord rec = VocabularyAPIManager.getInstance().vocabularyRecords().get(ref);
return rec.getMainValue();
} catch (Exception e) {
log.warn("Unable to retrieve vocabulary record reference \"{}\"", ref);
return "Broken vocabulary reference";
}
}

private List<SelectItem> getSelectedVocabularyRecords() {
return new LinkedList<>(
getValueList().stream()
.map(ref -> new SelectItem(ref, readVocabularyMainValueForRecord(ref)))
.toList()
);
}

private void setSelectedValues(List<SelectItem> selectItems) {
this.setValueList(selectItems.stream()
.map(SelectItem::getValue)
.map(Object::toString)
.toList());
}

public boolean getBooleanValue() {
return this.value != null && "true".equalsIgnoreCase(this.value);
return "true".equalsIgnoreCase(this.value);
}

public void setBooleanValue(boolean val) {
Expand Down
90 changes: 60 additions & 30 deletions src/main/java/org/goobi/production/properties/PropertyParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import de.sub.goobi.helper.Helper;
import io.goobi.workflow.api.vocabulary.APIException;
import io.goobi.workflow.api.vocabulary.VocabularyAPIManager;
import org.apache.commons.configuration.ConfigurationException;
Expand Down Expand Up @@ -206,10 +208,13 @@ public List<ProcessProperty> getPropertiesForStep(Step mySchritt) {
pp.setName(config.getString(property + "/@name"));
pp.setContainer(config.getString(property + "/@container"));

// workflows

// project and workflows are configured correct?

// projects
int count = config.getMaxIndex(property + "/project");
for (int j = 0; j <= count; j++) {

pp.getProjects().add(config.getString(property + "/project[" + (j + 1) + "]"));
}

Expand Down Expand Up @@ -273,12 +278,17 @@ public List<ProcessProperty> getPropertiesForStep(Step mySchritt) {
pp.setReadValue("");
}

// possible values
count = config.getMaxIndex(property + "/value");
for (int j = 0; j <= count; j++) {
String value = config.getString(property + "/value[" + (j + 1) + "]");
pp.getPossibleValues().add(new SelectItem(value, value));
if (Type.VOCABULARYREFERENCE.equals(pp.getType()) || Type.VOCABULARYMULTIREFERENCE.equals(pp.getType())) {
populatePossibleValuesWithVocabulary(property, pp);
} else {
// possible values
count = config.getMaxIndex(property + "/value");
for (int j = 0; j <= count; j++) {
String value = config.getString(property + "/value[" + (j + 1) + "]");
pp.getPossibleValues().add(new SelectItem(value, value));
}
}

properties.add(pp);
}
}
Expand Down Expand Up @@ -404,28 +414,20 @@ public List<ProcessProperty> getPropertiesForProcess(Process process) {
pp.setReadValue("");
}

if (Type.VOCABULARYREFERENCE.equals(pp.getType())) {
String vocabularyName = config.getString(property + "/vocabulary");
try {
long vocabularyId = VocabularyAPIManager.getInstance().vocabularies().findByName(vocabularyName).getId();
pp.setPossibleValues(VocabularyAPIManager.getInstance().vocabularyRecords().list(vocabularyId)
.all()
.request()
.getContent()
.stream()
.map(r -> new SelectItem(r.getURI(), r.getMainValue()))
.toList());
} catch (APIException e) {
log.warn("Unable to parse vocabulary reference property \"{}\"", property, e);
if (Type.VOCABULARYREFERENCE.equals(pp.getType()) || Type.VOCABULARYMULTIREFERENCE.equals(pp.getType())) {
populatePossibleValuesWithVocabulary(property, pp);
} else {
// possible values
count = config.getMaxIndex(property + "/value");
if (count > 0 && pp.getPossibleValues().isEmpty() && !Type.LISTMULTISELECT.equals(pp.getType())) {
pp.getPossibleValues().add(new SelectItem("", Helper.getTranslation("bitteAuswaehlen")));
}
for (int j = 0; j <= count; j++) {
String value = config.getString(property + "/value[" + (j + 1) + "]");
pp.getPossibleValues().add(new SelectItem(value, value));
}
}

// possible values
count = config.getMaxIndex(property + "/value");
for (int j = 0; j <= count; j++) {
String value = config.getString(property + "/value[" + (j + 1) + "]");
pp.getPossibleValues().add(new SelectItem(value, value));
}
if (log.isDebugEnabled()) {
log.debug("add property A " + pp.getName() + " - " + pp.getValue() + " - " + pp.getContainer());
}
Expand Down Expand Up @@ -497,7 +499,10 @@ public List<ProcessProperty> getProcessCreationProperties(Process process, Strin
List<ProcessProperty> properties = new ArrayList<>();

List<HierarchicalConfiguration> propertyList = config.configurationsAt("/property");
for (HierarchicalConfiguration prop : propertyList) {
for (int i = 0; i < propertyList.size(); i++) {
HierarchicalConfiguration prop = propertyList.get(i);
String property = "/property[" + (i+1) + "]";

ProcessProperty pp = new ProcessProperty();
// general values for property
pp.setName(prop.getString("@name"));
Expand Down Expand Up @@ -549,15 +554,40 @@ public List<ProcessProperty> getProcessCreationProperties(Process process, Strin
pp.getProcessCreationConditions().add(new StringPair(hc.getString("@property"), hc.getString("@value")));
}

// possible values
pp.getPossibleValues().addAll(Arrays.stream(prop.getStringArray("/value"))
.map(v -> new SelectItem(v, v))
.toList());
if (Type.VOCABULARYREFERENCE.equals(pp.getType()) || Type.VOCABULARYMULTIREFERENCE.equals(pp.getType())) {
populatePossibleValuesWithVocabulary(property, pp);
} else {
// possible values
pp.getPossibleValues().addAll(Arrays.stream(prop.getStringArray("/value"))
.map(v -> new SelectItem(v, v))
.toList());
}

properties.add(pp);
}
}
return properties;

}

private void populatePossibleValuesWithVocabulary(String property, ProcessProperty pp) {
String vocabularyName = config.getString(property + "/vocabulary");
try {
long vocabularyId = VocabularyAPIManager.getInstance().vocabularies().findByName(vocabularyName).getId();
pp.setPossibleValues(new LinkedList<>());
// this "Please select" element is only required for non drop-down badge components, as this component handles it itself
if (Type.VOCABULARYREFERENCE.equals(pp.getType())) {
pp.getPossibleValues().add(new SelectItem("", Helper.getTranslation("bitteAuswaehlen")));
}
pp.getPossibleValues().addAll(VocabularyAPIManager.getInstance().vocabularyRecords().list(vocabularyId)
.all()
.request()
.getContent()
.stream()
.map(r -> new SelectItem(r.getURI(), r.getMainValue()))
.toList());
} catch (APIException e) {
log.warn("Unable to parse vocabulary (multi) reference property \"{}\"", property, e);
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/goobi/production/properties/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public enum Type {
LINK("link"),
METADATA("metadata"),
HTML("html"),
VOCABULARYREFERENCE("vocabularyreference");
VOCABULARYREFERENCE("vocabularyreference"),
VOCABULARYMULTIREFERENCE("vocabularymultireference");

@Getter
private String name;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ mets_navigateTwoImagesRight=Zwei Seiten nach rechts navigieren
mets_no_metadata_assigned=Es wurden keine Metadaten zugewiesen
mets_no_metadatagroups_assigned=Es wurden keine Metadatengruppen zugewiesen
mets_no_persons_assigned=Es wurden keine Personen zugewiesen
mets_notRestricted=Nicht zugriffsbeschr\u00E4nkt
mets_notRestricted=Zugriffsbeschr\u00E4nkung aktivieren zzz
mets_pageArea=Bereich auf {0}
mets_paginationAssignmentError=Die Seiten konnten nicht zugewiesen werden. M\u00F6glicherweise fehlt die erste oder letzte Seite oder die Reihenfolge ist vertauscht.
mets_personsOfCurrentDocStruct=Personen des ausgew\u00E4hlten Strukturelements
Expand All @@ -1886,7 +1886,7 @@ mets_removeTheseImages=Diese Bilder aus der Seitenzuweisung entfernen
mets_resetImageRotation=Bild zur\u00FCcksetzen
mets_resetPagination=Paginierung vollst\u00E4ndig zur\u00FCcksetzen
mets_reset_pagination_confirmation=Soll die Paginierung wirklich vollst\u00E4ndig zur\u00FCckgesetzt werden? Diese \u00C4nderung wird auf die Festplatte geschrieben und kann nur durch den Eingriff eines Administrators r\u00FCckg\u00E4ngig gemacht werden
mets_restricted=Zugriffsbeschr\u00E4nkt
mets_restricted=Zugriffsbeschr\u00E4nkung aktiv. Hier klicken, um diese zu entfernen. zzz
mets_rotateImageLeft=Bild nach links rotieren
mets_rotateImageRight=Bild nach rechts rotieren
mets_selectCountingType=Auswahl der Z\u00E4hlweise
Expand Down
Loading

0 comments on commit 15a1d5c

Please sign in to comment.