From 561424ddd8dd318f22105f8f046052c44ce44297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6hr?= Date: Thu, 10 Aug 2023 15:36:34 +0200 Subject: [PATCH] Print comments onto docket --- .../org/kitodo/api/docket/DocketData.java | 22 +++++++++---------- .../java/org/kitodo/docket/ExportXmlLog.java | 12 +++++++--- .../kitodo/docket/DocketDataGenerator.java | 3 ++- .../src/test/resources/docket_multipage.xsl | 16 ++++++++------ .../services/data/ProcessService.java | 15 ++++++++++++- Kitodo/src/main/resources/docket.xsl | 16 ++++++++------ .../src/main/resources/docket_multipage.xsl | 16 ++++++++------ 7 files changed, 63 insertions(+), 37 deletions(-) diff --git a/Kitodo-API/src/main/java/org/kitodo/api/docket/DocketData.java b/Kitodo-API/src/main/java/org/kitodo/api/docket/DocketData.java index 7b2d9b0e349..ef6b2c78272 100644 --- a/Kitodo-API/src/main/java/org/kitodo/api/docket/DocketData.java +++ b/Kitodo-API/src/main/java/org/kitodo/api/docket/DocketData.java @@ -39,8 +39,8 @@ public class DocketData { /** The creation Date of the process. */ private String creationDate; - /** A comment. */ - private String comment; + /** The comments. */ + private List comments = new ArrayList<>(); /** The template properties. */ private List templateProperties; @@ -185,22 +185,22 @@ public void setCreationDate(String creationDate) { } /** - * Gets the comment. + * Gets the comments. * - * @return The comment. + * @return The comments. */ - public String getComment() { - return comment; + public List getComments() { + return comments; } /** - * Sets the comment. + * Sets the comments. * - * @param comment - * The comment. + * @param comments + * The comments. */ - public void setComment(String comment) { - this.comment = comment; + public void setComments(List comments) { + this.comments = comments; } /** diff --git a/Kitodo-Docket/src/main/java/org/kitodo/docket/ExportXmlLog.java b/Kitodo-Docket/src/main/java/org/kitodo/docket/ExportXmlLog.java index 735ce9695d7..4e1e560d46b 100644 --- a/Kitodo-Docket/src/main/java/org/kitodo/docket/ExportXmlLog.java +++ b/Kitodo-Docket/src/main/java/org/kitodo/docket/ExportXmlLog.java @@ -300,9 +300,15 @@ private ArrayList processProcessInformation(DocketData docketData, Name ruleset.setText(docketData.getRulesetName()); processElements.add(ruleset); - Element comment = new Element("comment", xmlns); - comment.setText(docketData.getComment()); - processElements.add(comment); + Element comments = new Element("comments", xmlns); + List commentList = new ArrayList<>(); + for (String commentString : docketData.getComments()) { + Element comment = new Element("comment", xmlns); + comment.setText(commentString); + commentList.add(comment); + } + comments.addContent(commentList); + processElements.add(comments); List processProperties = prepareProperties(docketData.getProcessProperties(), xmlns); diff --git a/Kitodo-Docket/src/test/java/org/kitodo/docket/DocketDataGenerator.java b/Kitodo-Docket/src/test/java/org/kitodo/docket/DocketDataGenerator.java index 613c00cb03c..eed145b1584 100644 --- a/Kitodo-Docket/src/test/java/org/kitodo/docket/DocketDataGenerator.java +++ b/Kitodo-Docket/src/test/java/org/kitodo/docket/DocketDataGenerator.java @@ -14,6 +14,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.kitodo.api.docket.DocketData; @@ -32,7 +33,7 @@ public DocketData createDocketData(String processID, String signatur, String doc docketdata.setProcessName("ProcessTitle"); docketdata.setProjectName("projectTitle"); docketdata.setRulesetName("RulesetTitle"); - docketdata.setComment("A comment"); + docketdata.setComments(Collections.singletonList("A comment")); List templateProperties = new ArrayList<>(); Property propertyForDocket = new Property(); diff --git a/Kitodo-Docket/src/test/resources/docket_multipage.xsl b/Kitodo-Docket/src/test/resources/docket_multipage.xsl index ff6c22bdc17..f207a4519ad 100644 --- a/Kitodo-Docket/src/test/resources/docket_multipage.xsl +++ b/Kitodo-Docket/src/test/resources/docket_multipage.xsl @@ -334,13 +334,15 @@ - - - - - - - + + + + + + + + + diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java index 31f4218826d..0998c41634d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java @@ -37,6 +37,8 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -2036,7 +2038,7 @@ private static DocketData getDocketData(Process process) throws IOException { docketdata.setProcessName(process.getTitle()); docketdata.setProjectName(process.getProject().getTitle()); docketdata.setRulesetName(process.getRuleset().getTitle()); - docketdata.setComment(process.getWikiField()); + docketdata.setComments(getDocketDataForComments(process.getComments())); if (!process.getTemplates().isEmpty()) { docketdata.setTemplateProperties(getDocketDataForProperties(process.getTemplates())); @@ -2064,6 +2066,17 @@ private static ArrayList getDocketDataForPropert return propertiesForDocket; } + private static List getDocketDataForComments(List comments) { + List commentsForDocket = new ArrayList<>(); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + for (Comment comment : comments) { + String commentString = dateFormat.format(comment.getCreationDate()) + " " + + comment.getAuthor().getFullName() + ": " + comment.getMessage(); + commentsForDocket.add(commentString); + } + return commentsForDocket; + } + private List> getMetadataForIndex(Process process) { return getMetadataForIndex(process, false); } diff --git a/Kitodo/src/main/resources/docket.xsl b/Kitodo/src/main/resources/docket.xsl index 43608a11383..f4c3774e45f 100644 --- a/Kitodo/src/main/resources/docket.xsl +++ b/Kitodo/src/main/resources/docket.xsl @@ -333,13 +333,15 @@ - - - - - - - + + + + + + + + + diff --git a/Kitodo/src/main/resources/docket_multipage.xsl b/Kitodo/src/main/resources/docket_multipage.xsl index ff6c22bdc17..f207a4519ad 100644 --- a/Kitodo/src/main/resources/docket_multipage.xsl +++ b/Kitodo/src/main/resources/docket_multipage.xsl @@ -334,13 +334,15 @@ - - - - - - - + + + + + + + + +