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

Correction comment state #6155

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

solth
Copy link
Member

@solth solth commented Jul 30, 2024

This pull request slightly adjusts the WorkflowControllerService.solveProblem function so that a comment's corrected flag with value TRUE is saved to the database before closeTaskByUser is called. That method loads the comment from the database and requires the updated corrected state to work properly.

The updated corrected state is then saved to the index field correctionCommentStatus which in turn is used to determine whether the grey or red exclamation mark icon should be displayed in the process and task lists. Thereby fixes #5676

@solth solth added this to the Kitodo.Production 3.7.0 milestone Jul 30, 2024
@solth solth requested a review from BartChris July 30, 2024 14:59
} catch (DAOException e) {
Helper.setErrorMessage("errorSaving", new Object[] {"comment"}, logger, e);
if (Objects.nonNull(comment.getProcess())) {
comment.setProcess(ServiceManager.getProcessService().getById(comment.getProcess().getId()));
Copy link
Collaborator

@BartChris BartChris Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are setting the currentTask and the process again but do not save the comment object afterwards. If calling those setters is necessary should we not persist the comment object again?

Copy link
Member Author

@solth solth Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BartChris Yes, you are right, this is quite confusing. The reason why we re-add the process (and task!) to the comment without saving it again is that we are making use of a side effect here. This Comment object is used again in the calling method afterwards, but with an updated currentTask and process property. It's not a different process or task that is added here, but rather updated objects, so re-setting these properties in the comment acts as a "refresh" of the object. Since the database entry of the comment only contains the ID of the process and the currentTask, there is no need to save it again, because the IDs didn't change (e.g. its the same process and currentTask as before, like I mentioned above).

This is indeed implemented in a sub-optimal way and should be refactored more fundamentally when we find the time to do so but right now I do not have the resources for that, unfortunately. I think the bug should be fixed anyway, even if its just an incremental improvement over the status quo and not yet the optimal solution. I can add a comment or TODO as a reminder to the code that this code should be refactored and improved, if you like.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solth I see, thanks a lot for the explanation. In think you can go ahead and merge. Adding a TODO would be helpful.

@BartChris
Copy link
Collaborator

Functionality-wise everything works now, i just have a comment.

@BartChris BartChris self-requested a review August 1, 2024 08:46
@solth solth merged commit 1f5499d into kitodo:master Aug 1, 2024
5 checks passed
@solth solth deleted the correction-comment-state branch August 1, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marking a correction comment as "resolved" does not update the index properly
2 participants