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

Task action processor #5657

Merged
merged 42 commits into from
Oct 2, 2023
Merged

Conversation

markusweigelt
Copy link
Collaborator

@markusweigelt markusweigelt commented May 8, 2023

This pr add the new TaskActionProcessor and following TaskActions to process.

  • COMMENT action adds a comment to the task
  • ERROR_OPEN action lock the task and add an error comment when task status is OPEN or INWORK
  • ERROR_CLOSE action set the task status of logged task to OPEN
  • PROCESS action set task status of open task to INWORK
  • CLOSE action close a task

Please consider the updated documentation https://github.com/kitodo/kitodo-production/wiki/Developer_3.x-Active-MQ#processors and for simplified use of ActiveMQ testing, the Docker image and the Java client https://github.com/slub/kitodo-production-activemq.

@markusweigelt markusweigelt marked this pull request as ready for review May 8, 2023 16:22
@markusweigelt markusweigelt requested a review from solth June 5, 2023 15:11
@solth
Copy link
Member

solth commented Jun 14, 2023

@henning-gerhardt would you mind reviewing this pull request? As I am not very familiar with ActiveMQ, I am not very well suited for this review, I think.

@henning-gerhardt
Copy link
Collaborator

@solth , @markusweigelt : I can review this pull but reviewing it will take some time.

Copy link
Collaborator

@henning-gerhardt henning-gerhardt left a comment

Choose a reason for hiding this comment

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

This is the first round of reviewing this pull request and did only contain a read code review. Testing and getting experience with this pull request is next.

But I'm unsure about the setting task state to 'lock' as this is dangerous and was a sign of a big error in the workflow in the past. I will talk to you in next days.

@markusweigelt
Copy link
Collaborator Author

@henning-gerhardt I have added your comments from the review and hints from our conversation.

Task Action ERROR_OPEN

  • now only works in task processing status INWORK
  • If no correction identifier is set, the task remains in processing state INWORK

Task Action ERROR_CLOSE

  • If no correction identifier is set, the task processing state should be INWORK
  • If correction identifier is set, the task processing state should be LOCKED

The tests and the documentation linked above is adapted too.

Copy link
Collaborator

@henning-gerhardt henning-gerhardt left a comment

Choose a reason for hiding this comment

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

This is now a functional review. I tested a few use scenarios but I did not test the usage of the correction id! Without a correction id the new functionality is working even I'm not convinced by setting a task to "LOCKED" (red) as this is in my current experience world wrong: after a "DONE" (green) task only a "OPEN" (yellow) or "INPROCESS" (orange) task state an follow and never a "LOCKED" (red) state.

One bigger issue is that if a task is set to "INPROCESS" a second time the state is not saved to the database and the new processing time is even not updated.

I did even read your documentation in the wiki (thumbs up for this) but is was for me at least at two places confusing or not understandable to read:

ERROR_OPEN (documentation at https://github.com/kitodo/kitodo-production/wiki/Developer_3.x-Active-MQ#error_open)

Some kind of confusing to read "This action set the processing status of a task to LOCKED when correctionTaskId is set and creates an error comment." and later "When correctionTaskId is set the correction task is set to OPEN."

ERROR_CLOSE (documentation at https://github.com/kitodo/kitodo-production/wiki/Developer_3.x-Active-MQ#error_close)

It is difficult to understand or confusion to read (at least for me): Name of the action ingest that the task got closed. But first sentence says "OPEN". Next sentence says "LOCKED" (kind of close), except under some conditions is set or stay "INWORK" and last sentence says "DONE" (kind of close).

Maybe you can explain this two actions in a better or other way. Maybe even renaming the action names to more meaning and understandable names.

…x is already call, set processing date all the time
@markusweigelt
Copy link
Collaborator Author

markusweigelt commented Jul 5, 2023

@henning-gerhardt have incorporated your comments and hints in the implemenation. If you are satisfied with it, then please approve.

Copy link
Collaborator

@henning-gerhardt henning-gerhardt left a comment

Choose a reason for hiding this comment

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

Works for me in my usage scenarios without using a correction id.

@solth
Copy link
Member

solth commented Sep 28, 2023

@markusweigelt please rebase against current master.

@markusweigelt
Copy link
Collaborator Author

markusweigelt commented Sep 28, 2023

@solth Merged against the current master. The current error in the CI is unrelated to this PR. ( Occured only in my repo actions run https://github.com/markusweigelt/kitodo-production/actions/runs/6338902470/job/17216941936)

import org.kitodo.data.database.enums.TaskEditType;
import org.kitodo.data.database.enums.TaskStatus;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.data.elasticsearch.exceptions.CustomResponseException;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import org.kitodo.data.elasticsearch.exceptions.CustomResponseException;

Unused import

currentTask.getProcessingStatus())) || (mapMessageObjectReader.hasField(
KEY_CORRECTION_TASK_ID) && !TaskStatus.LOCKED.equals(currentTask.getProcessingStatus()))) {
throw new ProcessorException(
"Status of task is not INWORK if there is a no corrected task ID or LOCKED if there is a corrected task ID.");
Copy link
Member

Choose a reason for hiding this comment

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

Just curious: shouldn't this be "correction task ID" instead of "corrected task ID"? It is not yet corrected at this moment, is it?

@solth
Copy link
Member

solth commented Sep 29, 2023

@markusweigelt I am not sure but I think the following line in https://github.com/markusweigelt/kitodo-production/blob/edfe9b1176d973a193d8fee99376db9c6e073321/Kitodo/src/main/java/org/kitodo/production/forms/CommentForm.java#L243 can potentially throw a NullPointerException that needs to be handled because now Comment.correctionComment can be null, right?

if (!processComment.isCorrected()
                        && processComment.getCorrectionTask().getTitle().equals(comment.getCorrectionTask().getTitle())) {

@markusweigelt
Copy link
Collaborator Author

@solth I resolved a potential null pointer exception and checked if there were more occurrences with 'getCorrectionTask,' but I didn't find any.

@solth solth merged commit eb3d4df into kitodo:master Oct 2, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants