diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java index 969004ef01b..dc69926aca4 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java @@ -116,6 +116,9 @@ public class Process extends BaseTemplateBean { @Column(name = "inChoiceListShown") Boolean inChoiceListShown; + @Column(name = "ocrd_workflow_id") + private String ocrdWorkflowId; + @Transient private User blockedUser; @@ -651,4 +654,23 @@ public void setNumberOfImages(int numberOfImages) { public void setNumberOfStructures(int numberOfStructures) { this.numberOfStructures = numberOfStructures; } + + /** + * Get OCR-D workflow identifier. + * + * @return The OCR-D workflow identifier + */ + public String getOcrdWorkflowId() { + return ocrdWorkflowId; + } + + /** + * Set the OCR-D workflow identifier. + * + * @param ocrdWorkflowId + * The identifier of the OCR-D workflow + */ + public void setOcrdWorkflowId(String ocrdWorkflowId) { + this.ocrdWorkflowId = ocrdWorkflowId; + } } diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java index 93e997ab8ce..e26c256a697 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java @@ -65,6 +65,9 @@ public class Template extends BaseTemplateBean { @JoinColumn(name = "project_id", foreignKey = @ForeignKey(name = "FK_project_x_template_project_id")) }) private List projects; + @Column(name = "ocrd_workflow_id") + private String ocrdWorkflowId; + /** * Constructor. */ @@ -168,6 +171,26 @@ public void setWorkflow(Workflow workflow) { this.workflow = workflow; } + + /** + * Get OCR-D workflow identifier. + * + * @return value of OCR-D workflow identifier + */ + public String getOcrdWorkflowId() { + return ocrdWorkflowId; + } + + /** + * Set the OCR-D workflow identifier. + * + * @param ocrdWorkflowId + * The identifier of the OCR-D workflow + */ + public void setOcrdWorkflowId(String ocrdWorkflowId) { + this.ocrdWorkflowId = ocrdWorkflowId; + } + /** * Get projects list. * diff --git a/Kitodo-DataManagement/src/main/resources/db/migration/V2_126__Add_authority_and_fields_for_ocrd_workflows.sql b/Kitodo-DataManagement/src/main/resources/db/migration/V2_126__Add_authority_and_fields_for_ocrd_workflows.sql new file mode 100644 index 00000000000..336275943f2 --- /dev/null +++ b/Kitodo-DataManagement/src/main/resources/db/migration/V2_126__Add_authority_and_fields_for_ocrd_workflows.sql @@ -0,0 +1,17 @@ +-- +-- (c) Kitodo. Key to digital objects e. V. +-- +-- This file is part of the Kitodo project. +-- +-- It is licensed under GNU General Public License version 3 or later. +-- +-- For the full copyright and license information, please read the +-- GPL3-License.txt file that was distributed with this source code. +-- + +-- Add authority to assign OCR-D workflow in template or process details +INSERT IGNORE INTO authority (title) VALUES ('assignOcrdWorkflow_clientAssignable'); + +-- Add columns of OCR-D workflow identifier +ALTER TABLE process ADD ocrd_workflow_id varchar(255) DEFAULT NULL; +ALTER TABLE template ADD ocrd_workflow_id varchar(255) DEFAULT NULL; diff --git a/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java b/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java index c00448985bd..70fee5f5879 100644 --- a/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java +++ b/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java @@ -46,6 +46,12 @@ public enum ParameterCore implements ParameterInterface { */ DIR_RULESETS(new Parameter("directory.rulesets")), + /** + * Absolute path to the directory that the OCR-D workflow files will be + * read from. It must be terminated by a directory separator ("/"). + */ + OCRD_WORKFLOWS_DIR(new Parameter<>("ocrd.workflows.directory", "")), + /** * Absolute path to the directory that XSLT files are stored in which are used * to transform the "XML log" (as visible from the XML button in the processes diff --git a/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java b/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java index 032f46ef4ba..72eb057e8e4 100644 --- a/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java +++ b/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java @@ -222,6 +222,15 @@ public boolean hasAuthorityToAddOnProjectPage() { return securityAccessService.hasAuthorityToAddOnProjectPage(); } + /** + * Check if the current user has the authority to add OCR-D workflow. + * + * @return true if the current user has the authority to add OCR-D workflow. + */ + public boolean hasAuthorityToAssignOcrdWorkflow() { + return securityAccessService.hasAuthorityToAssignOcrdWorkflow(); + } + /** * Check if the current user has the authority to delete the batch. * diff --git a/Kitodo/src/main/java/org/kitodo/production/converter/OcrdWorkflowConverter.java b/Kitodo/src/main/java/org/kitodo/production/converter/OcrdWorkflowConverter.java new file mode 100644 index 00000000000..4070df06cf5 --- /dev/null +++ b/Kitodo/src/main/java/org/kitodo/production/converter/OcrdWorkflowConverter.java @@ -0,0 +1,45 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.production.converter; + +import java.util.Objects; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.inject.Named; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; +import org.kitodo.production.services.ServiceManager; + + +@Named +public class OcrdWorkflowConverter extends BeanConverter implements Converter { + + @Override + public Object getAsObject(FacesContext context, UIComponent component, String value) { + if (StringUtils.isNotEmpty(value)) { + return ServiceManager.getOcrdWorkflowService().getOcrdWorkflow(value); + } + return null; + } + + @Override + public String getAsString(FacesContext context, UIComponent component, Object value) { + if (Objects.nonNull(value) && value instanceof Pair) { + return (String) ((Pair) value).getKey(); + } + return null; + } + +} diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java index adf505d954e..0bd56c0dcbf 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java @@ -31,6 +31,7 @@ import javax.inject.Named; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.config.ConfigCore; @@ -877,6 +878,47 @@ public List getProjects() { return ServiceManager.getProjectService().getAllForSelectedClient(); } + /** + * Get list of OCR-D workflows for select list. + * + * @return list of OCR-D workflows + */ + public List> getOcrdWorkflows() { + return ServiceManager.getOcrdWorkflowService().getOcrdWorkflows(); + } + + /** + * Get the OCR-D workflow. + * + * @return Immutable key value pair + */ + public Pair getOcrdWorkflow() { + return ServiceManager.getOcrdWorkflowService().getOcrdWorkflow(process.getOcrdWorkflowId()); + } + + /** + * Get the OCR-D workflow of process template. + * + * @return Immutable key value pair + */ + public Pair getOcrdWorkflowOfTemplate() { + return ServiceManager.getOcrdWorkflowService().getOcrdWorkflow(process.getTemplate().getOcrdWorkflowId()); + } + + /** + * Set the OCR-D workflow. + * + * @param ocrdWorkflow + * The immutable key value pair + */ + public void setOcrdWorkflow(Pair ocrdWorkflow) { + String ocrdWorkflowId = StringUtils.EMPTY; + if (Objects.nonNull(ocrdWorkflow)) { + ocrdWorkflowId = ocrdWorkflow.getKey().toString(); + } + process.setOcrdWorkflowId(ocrdWorkflowId); + } + /** * Get rulesets for select list. * diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java index 2af30725d4d..e852d31f89b 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java @@ -24,6 +24,7 @@ import javax.inject.Named; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.data.database.beans.Docket; @@ -274,6 +275,38 @@ public List getWorkflows() { return ServiceManager.getWorkflowService().getAvailableWorkflows(); } + /** + * Get list of OCR-D workflows for select list. + * + * @return list of OCR-D workflows + */ + public List> getOcrdWorkflows() { + return ServiceManager.getOcrdWorkflowService().getOcrdWorkflows(); + } + + /** + * Get the OCR-D workflow. + * + * @return Immutable key value pair + */ + public Pair getOcrdWorkflow() { + return ServiceManager.getOcrdWorkflowService().getOcrdWorkflow(template.getOcrdWorkflowId()); + } + + /** + * Set the OCR-D workflow. + * + * @param ocrdWorkflow + * The immutable key value pair + */ + public void setOcrdWorkflow(Pair ocrdWorkflow) { + String ocrdWorkflowId = StringUtils.EMPTY; + if (Objects.nonNull(ocrdWorkflow)) { + ocrdWorkflowId = ocrdWorkflow.getKey().toString(); + } + template.setOcrdWorkflowId(ocrdWorkflowId); + } + /** * Check if user is not assigned to the project. Used for disabling projects. * diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java b/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java index 43571f8e4f8..2ff1e071157 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java @@ -21,6 +21,7 @@ import java.util.regex.Pattern; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.dataformat.LogicalDivision; @@ -70,10 +71,9 @@ private enum MetadataLevel { * be replaced. */ private static final Pattern VARIABLE_FINDER_REGEX = Pattern.compile( - "(\\$?)\\((?:(prefs|processid|processtitle|projectid|stepid|stepname|generatorsource|generatorsourcepath)|" - + "(?:(meta|process|product|template)\\.(?:(firstchild|topstruct)\\.)?([^)]+)|" - + "(?:(filename|basename|relativepath))))\\)"); - + "(\\$?)\\((?:(prefs|processid|processtitle|projectid|stepid|stepname|generatorsource|generatorsourcepath|ocrdworkflowid)|" + + "(?:(meta|process|product|template)\\.(?:(firstchild|topstruct)\\.)?([^)]+)|" + + "(?:(filename|basename|relativepath))))\\)"); /** * The map is filled with replacement instructions that are required for * backwards compatibility with version 2. @@ -244,6 +244,8 @@ private String determineReplacementForInternalValue(Matcher variableFinder) { case "generatorsource" : case "generatorsourcepath": return determineReplacementForGeneratorSource(variableFinder, variableFinder.group(2)); + case "ocrdworkflowid": + return determineReplacementForOcrdWorkflowId(variableFinder); default: logger.warn("Cannot replace \"{}\": no such case defined in switch", variableFinder.group()); return variableFinder.group(); @@ -281,6 +283,28 @@ private String determineReplacementForProcessid(Matcher variableFinder) { return variableFinder.group(1) + process.getId().toString(); } + private String determineReplacementForOcrdWorkflowId(Matcher variableFinder) { + if (Objects.isNull(process)) { + logger.warn("Cannot replace \"(ocrdworkflowid)\": no process given"); + return variableFinder.group(1); + } + + if (StringUtils.isNotEmpty(process.getOcrdWorkflowId())) { + return variableFinder.group(1) + process.getOcrdWorkflowId(); + } + + if (Objects.isNull(process.getTemplate())) { + logger.warn("Cannot replace \"(ocrdworkflowid)\": process has no template assigned"); + return variableFinder.group(1); + } + + if (StringUtils.isEmpty(process.getTemplate().getOcrdWorkflowId())) { + logger.warn("Cannot replace \"(ocrdworkflowid)\": template has no OCR-D workflow assigned"); + return variableFinder.group(1); + } + return variableFinder.group(1) + process.getTemplate().getOcrdWorkflowId(); + } + private String determineReplacementForProcesstitle(Matcher variableFinder) { if (Objects.isNull(process)) { logger.warn("Cannot replace \"(processtitle)\": no process given"); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/ServiceManager.java b/Kitodo/src/main/java/org/kitodo/production/services/ServiceManager.java index 10bbe24abe1..30c82187d79 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/ServiceManager.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/ServiceManager.java @@ -48,6 +48,7 @@ import org.kitodo.production.services.image.ImageService; import org.kitodo.production.services.index.IndexingService; import org.kitodo.production.services.migration.MigrationService; +import org.kitodo.production.services.ocr.OcrdWorkflowService; import org.kitodo.production.services.schema.SchemaService; import org.kitodo.production.services.security.SecurityAccessService; import org.kitodo.production.services.security.SessionService; @@ -83,6 +84,7 @@ public class ServiceManager { private static MetsService metsService; private static MigrationService migrationService; private static ImportConfigurationService importConfigurationService; + private static OcrdWorkflowService ocrdWorkflowService; private static PropertyService propertyService; private static ProcessService processService; private static ProjectService projectService; @@ -201,6 +203,12 @@ private static void initializeFolderService() { } } + private static void initializeOcrdWorkflowService() { + if (Objects.isNull(ocrdWorkflowService)) { + ocrdWorkflowService = OcrdWorkflowService.getInstance(); + } + } + private static void initializeProjectService() { if (Objects.isNull(projectService)) { projectService = ProjectService.getInstance(); @@ -507,6 +515,17 @@ public static FolderService getFolderService() { return folderService; } + /** + * Initialize OcrdWorkflowService if it is not yet initialized and next return + * it. + * + * @return OcrdWorkflowService object + */ + public static OcrdWorkflowService getOcrdWorkflowService() { + initializeOcrdWorkflowService(); + return ocrdWorkflowService; + } + /** * Initialize ProjectService if it is not yet initialized and next return * it. diff --git a/Kitodo/src/main/java/org/kitodo/production/services/ocr/OcrdWorkflowService.java b/Kitodo/src/main/java/org/kitodo/production/services/ocr/OcrdWorkflowService.java new file mode 100644 index 00000000000..ab8d4f41e18 --- /dev/null +++ b/Kitodo/src/main/java/org/kitodo/production/services/ocr/OcrdWorkflowService.java @@ -0,0 +1,102 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.production.services.ocr; + +import java.io.IOException; +import java.nio.file.FileVisitOption; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.kitodo.config.ConfigCore; +import org.kitodo.config.enums.ParameterCore; + +public class OcrdWorkflowService { + + private static final Logger logger = LogManager.getLogger(OcrdWorkflowService.class); + private static volatile OcrdWorkflowService instance = null; + + /** + * Return singleton variable of type OcrdWorkflowService. + * + * @return unique instance of OcrdWorkflowService + */ + public static OcrdWorkflowService getInstance() { + OcrdWorkflowService localReference = instance; + if (Objects.isNull(localReference)) { + synchronized (OcrdWorkflowService.class) { + localReference = instance; + if (Objects.isNull(localReference)) { + localReference = new OcrdWorkflowService(); + instance = localReference; + } + } + } + return localReference; + } + + /** + * Get list of OCR-D workflows from directory. + *

+ * The files are relative paths to the OCR-D workflow directory. + *

+ * + * @return list of OCR-D workflows + */ + public List> getOcrdWorkflows() { + String ocrdWorkflowsDirectoryConfig = ConfigCore.getParameterOrDefaultValue(ParameterCore.OCRD_WORKFLOWS_DIR); + if (StringUtils.isNotEmpty(ocrdWorkflowsDirectoryConfig)) { + Path ocrdWorkflowsDirectory = Path.of(ocrdWorkflowsDirectoryConfig); + if (Files.isDirectory(ocrdWorkflowsDirectory)) { + try (Stream ocrProfilePaths = Files.walk(ocrdWorkflowsDirectory, FileVisitOption.FOLLOW_LINKS)) { + return ocrProfilePaths.filter(Files::isRegularFile).map(Path::toAbsolutePath).sorted() + .map(path -> getImmutablePairFromPath(path, ocrdWorkflowsDirectory)) + .collect(Collectors.toList()); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } + } + return new ArrayList<>(); + } + + private static Pair getImmutablePairFromPath(Path filePath, Path ocrdWorkflowsDirectory) { + String path = filePath.toString(); + path = path.replace(ocrdWorkflowsDirectory.toString(), StringUtils.EMPTY); + path = StringUtils.removeStart(path, "/"); + return ImmutablePair.of(path, path); + } + + /** + * Get an OCR-D workflow by identifier. + * + * @param ocrdWorkflowId The OCR-D workflow identifier + * @return The OCR-D workflow + */ + public Pair getOcrdWorkflow(String ocrdWorkflowId) { + if (StringUtils.isNotEmpty(ocrdWorkflowId)) { + return getOcrdWorkflows().stream().filter(pair -> pair.getKey().equals(ocrdWorkflowId)).findFirst() + .orElse(null); + } + return null; + } + +} diff --git a/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java b/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java index 963344c9b9d..97a1967786a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java @@ -233,6 +233,15 @@ public boolean hasAuthorityToAddOnProjectPage() { return hasAnyAuthorityForClient("addProject, addTemplate, addWorkflow, addDocket, addRuleset"); } + /** + * Check if the current user has the authority to assign an OCR-D workflow to template or process. + * + * @return true if the current user has the authority to assign an OCR-D workflow + */ + public boolean hasAuthorityToAssignOcrdWorkflow() { + return hasAnyAuthorityForClient("assignOcrdWorkflow"); + } + /** * Check if the current user has the authority to delete the batch. * diff --git a/Kitodo/src/main/resources/kitodo_config.properties b/Kitodo/src/main/resources/kitodo_config.properties index 6dba7badc64..e1fb72ff1c8 100644 --- a/Kitodo/src/main/resources/kitodo_config.properties +++ b/Kitodo/src/main/resources/kitodo_config.properties @@ -71,6 +71,9 @@ directory.modules=/usr/local/kitodo/modules/ # Falls Dateien zum Debuggen / Tracen geschrieben werden sollen, hier ein Verzeichnis angeben directory.debug=/usr/local/kitodo/debug/ +# Absolute path to the directory that the OCR-D workflow files will be +# read from. It must be terminated by a directory separator ("/"). +ocrd.workflows.directory=/usr/local/kitodo/ocrd_workflows/ # ----------------------------------- # Directory management diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 40df24eb61b..9f50b2a9971 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -58,6 +58,7 @@ ARCHIVED=Archiviert assigned=Zugewiesen assignedTo=In Bearbeitung durch assignMedia=und ausgew\u00E4hlte Medien zuweisen +assignOcrdWorkflow=OCR-D Workflow zuweisen assignToNextElement=Mit n\u00E4chstem Element verkn\u00FCpfen ats=ATS actions=Aktionen @@ -845,6 +846,7 @@ numberVolumes=Anzahl der B\u00E4nde numberOfMetadata=Anzahl Metadaten objectType=Objekttyp ocr=OCR +ocrdWorkflow=OCR-D Workflow ok=Ok oldPassword=Altes Passwort onlySelectedPages=Nur die markierten Seiten @@ -896,6 +898,7 @@ position=Position ppn=PPN priority=Priorit\u00E4t process=Vorgang +processConfig.fromTemplate=aus Produktionsvorlage processData=Vorgangsdaten processDetails=Vorgangsdetails processList=Vorgangsliste diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index dbdad175a7a..049f9cc6243 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -58,6 +58,7 @@ ARCHIVED=Archived assigned=Assigned assignedTo=In edition by assignMedia=and assign selected media +assignOcrdWorkflow=Assign OCR-D workflow assignToNextElement=Assign to next element ats=ATS actions=Actions @@ -846,6 +847,7 @@ numberVolumes=Number of volumes numberOfMetadata=Number of metadata objectType=Object type ocr=OCR +ocrdWorkflow=OCR-D workflow ok=Ok oldPassword=Old password onlySelectedPages=Only the selected pages @@ -897,6 +899,7 @@ position=Position ppn=PPN priority=Priority process=Process +processConfig.fromTemplate=From process template processData=Process data processDetails=Process details processList=Process list diff --git a/Kitodo/src/main/resources/xslt/dfg-viewer.xsl b/Kitodo/src/main/resources/xslt/dfg-viewer.xsl index fe27b34bdb1..a38b30f33cc 100644 --- a/Kitodo/src/main/resources/xslt/dfg-viewer.xsl +++ b/Kitodo/src/main/resources/xslt/dfg-viewer.xsl @@ -11,13 +11,135 @@ * GPL3-License.txt file that was distributed with this source code. * --> - + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + physSequence + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processEdit/details.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processEdit/details.xhtml index c928b1bbf85..45474d56a97 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processEdit/details.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processEdit/details.xhtml @@ -13,6 +13,7 @@ @@ -46,6 +47,7 @@ + @@ -80,6 +82,22 @@ + +
+ + + + + + +
diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/roleEdit/details.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/roleEdit/details.xhtml index 34752a6435e..503a33fe4f9 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/roleEdit/details.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/roleEdit/details.xhtml @@ -42,52 +42,53 @@ -
- - - - -

- -

- - #{msgs.available} - #{msgs.assigned} - -
+ + + + +

+ +

+ + #{msgs.available} + #{msgs.assigned} + +
+
- - -

- -

- - #{msgs.available} - #{msgs.assigned} - -
-
-
+ + + +

+ +

+ + #{msgs.available} + #{msgs.assigned} + +
+
+ diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/templateEdit/details.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/templateEdit/details.xhtml index 73cd95a1402..88005b27ae3 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/templateEdit/details.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/templateEdit/details.xhtml @@ -13,6 +13,7 @@ @@ -95,6 +96,21 @@ +
+ + + + + + +
diff --git a/Kitodo/src/test/java/org/kitodo/production/helper/VariableReplacerTest.java b/Kitodo/src/test/java/org/kitodo/production/helper/VariableReplacerTest.java index de8cee8174e..403fbaf4b24 100644 --- a/Kitodo/src/test/java/org/kitodo/production/helper/VariableReplacerTest.java +++ b/Kitodo/src/test/java/org/kitodo/production/helper/VariableReplacerTest.java @@ -23,6 +23,7 @@ import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.beans.Project; import org.kitodo.data.database.beans.Ruleset; +import org.kitodo.data.database.beans.Template; public class VariableReplacerTest { @@ -159,6 +160,26 @@ public void shouldReplaceGeneratorSourcePath() { replaced); } + @Test + public void shouldReplaceOcrdWorkflowId() { + Process process = prepareProcess(); + Template template = new Template(); + template.setOcrdWorkflowId("/template-ocrd-workflow.sh"); + process.setTemplate(template); + + VariableReplacer variableReplacerTemplate = new VariableReplacer(null, process, null); + String replaced = variableReplacerTemplate.replace("-title (ocrdworkflowid) -hardcoded test"); + String expected = "-title " + template.getOcrdWorkflowId() + " -hardcoded test"; + assertEquals("String was replaced incorrectly!", expected, replaced); + + process.setOcrdWorkflowId("/process-ocrd-workflow.sh"); + VariableReplacer variableReplacerProcess = new VariableReplacer(null, process, null); + replaced = variableReplacerProcess.replace("-title (ocrdworkflowid) -hardcoded test"); + expected = "-title " + process.getOcrdWorkflowId() + " -hardcoded test"; + assertEquals("String was replaced incorrectly!", expected, replaced); + } + + private Process prepareProcess() { Process process = new Process(); process.setId(2);