Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from kitodo:master #258

Merged
merged 41 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
15ee10e
Improve correction icon
oliver-stoehr Jun 1, 2023
6785fe2
Pontus osterdahl patch 5 (#13)
pontus-osterdahl Jul 4, 2023
0069456
Codacy issues
pontus-osterdahl Jul 6, 2023
db782c9
Codacy
pontus-osterdahl Jul 6, 2023
f9368a8
Improve format
pontus-osterdahl Jul 6, 2023
803f85f
Add missing bracket
pontus-osterdahl Jul 6, 2023
7c5e9fb
Only allow edit/delete of most recent comment and by its author
pontus-osterdahl Jul 11, 2023
1314bd4
Remove unnecessary code and add helper method (#17)
pontus-osterdahl Jul 12, 2023
fda718c
Change return from null-String to void
pontus-osterdahl Jul 17, 2023
561424d
Print comments onto docket
oliver-stoehr Aug 10, 2023
85c48bd
Update editCommentDialog.xhtml
pontus-osterdahl Sep 21, 2023
bf81f34
Pontus osterdahl patch 5 (#13)
pontus-osterdahl Jul 4, 2023
99ebc0f
Codacy issues
pontus-osterdahl Jul 6, 2023
1c41067
Codacy
pontus-osterdahl Jul 6, 2023
c594b4d
Improve format
pontus-osterdahl Jul 6, 2023
2499735
Add missing bracket
pontus-osterdahl Jul 6, 2023
ca0ee71
Only allow edit/delete of most recent comment and by its author
pontus-osterdahl Jul 11, 2023
142866c
Remove unnecessary code and add helper method (#17)
pontus-osterdahl Jul 12, 2023
6e3ed30
Change return from null-String to void
pontus-osterdahl Jul 17, 2023
738f087
Update editCommentDialog.xhtml
pontus-osterdahl Sep 21, 2023
2afadc4
Merge branch 'Enable-editing-and-delete-info-comments' of https://git…
Sep 21, 2023
a650830
Merge branch 'master' into Enable-editing-and-delete-info-comments-patch
pontus-osterdahl Oct 4, 2023
2573802
Fix correction icon in processes widget
oliver-stoehr Oct 6, 2023
118c5b3
Add security policy
solth Oct 6, 2023
c83d603
Pontus osterdahl patch 11 (#19)
pontus-osterdahl Oct 9, 2023
371decc
Make removeComment non-static
pontus-osterdahl Oct 10, 2023
7e63222
Update Kitodo/src/main/java/org/kitodo/production/services/data/Comme…
pontus-osterdahl Oct 11, 2023
507d8df
Update Kitodo/src/main/java/org/kitodo/production/services/data/Comme…
pontus-osterdahl Oct 11, 2023
fd466ff
Update Kitodo/src/main/java/org/kitodo/production/services/data/Comme…
pontus-osterdahl Oct 11, 2023
a025c7a
Update Kitodo/src/main/webapp/WEB-INF/templates/includes/comments/edi…
pontus-osterdahl Oct 11, 2023
ef64c98
Update Kitodo/src/test/java/org/kitodo/production/services/data/Comme…
pontus-osterdahl Oct 11, 2023
e3abd88
Update Kitodo/src/test/java/org/kitodo/production/services/data/Comme…
pontus-osterdahl Oct 11, 2023
48a53aa
Update Kitodo/src/test/java/org/kitodo/production/services/data/Comme…
pontus-osterdahl Oct 11, 2023
40f3537
Merge pull request #5785 from pontus-osterdahl/Enable-editing-and-del…
solth Oct 13, 2023
ea50685
Merge pull request #5679 from effective-webwork/improve-correction-icon
solth Oct 13, 2023
3551dd3
Always reset password input fields when opening 'change password' dialog
solth Oct 13, 2023
99e97da
Merge pull request #5747 from effective-webwork/comments-docket
solth Oct 18, 2023
3dd478b
Merge pull request #5811 from effective-webwork/reset-password-input-…
solth Oct 18, 2023
6e8c322
Merge pull request #5804 from effective-webwork/security-policy
solth Oct 21, 2023
ec05719
Bump org.json:json from 20230227 to 20231013
dependabot[bot] Oct 23, 2023
98be130
Merge pull request #5814 from kitodo/dependabot/maven/org.json-json-2…
solth Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class Process extends BaseTemplateBean {
@OrderBy("ordering")
private List<Task> tasks;

@OneToMany(mappedBy = "process", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "process", cascade = CascadeType.PERSIST, orphanRemoval = true)
private List<Comment> comments;

@ManyToMany(cascade = CascadeType.ALL)
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,7 @@ public enum ObjectType {
FILTER("filter", "filters", true),
IMPORT_CONFIGURATION("importConfig.configuration", "importConfig.configurations", false),
MAPPING_FILE("mappingFile.file", "mappingFile.files", false),
COMMENT("comment", "comments", false),
NONE("", "", false);

private final String messageKeySingular;
Expand Down
65 changes: 59 additions & 6 deletions Kitodo/src/main/java/org/kitodo/production/forms/CommentForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
public class CommentForm extends BaseForm {
private static final Logger logger = LogManager.getLogger(CommentForm.class);
private boolean correctionComment = false;
private Comment editedComment = null;
private String commentMessage;
private String correctionTaskId;
private Task currentTask;
Expand All @@ -60,6 +61,21 @@ public Process getProcess() {
return process;
}

/**
* Remove a given comment.
*
* @param comment to be removed.
*/
public void removeComment(Comment comment) {
try {
ServiceManager.getCommentService().removeComment(comment);
saveProcessAndTasksToIndex();
} catch (CustomResponseException | DAOException | DataException | IOException e) {
Helper.setErrorMessage(ERROR_DELETING, new Object[]{ObjectType.COMMENT.getTranslationSingular()},
logger, e);
}
}

/**
* Set process by ID.
*
Expand Down Expand Up @@ -103,6 +119,32 @@ public void setCommentMessage(String commentMessage) {
this.commentMessage = commentMessage;
}

/**
* Set's edited comment.
*
* @param comment to be set as editedComment.
*/
public void setEditedComment(Comment comment) {
this.editedComment = comment;
}

/**
* Returns edited comment.
*
* @return edited comment.
*/
public Comment getEditedComment() {
return this.editedComment;
}

private void saveProcessAndTasksToIndex() throws CustomResponseException, DataException, IOException {
ServiceManager.getProcessService().saveToIndex(this.process, true);
for (Task task : this.process.getTasks()) {
// update tasks in elastic search index, which includes correction comment status
ServiceManager.getTaskService().saveToIndex(task, true);
}
}

/**
* Add a new comment to the process.
*/
Expand All @@ -128,12 +170,8 @@ public String addComment() {
}
try {
ServiceManager.getCommentService().saveToDatabase(comment);
ServiceManager.getProcessService().saveToIndex(this.process, true);
for (Task task : this.process.getTasks()) {
// update tasks in elastic search index, which includes correction comment status
ServiceManager.getTaskService().saveToIndex(task, true);
}
} catch (DAOException | CustomResponseException | DataException | IOException e) {
saveProcessAndTasksToIndex();
} catch (CustomResponseException | DAOException | DataException | IOException e) {
Helper.setErrorMessage(ERROR_SAVING, logger, e);
}
newComment(false);
Expand All @@ -144,6 +182,21 @@ public String addComment() {
return null;
}

/**
* Saves the edited comment to database.
*/
public void saveEditedComment() {
if (Objects.nonNull(this.editedComment) && this.editedComment.getType().equals(CommentType.INFO)) {
try {
ServiceManager.getCommentService().saveToDatabase(this.editedComment);
saveProcessAndTasksToIndex();
} catch (CustomResponseException | DAOException | DataException | IOException e) {
Helper.setErrorMessage(ERROR_SAVING, logger, e);
}
}
this.editedComment = null;
}

/**
* Add a new comment to all batch processes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.kitodo.data.database.beans.Task;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.data.database.persistence.CommentDAO;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.SearchDatabaseService;
import org.primefaces.model.SortOrder;

Expand Down Expand Up @@ -91,4 +92,14 @@ public List<Comment> getAllCommentsByTask(Task task) {
public void saveList(List<Comment> list) throws DAOException {
dao.saveList(list);
}

/**
* Remove comment from database and resolve associations.
*
* @param comment to be removed.
*/
public void removeComment(Comment comment) throws DAOException {
comment.getProcess().getComments().remove(comment);
ServiceManager.getCommentService().removeFromDatabase(comment);
}
}
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
3 changes: 2 additions & 1 deletion Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ columnConfigurationSaved=Spaltenkonfiguration gespeichert
columnCount=Spaltenz\u00E4hlung
comment=Kommentieren
comments=Kommentare
commentDelete=Kommentar l\u00F6schen
commentEdit=Kommentar bearbeiten
commentWrite=Kommentar schreiben
configureColumns=Spalten konfigurieren
configurationChanged=Einstellungen ge\u00E4ndert
Expand Down Expand Up @@ -222,7 +224,6 @@ copyRolesToClient=Rollen zum Mandanten hinzuf\u00FCgen
copyTemplates=Projekt inkl. Templates kopieren
correction=Korrektur
correctionFor=Korrektur f\u00FCr Schritt
correctionK=K
correctionMessage=Korrekturmeldung
correctionMessageSend=Korrekturmeldung senden
correctionMessageSendAllTasks=Korrekturmeldung f\u00FCr alle Schritte senden
Expand Down
3 changes: 2 additions & 1 deletion Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ columnConfigurationSaved=Column configuration saved
columnCount=Column counting
comment=Add comment
comments=Comments
commentDelete=Delete comment
commentEdit=Edit comment
commentWrite=Write comment
configureColumns=Configure columns
configurationChanged=Configuration changed
Expand Down Expand Up @@ -222,7 +224,6 @@ copyRolesToClient=Copy roles to client
copyTemplates=Copy Project including Templates
correction=Correction
correctionFor=Correction for step
correctionK=C
correctionMessage=Correction message
correctionMessageSend=Send correction message
correctionMessageSendAllTasks=send correction message to all tasks
Expand Down
1 change: 0 additions & 1 deletion Kitodo/src/main/resources/messages/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ copyRolesToClient=Añadir funciones al cliente
copyTemplates=Copiar el proyecto incluyendo las plantillas
correction=Corrección
correctionFor=Corrección del paso
correctionK=C
correctionMessage=Mensaje de corrección
correctionMessageSend=Enviar mensaje de corrección
correctionMessageSendAllTasks=Enviar mensaje de corrección para todos los pasos
Expand Down
Loading
Loading