Skip to content

Commit

Permalink
Merge pull request kitodo#5747 from effective-webwork/comments-docket
Browse files Browse the repository at this point in the history
Print comments onto docket
  • Loading branch information
solth authored Oct 18, 2023
2 parents ea50685 + 561424d commit 99e97da
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 37 deletions.
22 changes: 11 additions & 11 deletions Kitodo-API/src/main/java/org/kitodo/api/docket/DocketData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> comments = new ArrayList<>();

/** The template properties. */
private List<Property> templateProperties;
Expand Down Expand Up @@ -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<String> 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<String> comments) {
this.comments = comments;
}

/**
Expand Down
12 changes: 9 additions & 3 deletions Kitodo-Docket/src/main/java/org/kitodo/docket/ExportXmlLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,15 @@ private ArrayList<Element> 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<Element> 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<Element> processProperties = prepareProperties(docketData.getProcessProperties(), xmlns);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Property> templateProperties = new ArrayList<>();
Property propertyForDocket = new Property();
Expand Down
16 changes: 9 additions & 7 deletions Kitodo-Docket/src/test/resources/docket_multipage.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,15 @@
<fo:table line-height="14pt">
<fo:table-column column-width="12.8cm"/>
<fo:table-body>
<fo:table-row height="2cm" border-width="1pt" border-style="solid">
<fo:table-cell>
<fo:block>
<xsl:value-of select="kitodo:comment"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="kitodo:comments/kitodo:comment">
<fo:table-row border-width="1pt" border-style="solid">
<fo:table-cell>
<fo:block>
<xsl:value-of select="text()"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -2064,6 +2066,17 @@ private static ArrayList<org.kitodo.api.docket.Property> getDocketDataForPropert
return propertiesForDocket;
}

private static List<String> getDocketDataForComments(List<Comment> comments) {
List<String> 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<Map<String, Object>> getMetadataForIndex(Process process) {
return getMetadataForIndex(process, false);
}
Expand Down
16 changes: 9 additions & 7 deletions Kitodo/src/main/resources/docket.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,15 @@
<fo:table line-height="14pt">
<fo:table-column column-width="12.8cm"/>
<fo:table-body>
<fo:table-row height="2cm" border-width="1pt" border-style="solid">
<fo:table-cell>
<fo:block>
<xsl:value-of select="kitodo:comment"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="kitodo:comments/kitodo:comment">
<fo:table-row border-width="1pt" border-style="solid">
<fo:table-cell>
<fo:block>
<xsl:value-of select="text()"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>

Expand Down
16 changes: 9 additions & 7 deletions Kitodo/src/main/resources/docket_multipage.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,15 @@
<fo:table line-height="14pt">
<fo:table-column column-width="12.8cm"/>
<fo:table-body>
<fo:table-row height="2cm" border-width="1pt" border-style="solid">
<fo:table-cell>
<fo:block>
<xsl:value-of select="kitodo:comment"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="kitodo:comments/kitodo:comment">
<fo:table-row border-width="1pt" border-style="solid">
<fo:table-cell>
<fo:block>
<xsl:value-of select="text()"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>

Expand Down

0 comments on commit 99e97da

Please sign in to comment.