TSK-525: Replace force flags by separate methods
This commit is contained in:
parent
fd564b3053
commit
000a728f4e
|
|
@ -1,84 +1,84 @@
|
||||||
package pro.taskana;
|
package pro.taskana;
|
||||||
|
|
||||||
import javax.ejb.EJB;
|
import javax.ejb.EJB;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||||
import pro.taskana.exceptions.DomainNotFoundException;
|
import pro.taskana.exceptions.DomainNotFoundException;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.InvalidOwnerException;
|
import pro.taskana.exceptions.InvalidOwnerException;
|
||||||
import pro.taskana.exceptions.InvalidStateException;
|
import pro.taskana.exceptions.InvalidStateException;
|
||||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||||
import pro.taskana.exceptions.TaskNotFoundException;
|
import pro.taskana.exceptions.TaskNotFoundException;
|
||||||
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.impl.ObjectReference;
|
import pro.taskana.impl.ObjectReference;
|
||||||
|
|
||||||
@Path("/test")
|
@Path("/test")
|
||||||
public class TaskanaRestTest {
|
public class TaskanaRestTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TaskanaRestTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(TaskanaRestTest.class);
|
||||||
|
|
||||||
@EJB
|
@EJB
|
||||||
private TaskanaEjb taskanaEjb;
|
private TaskanaEjb taskanaEjb;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ClassificationService classificationService;
|
private ClassificationService classificationService;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException,
|
public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException,
|
||||||
ClassificationNotFoundException, ClassificationAlreadyExistException, InvalidWorkbasketException,
|
ClassificationNotFoundException, ClassificationAlreadyExistException, InvalidWorkbasketException,
|
||||||
TaskAlreadyExistException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
TaskAlreadyExistException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||||
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key", "cdiDomain");
|
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key", "cdiDomain");
|
||||||
workbasket.setName("wb");
|
workbasket.setName("wb");
|
||||||
workbasket.setType(WorkbasketType.PERSONAL);
|
workbasket.setType(WorkbasketType.PERSONAL);
|
||||||
taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
|
taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
|
||||||
Classification classification = classificationService.newClassification("TEST", "cdiDomain", "t1");
|
Classification classification = classificationService.newClassification("TEST", "cdiDomain", "t1");
|
||||||
taskanaEjb.getClassificationService().createClassification(classification);
|
taskanaEjb.getClassificationService().createClassification(classification);
|
||||||
|
|
||||||
Task task = taskanaEjb.getTaskService().newTask(workbasket.getKey());
|
Task task = taskanaEjb.getTaskService().newTask(workbasket.getKey());
|
||||||
task.setClassificationKey(classification.getKey());
|
task.setClassificationKey(classification.getKey());
|
||||||
ObjectReference objRef = new ObjectReference();
|
ObjectReference objRef = new ObjectReference();
|
||||||
objRef.setCompany("aCompany");
|
objRef.setCompany("aCompany");
|
||||||
objRef.setSystem("aSystem");
|
objRef.setSystem("aSystem");
|
||||||
objRef.setSystemInstance("anInstance");
|
objRef.setSystemInstance("anInstance");
|
||||||
objRef.setType("aType");
|
objRef.setType("aType");
|
||||||
objRef.setValue("aValue");
|
objRef.setValue("aValue");
|
||||||
task.setPrimaryObjRef(objRef);
|
task.setPrimaryObjRef(objRef);
|
||||||
|
|
||||||
Task result = taskanaEjb.getTaskService().createTask(task);
|
Task result = taskanaEjb.getTaskService().createTask(task);
|
||||||
|
|
||||||
logger.info(result.getId() + ":" + result.getOwner());
|
logger.info(result.getId() + ":" + result.getOwner());
|
||||||
return Response.status(200).entity(result.getId()).build();
|
return Response.status(200).entity(result.getId()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
public Response rollbackTask()
|
public Response rollbackTask()
|
||||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
||||||
InvalidWorkbasketException, TaskAlreadyExistException, InvalidArgumentException {
|
InvalidWorkbasketException, TaskAlreadyExistException, InvalidArgumentException {
|
||||||
taskanaEjb.triggerRollback();
|
taskanaEjb.triggerRollback();
|
||||||
return Response.status(204).build();
|
return Response.status(204).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public void completeTask(@PathParam("id") String id)
|
public void completeTask(@PathParam("id") String id)
|
||||||
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, ClassificationNotFoundException,
|
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, ClassificationNotFoundException,
|
||||||
NotAuthorizedException {
|
NotAuthorizedException {
|
||||||
logger.info(id);
|
logger.info(id);
|
||||||
taskanaEjb.getTaskService().completeTask(id, true);
|
taskanaEjb.getTaskService().forceCompleteTask(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,411 +1,401 @@
|
||||||
package pro.taskana;
|
package pro.taskana;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import pro.taskana.exceptions.AttachmentPersistenceException;
|
import pro.taskana.exceptions.AttachmentPersistenceException;
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||||
import pro.taskana.exceptions.ConcurrencyException;
|
import pro.taskana.exceptions.ConcurrencyException;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.InvalidOwnerException;
|
import pro.taskana.exceptions.InvalidOwnerException;
|
||||||
import pro.taskana.exceptions.InvalidStateException;
|
import pro.taskana.exceptions.InvalidStateException;
|
||||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||||
import pro.taskana.exceptions.TaskNotFoundException;
|
import pro.taskana.exceptions.TaskNotFoundException;
|
||||||
import pro.taskana.exceptions.TaskanaException;
|
import pro.taskana.exceptions.TaskanaException;
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.impl.BulkOperationResults;
|
import pro.taskana.impl.BulkOperationResults;
|
||||||
import pro.taskana.impl.ObjectReference;
|
import pro.taskana.impl.ObjectReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Task Service manages all operations on tasks.
|
* The Task Service manages all operations on tasks.
|
||||||
*/
|
*/
|
||||||
public interface TaskService {
|
public interface TaskService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Claim an existing task for the current user.
|
* Claim an existing task for the current user.
|
||||||
*
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* the id of the task to be claimed
|
* the id of the task to be claimed
|
||||||
* @return claimed Task
|
* @return claimed Task
|
||||||
* @throws TaskNotFoundException
|
* @throws TaskNotFoundException
|
||||||
* if the task with taskId was not found
|
* if the task with taskId was not found
|
||||||
* @throws InvalidStateException
|
* @throws InvalidStateException
|
||||||
* if the state of the task with taskId is not READY
|
* if the state of the task with taskId is not READY
|
||||||
* @throws InvalidOwnerException
|
* @throws InvalidOwnerException
|
||||||
* if the task with taskId is claimed by some else
|
* if the task with taskId is claimed by some else
|
||||||
* @throws NotAuthorizedException
|
* @throws NotAuthorizedException
|
||||||
* if the current user has no read permission for the workbasket the task is in
|
* if the current user has no read permission for the workbasket the task is in
|
||||||
*/
|
*/
|
||||||
Task claim(String taskId)
|
Task claim(String taskId)
|
||||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Claim an existing task for the current user. Enable forced claim.
|
* Claim an existing task for the current user even if it is already claimed by someone else.
|
||||||
*
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* the id of the task to be claimed
|
* the id of the task to be claimed
|
||||||
* @param forceClaim
|
* @return claimed Task
|
||||||
* if true, claim is performed even if the task is already claimed by someone else
|
* @throws TaskNotFoundException
|
||||||
* @return claimed Task
|
* if the task with taskId was not found
|
||||||
* @throws TaskNotFoundException
|
* @throws InvalidStateException
|
||||||
* if the task with taskId was not found
|
* if the state of the task with taskId is not READY
|
||||||
* @throws InvalidStateException
|
* @throws InvalidOwnerException
|
||||||
* if the state of the task with taskId is not READY
|
* if the task with taskId is claimed by someone else
|
||||||
* @throws InvalidOwnerException
|
* @throws NotAuthorizedException
|
||||||
* if the task with taskId is claimed by someone else
|
* if the current user has no read permission for the workbasket the task is in
|
||||||
* @throws NotAuthorizedException
|
*/
|
||||||
* if the current user has no read permission for the workbasket the task is in
|
Task forceClaim(String taskId)
|
||||||
*/
|
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
||||||
Task claim(String taskId, boolean forceClaim)
|
|
||||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
/**
|
||||||
|
* Cancel the claim of an existing task if it was claimed by the current user before.
|
||||||
/**
|
*
|
||||||
* Unclaim a existing Task which was claimed and owned by you before.
|
* @param taskId
|
||||||
*
|
* id of the task which should be unclaimed.
|
||||||
* @param taskId
|
* @return updated unclaimed task
|
||||||
* id of the task which should be unclaimed.
|
* @throws TaskNotFoundException
|
||||||
* @return updated unclaimed task
|
* if the task can´t be found or does not exist
|
||||||
* @throws TaskNotFoundException
|
* @throws InvalidStateException
|
||||||
* if the task can´t be found or does not exist
|
* when the task is already completed.
|
||||||
* @throws InvalidStateException
|
* @throws InvalidOwnerException
|
||||||
* when the task is already completed.
|
* when the task is claimed by another user.
|
||||||
* @throws InvalidOwnerException
|
* @throws NotAuthorizedException
|
||||||
* when the task is claimed by another user.
|
* if the current user has no read permission for the workbasket the task is in
|
||||||
* @throws NotAuthorizedException
|
*/
|
||||||
* if the current user has no read permission for the workbasket the task is in
|
Task cancelClaim(String taskId)
|
||||||
*/
|
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
||||||
Task cancelClaim(String taskId)
|
|
||||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
/**
|
||||||
|
* Cancel the claim of an existing task even if it was claimed by another user.
|
||||||
/**
|
*
|
||||||
* Unclaim a existing Task which was claimed and owned by you before. Also there can be enabled a force flag for
|
* @param taskId
|
||||||
* admins.
|
* id of the task which should be unclaimed.
|
||||||
*
|
* @return updated unclaimed task
|
||||||
* @param taskId
|
* @throws TaskNotFoundException
|
||||||
* id of the task which should be unclaimed.
|
* if the task can´t be found or does not exist
|
||||||
* @param forceCancel
|
* @throws InvalidStateException
|
||||||
* force the cancellation of claim. If true, the task is unclaimed even if it was claimed by another
|
* when the task is already completed.
|
||||||
* user.
|
* @throws InvalidOwnerException
|
||||||
* @return updated unclaimed task
|
* when forceCancel is false and the task is claimed by another user.
|
||||||
* @throws TaskNotFoundException
|
* @throws NotAuthorizedException
|
||||||
* if the task can´t be found or does not exist
|
* if the current user has no read permission for the workbasket the task is in
|
||||||
* @throws InvalidStateException
|
*/
|
||||||
* when the task is already completed.
|
Task forceCancelClaim(String taskId)
|
||||||
* @throws InvalidOwnerException
|
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
||||||
* when forceCancel is false and the task is claimed by another user.
|
|
||||||
* @throws NotAuthorizedException
|
/**
|
||||||
* if the current user has no read permission for the workbasket the task is in
|
* Complete a claimed Task as owner/admin and update State and Timestamps.
|
||||||
*/
|
*
|
||||||
Task cancelClaim(String taskId, boolean forceCancel)
|
* @param taskId
|
||||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
|
* - Id of the Task which should be completed.
|
||||||
|
* @return Task - updated task after completion.
|
||||||
/**
|
* @throws InvalidStateException
|
||||||
* Complete a claimed Task as owner/admin and update State and Timestamps.
|
* when Task wasn´t claimed before.
|
||||||
*
|
* @throws TaskNotFoundException
|
||||||
* @param taskId
|
* if the given Task can´t be found in DB.
|
||||||
* - Id of the Task which should be completed.
|
* @throws InvalidOwnerException
|
||||||
* @return Task - updated task after completion.
|
* if current user is not the task-owner or administrator.
|
||||||
* @throws InvalidStateException
|
* @throws NotAuthorizedException
|
||||||
* when Task wasn´t claimed before.
|
* if the current user has no read permission for the workbasket the task is in
|
||||||
* @throws TaskNotFoundException
|
*/
|
||||||
* if the given Task can´t be found in DB.
|
Task completeTask(String taskId)
|
||||||
* @throws InvalidOwnerException
|
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
|
||||||
* if current user is not the task-owner or administrator.
|
|
||||||
* @throws NotAuthorizedException
|
/**
|
||||||
* if the current user has no read permission for the workbasket the task is in
|
* Complete a Task and update State and Timestamps in every case if the Task exists.
|
||||||
*/
|
*
|
||||||
Task completeTask(String taskId)
|
* @param taskId
|
||||||
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
|
* - Id of the Task which should be completed.
|
||||||
|
* @return Task - updated task after completion.
|
||||||
/**
|
* @throws InvalidStateException
|
||||||
* Complete a claimed Task and update State and Timestamps.
|
* when Task wasn´t claimed before.
|
||||||
*
|
* @throws TaskNotFoundException
|
||||||
* @param taskId
|
* if the given Task can´t be found in DB.
|
||||||
* - Id of the Task which should be completed.
|
* @throws InvalidOwnerException
|
||||||
* @param isForced
|
* if current user is not the task-owner or administrator.
|
||||||
* - Flag which can complete a Task in every case if Task does exist.
|
* @throws NotAuthorizedException
|
||||||
* @return Task - updated task after completion.
|
* if the current user has no read permission for the workbasket the task is in
|
||||||
* @throws InvalidStateException
|
*/
|
||||||
* when Task wasn´t claimed before.
|
Task forceCompleteTask(String taskId)
|
||||||
* @throws TaskNotFoundException
|
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
|
||||||
* if the given Task can´t be found in DB.
|
|
||||||
* @throws InvalidOwnerException
|
/**
|
||||||
* if current user is not the task-owner or administrator.
|
* Persists a not persisted Task which does not exist already.
|
||||||
* @throws NotAuthorizedException
|
*
|
||||||
* if the current user has no read permission for the workbasket the task is in
|
* @param taskToCreate
|
||||||
*/
|
* the transient task object to be persisted
|
||||||
Task completeTask(String taskId, boolean isForced)
|
* @return the created and persisted task
|
||||||
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
|
* @throws TaskAlreadyExistException
|
||||||
|
* when the Task does already exist.
|
||||||
/**
|
* @throws NotAuthorizedException
|
||||||
* Persists a not persisted Task which does not exist already.
|
* thrown if the current user is not authorized to create that task
|
||||||
*
|
* @throws WorkbasketNotFoundException
|
||||||
* @param taskToCreate
|
* thrown if the work basket referenced by the task is not found
|
||||||
* the transient task object to be persisted
|
* @throws ClassificationNotFoundException
|
||||||
* @return the created and persisted task
|
* thrown if the {@link Classification} referenced by the task is not found
|
||||||
* @throws TaskAlreadyExistException
|
* @throws InvalidArgumentException
|
||||||
* when the Task does already exist.
|
* thrown if the primary ObjectReference is invalid
|
||||||
* @throws NotAuthorizedException
|
*/
|
||||||
* thrown if the current user is not authorized to create that task
|
Task createTask(Task taskToCreate)
|
||||||
* @throws WorkbasketNotFoundException
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
||||||
* thrown if the work basket referenced by the task is not found
|
TaskAlreadyExistException, InvalidArgumentException;
|
||||||
* @throws ClassificationNotFoundException
|
|
||||||
* thrown if the {@link Classification} referenced by the task is not found
|
/**
|
||||||
* @throws InvalidArgumentException
|
* Get the details of a task by Id without checking permissions.
|
||||||
* thrown if the primary ObjectReference is invalid
|
*
|
||||||
*/
|
* @param taskId
|
||||||
Task createTask(Task taskToCreate)
|
* the id of the task
|
||||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
* @return the Task
|
||||||
TaskAlreadyExistException, InvalidArgumentException;
|
* @throws TaskNotFoundException
|
||||||
|
* thrown of the {@link Task} with taskId is not found
|
||||||
/**
|
* @throws NotAuthorizedException
|
||||||
* Get the details of a task by Id without checking permissions.
|
* if the current user has no READ permission for the workbasket the task is in.
|
||||||
*
|
*/
|
||||||
* @param taskId
|
Task getTask(String taskId) throws TaskNotFoundException, NotAuthorizedException;
|
||||||
* the id of the task
|
|
||||||
* @return the Task
|
/**
|
||||||
* @throws TaskNotFoundException
|
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
|
||||||
* thrown of the {@link Task} with taskId is not found
|
*
|
||||||
* @throws NotAuthorizedException
|
* @param taskId
|
||||||
* if the current user has no READ permission for the workbasket the task is in.
|
* The id of the {@link Task} to be transferred
|
||||||
*/
|
* @param destinationWorkbasketId
|
||||||
Task getTask(String taskId) throws TaskNotFoundException, NotAuthorizedException;
|
* The Id of the target work basket
|
||||||
|
* @return the transferred task
|
||||||
/**
|
* @throws TaskNotFoundException
|
||||||
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
|
* Thrown if the {@link Task} with taskId was not found.
|
||||||
*
|
* @throws WorkbasketNotFoundException
|
||||||
* @param taskId
|
* Thrown if the target work basket was not found.
|
||||||
* The id of the {@link Task} to be transferred
|
* @throws NotAuthorizedException
|
||||||
* @param destinationWorkbasketId
|
* Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket
|
||||||
* The Id of the target work basket
|
* @throws InvalidWorkbasketException
|
||||||
* @return the transferred task
|
* Thrown if either the source or the target workbasket has a missing required property
|
||||||
* @throws TaskNotFoundException
|
* @throws InvalidStateException
|
||||||
* Thrown if the {@link Task} with taskId was not found.
|
* Thrown if the task is in a state which does not allow transferring
|
||||||
* @throws WorkbasketNotFoundException
|
*/
|
||||||
* Thrown if the target work basket was not found.
|
Task transfer(String taskId, String destinationWorkbasketId)
|
||||||
* @throws NotAuthorizedException
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||||
* Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket
|
InvalidStateException;
|
||||||
* @throws InvalidWorkbasketException
|
|
||||||
* Thrown if either the source or the target workbasket has a missing required property
|
/**
|
||||||
* @throws InvalidStateException
|
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
|
||||||
* Thrown if the task is in a state which does not allow transferring
|
*
|
||||||
*/
|
* @param taskId
|
||||||
Task transfer(String taskId, String destinationWorkbasketId)
|
* The id of the {@link Task} to be transferred
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
* @param workbasketKey
|
||||||
InvalidStateException;
|
* The key of the target work basket
|
||||||
|
* @param domain
|
||||||
/**
|
* The domain of the target work basket
|
||||||
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
|
* @return the transferred task
|
||||||
*
|
* @throws TaskNotFoundException
|
||||||
* @param taskId
|
* Thrown if the {@link Task} with taskId was not found.
|
||||||
* The id of the {@link Task} to be transferred
|
* @throws WorkbasketNotFoundException
|
||||||
* @param workbasketKey
|
* Thrown if the target work basket was not found.
|
||||||
* The key of the target work basket
|
* @throws NotAuthorizedException
|
||||||
* @param domain
|
* Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket
|
||||||
* The domain of the target work basket
|
* @throws InvalidWorkbasketException
|
||||||
* @return the transferred task
|
* Thrown if either the source or the target workbasket has a missing required property
|
||||||
* @throws TaskNotFoundException
|
* @throws InvalidStateException
|
||||||
* Thrown if the {@link Task} with taskId was not found.
|
* Thrown if the task is in a state which does not allow transferring
|
||||||
* @throws WorkbasketNotFoundException
|
*/
|
||||||
* Thrown if the target work basket was not found.
|
Task transfer(String taskId, String workbasketKey, String domain)
|
||||||
* @throws NotAuthorizedException
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||||
* Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket
|
InvalidStateException;
|
||||||
* @throws InvalidWorkbasketException
|
|
||||||
* Thrown if either the source or the target workbasket has a missing required property
|
/**
|
||||||
* @throws InvalidStateException
|
* Marks a task as read.
|
||||||
* Thrown if the task is in a state which does not allow transferring
|
*
|
||||||
*/
|
* @param taskId
|
||||||
Task transfer(String taskId, String workbasketKey, String domain)
|
* the id of the task to be updated
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
* @param isRead
|
||||||
InvalidStateException;
|
* the new status of the read flag.
|
||||||
|
* @return the updated Task
|
||||||
/**
|
* @throws TaskNotFoundException
|
||||||
* Marks a task as read.
|
* Thrown if the {@link Task} with taskId was not found
|
||||||
*
|
* @throws NotAuthorizedException
|
||||||
* @param taskId
|
* if the current user has no read permission for the workbasket the task is in
|
||||||
* the id of the task to be updated
|
*/
|
||||||
* @param isRead
|
Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException, NotAuthorizedException;
|
||||||
* the new status of the read flag.
|
|
||||||
* @return the updated Task
|
/**
|
||||||
* @throws TaskNotFoundException
|
* This method provides a query builder for quering the database.
|
||||||
* Thrown if the {@link Task} with taskId was not found
|
*
|
||||||
* @throws NotAuthorizedException
|
* @return a {@link TaskQuery}
|
||||||
* if the current user has no read permission for the workbasket the task is in
|
*/
|
||||||
*/
|
TaskQuery createTaskQuery();
|
||||||
Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException, NotAuthorizedException;
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a not persisted instance of {@link Task}.
|
||||||
* This method provides a query builder for quering the database.
|
*
|
||||||
*
|
* @param workbasketId
|
||||||
* @return a {@link TaskQuery}
|
* the id of the workbasket to which the task belongs
|
||||||
*/
|
* @return an empty new Task
|
||||||
TaskQuery createTaskQuery();
|
*/
|
||||||
|
Task newTask(String workbasketId);
|
||||||
/**
|
|
||||||
* Returns a not persisted instance of {@link Task}.
|
/**
|
||||||
*
|
* Returns a not persisted instance of {@link Task}.
|
||||||
* @param workbasketId
|
*
|
||||||
* the id of the workbasket to which the task belongs
|
* @param workbasketKey
|
||||||
* @return an empty new Task
|
* the key of the workbasket to which the task belongs
|
||||||
*/
|
* @param domain
|
||||||
Task newTask(String workbasketId);
|
* the domain of the workbasket to which the task belongs
|
||||||
|
* @return an empty new Task
|
||||||
/**
|
*/
|
||||||
* Returns a not persisted instance of {@link Task}.
|
Task newTask(String workbasketKey, String domain);
|
||||||
*
|
|
||||||
* @param workbasketKey
|
/**
|
||||||
* the key of the workbasket to which the task belongs
|
* Returns a not persisted instance of {@link Attachment}.
|
||||||
* @param domain
|
*
|
||||||
* the domain of the workbasket to which the task belongs
|
* @return an empty new Attachment
|
||||||
* @return an empty new Task
|
*/
|
||||||
*/
|
Attachment newAttachment();
|
||||||
Task newTask(String workbasketKey, String domain);
|
|
||||||
|
/**
|
||||||
/**
|
* Update a task.
|
||||||
* Returns a not persisted instance of {@link Attachment}.
|
*
|
||||||
*
|
* @param task
|
||||||
* @return an empty new Attachment
|
* the task to be updated in the database
|
||||||
*/
|
* @return the updated task
|
||||||
Attachment newAttachment();
|
* @throws InvalidArgumentException
|
||||||
|
* if the task to be updated contains invalid properties like e.g. invalid object references
|
||||||
/**
|
* @throws TaskNotFoundException
|
||||||
* Update a task.
|
* if the id of the task is not found in the database
|
||||||
*
|
* @throws ConcurrencyException
|
||||||
* @param task
|
* if the task has already been updated by another user
|
||||||
* the task to be updated in the database
|
* @throws InvalidWorkbasketException
|
||||||
* @return the updated task
|
* if the updated task refers to a workbasket that has missing required properties
|
||||||
* @throws InvalidArgumentException
|
* @throws ClassificationNotFoundException
|
||||||
* if the task to be updated contains invalid properties like e.g. invalid object references
|
* if the updated task refers to a classification that cannot be found
|
||||||
* @throws TaskNotFoundException
|
* @throws WorkbasketNotFoundException
|
||||||
* if the id of the task is not found in the database
|
* if the updated task refers to a work basket that cannot be found
|
||||||
* @throws ConcurrencyException
|
* @throws NotAuthorizedException
|
||||||
* if the task has already been updated by another user
|
* if the current user is not authorized to update the task
|
||||||
* @throws InvalidWorkbasketException
|
* @throws AttachmentPersistenceException
|
||||||
* if the updated task refers to a workbasket that has missing required properties
|
* if an Attachment with ID will be added multiple times without using the task-methods.
|
||||||
* @throws ClassificationNotFoundException
|
*/
|
||||||
* if the updated task refers to a classification that cannot be found
|
Task updateTask(Task task) throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException,
|
||||||
* @throws WorkbasketNotFoundException
|
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidWorkbasketException,
|
||||||
* if the updated task refers to a work basket that cannot be found
|
NotAuthorizedException, AttachmentPersistenceException;
|
||||||
* @throws NotAuthorizedException
|
|
||||||
* if the current user is not authorized to update the task
|
/**
|
||||||
* @throws AttachmentPersistenceException
|
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on
|
||||||
* if an Attachment with ID will be added multiple times without using the task-methods.
|
* the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.
|
||||||
*/
|
*
|
||||||
Task updateTask(Task task) throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException,
|
* @param destinationWorkbasketId
|
||||||
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidWorkbasketException,
|
* target workbasket id
|
||||||
NotAuthorizedException, AttachmentPersistenceException;
|
* @param taskIds
|
||||||
|
* source task which will be moved
|
||||||
/**
|
* @return Bulkresult with ID and Error in it for failed transactions.
|
||||||
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on
|
* @throws NotAuthorizedException
|
||||||
* the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.
|
* if the caller hasn´t permissions on tarket WB.
|
||||||
*
|
* @throws InvalidArgumentException
|
||||||
* @param destinationWorkbasketId
|
* if the method paramesters are EMPTY or NULL.
|
||||||
* target workbasket id
|
* @throws WorkbasketNotFoundException
|
||||||
* @param taskIds
|
* if the target WB can´t be found.
|
||||||
* source task which will be moved
|
*/
|
||||||
* @return Bulkresult with ID and Error in it for failed transactions.
|
BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId, List<String> taskIds)
|
||||||
* @throws NotAuthorizedException
|
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
|
||||||
* if the caller hasn´t permissions on tarket WB.
|
|
||||||
* @throws InvalidArgumentException
|
/**
|
||||||
* if the method paramesters are EMPTY or NULL.
|
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on
|
||||||
* @throws WorkbasketNotFoundException
|
* the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.
|
||||||
* if the target WB can´t be found.
|
*
|
||||||
*/
|
* @param destinationWorkbasketKey
|
||||||
BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId, List<String> taskIds)
|
* target workbasket key
|
||||||
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
|
* @param destinationWorkbasketDomain
|
||||||
|
* target workbasket domain
|
||||||
/**
|
* @param taskIds
|
||||||
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on
|
* source task which will be moved
|
||||||
* the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.
|
* @return Bulkresult with ID and Error in it for failed transactions.
|
||||||
*
|
* @throws NotAuthorizedException
|
||||||
* @param destinationWorkbasketKey
|
* if the caller hasn´t permissions on tarket WB.
|
||||||
* target workbasket key
|
* @throws InvalidArgumentException
|
||||||
* @param destinationWorkbasketDomain
|
* if the method paramesters are EMPTY or NULL.
|
||||||
* target workbasket domain
|
* @throws WorkbasketNotFoundException
|
||||||
* @param taskIds
|
* if the target WB can´t be found.
|
||||||
* source task which will be moved
|
*/
|
||||||
* @return Bulkresult with ID and Error in it for failed transactions.
|
BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketKey,
|
||||||
* @throws NotAuthorizedException
|
String destinationWorkbasketDomain, List<String> taskIds)
|
||||||
* if the caller hasn´t permissions on tarket WB.
|
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
|
||||||
* @throws InvalidArgumentException
|
|
||||||
* if the method paramesters are EMPTY or NULL.
|
/**
|
||||||
* @throws WorkbasketNotFoundException
|
* Deletes the task with the given Id.
|
||||||
* if the target WB can´t be found.
|
*
|
||||||
*/
|
* @param taskId
|
||||||
BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketKey,
|
* The Id of the task to delete.
|
||||||
String destinationWorkbasketDomain, List<String> taskIds)
|
* @throws TaskNotFoundException
|
||||||
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
|
* If the given Id does not refer to an existing task.
|
||||||
|
* @throws InvalidStateException
|
||||||
/**
|
* If the state of the referenced task is not Completed.
|
||||||
* Deletes the task with the given Id.
|
* @throws NotAuthorizedException
|
||||||
*
|
* if the current user is not member of role ADMIN
|
||||||
* @param taskId
|
*/
|
||||||
* The Id of the task to delete.
|
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
|
||||||
* @throws TaskNotFoundException
|
|
||||||
* If the given Id does not refer to an existing task.
|
/**
|
||||||
* @throws InvalidStateException
|
* Deletes the task with the given Id even if it is not completed.
|
||||||
* If the state of the referenced task is not Completed.
|
*
|
||||||
* @throws NotAuthorizedException
|
* @param taskId
|
||||||
* if the current user is not member of role ADMIN
|
* The Id of the task to delete.
|
||||||
*/
|
* @throws TaskNotFoundException
|
||||||
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
|
* If the given Id does not refer to an existing task.
|
||||||
|
* @throws InvalidStateException
|
||||||
/**
|
* If the state of the referenced task is not Completed and forceDelet is false.
|
||||||
* Deletes the task with the given Id.
|
* @throws NotAuthorizedException
|
||||||
*
|
* if the current user is not member of role ADMIN
|
||||||
* @param taskId
|
*/
|
||||||
* The Id of the task to delete.
|
void forceDeleteTask(String taskId)
|
||||||
* @param forceDelete
|
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
|
||||||
* force the deletion. If true, a task is deleted even if it is not in state completed.
|
|
||||||
* @throws TaskNotFoundException
|
/**
|
||||||
* If the given Id does not refer to an existing task.
|
* Deletes a list of tasks.
|
||||||
* @throws InvalidStateException
|
*
|
||||||
* If the state of the referenced task is not Completed and forceDelet is false.
|
* @param tasks
|
||||||
* @throws NotAuthorizedException
|
* the ids of the tasks to delete.
|
||||||
* if the current user is not member of role ADMIN
|
* @return the result of the operations with Id and Exception for each failed task deletion.
|
||||||
*/
|
* @throws InvalidArgumentException
|
||||||
void deleteTask(String taskId, boolean forceDelete)
|
* if the TaskIds parameter is NULL
|
||||||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
|
*/
|
||||||
|
BulkOperationResults<String, TaskanaException> deleteTasks(List<String> tasks) throws InvalidArgumentException;
|
||||||
/**
|
|
||||||
* Deletes a list of tasks.
|
/**
|
||||||
*
|
* Completes a list of tasks.
|
||||||
* @param tasks
|
*
|
||||||
* the ids of the tasks to delete.
|
* @param taskIds
|
||||||
* @return the result of the operations with Id and Exception for each failed task deletion.
|
* of the tasks which should be completed.
|
||||||
* @throws InvalidArgumentException
|
* @return the result of the operations with Id and Exception for each failed task completion.
|
||||||
* if the TaskIds parameter is NULL
|
* @throws InvalidArgumentException
|
||||||
*/
|
* If the taskId parameter is NULL.
|
||||||
BulkOperationResults<String, TaskanaException> deleteTasks(List<String> tasks) throws InvalidArgumentException;
|
*/
|
||||||
|
BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds)
|
||||||
/**
|
throws InvalidArgumentException;
|
||||||
* Completes a list of tasks.
|
|
||||||
*
|
/**
|
||||||
* @param taskIds
|
* Completes tasks with a matching {@link ObjectReference}.
|
||||||
* of the tasks which should be completed.
|
*
|
||||||
* @return the result of the operations with Id and Exception for each failed task completion.
|
* @param selectionCriteria
|
||||||
* @throws InvalidArgumentException
|
* the {@link ObjectReference} that is used to select the tasks.
|
||||||
* If the taskId parameter is NULL.
|
* @param customFieldsToUpdate
|
||||||
*/
|
* a {@link Map} that contains as key the identification of the custom field and as value the
|
||||||
BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds)
|
* corresponding new value of that custom field. The key for identification of the custom field must be a
|
||||||
throws InvalidArgumentException;
|
* String with value "1", "2" ... "16" as in the setCustomAttribute or getCustomAttribute method of
|
||||||
|
* {@link Task}
|
||||||
/**
|
* @return a list of the Ids of all modified tasks
|
||||||
* Completes tasks with a matching {@link ObjectReference}.
|
* @throws InvalidArgumentException
|
||||||
*
|
* If the customFieldsToUpdate map contains an invalid key or if the selectionCriteria is invalid
|
||||||
* @param selectionCriteria
|
*/
|
||||||
* the {@link ObjectReference} that is used to select the tasks.
|
List<String> updateTasks(ObjectReference selectionCriteria,
|
||||||
* @param customFieldsToUpdate
|
Map<String, String> customFieldsToUpdate) throws InvalidArgumentException;
|
||||||
* a {@link Map} that contains as key the identification of the custom field and as value the
|
}
|
||||||
* corresponding new value of that custom field. The key for identification of the custom field must be a
|
|
||||||
* String with value "1", "2" ... "16" as in the setCustomAttribute or getCustomAttribute method of
|
|
||||||
* {@link Task}
|
|
||||||
* @return a list of the Ids of all modified tasks
|
|
||||||
* @throws InvalidArgumentException
|
|
||||||
* If the customFieldsToUpdate map contains an invalid key or if the selectionCriteria is invalid
|
|
||||||
*/
|
|
||||||
List<String> updateTasks(ObjectReference selectionCriteria,
|
|
||||||
Map<String, String> customFieldsToUpdate) throws InvalidArgumentException;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,137 +1,137 @@
|
||||||
package acceptance.task;
|
package acceptance.task;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
import pro.taskana.Task;
|
import pro.taskana.Task;
|
||||||
import pro.taskana.TaskService;
|
import pro.taskana.TaskService;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.InvalidStateException;
|
import pro.taskana.exceptions.InvalidStateException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.exceptions.TaskNotFoundException;
|
import pro.taskana.exceptions.TaskNotFoundException;
|
||||||
import pro.taskana.exceptions.TaskanaException;
|
import pro.taskana.exceptions.TaskanaException;
|
||||||
import pro.taskana.impl.BulkOperationResults;
|
import pro.taskana.impl.BulkOperationResults;
|
||||||
import pro.taskana.security.JAASRunner;
|
import pro.taskana.security.JAASRunner;
|
||||||
import pro.taskana.security.WithAccessId;
|
import pro.taskana.security.WithAccessId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acceptance test for all "delete task" scenarios.
|
* Acceptance test for all "delete task" scenarios.
|
||||||
*/
|
*/
|
||||||
@RunWith(JAASRunner.class)
|
@RunWith(JAASRunner.class)
|
||||||
public class DeleteTaskAccTest extends AbstractAccTest {
|
public class DeleteTaskAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
public DeleteTaskAccTest() {
|
public DeleteTaskAccTest() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test(expected = NotAuthorizedException.class)
|
@Test(expected = NotAuthorizedException.class)
|
||||||
public void testDeleteSingleTaskNotAuthorized()
|
public void testDeleteSingleTaskNotAuthorized()
|
||||||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
taskService.deleteTask("TKI:000000000000000000000000000000000037");
|
taskService.deleteTask("TKI:000000000000000000000000000000000037");
|
||||||
fail("NotAuthorizedException should have been thrown");
|
fail("NotAuthorizedException should have been thrown");
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1", "admin"})
|
groupNames = {"group_1", "admin"})
|
||||||
@Test(expected = TaskNotFoundException.class)
|
@Test(expected = TaskNotFoundException.class)
|
||||||
public void testDeleteSingleTask() throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
public void testDeleteSingleTask() throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000036");
|
Task task = taskService.getTask("TKI:000000000000000000000000000000000036");
|
||||||
|
|
||||||
taskService.deleteTask(task.getId());
|
taskService.deleteTask(task.getId());
|
||||||
|
|
||||||
taskService.getTask("TKI:000000000000000000000000000000000036");
|
taskService.getTask("TKI:000000000000000000000000000000000036");
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1", "admin"})
|
groupNames = {"group_1", "admin"})
|
||||||
@Test(expected = InvalidStateException.class)
|
@Test(expected = InvalidStateException.class)
|
||||||
public void testThrowsExceptionIfTaskIsNotCompleted()
|
public void testThrowsExceptionIfTaskIsNotCompleted()
|
||||||
throws TaskNotFoundException, InvalidStateException, SQLException, NotAuthorizedException {
|
throws TaskNotFoundException, InvalidStateException, SQLException, NotAuthorizedException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000029");
|
Task task = taskService.getTask("TKI:000000000000000000000000000000000029");
|
||||||
|
|
||||||
taskService.deleteTask(task.getId());
|
taskService.deleteTask(task.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1", "admin"})
|
groupNames = {"group_1", "admin"})
|
||||||
@Test(expected = TaskNotFoundException.class)
|
@Test(expected = TaskNotFoundException.class)
|
||||||
public void testForceDeleteTaskIfNotCompleted()
|
public void testForceDeleteTaskIfNotCompleted()
|
||||||
throws SQLException, TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
throws SQLException, TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
|
Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
|
||||||
try {
|
try {
|
||||||
taskService.deleteTask(task.getId());
|
taskService.deleteTask(task.getId());
|
||||||
fail("Should not be possible to delete claimed task without force flag");
|
fail("Should not be possible to delete claimed task without force flag");
|
||||||
} catch (InvalidStateException ex) {
|
} catch (InvalidStateException ex) {
|
||||||
taskService.deleteTask(task.getId(), true);
|
taskService.forceDeleteTask(task.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
taskService.getTask("TKI:000000000000000000000000000000000027");
|
taskService.getTask("TKI:000000000000000000000000000000000027");
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test(expected = TaskNotFoundException.class)
|
@Test(expected = TaskNotFoundException.class)
|
||||||
public void testBulkDeleteTask() throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
|
public void testBulkDeleteTask() throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
ArrayList<String> taskIdList = new ArrayList<>();
|
ArrayList<String> taskIdList = new ArrayList<>();
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000037");
|
taskIdList.add("TKI:000000000000000000000000000000000037");
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000038");
|
taskIdList.add("TKI:000000000000000000000000000000000038");
|
||||||
|
|
||||||
BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
|
BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
|
||||||
|
|
||||||
assertFalse(results.containsErrors());
|
assertFalse(results.containsErrors());
|
||||||
taskService.getTask("TKI:000000000000000000000000000000000038");
|
taskService.getTask("TKI:000000000000000000000000000000000038");
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test(expected = TaskNotFoundException.class)
|
@Test(expected = TaskNotFoundException.class)
|
||||||
public void testBulkDeleteTasksWithException()
|
public void testBulkDeleteTasksWithException()
|
||||||
throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
|
throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
ArrayList<String> taskIdList = new ArrayList<>();
|
ArrayList<String> taskIdList = new ArrayList<>();
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000039");
|
taskIdList.add("TKI:000000000000000000000000000000000039");
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000040");
|
taskIdList.add("TKI:000000000000000000000000000000000040");
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000028");
|
taskIdList.add("TKI:000000000000000000000000000000000028");
|
||||||
|
|
||||||
BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
|
BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
|
||||||
|
|
||||||
String expectedFailedId = "TKI:000000000000000000000000000000000028";
|
String expectedFailedId = "TKI:000000000000000000000000000000000028";
|
||||||
assertTrue(results.containsErrors());
|
assertTrue(results.containsErrors());
|
||||||
List<String> failedTaskIds = results.getFailedIds();
|
List<String> failedTaskIds = results.getFailedIds();
|
||||||
assertTrue(failedTaskIds.size() == 1);
|
assertTrue(failedTaskIds.size() == 1);
|
||||||
assertTrue(expectedFailedId.equals(failedTaskIds.get(0)));
|
assertTrue(expectedFailedId.equals(failedTaskIds.get(0)));
|
||||||
assertTrue(results.getErrorMap().get(expectedFailedId).getClass() == InvalidStateException.class);
|
assertTrue(results.getErrorMap().get(expectedFailedId).getClass() == InvalidStateException.class);
|
||||||
|
|
||||||
Task notDeletedTask = taskService.getTask("TKI:000000000000000000000000000000000028");
|
Task notDeletedTask = taskService.getTask("TKI:000000000000000000000000000000000028");
|
||||||
assertTrue(notDeletedTask != null);
|
assertTrue(notDeletedTask != null);
|
||||||
taskService.getTask("TKI:000000000000000000000000000000000040");
|
taskService.getTask("TKI:000000000000000000000000000000000040");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,302 +1,302 @@
|
||||||
package acceptance.task;
|
package acceptance.task;
|
||||||
|
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
import pro.taskana.Task;
|
import pro.taskana.Task;
|
||||||
import pro.taskana.TaskService;
|
import pro.taskana.TaskService;
|
||||||
import pro.taskana.TaskState;
|
import pro.taskana.TaskState;
|
||||||
import pro.taskana.exceptions.AttachmentPersistenceException;
|
import pro.taskana.exceptions.AttachmentPersistenceException;
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||||
import pro.taskana.exceptions.ConcurrencyException;
|
import pro.taskana.exceptions.ConcurrencyException;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.InvalidOwnerException;
|
import pro.taskana.exceptions.InvalidOwnerException;
|
||||||
import pro.taskana.exceptions.InvalidStateException;
|
import pro.taskana.exceptions.InvalidStateException;
|
||||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||||
import pro.taskana.exceptions.TaskNotFoundException;
|
import pro.taskana.exceptions.TaskNotFoundException;
|
||||||
import pro.taskana.exceptions.TaskanaException;
|
import pro.taskana.exceptions.TaskanaException;
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.impl.BulkOperationResults;
|
import pro.taskana.impl.BulkOperationResults;
|
||||||
import pro.taskana.security.JAASRunner;
|
import pro.taskana.security.JAASRunner;
|
||||||
import pro.taskana.security.WithAccessId;
|
import pro.taskana.security.WithAccessId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acceptance test for all "work on task" scenarios. This includes claim, complete...
|
* Acceptance test for all "work on task" scenarios. This includes claim, complete...
|
||||||
*/
|
*/
|
||||||
@RunWith(JAASRunner.class)
|
@RunWith(JAASRunner.class)
|
||||||
public class WorkOnTaskAccTest extends AbstractAccTest {
|
public class WorkOnTaskAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
public WorkOnTaskAccTest() {
|
public WorkOnTaskAccTest() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testClaimTask()
|
public void testClaimTask()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000025");
|
Task task = taskService.getTask("TKI:000000000000000000000000000000000025");
|
||||||
|
|
||||||
taskService.claim(task.getId());
|
taskService.claim(task.getId());
|
||||||
|
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000025");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000025");
|
||||||
assertNotNull(claimedTask);
|
assertNotNull(claimedTask);
|
||||||
assertEquals(TaskState.CLAIMED, claimedTask.getState());
|
assertEquals(TaskState.CLAIMED, claimedTask.getState());
|
||||||
assertNotNull(claimedTask.getClaimed());
|
assertNotNull(claimedTask.getClaimed());
|
||||||
assertNotEquals(claimedTask.getCreated(), claimedTask.getModified());
|
assertNotEquals(claimedTask.getCreated(), claimedTask.getModified());
|
||||||
assertEquals(claimedTask.getClaimed(), claimedTask.getModified());
|
assertEquals(claimedTask.getClaimed(), claimedTask.getModified());
|
||||||
assertTrue(claimedTask.isRead());
|
assertTrue(claimedTask.isRead());
|
||||||
assertEquals("user_1_2", claimedTask.getOwner());
|
assertEquals("user_1_2", claimedTask.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test(expected = InvalidOwnerException.class)
|
@Test(expected = InvalidOwnerException.class)
|
||||||
public void testThrowsExceptionIfTaskIsAlreadyClaimed()
|
public void testThrowsExceptionIfTaskIsAlreadyClaimed()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000026");
|
Task task = taskService.getTask("TKI:000000000000000000000000000000000026");
|
||||||
|
|
||||||
taskService.claim(task.getId());
|
taskService.claim(task.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testClaimAlreadyClaimedByCallerTask()
|
public void testClaimAlreadyClaimedByCallerTask()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
|
Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
|
||||||
|
|
||||||
taskService.claim(task.getId());
|
taskService.claim(task.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test(expected = InvalidOwnerException.class)
|
@Test(expected = InvalidOwnerException.class)
|
||||||
public void testForceClaimTaskWhichIsAlreadyClaimedByAnotherUser()
|
public void testForceClaimTaskWhichIsAlreadyClaimedByAnotherUser()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000028");
|
Task task = taskService.getTask("TKI:000000000000000000000000000000000028");
|
||||||
|
|
||||||
taskService.claim(task.getId());
|
taskService.claim(task.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testCancelClaimTask()
|
public void testCancelClaimTask()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
|
||||||
|
|
||||||
taskService.cancelClaim(claimedTask.getId());
|
taskService.cancelClaim(claimedTask.getId());
|
||||||
|
|
||||||
Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
|
Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
|
||||||
assertNotNull(unclaimedTask);
|
assertNotNull(unclaimedTask);
|
||||||
assertEquals(TaskState.READY, unclaimedTask.getState());
|
assertEquals(TaskState.READY, unclaimedTask.getState());
|
||||||
assertNull(unclaimedTask.getClaimed());
|
assertNull(unclaimedTask.getClaimed());
|
||||||
assertTrue(unclaimedTask.isRead());
|
assertTrue(unclaimedTask.isRead());
|
||||||
assertNull(unclaimedTask.getOwner());
|
assertNull(unclaimedTask.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test(expected = InvalidOwnerException.class)
|
@Test(expected = InvalidOwnerException.class)
|
||||||
public void testThrowsExceptionIfCancelClaimOfTaskFromAnotherUser()
|
public void testThrowsExceptionIfCancelClaimOfTaskFromAnotherUser()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000030");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000030");
|
||||||
|
|
||||||
taskService.cancelClaim(claimedTask.getId());
|
taskService.cancelClaim(claimedTask.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testForceCancelClaimOfTaskFromAnotherUser()
|
public void testForceCancelClaimOfTaskFromAnotherUser()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
|
||||||
|
|
||||||
taskService.cancelClaim(claimedTask.getId(), true);
|
taskService.forceCancelClaim(claimedTask.getId());
|
||||||
|
|
||||||
Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
|
Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
|
||||||
assertNotNull(unclaimedTask);
|
assertNotNull(unclaimedTask);
|
||||||
assertEquals(TaskState.READY, unclaimedTask.getState());
|
assertEquals(TaskState.READY, unclaimedTask.getState());
|
||||||
assertNull(unclaimedTask.getClaimed());
|
assertNull(unclaimedTask.getClaimed());
|
||||||
assertTrue(unclaimedTask.isRead());
|
assertTrue(unclaimedTask.isRead());
|
||||||
assertNull(unclaimedTask.getOwner());
|
assertNull(unclaimedTask.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteTask()
|
public void testCompleteTask()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
Instant before = Instant.now().minus(Duration.ofSeconds(3L));
|
Instant before = Instant.now().minus(Duration.ofSeconds(3L));
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
|
||||||
|
|
||||||
taskService.completeTask(claimedTask.getId());
|
taskService.completeTask(claimedTask.getId());
|
||||||
|
|
||||||
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
|
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
|
||||||
assertNotNull(completedTask);
|
assertNotNull(completedTask);
|
||||||
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
||||||
assertNotNull(completedTask.getCompleted());
|
assertNotNull(completedTask.getCompleted());
|
||||||
assertEquals(completedTask.getCompleted(), completedTask.getModified());
|
assertEquals(completedTask.getCompleted(), completedTask.getModified());
|
||||||
assertTrue(completedTask.getCompleted().isAfter(before));
|
assertTrue(completedTask.getCompleted().isAfter(before));
|
||||||
assertTrue(completedTask.getModified().isAfter(before));
|
assertTrue(completedTask.getModified().isAfter(before));
|
||||||
assertTrue(completedTask.isRead());
|
assertTrue(completedTask.isRead());
|
||||||
assertEquals("user_1_2", completedTask.getOwner());
|
assertEquals("user_1_2", completedTask.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testForceCompleteUnclaimedTask()
|
public void testForceCompleteUnclaimedTask()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
|
||||||
|
|
||||||
taskService.completeTask(claimedTask.getId(), true);
|
taskService.forceCompleteTask(claimedTask.getId());
|
||||||
|
|
||||||
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
|
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
|
||||||
assertNotNull(completedTask);
|
assertNotNull(completedTask);
|
||||||
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
||||||
assertNotNull(completedTask.getCompleted());
|
assertNotNull(completedTask.getCompleted());
|
||||||
assertEquals(completedTask.getCompleted(), completedTask.getModified());
|
assertEquals(completedTask.getCompleted(), completedTask.getModified());
|
||||||
assertTrue(completedTask.isRead());
|
assertTrue(completedTask.isRead());
|
||||||
assertEquals("user_1_2", completedTask.getOwner());
|
assertEquals("user_1_2", completedTask.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test(expected = InvalidOwnerException.class)
|
@Test(expected = InvalidOwnerException.class)
|
||||||
public void testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser()
|
public void testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000034");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000034");
|
||||||
|
|
||||||
taskService.completeTask(claimedTask.getId());
|
taskService.completeTask(claimedTask.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testForceCompleteClaimedTaskOfAnotherUser()
|
public void testForceCompleteClaimedTaskOfAnotherUser()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
InvalidStateException, InvalidOwnerException {
|
InvalidStateException, InvalidOwnerException {
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
|
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
|
||||||
|
|
||||||
taskService.completeTask(claimedTask.getId(), true);
|
taskService.forceCompleteTask(claimedTask.getId());
|
||||||
|
|
||||||
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
|
Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
|
||||||
assertNotNull(completedTask);
|
assertNotNull(completedTask);
|
||||||
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
||||||
assertNotNull(completedTask.getCompleted());
|
assertNotNull(completedTask.getCompleted());
|
||||||
assertEquals(completedTask.getCompleted(), completedTask.getModified());
|
assertEquals(completedTask.getCompleted(), completedTask.getModified());
|
||||||
assertTrue(completedTask.isRead());
|
assertTrue(completedTask.isRead());
|
||||||
assertEquals("user_1_2", completedTask.getOwner());
|
assertEquals("user_1_2", completedTask.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testBulkCompleteTasks()
|
public void testBulkCompleteTasks()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
ConcurrencyException, AttachmentPersistenceException {
|
ConcurrencyException, AttachmentPersistenceException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
List<String> taskIdList = new ArrayList<>();
|
List<String> taskIdList = new ArrayList<>();
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000100");
|
taskIdList.add("TKI:000000000000000000000000000000000100");
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000101");
|
taskIdList.add("TKI:000000000000000000000000000000000101");
|
||||||
|
|
||||||
BulkOperationResults<String, TaskanaException> results = taskService.completeTasks(taskIdList);
|
BulkOperationResults<String, TaskanaException> results = taskService.completeTasks(taskIdList);
|
||||||
|
|
||||||
assertFalse(results.containsErrors());
|
assertFalse(results.containsErrors());
|
||||||
Task completedTask1 = taskService.getTask("TKI:000000000000000000000000000000000100");
|
Task completedTask1 = taskService.getTask("TKI:000000000000000000000000000000000100");
|
||||||
assertEquals(TaskState.COMPLETED, completedTask1.getState());
|
assertEquals(TaskState.COMPLETED, completedTask1.getState());
|
||||||
assertNotNull(completedTask1.getCompleted());
|
assertNotNull(completedTask1.getCompleted());
|
||||||
Task completedTask2 = taskService.getTask("TKI:000000000000000000000000000000000101");
|
Task completedTask2 = taskService.getTask("TKI:000000000000000000000000000000000101");
|
||||||
assertEquals(TaskState.COMPLETED, completedTask2.getState());
|
assertEquals(TaskState.COMPLETED, completedTask2.getState());
|
||||||
assertNotNull(completedTask2.getCompleted());
|
assertNotNull(completedTask2.getCompleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
public void testBulkDeleteTasksWithException()
|
public void testBulkDeleteTasksWithException()
|
||||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
ConcurrencyException, AttachmentPersistenceException {
|
ConcurrencyException, AttachmentPersistenceException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
List<String> taskIdList = new ArrayList<>();
|
List<String> taskIdList = new ArrayList<>();
|
||||||
taskIdList.add("TKI:000000000000000000000000000000000102");
|
taskIdList.add("TKI:000000000000000000000000000000000102");
|
||||||
taskIdList.add("TKI:000000000000000000000000000000003333");
|
taskIdList.add("TKI:000000000000000000000000000000003333");
|
||||||
|
|
||||||
BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
|
BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
|
||||||
|
|
||||||
assertTrue(results.containsErrors());
|
assertTrue(results.containsErrors());
|
||||||
assertThat(results.getErrorMap().size(), equalTo(2));
|
assertThat(results.getErrorMap().size(), equalTo(2));
|
||||||
assertTrue(results.getErrorForId("TKI:000000000000000000000000000000003333") instanceof TaskNotFoundException);
|
assertTrue(results.getErrorForId("TKI:000000000000000000000000000000003333") instanceof TaskNotFoundException);
|
||||||
assertTrue(results.getErrorForId("TKI:000000000000000000000000000000000102") instanceof InvalidStateException);
|
assertTrue(results.getErrorForId("TKI:000000000000000000000000000000000102") instanceof InvalidStateException);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,50 +1,50 @@
|
||||||
package pro.taskana;
|
package pro.taskana;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.InvalidOwnerException;
|
import pro.taskana.exceptions.InvalidOwnerException;
|
||||||
import pro.taskana.exceptions.InvalidStateException;
|
import pro.taskana.exceptions.InvalidStateException;
|
||||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||||
import pro.taskana.exceptions.TaskNotFoundException;
|
import pro.taskana.exceptions.TaskNotFoundException;
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.impl.ObjectReference;
|
import pro.taskana.impl.ObjectReference;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Transactional
|
@Transactional
|
||||||
public class ExampleBootstrap {
|
public class ExampleBootstrap {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void test() throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException,
|
public void test() throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException,
|
||||||
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, InvalidWorkbasketException,
|
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, InvalidWorkbasketException,
|
||||||
TaskAlreadyExistException, InvalidArgumentException {
|
TaskAlreadyExistException, InvalidArgumentException {
|
||||||
System.out.println("---------------------------> Start App");
|
System.out.println("---------------------------> Start App");
|
||||||
Task task = taskService.newTask("1");
|
Task task = taskService.newTask("1");
|
||||||
task.setName("Spring example task");
|
task.setName("Spring example task");
|
||||||
ObjectReference objRef = new ObjectReference();
|
ObjectReference objRef = new ObjectReference();
|
||||||
objRef.setCompany("aCompany");
|
objRef.setCompany("aCompany");
|
||||||
objRef.setSystem("aSystem");
|
objRef.setSystem("aSystem");
|
||||||
objRef.setSystemInstance("anInstance");
|
objRef.setSystemInstance("anInstance");
|
||||||
objRef.setType("aType");
|
objRef.setType("aType");
|
||||||
objRef.setValue("aValue");
|
objRef.setValue("aValue");
|
||||||
task.setPrimaryObjRef(objRef);
|
task.setPrimaryObjRef(objRef);
|
||||||
task = taskService.createTask(task);
|
task = taskService.createTask(task);
|
||||||
System.out.println("---------------------------> Task started: " + task.getId());
|
System.out.println("---------------------------> Task started: " + task.getId());
|
||||||
taskService.claim(task.getId());
|
taskService.claim(task.getId());
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"---------------------------> Task claimed: " + taskService.getTask(task.getId()).getOwner());
|
"---------------------------> Task claimed: " + taskService.getTask(task.getId()).getOwner());
|
||||||
taskService.completeTask(task.getId(), true);
|
taskService.forceCompleteTask(task.getId());
|
||||||
System.out.println("---------------------------> Task completed");
|
System.out.println("---------------------------> Task completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,369 +1,369 @@
|
||||||
package pro.taskana.rest;
|
package pro.taskana.rest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.hateoas.PagedResources;
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import pro.taskana.BaseQuery.SortDirection;
|
import pro.taskana.BaseQuery.SortDirection;
|
||||||
import pro.taskana.KeyDomain;
|
import pro.taskana.KeyDomain;
|
||||||
import pro.taskana.Task;
|
import pro.taskana.Task;
|
||||||
import pro.taskana.TaskQuery;
|
import pro.taskana.TaskQuery;
|
||||||
import pro.taskana.TaskService;
|
import pro.taskana.TaskService;
|
||||||
import pro.taskana.TaskState;
|
import pro.taskana.TaskState;
|
||||||
import pro.taskana.TaskSummary;
|
import pro.taskana.TaskSummary;
|
||||||
import pro.taskana.exceptions.AttachmentPersistenceException;
|
import pro.taskana.exceptions.AttachmentPersistenceException;
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||||
import pro.taskana.exceptions.ConcurrencyException;
|
import pro.taskana.exceptions.ConcurrencyException;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.InvalidOwnerException;
|
import pro.taskana.exceptions.InvalidOwnerException;
|
||||||
import pro.taskana.exceptions.InvalidStateException;
|
import pro.taskana.exceptions.InvalidStateException;
|
||||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||||
import pro.taskana.exceptions.TaskNotFoundException;
|
import pro.taskana.exceptions.TaskNotFoundException;
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.rest.resource.TaskResource;
|
import pro.taskana.rest.resource.TaskResource;
|
||||||
import pro.taskana.rest.resource.TaskSummaryResource;
|
import pro.taskana.rest.resource.TaskSummaryResource;
|
||||||
import pro.taskana.rest.resource.assembler.TaskResourceAssembler;
|
import pro.taskana.rest.resource.assembler.TaskResourceAssembler;
|
||||||
import pro.taskana.rest.resource.assembler.TaskSummaryResourcesAssembler;
|
import pro.taskana.rest.resource.assembler.TaskSummaryResourcesAssembler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for all {@link Task} related endpoints.
|
* Controller for all {@link Task} related endpoints.
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
||||||
@RequestMapping(path = "/v1/tasks", produces = "application/hal+json")
|
@RequestMapping(path = "/v1/tasks", produces = "application/hal+json")
|
||||||
public class TaskController extends AbstractPagingController {
|
public class TaskController extends AbstractPagingController {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskController.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(TaskController.class);
|
||||||
|
|
||||||
private static final String STATE = "state";
|
private static final String STATE = "state";
|
||||||
private static final String STATE_VALUE_CLAIMED = "CLAIMED";
|
private static final String STATE_VALUE_CLAIMED = "CLAIMED";
|
||||||
private static final String STATE_VALUE_COMPLETED = "COMPLETED";
|
private static final String STATE_VALUE_COMPLETED = "COMPLETED";
|
||||||
private static final String STATE_VALUE_READY = "READY";
|
private static final String STATE_VALUE_READY = "READY";
|
||||||
private static final String PRIORITY = "priority";
|
private static final String PRIORITY = "priority";
|
||||||
private static final String NAME = "name";
|
private static final String NAME = "name";
|
||||||
private static final String OWNER = "owner";
|
private static final String OWNER = "owner";
|
||||||
private static final String DOMAIN = "domain";
|
private static final String DOMAIN = "domain";
|
||||||
private static final String WORKBASKET_ID = "workbasket-id";
|
private static final String WORKBASKET_ID = "workbasket-id";
|
||||||
private static final String WORKBASKET_KEY = "workbasket-key";
|
private static final String WORKBASKET_KEY = "workbasket-key";
|
||||||
private static final String CLASSIFICATION_KEY = "classification.key";
|
private static final String CLASSIFICATION_KEY = "classification.key";
|
||||||
private static final String POR_VALUE = "por.value";
|
private static final String POR_VALUE = "por.value";
|
||||||
private static final String POR_TYPE = "por.type";
|
private static final String POR_TYPE = "por.type";
|
||||||
private static final String POR_SYSTEM_INSTANCE = "por.instance";
|
private static final String POR_SYSTEM_INSTANCE = "por.instance";
|
||||||
private static final String POR_SYSTEM = "por.system";
|
private static final String POR_SYSTEM = "por.system";
|
||||||
private static final String POR_COMPANY = "por.company";
|
private static final String POR_COMPANY = "por.company";
|
||||||
private static final String DUE = "due";
|
private static final String DUE = "due";
|
||||||
private static final String PLANNED = "planned";
|
private static final String PLANNED = "planned";
|
||||||
|
|
||||||
private static final String SORT_BY = "sortBy";
|
private static final String SORT_BY = "sortBy";
|
||||||
private static final String SORT_DIRECTION = "order";
|
private static final String SORT_DIRECTION = "order";
|
||||||
|
|
||||||
private static final String PAGING_PAGE = "page";
|
private static final String PAGING_PAGE = "page";
|
||||||
private static final String PAGING_PAGE_SIZE = "page-size";
|
private static final String PAGING_PAGE_SIZE = "page-size";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TaskResourceAssembler taskResourceAssembler;
|
private TaskResourceAssembler taskResourceAssembler;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks(
|
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks(
|
||||||
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException, NotAuthorizedException {
|
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException, NotAuthorizedException {
|
||||||
|
|
||||||
TaskQuery query = taskService.createTaskQuery();
|
TaskQuery query = taskService.createTaskQuery();
|
||||||
query = applyFilterParams(query, params);
|
query = applyFilterParams(query, params);
|
||||||
query = applySortingParams(query, params);
|
query = applySortingParams(query, params);
|
||||||
|
|
||||||
PageMetadata pageMetadata = null;
|
PageMetadata pageMetadata = null;
|
||||||
List<TaskSummary> taskSummaries = null;
|
List<TaskSummary> taskSummaries = null;
|
||||||
String page = params.getFirst(PAGING_PAGE);
|
String page = params.getFirst(PAGING_PAGE);
|
||||||
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
|
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
|
||||||
params.remove(PAGING_PAGE);
|
params.remove(PAGING_PAGE);
|
||||||
params.remove(PAGING_PAGE_SIZE);
|
params.remove(PAGING_PAGE_SIZE);
|
||||||
validateNoInvalidParameterIsLeft(params);
|
validateNoInvalidParameterIsLeft(params);
|
||||||
if (page != null && pageSize != null) {
|
if (page != null && pageSize != null) {
|
||||||
// paging
|
// paging
|
||||||
long totalElements = query.count();
|
long totalElements = query.count();
|
||||||
pageMetadata = initPageMetadata(pageSize, page,
|
pageMetadata = initPageMetadata(pageSize, page,
|
||||||
totalElements);
|
totalElements);
|
||||||
taskSummaries = query.listPage((int) pageMetadata.getNumber(),
|
taskSummaries = query.listPage((int) pageMetadata.getNumber(),
|
||||||
(int) pageMetadata.getSize());
|
(int) pageMetadata.getSize());
|
||||||
} else if (page == null && pageSize == null) {
|
} else if (page == null && pageSize == null) {
|
||||||
// not paging
|
// not paging
|
||||||
taskSummaries = query.list();
|
taskSummaries = query.list();
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException("Paging information is incomplete.");
|
throw new InvalidArgumentException("Paging information is incomplete.");
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskSummaryResourcesAssembler taskSummaryResourcesAssembler = new TaskSummaryResourcesAssembler();
|
TaskSummaryResourcesAssembler taskSummaryResourcesAssembler = new TaskSummaryResourcesAssembler();
|
||||||
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourcesAssembler.toResources(taskSummaries,
|
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourcesAssembler.toResources(taskSummaries,
|
||||||
pageMetadata);
|
pageMetadata);
|
||||||
|
|
||||||
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/{taskId}")
|
@GetMapping(path = "/{taskId}")
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskResource> getTask(@PathVariable String taskId)
|
public ResponseEntity<TaskResource> getTask(@PathVariable String taskId)
|
||||||
throws TaskNotFoundException, NotAuthorizedException {
|
throws TaskNotFoundException, NotAuthorizedException {
|
||||||
Task task = taskService.getTask(taskId);
|
Task task = taskService.getTask(taskId);
|
||||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(task),
|
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(task),
|
||||||
HttpStatus.OK);
|
HttpStatus.OK);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/{taskId}/claim")
|
@PostMapping(path = "/{taskId}/claim")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskResource> claimTask(@PathVariable String taskId, @RequestBody String userName)
|
public ResponseEntity<TaskResource> claimTask(@PathVariable String taskId, @RequestBody String userName)
|
||||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
|
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
|
||||||
// TODO verify user
|
// TODO verify user
|
||||||
taskService.claim(taskId);
|
taskService.claim(taskId);
|
||||||
Task updatedTask = taskService.getTask(taskId);
|
Task updatedTask = taskService.getTask(taskId);
|
||||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
||||||
HttpStatus.OK);
|
HttpStatus.OK);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/complete")
|
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/complete")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskResource> completeTask(@PathVariable String taskId)
|
public ResponseEntity<TaskResource> completeTask(@PathVariable String taskId)
|
||||||
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException {
|
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException {
|
||||||
taskService.completeTask(taskId, true);
|
taskService.forceCompleteTask(taskId);
|
||||||
Task updatedTask = taskService.getTask(taskId);
|
Task updatedTask = taskService.getTask(taskId);
|
||||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
||||||
HttpStatus.OK);
|
HttpStatus.OK);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = "/{taskId}")
|
@RequestMapping(method = RequestMethod.DELETE, value = "/{taskId}")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskResource> deleteTask(@PathVariable String taskId)
|
public ResponseEntity<TaskResource> deleteTask(@PathVariable String taskId)
|
||||||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||||
taskService.deleteTask(taskId, true);
|
taskService.forceDeleteTask(taskId);
|
||||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(HttpStatus.OK);
|
ResponseEntity<TaskResource> result = new ResponseEntity<>(HttpStatus.OK);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskResource> createTask(@RequestBody TaskResource taskResource)
|
public ResponseEntity<TaskResource> createTask(@RequestBody TaskResource taskResource)
|
||||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
|
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
|
||||||
Task createdTask = taskService.createTask(taskResourceAssembler.toModel(taskResource));
|
Task createdTask = taskService.createTask(taskResourceAssembler.toModel(taskResource));
|
||||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(createdTask),
|
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(createdTask),
|
||||||
HttpStatus.CREATED);
|
HttpStatus.CREATED);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = "/{taskId}/transfer/{workbasketKey}")
|
@RequestMapping(path = "/{taskId}/transfer/{workbasketKey}")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskResource> transferTask(@PathVariable String taskId, @PathVariable String workbasketKey)
|
public ResponseEntity<TaskResource> transferTask(@PathVariable String taskId, @PathVariable String workbasketKey)
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||||
InvalidStateException {
|
InvalidStateException {
|
||||||
Task updatedTask = taskService.transfer(taskId, workbasketKey);
|
Task updatedTask = taskService.transfer(taskId, workbasketKey);
|
||||||
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(updatedTask),
|
||||||
HttpStatus.OK);
|
HttpStatus.OK);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping(path = "/{taskId}")
|
@PutMapping(path = "/{taskId}")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskResource> updateTask(
|
public ResponseEntity<TaskResource> updateTask(
|
||||||
@PathVariable(value = "taskId") String taskId,
|
@PathVariable(value = "taskId") String taskId,
|
||||||
@RequestBody TaskResource taskResource) throws TaskNotFoundException, WorkbasketNotFoundException,
|
@RequestBody TaskResource taskResource) throws TaskNotFoundException, WorkbasketNotFoundException,
|
||||||
ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
|
ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
|
||||||
NotAuthorizedException, AttachmentPersistenceException {
|
NotAuthorizedException, AttachmentPersistenceException {
|
||||||
ResponseEntity<TaskResource> result;
|
ResponseEntity<TaskResource> result;
|
||||||
if (taskId.equals(taskResource.getTaskId())) {
|
if (taskId.equals(taskResource.getTaskId())) {
|
||||||
Task task = taskResourceAssembler.toModel(taskResource);
|
Task task = taskResourceAssembler.toModel(taskResource);
|
||||||
task = taskService.updateTask(task);
|
task = taskService.updateTask(task);
|
||||||
result = ResponseEntity.ok(taskResourceAssembler.toResource(task));
|
result = ResponseEntity.ok(taskResourceAssembler.toResource(task));
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
"TaskId ('" + taskId
|
"TaskId ('" + taskId
|
||||||
+ "') is not identical with the taskId of to object in the payload which should be updated. ID=('"
|
+ "') is not identical with the taskId of to object in the payload which should be updated. ID=('"
|
||||||
+ taskResource.getTaskId() + "')");
|
+ taskResource.getTaskId() + "')");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaskQuery applyFilterParams(TaskQuery taskQuery, MultiValueMap<String, String> params)
|
private TaskQuery applyFilterParams(TaskQuery taskQuery, MultiValueMap<String, String> params)
|
||||||
throws NotAuthorizedException, InvalidArgumentException {
|
throws NotAuthorizedException, InvalidArgumentException {
|
||||||
|
|
||||||
// apply filters
|
// apply filters
|
||||||
if (params.containsKey(NAME)) {
|
if (params.containsKey(NAME)) {
|
||||||
String[] names = extractCommaSeparatedFields(params.get(NAME));
|
String[] names = extractCommaSeparatedFields(params.get(NAME));
|
||||||
taskQuery.nameIn(names);
|
taskQuery.nameIn(names);
|
||||||
params.remove(NAME);
|
params.remove(NAME);
|
||||||
}
|
}
|
||||||
if (params.containsKey(PRIORITY)) {
|
if (params.containsKey(PRIORITY)) {
|
||||||
String[] prioritesInString = extractCommaSeparatedFields(params.get(PRIORITY));
|
String[] prioritesInString = extractCommaSeparatedFields(params.get(PRIORITY));
|
||||||
int[] priorites = extractPriorities(prioritesInString);
|
int[] priorites = extractPriorities(prioritesInString);
|
||||||
taskQuery.priorityIn(priorites);
|
taskQuery.priorityIn(priorites);
|
||||||
params.remove(PRIORITY);
|
params.remove(PRIORITY);
|
||||||
}
|
}
|
||||||
if (params.containsKey(STATE)) {
|
if (params.containsKey(STATE)) {
|
||||||
TaskState[] states = extractStates(params);
|
TaskState[] states = extractStates(params);
|
||||||
taskQuery.stateIn(states);
|
taskQuery.stateIn(states);
|
||||||
params.remove(STATE);
|
params.remove(STATE);
|
||||||
}
|
}
|
||||||
if (params.containsKey(CLASSIFICATION_KEY)) {
|
if (params.containsKey(CLASSIFICATION_KEY)) {
|
||||||
String[] classificationKeys = extractCommaSeparatedFields(params.get(CLASSIFICATION_KEY));
|
String[] classificationKeys = extractCommaSeparatedFields(params.get(CLASSIFICATION_KEY));
|
||||||
taskQuery.classificationKeyIn(classificationKeys);
|
taskQuery.classificationKeyIn(classificationKeys);
|
||||||
params.remove(CLASSIFICATION_KEY);
|
params.remove(CLASSIFICATION_KEY);
|
||||||
}
|
}
|
||||||
if (params.containsKey(WORKBASKET_ID)) {
|
if (params.containsKey(WORKBASKET_ID)) {
|
||||||
String[] workbaskets = extractCommaSeparatedFields(params.get(WORKBASKET_ID));
|
String[] workbaskets = extractCommaSeparatedFields(params.get(WORKBASKET_ID));
|
||||||
taskQuery.workbasketIdIn(workbaskets);
|
taskQuery.workbasketIdIn(workbaskets);
|
||||||
params.remove(WORKBASKET_ID);
|
params.remove(WORKBASKET_ID);
|
||||||
}
|
}
|
||||||
if (params.containsKey(WORKBASKET_KEY)) {
|
if (params.containsKey(WORKBASKET_KEY)) {
|
||||||
String[] domains = null;
|
String[] domains = null;
|
||||||
if (params.get(DOMAIN) != null) {
|
if (params.get(DOMAIN) != null) {
|
||||||
domains = extractCommaSeparatedFields(params.get(DOMAIN));
|
domains = extractCommaSeparatedFields(params.get(DOMAIN));
|
||||||
}
|
}
|
||||||
if (domains == null || domains.length != 1) {
|
if (domains == null || domains.length != 1) {
|
||||||
throw new InvalidArgumentException("workbasket-key requires excactly one domain as second parameter.");
|
throw new InvalidArgumentException("workbasket-key requires excactly one domain as second parameter.");
|
||||||
}
|
}
|
||||||
String[] workbasketKeys = extractCommaSeparatedFields(params.get(WORKBASKET_KEY));
|
String[] workbasketKeys = extractCommaSeparatedFields(params.get(WORKBASKET_KEY));
|
||||||
KeyDomain[] keyDomains = new KeyDomain[workbasketKeys.length];
|
KeyDomain[] keyDomains = new KeyDomain[workbasketKeys.length];
|
||||||
for (int i = 0; i < workbasketKeys.length; i++) {
|
for (int i = 0; i < workbasketKeys.length; i++) {
|
||||||
keyDomains[i] = new KeyDomain(workbasketKeys[i], domains[0]);
|
keyDomains[i] = new KeyDomain(workbasketKeys[i], domains[0]);
|
||||||
}
|
}
|
||||||
taskQuery.workbasketKeyDomainIn(keyDomains);
|
taskQuery.workbasketKeyDomainIn(keyDomains);
|
||||||
params.remove(WORKBASKET_KEY);
|
params.remove(WORKBASKET_KEY);
|
||||||
params.remove(DOMAIN);
|
params.remove(DOMAIN);
|
||||||
}
|
}
|
||||||
if (params.containsKey(OWNER)) {
|
if (params.containsKey(OWNER)) {
|
||||||
String[] owners = extractCommaSeparatedFields(params.get(OWNER));
|
String[] owners = extractCommaSeparatedFields(params.get(OWNER));
|
||||||
taskQuery.ownerIn(owners);
|
taskQuery.ownerIn(owners);
|
||||||
params.remove(OWNER);
|
params.remove(OWNER);
|
||||||
}
|
}
|
||||||
if (params.containsKey(POR_COMPANY)) {
|
if (params.containsKey(POR_COMPANY)) {
|
||||||
String[] companies = extractCommaSeparatedFields(params.get(POR_COMPANY));
|
String[] companies = extractCommaSeparatedFields(params.get(POR_COMPANY));
|
||||||
taskQuery.primaryObjectReferenceCompanyIn(companies);
|
taskQuery.primaryObjectReferenceCompanyIn(companies);
|
||||||
params.remove(POR_COMPANY);
|
params.remove(POR_COMPANY);
|
||||||
}
|
}
|
||||||
if (params.containsKey(POR_SYSTEM)) {
|
if (params.containsKey(POR_SYSTEM)) {
|
||||||
String[] systems = extractCommaSeparatedFields(params.get(POR_SYSTEM));
|
String[] systems = extractCommaSeparatedFields(params.get(POR_SYSTEM));
|
||||||
taskQuery.primaryObjectReferenceSystemIn(systems);
|
taskQuery.primaryObjectReferenceSystemIn(systems);
|
||||||
params.remove(POR_SYSTEM);
|
params.remove(POR_SYSTEM);
|
||||||
}
|
}
|
||||||
if (params.containsKey(POR_SYSTEM_INSTANCE)) {
|
if (params.containsKey(POR_SYSTEM_INSTANCE)) {
|
||||||
String[] systemInstances = extractCommaSeparatedFields(params.get(POR_SYSTEM_INSTANCE));
|
String[] systemInstances = extractCommaSeparatedFields(params.get(POR_SYSTEM_INSTANCE));
|
||||||
taskQuery.primaryObjectReferenceSystemInstanceIn(systemInstances);
|
taskQuery.primaryObjectReferenceSystemInstanceIn(systemInstances);
|
||||||
params.remove(POR_SYSTEM_INSTANCE);
|
params.remove(POR_SYSTEM_INSTANCE);
|
||||||
}
|
}
|
||||||
if (params.containsKey(POR_TYPE)) {
|
if (params.containsKey(POR_TYPE)) {
|
||||||
String[] types = extractCommaSeparatedFields(params.get(POR_TYPE));
|
String[] types = extractCommaSeparatedFields(params.get(POR_TYPE));
|
||||||
taskQuery.primaryObjectReferenceTypeIn(types);
|
taskQuery.primaryObjectReferenceTypeIn(types);
|
||||||
params.remove(POR_TYPE);
|
params.remove(POR_TYPE);
|
||||||
}
|
}
|
||||||
if (params.containsKey(POR_VALUE)) {
|
if (params.containsKey(POR_VALUE)) {
|
||||||
String[] values = extractCommaSeparatedFields(params.get(POR_VALUE));
|
String[] values = extractCommaSeparatedFields(params.get(POR_VALUE));
|
||||||
taskQuery.primaryObjectReferenceValueIn(values);
|
taskQuery.primaryObjectReferenceValueIn(values);
|
||||||
params.remove(POR_VALUE);
|
params.remove(POR_VALUE);
|
||||||
}
|
}
|
||||||
return taskQuery;
|
return taskQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaskQuery applySortingParams(TaskQuery taskQuery, MultiValueMap<String, String> params)
|
private TaskQuery applySortingParams(TaskQuery taskQuery, MultiValueMap<String, String> params)
|
||||||
throws NotAuthorizedException, InvalidArgumentException {
|
throws NotAuthorizedException, InvalidArgumentException {
|
||||||
|
|
||||||
// sorting
|
// sorting
|
||||||
String sortBy = params.getFirst(SORT_BY);
|
String sortBy = params.getFirst(SORT_BY);
|
||||||
if (sortBy != null) {
|
if (sortBy != null) {
|
||||||
SortDirection sortDirection;
|
SortDirection sortDirection;
|
||||||
if (params.getFirst(SORT_DIRECTION) != null && "desc".equals(params.getFirst(SORT_DIRECTION))) {
|
if (params.getFirst(SORT_DIRECTION) != null && "desc".equals(params.getFirst(SORT_DIRECTION))) {
|
||||||
sortDirection = SortDirection.DESCENDING;
|
sortDirection = SortDirection.DESCENDING;
|
||||||
} else {
|
} else {
|
||||||
sortDirection = SortDirection.ASCENDING;
|
sortDirection = SortDirection.ASCENDING;
|
||||||
}
|
}
|
||||||
switch (sortBy) {
|
switch (sortBy) {
|
||||||
case (CLASSIFICATION_KEY):
|
case (CLASSIFICATION_KEY):
|
||||||
taskQuery = taskQuery.orderByClassificationKey(sortDirection);
|
taskQuery = taskQuery.orderByClassificationKey(sortDirection);
|
||||||
break;
|
break;
|
||||||
case (POR_TYPE):
|
case (POR_TYPE):
|
||||||
taskQuery = taskQuery.orderByPrimaryObjectReferenceType(sortDirection);
|
taskQuery = taskQuery.orderByPrimaryObjectReferenceType(sortDirection);
|
||||||
break;
|
break;
|
||||||
case (POR_VALUE):
|
case (POR_VALUE):
|
||||||
taskQuery = taskQuery.orderByPrimaryObjectReferenceValue(sortDirection);
|
taskQuery = taskQuery.orderByPrimaryObjectReferenceValue(sortDirection);
|
||||||
break;
|
break;
|
||||||
case (STATE):
|
case (STATE):
|
||||||
taskQuery = taskQuery.orderByState(sortDirection);
|
taskQuery = taskQuery.orderByState(sortDirection);
|
||||||
break;
|
break;
|
||||||
case (NAME):
|
case (NAME):
|
||||||
taskQuery = taskQuery.orderByName(sortDirection);
|
taskQuery = taskQuery.orderByName(sortDirection);
|
||||||
break;
|
break;
|
||||||
case (DUE):
|
case (DUE):
|
||||||
taskQuery = taskQuery.orderByDue(sortDirection);
|
taskQuery = taskQuery.orderByDue(sortDirection);
|
||||||
break;
|
break;
|
||||||
case (PLANNED):
|
case (PLANNED):
|
||||||
taskQuery = taskQuery.orderByPlanned(sortDirection);
|
taskQuery = taskQuery.orderByPlanned(sortDirection);
|
||||||
break;
|
break;
|
||||||
case (PRIORITY):
|
case (PRIORITY):
|
||||||
taskQuery = taskQuery.orderByPriority(sortDirection);
|
taskQuery = taskQuery.orderByPriority(sortDirection);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException("Unknown filter attribute: " + sortBy);
|
throw new InvalidArgumentException("Unknown filter attribute: " + sortBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
params.remove(SORT_BY);
|
params.remove(SORT_BY);
|
||||||
params.remove(SORT_DIRECTION);
|
params.remove(SORT_DIRECTION);
|
||||||
return taskQuery;
|
return taskQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] extractPriorities(String[] prioritesInString) {
|
private int[] extractPriorities(String[] prioritesInString) {
|
||||||
int[] priorites = new int[prioritesInString.length];
|
int[] priorites = new int[prioritesInString.length];
|
||||||
for (int i = 0; i < prioritesInString.length; i++) {
|
for (int i = 0; i < prioritesInString.length; i++) {
|
||||||
priorites[i] = Integer.getInteger(prioritesInString[i]);
|
priorites[i] = Integer.getInteger(prioritesInString[i]);
|
||||||
}
|
}
|
||||||
return priorites;
|
return priorites;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaskState[] extractStates(MultiValueMap<String, String> params) throws InvalidArgumentException {
|
private TaskState[] extractStates(MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||||
List<TaskState> states = new ArrayList<>();
|
List<TaskState> states = new ArrayList<>();
|
||||||
for (String item : params.get(STATE)) {
|
for (String item : params.get(STATE)) {
|
||||||
for (String state : item.split(",")) {
|
for (String state : item.split(",")) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case STATE_VALUE_READY:
|
case STATE_VALUE_READY:
|
||||||
states.add(TaskState.READY);
|
states.add(TaskState.READY);
|
||||||
break;
|
break;
|
||||||
case STATE_VALUE_COMPLETED:
|
case STATE_VALUE_COMPLETED:
|
||||||
states.add(TaskState.COMPLETED);
|
states.add(TaskState.COMPLETED);
|
||||||
break;
|
break;
|
||||||
case STATE_VALUE_CLAIMED:
|
case STATE_VALUE_CLAIMED:
|
||||||
states.add(TaskState.CLAIMED);
|
states.add(TaskState.CLAIMED);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException("Unknown status '" + state + "'");
|
throw new InvalidArgumentException("Unknown status '" + state + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return states.toArray(new TaskState[0]);
|
return states.toArray(new TaskState[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue