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
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2b3812c
Initial implementation of step state processor
markusweigelt Jan 30, 2023
2aca882
Merge branch 'master' into step-state-processor
markusweigelt May 3, 2023
a6d979b
Merge branch 'kitodo:master' into step-state-processor
markusweigelt May 3, 2023
234bdc4
Refactoring, improve documentation and checkstyle
markusweigelt May 3, 2023
a294a17
Rename step to task
markusweigelt May 3, 2023
dfbec97
Minor improvements
markusweigelt May 3, 2023
623ce86
Update Kitodo/src/main/resources/kitodo_config.properties
markusweigelt May 3, 2023
464b229
Revert WorkflowControllerService changes
markusweigelt May 3, 2023
3d49255
Merge branch 'step-state-processor' of github.com:markusweigelt/kitod…
markusweigelt May 3, 2023
2c22629
Revert changes and add null check again
markusweigelt May 3, 2023
55c1b80
Improve order of null check
markusweigelt May 3, 2023
0a6d5d6
Rename processor and enium to more unambiguous name, inital adding test
markusweigelt May 4, 2023
5a89fed
Renaming processor and enum, improve tests and processor
markusweigelt May 5, 2023
b566b5f
Improvements comments and add futher tests
markusweigelt May 8, 2023
5fc60bc
Rename comment dao function
markusweigelt May 8, 2023
f85e32c
Improve comment and fix bug
markusweigelt May 8, 2023
ae85dfb
Remove unnecessary comment from kitodo_config.properties
markusweigelt May 8, 2023
69d4f1a
Improve comment
markusweigelt May 8, 2023
b288bbe
Use switch case, rename comment
markusweigelt May 10, 2023
b81be78
Add default to switch case
markusweigelt May 10, 2023
44ec676
Improvments of error open and close behaviour
markusweigelt May 10, 2023
07989da
Add javadoc
markusweigelt May 10, 2023
bfb6ea1
Add test for correction task
markusweigelt May 10, 2023
f73738d
Change javadoc
markusweigelt May 11, 2023
476f0a8
Merge branch 'kitodo:master' into task-action-processor
markusweigelt May 15, 2023
56cf1d5
Merge branch 'kitodo:master' into task-action-processor
markusweigelt May 23, 2023
13bd1d3
Update Kitodo/src/main/java/org/kitodo/production/interfaces/activemq…
markusweigelt May 30, 2023
df3472d
Update Kitodo/src/main/java/org/kitodo/production/interfaces/activemq…
markusweigelt May 30, 2023
2c2d391
Update Kitodo/src/main/java/org/kitodo/production/interfaces/activemq…
markusweigelt May 30, 2023
263921d
Merge branch 'kitodo:master' into task-action-processor
markusweigelt Jun 5, 2023
48286d9
Refactoring correction task
markusweigelt Jun 5, 2023
92987da
Remove legacy check function
markusweigelt Jun 5, 2023
a44f395
Remove unnecessary formatting
markusweigelt Jun 5, 2023
7136064
Remove unnecessary formatting
markusweigelt Jun 5, 2023
dc0395e
Review changes
markusweigelt Jun 7, 2023
1d00f3f
Revert change of table name
markusweigelt Jun 7, 2023
d6ed2f6
Merge branch 'kitodo:master' into task-action-processor
markusweigelt Jun 13, 2023
1660538
Add code review improvements, change state to open errors and set tas…
markusweigelt Jun 23, 2023
b3aa64e
Update task action comments
markusweigelt Jun 23, 2023
12be95b
Remove seperate saveToIndex cause within save function the saveToInde…
markusweigelt Jul 5, 2023
edfe9b1
Merge branch 'kitodo:master' into task-action-processor
markusweigelt Sep 28, 2023
b7fa835
add verify method to compare correction tasks
markusweigelt Oct 2, 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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public enum TaskEditType {
/**
* Automatic = all kinds of automatic steps.
*/
AUTOMATIC(4, "automatic");
AUTOMATIC(4, "automatic"),

/**
* Queue = all kinds of changes by ActiveMQ.
*/
QUEUE(5, "queue");

private int value;
private String title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.kitodo.data.database.beans.Comment;
import org.kitodo.data.database.beans.Process;
import org.kitodo.data.database.beans.Task;
import org.kitodo.data.database.exceptions.DAOException;

public class CommentDAO extends BaseDAO<Comment> {
Expand Down Expand Up @@ -54,6 +55,18 @@ public List<Comment> getAllByProcess(Process process) {
Collections.singletonMap("processId", process.getId()));
}

/**
* Get all comments by task ordered by id ascending.
*
* @param task
* The current task to get the comments for
* @return List of comments
*/
public List<Comment> getAllByTask(Task task) {
return getByQuery("FROM Comment WHERE currentTask_id = :taskId ORDER BY id ASC",
markusweigelt marked this conversation as resolved.
Show resolved Hide resolved
Collections.singletonMap("taskId", task.getId()));
}

/**
* Save list of comments.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ public enum ParameterCore implements ParameterInterface {

ACTIVE_MQ_FINALIZE_STEP_QUEUE(new Parameter<UndefinedParameter>("activeMQ.finalizeStep.queue")),

ACTIVE_MQ_TASK_ACTION_QUEUE(new Parameter<UndefinedParameter>("activeMQ.taskAction.queue")),

ACTIVE_MQ_USER(new Parameter<UndefinedParameter>("activeMQ.user")),

ACTIVE_MQ_RESULTS_TOPIC(new Parameter<UndefinedParameter>("activeMQ.results.topic")),
Expand Down
36 changes: 36 additions & 0 deletions Kitodo/src/main/java/org/kitodo/exceptions/ProcessorException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.exceptions;

public class ProcessorException extends Exception {

/**
* Constructor with given exception.
*
* @param exception
* as Exception
*/
public ProcessorException(Exception exception) {
super(exception);
}

/**
* Constructor with given message.
*
* @param message
* the exception message
*/
public ProcessorException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.kitodo.data.database.beans.Process;
import org.kitodo.data.database.beans.Task;
import org.kitodo.data.database.enums.CommentType;
import org.kitodo.data.database.enums.TaskEditType;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.data.elasticsearch.exceptions.CustomResponseException;
import org.kitodo.data.exceptions.DataException;
Expand Down Expand Up @@ -159,7 +160,7 @@ public String addCommentToAllBatchProcesses() {
*/
private void reportProblem(Comment comment) {
try {
this.workflowControllerService.reportProblem(comment);
this.workflowControllerService.reportProblem(comment, TaskEditType.MANUAL_SINGLE);
} catch (DataException e) {
Helper.setErrorMessage("reportingProblem", logger, e);
}
Expand Down Expand Up @@ -225,11 +226,11 @@ public int getSizeOfPreviousStepsForProblemReporting() {
*/
public String solveProblem(Comment comment) {
try {
this.workflowControllerService.solveProblem(comment);
this.workflowControllerService.solveProblem(comment, TaskEditType.MANUAL_SINGLE);
} catch (DataException | DAOException | IOException e) {
Helper.setErrorMessage("SolveProblem", logger, e);
}
refreshProcess(this.currentTask.getProcess());
refreshProcess(comment.getCurrentTask().getProcess());
return MessageFormat.format(REDIRECT_PATH, "tasks");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class ActiveMQDirector implements Runnable, ServletContextListener {
private static Collection<? extends ActiveMQProcessor> services;

static {
services = Arrays.asList(new FinalizeStepProcessor());
services = Arrays.asList(new FinalizeStepProcessor(), new TaskActionProcessor());
}

private static Connection connection = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.kitodo.data.database.beans.Client;
import org.kitodo.data.database.beans.User;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.exceptions.ProcessorException;
import org.kitodo.production.enums.ReportLevel;
import org.kitodo.production.helper.Helper;
import org.kitodo.production.security.SecurityUserDetails;
Expand Down Expand Up @@ -63,7 +64,7 @@ public abstract class ActiveMQProcessor implements MessageListener {
* an object providing access to the fields of the received map
* message
*/
protected abstract void process(MapMessageObjectReader ticket) throws DAOException, JMSException;
protected abstract void process(MapMessageObjectReader ticket) throws ProcessorException, JMSException;

/**
* Instantiating the class ActiveMQProcessor always requires to pass the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.kitodo.data.database.beans.Property;
import org.kitodo.data.database.enums.CommentType;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.exceptions.ProcessorException;
import org.kitodo.production.forms.CurrentTaskForm;
import org.kitodo.production.services.ServiceManager;

Expand All @@ -44,32 +45,36 @@ public FinalizeStepProcessor() {
}

/**
* This is the main routine processing incoming tickets. It gets an
* CurrentTaskForm object, sets it to the appropriate step which is
* retrieved from the database, appends the message − if any − to the wiki
* field, and executes the form’s the step close function.
* This is the main routine processing incoming tickets. It gets an CurrentTaskForm object, sets it to the
* appropriate step which is retrieved from the database, appends the message − if any − to the wiki field, and
* executes the form’s the step close function.
*
* @param ticket
* the incoming message
* the incoming message
*/
@Override
protected void process(MapMessageObjectReader ticket) throws DAOException, JMSException {
protected void process(MapMessageObjectReader ticket) throws ProcessorException, JMSException {
CurrentTaskForm dialog = new CurrentTaskForm();
Integer stepID = ticket.getMandatoryInteger("id");
dialog.setCurrentTask(ServiceManager.getTaskService().getById(stepID));
if (ticket.hasField("properties")) {
updateProperties(dialog, ticket.getMapOfStringToString("properties"));
}
if (ticket.hasField("message")) {
Comment comment = new Comment();
comment.setProcess(dialog.getCurrentTask().getProcess());
comment.setAuthor(ServiceManager.getUserService().getCurrentUser());
comment.setMessage(ticket.getString("message"));
comment.setType(CommentType.INFO);
comment.setCreationDate(new Date());
ServiceManager.getCommentService().saveToDatabase(comment);
try {
Integer stepID = ticket.getMandatoryInteger("id");
dialog.setCurrentTask(ServiceManager.getTaskService().getById(stepID));

if (ticket.hasField("properties")) {
updateProperties(dialog, ticket.getMapOfStringToString("properties"));
}
if (ticket.hasField("message")) {
Comment comment = new Comment();
comment.setProcess(dialog.getCurrentTask().getProcess());
comment.setMessage(ticket.getString("message"));
comment.setAuthor(ServiceManager.getUserService().getCurrentUser());
comment.setType(CommentType.INFO);
comment.setCreationDate(new Date());
ServiceManager.getCommentService().saveToDatabase(comment);
}
dialog.closeTaskByUser();
} catch (DAOException e) {
throw new ProcessorException(e);
}
dialog.closeTaskByUser();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.production.interfaces.activemq;

public enum TaskAction {
/**
* Adds a comment to the task.
*/
COMMENT,

/**
* Lock a task and add an error comment when task status is OPEN or INWORK.
*/
ERROR_OPEN,

/**
* Set task status of locked task to OPEN.
*/
ERROR_CLOSE,

/**
* Set task status of open task to INWORK.
*/
PROCESS,

/**
* Close a task.
*/
CLOSE
}
Loading