Created a query api for task and the linked objects classification and objectReference
This commit is contained in:
parent
c3beb84eae
commit
b7b3a49cb1
|
@ -3,6 +3,7 @@ package org.taskana;
|
|||
import java.util.List;
|
||||
|
||||
import org.taskana.model.Classification;
|
||||
import org.taskana.persistence.ClassificationQuery;
|
||||
|
||||
/**
|
||||
* This class manages the classifications.
|
||||
|
@ -43,4 +44,10 @@ public interface ClassificationService {
|
|||
* the Classification to update
|
||||
*/
|
||||
void updateClassification(Classification classification);
|
||||
|
||||
/**
|
||||
* This method provides a query builder for quering the database.
|
||||
* @return a {@link ClassificationQuery}
|
||||
*/
|
||||
ClassificationQuery createClassificationQuery();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.taskana.model.DueWorkbasketCounter;
|
|||
import org.taskana.model.Task;
|
||||
import org.taskana.model.TaskState;
|
||||
import org.taskana.model.TaskStateCounter;
|
||||
import org.taskana.persistence.TaskQuery;
|
||||
|
||||
/**
|
||||
* The Task Service manages all operations on tasks.
|
||||
|
@ -49,30 +50,6 @@ public interface TaskService {
|
|||
*/
|
||||
Task getTaskById(String taskId) throws TaskNotFoundException;
|
||||
|
||||
/**
|
||||
* Query all tasks for a workbasket.
|
||||
* @param workbasketId
|
||||
* the workbasket to query
|
||||
* @return the list of tasks, which reside in the workbasket
|
||||
* @throws NotAuthorizedException
|
||||
*/
|
||||
List<Task> getTasksForWorkbasket(String workbasketId) throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Query all tasks for a workbasket.
|
||||
* @param workbasketId
|
||||
* the workbasket to query
|
||||
* @return the list of tasks, which reside in the workbasket
|
||||
* @throws NotAuthorizedException
|
||||
*/
|
||||
List<Task> getTasksForWorkbasket(List<String> workbaskets, List<TaskState> states) throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* This method returns all Tasks.
|
||||
* @return a {@link List<Task>} of {@link Task}
|
||||
*/
|
||||
List<Task> getTasks();
|
||||
|
||||
/**
|
||||
* This method counts all tasks with a given state.
|
||||
* @param states
|
||||
|
@ -81,14 +58,6 @@ public interface TaskService {
|
|||
*/
|
||||
List<TaskStateCounter> getTaskCountForState(List<TaskState> states);
|
||||
|
||||
/**
|
||||
* This method returns all tasks with the specified states.
|
||||
* @param states
|
||||
* all List with the needed states
|
||||
* @return a list of Tasks
|
||||
*/
|
||||
List<Task> findTasks(List<TaskState> states);
|
||||
|
||||
/**
|
||||
* Count all Tasks in a given workbasket with daysInPast as Days from today in
|
||||
* the past and a specific state.
|
||||
|
@ -99,6 +68,8 @@ public interface TaskService {
|
|||
*/
|
||||
long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast, List<TaskState> states);
|
||||
|
||||
List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast, List<TaskState> states);
|
||||
|
||||
/**
|
||||
* Transfer task to another workbasket. The transfer set the transferred flag
|
||||
* and resets the read flag.
|
||||
|
@ -119,6 +90,10 @@ public interface TaskService {
|
|||
*/
|
||||
Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException;
|
||||
|
||||
List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast, List<TaskState> states);
|
||||
/**
|
||||
* This method provides a query builder for quering the database.
|
||||
* @return a {@link TaskQuery}
|
||||
*/
|
||||
TaskQuery createTaskQuery();
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.time.LocalDate;
|
|||
import java.util.List;
|
||||
|
||||
import org.taskana.ClassificationService;
|
||||
import org.taskana.TaskanaEngine;
|
||||
import org.taskana.impl.persistence.ClassificationQueryImpl;
|
||||
import org.taskana.impl.util.IdGenerator;
|
||||
import org.taskana.model.Classification;
|
||||
import org.taskana.model.mappings.ClassificationMapper;
|
||||
import org.taskana.persistence.ClassificationQuery;
|
||||
|
||||
/**
|
||||
* This is the implementation of ClassificationService.
|
||||
|
@ -18,9 +21,11 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
private static final String ID_PREFIX_CLASSIFICATION = "CLI";
|
||||
|
||||
private ClassificationMapper classificationMapper;
|
||||
private TaskanaEngine taskanaEngine;
|
||||
|
||||
public ClassificationServiceImpl(ClassificationMapper classificationMapper) {
|
||||
public ClassificationServiceImpl(TaskanaEngine taskanaEngine, ClassificationMapper classificationMapper) {
|
||||
super();
|
||||
this.taskanaEngine = taskanaEngine;
|
||||
this.classificationMapper = classificationMapper;
|
||||
}
|
||||
|
||||
|
@ -76,4 +81,9 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery createClassificationQuery() {
|
||||
return new ClassificationQueryImpl(taskanaEngine);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.taskana.TaskanaEngine;
|
|||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.exceptions.TaskNotFoundException;
|
||||
import org.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import org.taskana.impl.persistence.TaskQueryImpl;
|
||||
import org.taskana.impl.util.IdGenerator;
|
||||
import org.taskana.model.DueWorkbasketCounter;
|
||||
import org.taskana.model.ObjectReference;
|
||||
|
@ -22,6 +23,8 @@ import org.taskana.model.TaskStateCounter;
|
|||
import org.taskana.model.WorkbasketAuthorization;
|
||||
import org.taskana.model.mappings.ObjectReferenceMapper;
|
||||
import org.taskana.model.mappings.TaskMapper;
|
||||
import org.taskana.persistence.TaskQuery;
|
||||
|
||||
/**
|
||||
* This is the implementation of TaskService.
|
||||
*/
|
||||
|
@ -113,34 +116,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getTasksForWorkbasket(String workbasketId) throws NotAuthorizedException {
|
||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId, WorkbasketAuthorization.OPEN);
|
||||
|
||||
return taskMapper.findByWorkBasketId(workbasketId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> findTasks(List<TaskState> states) {
|
||||
return taskMapper.findByStates(states);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getTasksForWorkbasket(List<String> workbasketIds, List<TaskState> states)
|
||||
throws NotAuthorizedException {
|
||||
|
||||
for (String workbasket : workbasketIds) {
|
||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasket, WorkbasketAuthorization.OPEN);
|
||||
}
|
||||
|
||||
return taskMapper.findByWorkbasketIdsAndStates(workbasketIds, states);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getTasks() {
|
||||
return taskMapper.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskStateCounter> getTaskCountForState(List<TaskState> states) {
|
||||
return taskMapper.getTaskCountForState(states);
|
||||
|
@ -203,4 +178,8 @@ public class TaskServiceImpl implements TaskService {
|
|||
return getTaskById(taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery createTaskQuery() {
|
||||
return new TaskQueryImpl(taskanaEngine);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.taskana.impl.persistence.MapTypeHandler;
|
|||
import org.taskana.model.mappings.ClassificationMapper;
|
||||
import org.taskana.model.mappings.DistributionTargetMapper;
|
||||
import org.taskana.model.mappings.ObjectReferenceMapper;
|
||||
import org.taskana.model.mappings.QueryMapper;
|
||||
import org.taskana.model.mappings.TaskMapper;
|
||||
import org.taskana.model.mappings.WorkbasketAccessMapper;
|
||||
import org.taskana.model.mappings.WorkbasketMapper;
|
||||
|
@ -71,7 +72,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
|
||||
@Override
|
||||
public ClassificationService getClassificationService() {
|
||||
return new ClassificationServiceImpl(this.classificationMapper);
|
||||
return new ClassificationServiceImpl(this, this.classificationMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,6 +105,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
configuration.addMapper(ClassificationMapper.class);
|
||||
configuration.addMapper(WorkbasketAccessMapper.class);
|
||||
configuration.addMapper(ObjectReferenceMapper.class);
|
||||
configuration.addMapper(QueryMapper.class);
|
||||
configuration.getTypeHandlerRegistry().register(MapTypeHandler.class);
|
||||
return new SqlSessionFactoryBuilder().build(configuration);
|
||||
}
|
||||
|
@ -116,4 +118,12 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
}
|
||||
}
|
||||
|
||||
public SqlSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setSession(SqlSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
package org.taskana.impl.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.taskana.TaskanaEngine;
|
||||
import org.taskana.impl.TaskanaEngineImpl;
|
||||
import org.taskana.model.Classification;
|
||||
import org.taskana.persistence.ClassificationQuery;
|
||||
|
||||
/**
|
||||
* Implementation of ClassificationQuery interface.
|
||||
* @author EH
|
||||
*/
|
||||
public class ClassificationQueryImpl implements ClassificationQuery {
|
||||
|
||||
private static final String LINK_TO_MAPPER = "org.taskana.model.mappings.QueryMapper.queryClassification";
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private String tenantId;
|
||||
private String[] parentClassificationId;
|
||||
private String[] category;
|
||||
private String[] type;
|
||||
private String[] name;
|
||||
private String description;
|
||||
private int[] priority;
|
||||
private String[] serviceLevel;
|
||||
|
||||
public ClassificationQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery parentClassification(String... parentClassificationId) {
|
||||
this.parentClassificationId = parentClassificationId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery category(String... category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery type(String... type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery name(String... name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery descriptionLike(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery priority(int... priorities) {
|
||||
this.priority = priorities;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery serviceLevel(String... serviceLevel) {
|
||||
this.serviceLevel = serviceLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Classification> list() {
|
||||
return taskanaEngine.getSession().selectList(LINK_TO_MAPPER, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Classification> list(int offset, int limit) {
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
return taskanaEngine.getSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Classification single() {
|
||||
return taskanaEngine.getSession().selectOne(LINK_TO_MAPPER, this);
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String[] getParentClassificationId() {
|
||||
return parentClassificationId;
|
||||
}
|
||||
|
||||
public void setParentClassificationId(String[] parentClassificationId) {
|
||||
this.parentClassificationId = parentClassificationId;
|
||||
}
|
||||
|
||||
public String[] getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String[] category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String[] getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String[] type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String[] getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int[] getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int[] priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String[] getServiceLevel() {
|
||||
return serviceLevel;
|
||||
}
|
||||
|
||||
public void setServiceLevel(String[] serviceLevel) {
|
||||
this.serviceLevel = serviceLevel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package org.taskana.impl.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.taskana.TaskanaEngine;
|
||||
import org.taskana.impl.TaskanaEngineImpl;
|
||||
import org.taskana.model.ObjectReference;
|
||||
import org.taskana.persistence.ObjectReferenceQuery;
|
||||
|
||||
/**
|
||||
* Implementation of ObjectReferenceQuery interface.
|
||||
* @author EH
|
||||
*/
|
||||
public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
||||
|
||||
private static final String LINK_TO_MAPPER = "org.taskana.model.mappings.QueryMapper.queryObjectReference";
|
||||
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private String tenantId;
|
||||
private String[] company;
|
||||
private String[] system;
|
||||
private String[] systemInstance;
|
||||
private String[] type;
|
||||
private String[] value;
|
||||
|
||||
public ObjectReferenceQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery tenantId(String tenantIds) {
|
||||
this.tenantId = tenantIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery company(String... companies) {
|
||||
this.company = companies;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery system(String... systems) {
|
||||
this.system = systems;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery systemInstance(String... systemInstances) {
|
||||
this.systemInstance = systemInstances;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery type(String... types) {
|
||||
this.type = types;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery value(String... values) {
|
||||
this.value = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ObjectReference> list() {
|
||||
return taskanaEngine.getSession().selectList(LINK_TO_MAPPER, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ObjectReference> list(int offset, int limit) {
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
return taskanaEngine.getSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReference single() {
|
||||
return taskanaEngine.getSession().selectOne(LINK_TO_MAPPER, this);
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String[] getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(String[] company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
public String[] getSystem() {
|
||||
return system;
|
||||
}
|
||||
|
||||
public void setSystem(String[] system) {
|
||||
this.system = system;
|
||||
}
|
||||
|
||||
public String[] getSystemInstance() {
|
||||
return systemInstance;
|
||||
}
|
||||
|
||||
public void setSystemInstance(String[] systemInstance) {
|
||||
this.systemInstance = systemInstance;
|
||||
}
|
||||
|
||||
public String[] getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String[] type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String[] getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String[] value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,249 @@
|
|||
package org.taskana.impl.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.taskana.TaskanaEngine;
|
||||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.impl.TaskanaEngineImpl;
|
||||
import org.taskana.model.Task;
|
||||
import org.taskana.model.TaskState;
|
||||
import org.taskana.model.WorkbasketAuthorization;
|
||||
import org.taskana.persistence.ClassificationQuery;
|
||||
import org.taskana.persistence.ObjectReferenceQuery;
|
||||
import org.taskana.persistence.TaskQuery;
|
||||
|
||||
/**
|
||||
* TaskQuery for generating dynamic sql.
|
||||
*/
|
||||
public class TaskQueryImpl implements TaskQuery {
|
||||
|
||||
private static final String LINK_TO_MAPPER = "org.taskana.model.mappings.QueryMapper.queryTasks";
|
||||
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
|
||||
private String tenantId;
|
||||
private String[] name;
|
||||
private String description;
|
||||
private int[] priority;
|
||||
private TaskState[] states;
|
||||
private ClassificationQuery classificationQuery;
|
||||
private String[] workbasketId;
|
||||
private String[] owner;
|
||||
private ObjectReferenceQuery objectReferenceQuery;
|
||||
private Boolean isRead;
|
||||
private Boolean isTransferred;
|
||||
private String[] customFields;
|
||||
|
||||
public TaskQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery name(String... names) {
|
||||
this.name = names;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery descriptionLike(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery priority(int... priorities) {
|
||||
this.priority = priorities;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery state(TaskState... states) {
|
||||
this.states = states;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery classification(ClassificationQuery classificationQuery) {
|
||||
this.classificationQuery = classificationQuery;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery workbasketId(String... workbasketIds) {
|
||||
this.workbasketId = workbasketIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery owner(String... owners) {
|
||||
this.owner = owners;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery objectReference(ObjectReferenceQuery objectReferenceQuery) {
|
||||
this.objectReferenceQuery = objectReferenceQuery;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery read(Boolean isRead) {
|
||||
this.isRead = isRead;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery transferred(Boolean isTransferred) {
|
||||
this.isTransferred = isTransferred;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskQuery customFields(String... customFields) {
|
||||
this.customFields = customFields;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery createObjectReferenceQuery() {
|
||||
return new ObjectReferenceQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> list() throws NotAuthorizedException {
|
||||
checkAuthorization();
|
||||
return taskanaEngine.getSession().selectList(LINK_TO_MAPPER, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> list(int offset, int limit) throws NotAuthorizedException {
|
||||
checkAuthorization();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
return taskanaEngine.getSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task single() throws NotAuthorizedException {
|
||||
checkAuthorization();
|
||||
return taskanaEngine.getSession().selectOne(LINK_TO_MAPPER, this);
|
||||
}
|
||||
|
||||
private void checkAuthorization() throws NotAuthorizedException {
|
||||
if (this.workbasketId != null && this.workbasketId.length > 0) {
|
||||
for (String workbasket : this.workbasketId) {
|
||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasket, WorkbasketAuthorization.OPEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TaskanaEngineImpl getTaskanaEngine() {
|
||||
return taskanaEngine;
|
||||
}
|
||||
|
||||
public void setTaskanaEngine(TaskanaEngineImpl taskanaEngine) {
|
||||
this.taskanaEngine = taskanaEngine;
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String[] getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int[] getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int[] priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public TaskState[] getStates() {
|
||||
return states;
|
||||
}
|
||||
|
||||
public void setStates(TaskState[] states) {
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
public ClassificationQuery getClassificationQuery() {
|
||||
return classificationQuery;
|
||||
}
|
||||
|
||||
public void setClassificationQuery(ClassificationQuery classificationQuery) {
|
||||
this.classificationQuery = classificationQuery;
|
||||
}
|
||||
|
||||
public String[] getWorkbasketId() {
|
||||
return workbasketId;
|
||||
}
|
||||
|
||||
public void setWorkbasketId(String[] workbasketId) {
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
||||
public String[] getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String[] owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public ObjectReferenceQuery getObjectReferenceQuery() {
|
||||
return objectReferenceQuery;
|
||||
}
|
||||
|
||||
public void setObjectReferenceQuery(ObjectReferenceQuery objectReferenceQuery) {
|
||||
this.objectReferenceQuery = objectReferenceQuery;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return isRead;
|
||||
}
|
||||
|
||||
public void setRead(boolean isRead) {
|
||||
this.isRead = isRead;
|
||||
}
|
||||
|
||||
public boolean isTransferred() {
|
||||
return isTransferred;
|
||||
}
|
||||
|
||||
public void setTransferred(boolean isTransferred) {
|
||||
this.isTransferred = isTransferred;
|
||||
}
|
||||
|
||||
public String[] getCustomFields() {
|
||||
return customFields;
|
||||
}
|
||||
|
||||
public void setCustomFields(String[] customFields) {
|
||||
this.customFields = customFields;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package org.taskana.model.mappings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.One;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.taskana.impl.persistence.ClassificationQueryImpl;
|
||||
import org.taskana.impl.persistence.ObjectReferenceQueryImpl;
|
||||
import org.taskana.impl.persistence.TaskQueryImpl;
|
||||
import org.taskana.model.Classification;
|
||||
import org.taskana.model.ObjectReference;
|
||||
import org.taskana.model.Task;
|
||||
|
||||
/**
|
||||
* This class provides a mapper for all queries.
|
||||
*/
|
||||
public interface QueryMapper {
|
||||
|
||||
String OBJECTREFERENCEMAPPER_FINDBYID = "org.taskana.model.mappings.ObjectReferenceMapper.findById";
|
||||
String CLASSIFICATION_FINDBYID = "org.taskana.model.mappings.ClassificationMapper.findById";
|
||||
|
||||
@Select("<script>SELECT t.ID, t.TENANT_ID, t.CREATED, t.CLAIMED, t.COMPLETED, t.MODIFIED, t.PLANNED, t.DUE, t.NAME, t.DESCRIPTION, t.PRIORITY, t.STATE, t.CLASSIFICATION_ID, t.WORKBASKETID, t.OWNER, t.PRIMARY_OBJ_REF_ID, t.IS_READ, t.IS_TRANSFERRED, t.CUSTOM_1, t.CUSTOM_2, t.CUSTOM_3, t.CUSTOM_4, t.CUSTOM_5, t.CUSTOM_6, t.CUSTOM_7, t.CUSTOM_8, t.CUSTOM_9, t.CUSTOM_10 "
|
||||
+ "FROM TASK t "
|
||||
// Joins if Classification or Object Reference Query is needed
|
||||
+ "<if test='classificationQuery != null'>LEFT OUTER JOIN CLASSIFICATION c on t.CLASSIFICATION_ID = c.ID</if> "
|
||||
+ "<if test='objectReferenceQuery != null'>LEFT OUTER JOIN OBJECT_REFERENCE o on t.PRIMARY_OBJ_REF_ID = o.ID</if> "
|
||||
+ "<where>"
|
||||
+ "<if test='tenantId != null'>t.TENANT_ID = #{tenantId}</if> "
|
||||
+ "<if test='name != null'>AND t.NAME IN(<foreach item='item' collection='name' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='description != null'>AND t.DESCRIPTION like #{description}</if> "
|
||||
+ "<if test='priority != null'>AND t.PRIORITY IN(<foreach item='item' collection='priority' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='states != null'>AND t.STATE IN(<foreach item='item' collection='states' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='workbasketId != null'>AND t.WORKBASKETID IN(<foreach item='item' collection='workbasketId' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='owner != null'>AND t.OWNER IN(<foreach item='item' collection='owner' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='isRead != null'>AND t.IS_READ = #{isRead}</if> "
|
||||
+ "<if test='isTransferred != null'>AND t.IS_TRANSFERRED = #{isTransferred}</if> "
|
||||
+ "<if test='customFields != null'>AND (t.CUSTOM_1 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_2 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_3 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_4 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_5 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_6 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_7 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_8 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_9 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_10 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>))</if> "
|
||||
// Classification Query
|
||||
+ "<if test='classificationQuery != null'>"
|
||||
+ "<if test='classificationQuery.tenantId != null'>AND c.TENANT_ID = #{classificationQuery.tenantId}</if> "
|
||||
+ "<if test='classificationQuery.parentClassificationId != null'>AND c.PARENT_CLASSIFICATION_ID IN(<foreach item='item' collection='classificationQuery.parentClassificationId' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='classificationQuery.category != null'>AND c.CATEGORY IN(<foreach item='item' collection='classificationQuery.category' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='classificationQuery.type != null'>AND c.TYPE IN(<foreach item='item' collection='classificationQuery.type' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='classificationQuery.name != null'>AND c.NAME IN(<foreach item='item' collection='classificationQuery.name' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='classificationQuery.description != null'>AND c.DESCRIPTION like #{classificationQuery.description}</if> "
|
||||
+ "<if test='classificationQuery.priority != null'>AND c.PRIORITY IN(<foreach item='item' collection='classificationQuery.priority' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='classificationQuery.serviceLevel != null'>AND c.SERVICE_LEVEL IN(<foreach item='item' collection='classificationQuery.serviceLevel' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "</if>"
|
||||
// Object Reference Query
|
||||
+ "<if test='objectReferenceQuery != null'>"
|
||||
+ "<if test='objectReferenceQuery.tenantId != null'>AND o.TENANT_ID = #{objectReferenceQuery.tenantId}</if> "
|
||||
+ "<if test='objectReferenceQuery.company != null'>AND o.COMPANY IN(<foreach item='item' collection='objectReferenceQuery.company' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='objectReferenceQuery.system != null'>AND o.SYSTEM IN(<foreach item='item' collection='objectReferenceQuery.system' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='objectReferenceQuery.systemInstance != null'>AND o.SYSTEM_INSTANCE IN(<foreach item='item' collection='objectReferenceQuery.systemInstance' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='objectReferenceQuery.type != null'>AND o.TYPE IN(<foreach item='item' collection='objectReferenceQuery.type' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='objectReferenceQuery.value != null'>AND o.VALUE IN(<foreach item='item' collection='objectReferenceQuery.value' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "</if>"
|
||||
+ "</where>"
|
||||
+ "</script>")
|
||||
@Results(value = { @Result(property = "id", column = "ID"),
|
||||
@Result(property = "tenantId", column = "TENANT_ID"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "claimed", column = "CLAIMED"),
|
||||
@Result(property = "completed", column = "COMPLETED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "planned", column = "PLANNED"),
|
||||
@Result(property = "due", column = "DUE"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "state", column = "STATE"),
|
||||
@Result(property = "classification", column = "CLASSIFICATION_ID", javaType = Classification.class, one = @One(select = CLASSIFICATION_FINDBYID)),
|
||||
@Result(property = "workbasketId", column = "WORKBASKETID"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "primaryObjRef", column = "PRIMARY_OBJ_REF_ID", javaType = ObjectReference.class, one = @One(select = OBJECTREFERENCEMAPPER_FINDBYID)),
|
||||
@Result(property = "isRead", column = "IS_READ"),
|
||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
List<Task> queryTasks(TaskQueryImpl taskQuery);
|
||||
|
||||
@Select("<script>SELECT ID, TENANT_ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, CREATED, MODIFIED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "<where>"
|
||||
+ "<if test='tenantId != null'>TENANT_ID = #{tenantId}</if> "
|
||||
+ "<if test='parentClassificationId != null'>AND PARENT_CLASSIFICATION_ID IN(<foreach item='item' collection='parentClassificationId' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='category != null'>AND CATEGORY IN(<foreach item='item' collection='category' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='type != null'>AND TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='name != null'>AND NAME IN(<foreach item='item' collection='name' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='description != null'>AND DESCRIPTION like #{description}</if> "
|
||||
+ "<if test='priority != null'>AND PRIORITY IN(<foreach item='item' collection='.priority' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='serviceLevel != null'>AND SERVICE_LEVEL IN(<foreach item='item' collection='serviceLevel' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "</where>"
|
||||
+ "</script>")
|
||||
@Results({ @Result(property = "id", column = "ID"),
|
||||
@Result(property = "tenantId", column = "TENANT_ID"),
|
||||
@Result(property = "parentClassificationId", column = "PARENT_CLASSIFICATION_ID"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL") })
|
||||
List<Classification> queryClassification(ClassificationQueryImpl classificationQuery);
|
||||
|
||||
|
||||
@Select("<script>SELECT ID, TENANT_ID, COMPANY, SYSTEM, SYSTEM_INSTANCE, TYPE, VALUE "
|
||||
+ "FROM OBJECT_REFERENCE "
|
||||
+ "<where>"
|
||||
+ "<if test='tenantId != null'>TENANT_ID = #{tenantId}</if> "
|
||||
+ "<if test='company != null'>AND COMPANY IN(<foreach item='item' collection='company' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='system != null'>AND SYSTEM IN(<foreach item='item' collection='system' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='systemInstance != null'>AND SYSTEM_INSTANCE IN(<foreach item='item' collection='systemInstance' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='type != null'>AND TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='value != null'>AND VALUE IN(<foreach item='item' collection='value' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "</where>"
|
||||
+ "</script>")
|
||||
@Results({
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "tenantId", column = "TENANT_ID"),
|
||||
@Result(property = "company", column = "COMPANY"),
|
||||
@Result(property = "system", column = "SYSTEM"),
|
||||
@Result(property = "systemInstance", column = "SYSTEM_INSTANCE"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "value", column = "VALUE") })
|
||||
List<ObjectReference> queryObjectReference(ObjectReferenceQueryImpl objectReference);
|
||||
}
|
|
@ -66,153 +66,6 @@ public interface TaskMapper {
|
|||
})
|
||||
Task findById(@Param("id") String id);
|
||||
|
||||
@Select("SELECT ID, TENANT_ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_ID, WORKBASKETID, OWNER, PRIMARY_OBJ_REF_ID, IS_READ, IS_TRANSFERRED, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
|
||||
+ "FROM TASK "
|
||||
+ "WHERE WORKBASKETID = #{workbasketId} "
|
||||
+ "ORDER BY ID")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "tenantId", column = "TENANT_ID"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "claimed", column = "CLAIMED"),
|
||||
@Result(property = "completed", column = "COMPLETED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "planned", column = "PLANNED"),
|
||||
@Result(property = "due", column = "DUE"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "state", column = "STATE"),
|
||||
@Result(property = "classification", column = "CLASSIFICATION_ID", javaType = Classification.class, one = @One(select = CLASSIFICATION_FINDBYID)),
|
||||
@Result(property = "workbasketId", column = "WORKBASKETID"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "primaryObjRef", column = "PRIMARY_OBJ_REF_ID", javaType = ObjectReference.class, one = @One(select = OBJECTREFERENCEMAPPER_FINDBYID)),
|
||||
@Result(property = "isRead", column = "IS_READ"),
|
||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")
|
||||
})
|
||||
List<Task> findByWorkBasketId(@Param("workbasketId") String workbasketId);
|
||||
|
||||
@Select("<script>"
|
||||
+ "SELECT ID, TENANT_ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_ID, WORKBASKETID, OWNER, PRIMARY_OBJ_REF_ID, IS_READ, IS_TRANSFERRED, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
|
||||
+ "FROM TASK "
|
||||
+ "WHERE WORKBASKETID IN (<foreach item='item' collection='workbasketIds' separator=','>#{item}</foreach>) "
|
||||
+ "AND STATE IN (<foreach item='item' collection='states' separator=',' >#{item}</foreach>) "
|
||||
+ "ORDER BY ID"
|
||||
+ "</script>")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "tenantId", column = "TENANT_ID"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "claimed", column = "CLAIMED"),
|
||||
@Result(property = "completed", column = "COMPLETED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "planned", column = "PLANNED"),
|
||||
@Result(property = "due", column = "DUE"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "state", column = "STATE"),
|
||||
@Result(property = "classification", column = "CLASSIFICATION_ID", javaType = Classification.class, one = @One(select = CLASSIFICATION_FINDBYID)),
|
||||
@Result(property = "workbasketId", column = "WORKBASKETID"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "primaryObjRef", column = "PRIMARY_OBJ_REF_ID", javaType = ObjectReference.class, one = @One(select = OBJECTREFERENCEMAPPER_FINDBYID)),
|
||||
@Result(property = "isRead", column = "IS_READ"),
|
||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")
|
||||
})
|
||||
List<Task> findByWorkbasketIdsAndStates(@Param("workbasketIds") List<String> workbasketIds, @Param("states") List<TaskState> states);
|
||||
|
||||
@Select("<script>"
|
||||
+ "SELECT ID, TENANT_ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_ID, WORKBASKETID, OWNER, PRIMARY_OBJ_REF_ID, IS_READ, IS_TRANSFERRED, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
|
||||
+ "FROM TASK "
|
||||
+ "WHERE STATE IN (<foreach item='item' collection='states' separator=',' >#{item}</foreach>) "
|
||||
+ "ORDER BY ID"
|
||||
+ "</script>")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "tenantId", column = "TENANT_ID"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "claimed", column = "CLAIMED"),
|
||||
@Result(property = "completed", column = "COMPLETED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "planned", column = "PLANNED"),
|
||||
@Result(property = "due", column = "DUE"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "state", column = "STATE"),
|
||||
@Result(property = "classification", column = "CLASSIFICATION_ID", javaType = Classification.class, one = @One(select = CLASSIFICATION_FINDBYID)),
|
||||
@Result(property = "workbasketId", column = "WORKBASKETID"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "primaryObjRef", column = "PRIMARY_OBJ_REF_ID", javaType = ObjectReference.class, one = @One(select = OBJECTREFERENCEMAPPER_FINDBYID)),
|
||||
@Result(property = "isRead", column = "IS_READ"),
|
||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")
|
||||
})
|
||||
List<Task> findByStates(@Param("states") List<TaskState> states);
|
||||
|
||||
@Select("SELECT ID, TENANT_ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_ID, WORKBASKETID, OWNER, PRIMARY_OBJ_REF_ID, IS_READ, IS_TRANSFERRED, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
|
||||
+ "FROM TASK ")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "tenantId", column = "TENANT_ID"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "claimed", column = "CLAIMED"),
|
||||
@Result(property = "completed", column = "COMPLETED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "planned", column = "PLANNED"),
|
||||
@Result(property = "due", column = "DUE"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "state", column = "STATE"),
|
||||
@Result(property = "classification", column = "CLASSIFICATION_ID", javaType = Classification.class, one = @One(select = CLASSIFICATION_FINDBYID)),
|
||||
@Result(property = "workbasketId", column = "WORKBASKETID"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "primaryObjRef", column = "PRIMARY_OBJ_REF_ID", javaType = ObjectReference.class, one = @One(select = OBJECTREFERENCEMAPPER_FINDBYID)),
|
||||
@Result(property = "isRead", column = "IS_READ"),
|
||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")
|
||||
})
|
||||
List<Task> findAll();
|
||||
|
||||
@Select("<script>"
|
||||
+ "SELECT STATE, COUNT (STATE) as counter "
|
||||
+ "FROM TASK "
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package org.taskana.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Main query interface.
|
||||
* @author EH
|
||||
* @param <T>
|
||||
* specifies the return type of the follwing methods
|
||||
*/
|
||||
public interface BaseQuery<T> {
|
||||
|
||||
/**
|
||||
* This method will return a list of defined {@link T} objects.
|
||||
* @return
|
||||
* @throws NotAuthorizedException
|
||||
*/
|
||||
List<T> list() throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* This method will return a list of defined {@link T} objects with specified
|
||||
* offset and an limit.
|
||||
* @param offset
|
||||
* @param limit
|
||||
* @return
|
||||
* @throws NotAuthorizedException
|
||||
*/
|
||||
List<T> list(int offset, int limit) throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* This method will return a single object of {@link T}.
|
||||
* @return
|
||||
* @throws NotAuthorizedException
|
||||
*/
|
||||
T single() throws NotAuthorizedException;
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package org.taskana.persistence;
|
||||
|
||||
import org.taskana.model.Classification;
|
||||
|
||||
/**
|
||||
* ClassificationQuery for generating dynamic sql.
|
||||
*/
|
||||
public interface ClassificationQuery extends BaseQuery<Classification> {
|
||||
/**
|
||||
* Add your tenant id to your query.
|
||||
* @param tenantId
|
||||
* the tenant id as String
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery tenantId(String tenantId);
|
||||
|
||||
/**
|
||||
* Add your parentClassification to your query.
|
||||
* @param parentClassificationId
|
||||
* as String
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery parentClassification(String... parentClassificationId);
|
||||
|
||||
/**
|
||||
* Add your category to your query.
|
||||
* @param category
|
||||
* as String
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery category(String... category);
|
||||
|
||||
/**
|
||||
* Add your type to your query.
|
||||
* @param type
|
||||
* as String
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery type(String... type);
|
||||
|
||||
/**
|
||||
* Add your name to your query.
|
||||
* @param name
|
||||
* as String
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery name(String... name);
|
||||
|
||||
/**
|
||||
* Add your description to your query. It will be compared in SQL with an LIKE.
|
||||
* If you use a wildcard like % tehn it will be transmitted to the database.
|
||||
* @param description
|
||||
* your description
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery descriptionLike(String description);
|
||||
|
||||
/**
|
||||
* Add your priority to your query.
|
||||
* @param priorities
|
||||
* as integers
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery priority(int... priorities);
|
||||
|
||||
/**
|
||||
* Add your serviceLevel to your query.
|
||||
* @param serviceLevel
|
||||
* as String
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery serviceLevel(String... serviceLevel);
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package org.taskana.persistence;
|
||||
|
||||
import org.taskana.model.ObjectReference;
|
||||
|
||||
/**
|
||||
* ObjectReferenceQuery for generating dynamic sql.
|
||||
*/
|
||||
public interface ObjectReferenceQuery extends BaseQuery<ObjectReference> {
|
||||
/**
|
||||
* Add your tenant id to your query.
|
||||
* @param tenantId
|
||||
* the tenant id as String
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery tenantId(String tenantId);
|
||||
|
||||
/**
|
||||
* Add your company to your query.
|
||||
* @param companies
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery company(String... companies);
|
||||
|
||||
/**
|
||||
* Add your system to your query.
|
||||
* @param systems
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery system(String... systems);
|
||||
|
||||
/**
|
||||
* Add your systemInstance to your query.
|
||||
* @param systemInstances
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery systemInstance(String... systemInstances);
|
||||
|
||||
/**
|
||||
* Add your type to your query.
|
||||
* @param types
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery type(String... types);
|
||||
|
||||
/**
|
||||
* Add your value to your query.
|
||||
* @param values
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery value(String... values);
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package org.taskana.persistence;
|
||||
|
||||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.model.Task;
|
||||
import org.taskana.model.TaskState;
|
||||
|
||||
/**
|
||||
* TaskQuery for generating dynamic sql.
|
||||
*/
|
||||
public interface TaskQuery extends BaseQuery<Task> {
|
||||
|
||||
/**
|
||||
* Add your tenant id to your query.
|
||||
* @param tenantId
|
||||
* the tenant id as String
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery tenantId(String tenantId);
|
||||
|
||||
/**
|
||||
* Add your names to your query.
|
||||
* @param name
|
||||
* the names as Strings
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery name(String... name);
|
||||
|
||||
/**
|
||||
* Add your description to your query. It will be compared in SQL with an LIKE.
|
||||
* If you use a wildcard like % tehn it will be transmitted to the database.
|
||||
* @param description
|
||||
* your description
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery descriptionLike(String description);
|
||||
|
||||
/**
|
||||
* Add your priorities to your query.
|
||||
* @param priorities
|
||||
* as a integer
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery priority(int... priorities);
|
||||
|
||||
/**
|
||||
* Add your state to your query.
|
||||
* @param states
|
||||
* the states as {@link TaskState}
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery state(TaskState... states);
|
||||
|
||||
/**
|
||||
* Add your classification to your query. The classification query can be
|
||||
* obtained from the ClassificationService
|
||||
* @param classificationQuery
|
||||
* the classification query
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery classification(ClassificationQuery classificationQuery);
|
||||
|
||||
/**
|
||||
* Add your workbasket id to the query.
|
||||
* @param workbasketIds
|
||||
* the workbasket ids as String
|
||||
* @return the query
|
||||
* @throws NotAuthorizedException
|
||||
* if the user have no rights
|
||||
*/
|
||||
TaskQuery workbasketId(String... workbasketIds) throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Add the owners to your query.
|
||||
* @param owners
|
||||
* the owners as String
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery owner(String... owners);
|
||||
|
||||
/**
|
||||
* Add your objectReference to your query. The objectReference query can be
|
||||
* obtained from the TaskService
|
||||
* @param objectReferenceQuery
|
||||
* the objectReference query
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery objectReference(ObjectReferenceQuery objectReferenceQuery);
|
||||
|
||||
/**
|
||||
* Add the isRead flag to the query.
|
||||
* @param isRead
|
||||
* as Boolean. If null, it won't be integrated into the statement.
|
||||
* You have to set false.
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery read(Boolean isRead);
|
||||
|
||||
/**
|
||||
* Add the isTransferred flag to the query.
|
||||
* @param isTransferred
|
||||
* as Boolean. If null, it won't be integrated into the statement.
|
||||
* You have to set false.
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery transferred(Boolean isTransferred);
|
||||
|
||||
/**
|
||||
* Filter the custom fields with this query. The scan will be run over all 10
|
||||
* fields.
|
||||
* @param customFields
|
||||
* the value in the fields
|
||||
* @return the query
|
||||
*/
|
||||
TaskQuery customFields(String... customFields);
|
||||
|
||||
/**
|
||||
* This method provides a query builder for quering the database.
|
||||
* @return a {@link ObjectReferenceQuery}
|
||||
*/
|
||||
ObjectReferenceQuery createObjectReferenceQuery();
|
||||
|
||||
}
|
|
@ -4,8 +4,6 @@ import static org.mockito.ArgumentMatchers.any;
|
|||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -33,7 +31,6 @@ import org.taskana.model.mappings.TaskMapper;
|
|||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TaskServiceImplTest {
|
||||
|
||||
private static final int LIST_SIZE = 3;
|
||||
private static final int SLEEP_TIME = 100;
|
||||
@InjectMocks
|
||||
TaskServiceImpl taskServiceImpl;
|
||||
|
@ -101,19 +98,6 @@ public class TaskServiceImplTest {
|
|||
taskServiceImpl.complete("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTasksForWorkbasket() throws NotAuthorizedException {
|
||||
registerBasicMocks(false);
|
||||
ArrayList<Task> tasks = new ArrayList<Task>();
|
||||
tasks.add(createUnitTestTask("1", "Unit Test Task 1", "1"));
|
||||
tasks.add(createUnitTestTask("2", "Unit Test Task 2", "1"));
|
||||
tasks.add(createUnitTestTask("3", "Unit Test Task 3", "1"));
|
||||
Mockito.when(taskMapper.findByWorkBasketId("1")).thenReturn(tasks);
|
||||
|
||||
List<Task> list = taskServiceImpl.getTasksForWorkbasket("1");
|
||||
Assert.assertEquals(LIST_SIZE, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferTaskZuDestinationWorkbasket()
|
||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.taskana.impl.integration;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.h2.jdbcx.JdbcDataSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -9,10 +13,12 @@ import org.taskana.exceptions.NotAuthorizedException;
|
|||
import org.taskana.exceptions.TaskNotFoundException;
|
||||
import org.taskana.impl.TaskServiceImpl;
|
||||
import org.taskana.impl.TaskanaEngineImpl;
|
||||
import org.taskana.impl.persistence.ClassificationQueryImpl;
|
||||
import org.taskana.impl.persistence.ObjectReferenceQueryImpl;
|
||||
import org.taskana.model.Task;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.SQLException;
|
||||
import org.taskana.model.TaskState;
|
||||
import org.taskana.persistence.ClassificationQuery;
|
||||
import org.taskana.persistence.ObjectReferenceQuery;
|
||||
|
||||
/**
|
||||
* Integration Test for TaskServiceImpl transactions.
|
||||
|
@ -83,4 +89,38 @@ public class TaskServiceImplTransactionTest {
|
|||
Assert.assertNotNull(task);
|
||||
Assert.assertNotNull(task.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException {
|
||||
JdbcDataSource ds = new JdbcDataSource();
|
||||
ds.setURL("jdbc:h2:~/data/test-db-taskservice-int2");
|
||||
ds.setPassword("sa");
|
||||
ds.setUser("sa");
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(ds, true, false);
|
||||
|
||||
TaskanaEngineImpl te = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskServiceImpl.create(task);
|
||||
|
||||
ClassificationQuery classificationQuery = new ClassificationQueryImpl(te).tenantId("asdasdasd")
|
||||
.parentClassification("pId1", "pId2").category("cat1", "cat2").type("oneType").name("1Name", "name2")
|
||||
.descriptionLike("my desc").priority(1, 2, 1).serviceLevel("me", "and", "you");
|
||||
|
||||
ObjectReferenceQuery objectReferenceQuery = new ObjectReferenceQueryImpl(te).tenantId("tenant1")
|
||||
.company("first comp", "sonstwo gmbh").system("sys").type("type1", "type2")
|
||||
.systemInstance("sysInst1", "sysInst2").value("val1", "val2", "val3");
|
||||
|
||||
List<Task> results = taskServiceImpl.createTaskQuery().tenantId("1").name("bla", "test").descriptionLike("test")
|
||||
.priority(1, 2, 2).state(TaskState.CLAIMED).workbasketId("asd", "asdasdasd")
|
||||
.owner("test", "test2", "bla").customFields("test").classification(classificationQuery)
|
||||
.objectReference(objectReferenceQuery).list();
|
||||
|
||||
Assert.assertEquals(0, results.size());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package org.taskana.impl.persistence;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.impl.TaskanaEngineImpl;
|
||||
import org.taskana.model.Classification;
|
||||
|
||||
/**
|
||||
* Test for ClassificationQueryImpl.
|
||||
* @author EH
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ClassificationQueryImplTest {
|
||||
|
||||
ClassificationQueryImpl classificationQueryImpl;
|
||||
|
||||
@Mock
|
||||
TaskanaEngineImpl taskanaEngine;
|
||||
|
||||
@Mock
|
||||
SqlSession sqlSession;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
classificationQueryImpl = new ClassificationQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<Classification> result = classificationQueryImpl.name("test", "asd", "blubber").type("cool", "bla").priority(1, 2)
|
||||
.parentClassification("superId").list();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnListWithOffset_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<Classification> result = classificationQueryImpl.name("test", "asd", "blubber").type("cool", "bla").priority(1, 2)
|
||||
.parentClassification("superId").list(1, 1);
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectOne(any(), any())).thenReturn(new Classification());
|
||||
|
||||
Classification result = classificationQueryImpl.name("test", "asd", "blubber").type("cool", "bla").priority(1, 2)
|
||||
.parentClassification("superId").single();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package org.taskana.impl.persistence;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.impl.TaskanaEngineImpl;
|
||||
import org.taskana.model.ObjectReference;
|
||||
|
||||
/**
|
||||
* Test for ObjectReferenceQueryImpl.
|
||||
* @author EH
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ObjectReferenceQueryImplTest {
|
||||
|
||||
ObjectReferenceQueryImpl objectReferenceQueryImpl;
|
||||
|
||||
@Mock
|
||||
TaskanaEngineImpl taskanaEngine;
|
||||
|
||||
@Mock
|
||||
SqlSession sqlSession;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
objectReferenceQueryImpl = new ObjectReferenceQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<ObjectReference> result = objectReferenceQueryImpl.value("test", "asd", "blubber").type("cool", "bla")
|
||||
.systemInstance("1", "2").system("superId").list();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnListWithOffset_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<ObjectReference> result = objectReferenceQueryImpl.value("test", "asd", "blubber").type("cool", "bla")
|
||||
.systemInstance("1", "2").system("superId").list(1, 1);
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectOne(any(), any())).thenReturn(new ObjectReference());
|
||||
|
||||
ObjectReference result = objectReferenceQueryImpl.value("test", "asd", "blubber").type("cool", "bla")
|
||||
.systemInstance("1", "2").system("superId").single();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package org.taskana.impl.persistence;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.impl.TaskanaEngineImpl;
|
||||
import org.taskana.model.Task;
|
||||
import org.taskana.model.TaskState;
|
||||
|
||||
/**
|
||||
* Test for TaskQueryImpl.
|
||||
* @author EH
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TaskQueryImplTest {
|
||||
|
||||
TaskQueryImpl taskQueryImpl;
|
||||
|
||||
@Mock
|
||||
TaskanaEngineImpl taskanaEngine;
|
||||
|
||||
@Mock
|
||||
SqlSession sqlSession;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
taskQueryImpl = new TaskQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<Task> result = taskQueryImpl.name("test", "asd", "blubber").customFields("cool", "bla").priority(1, 2)
|
||||
.state(TaskState.CLAIMED, TaskState.COMPLETED).list();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnListWithOffset_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<Task> result = taskQueryImpl.name("test", "asd", "blubber").customFields("cool", "bla").priority(1, 2)
|
||||
.state(TaskState.CLAIMED, TaskState.COMPLETED).list(1, 1);
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectOne(any(), any())).thenReturn(new Task());
|
||||
|
||||
Task result = taskQueryImpl.name("test", "asd", "blubber").customFields("cool", "bla").priority(1, 2)
|
||||
.state(TaskState.CLAIMED, TaskState.COMPLETED).single();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package org.taskana.rest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
@ -23,113 +21,87 @@ import org.taskana.TaskService;
|
|||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.exceptions.TaskNotFoundException;
|
||||
import org.taskana.model.Task;
|
||||
import org.taskana.model.TaskState;
|
||||
import org.taskana.rest.query.TaskFilter;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(path = "/v1/tasks", produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||
public class TaskController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TaskController.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(TaskController.class);
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private TaskFilter taskLogic;
|
||||
|
||||
@RequestMapping
|
||||
public ResponseEntity<List<Task>> getTasks(@RequestParam MultiValueMap<String, String> params)
|
||||
throws LoginException {
|
||||
try {
|
||||
if (params.keySet().size() == 0) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(taskService.getTasks());
|
||||
}
|
||||
if (params.containsKey("workbasketid") && params.containsKey("states")) {
|
||||
List<TaskState> states = extractStates(params);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(taskService.getTasksForWorkbasket(params.get("workbasketid"), states));
|
||||
}
|
||||
if (params.containsKey("states")) {
|
||||
List<TaskState> states = extractStates(params);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(taskService.findTasks(states));
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(taskService.getTasksForWorkbasket(params.getFirst("workbasketid")));
|
||||
} catch (NotAuthorizedException e) {
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
||||
}
|
||||
}
|
||||
@RequestMapping
|
||||
public ResponseEntity<List<Task>> getTasks(@RequestParam MultiValueMap<String, String> params)
|
||||
throws LoginException {
|
||||
try {
|
||||
if (params.keySet().size() == 0) {
|
||||
// get all
|
||||
return ResponseEntity.status(HttpStatus.OK).body(taskLogic.getAll());
|
||||
}
|
||||
|
||||
private List<TaskState> extractStates(MultiValueMap<String, String> params) {
|
||||
List<TaskState> states = new ArrayList<>();
|
||||
params.get("states").stream().forEach(item -> {
|
||||
for (String state : Arrays.asList(item.split(","))) {
|
||||
switch (state) {
|
||||
case "READY":
|
||||
states.add(TaskState.READY);
|
||||
break;
|
||||
case "COMPLETED":
|
||||
states.add(TaskState.COMPLETED);
|
||||
break;
|
||||
case "CLAIMED":
|
||||
states.add(TaskState.CLAIMED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return states;
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(taskLogic.inspectPrams(params));
|
||||
} catch (NotAuthorizedException e) {
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{taskId}")
|
||||
public ResponseEntity<Task> getTask(@PathVariable(value = "taskId") String taskId) {
|
||||
try {
|
||||
Task task = taskService.getTaskById(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(task);
|
||||
} catch (TaskNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
@RequestMapping(value = "/{taskId}")
|
||||
public ResponseEntity<Task> getTask(@PathVariable(value = "taskId") String taskId) {
|
||||
try {
|
||||
Task task = taskService.getTaskById(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(task);
|
||||
} catch (TaskNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/claim")
|
||||
public ResponseEntity<Task> claimTask(@PathVariable String taskId, @RequestBody String userName) {
|
||||
// TODO verify user
|
||||
try {
|
||||
taskService.claim(taskId, userName);
|
||||
Task updatedTask = taskService.getTaskById(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(updatedTask);
|
||||
} catch (TaskNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/claim")
|
||||
public ResponseEntity<Task> claimTask(@PathVariable String taskId, @RequestBody String userName) {
|
||||
// TODO verify user
|
||||
try {
|
||||
taskService.claim(taskId, userName);
|
||||
Task updatedTask = taskService.getTaskById(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(updatedTask);
|
||||
} catch (TaskNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/complete")
|
||||
public ResponseEntity<Task> completeTask(@PathVariable String taskId) {
|
||||
try {
|
||||
taskService.complete(taskId);
|
||||
Task updatedTask = taskService.getTaskById(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(updatedTask);
|
||||
} catch (TaskNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/complete")
|
||||
public ResponseEntity<Task> completeTask(@PathVariable String taskId) {
|
||||
try {
|
||||
taskService.complete(taskId);
|
||||
Task updatedTask = taskService.getTaskById(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(updatedTask);
|
||||
} catch (TaskNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public ResponseEntity<Task> createTask(@RequestBody Task task) {
|
||||
try {
|
||||
Task createdTask = taskService.create(task);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdTask);
|
||||
} catch (Exception e) {
|
||||
logger.error("Something went wrong: ", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public ResponseEntity<Task> createTask(@RequestBody Task task) {
|
||||
try {
|
||||
Task createdTask = taskService.create(task);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdTask);
|
||||
} catch (Exception e) {
|
||||
logger.error("Something went wrong: ", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/transfer/{workbasketId}")
|
||||
public ResponseEntity<Task> transferTask(@PathVariable String taskId, @PathVariable String workbasketId) {
|
||||
try {
|
||||
Task updatedTask = taskService.transfer(taskId, workbasketId);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(updatedTask);
|
||||
} catch (Exception e) {
|
||||
logger.error("Something went wrong: ", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/transfer/{workbasketId}")
|
||||
public ResponseEntity<Task> transferTask(@PathVariable String taskId, @PathVariable String workbasketId) {
|
||||
try {
|
||||
Task updatedTask = taskService.transfer(taskId, workbasketId);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(updatedTask);
|
||||
} catch (Exception e) {
|
||||
logger.error("Something went wrong: ", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
package org.taskana.rest.query;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.taskana.ClassificationService;
|
||||
import org.taskana.TaskService;
|
||||
import org.taskana.exceptions.NotAuthorizedException;
|
||||
import org.taskana.model.Task;
|
||||
import org.taskana.model.TaskState;
|
||||
import org.taskana.persistence.ClassificationQuery;
|
||||
import org.taskana.persistence.ObjectReferenceQuery;
|
||||
import org.taskana.persistence.TaskQuery;
|
||||
|
||||
@Component
|
||||
public class TaskFilter {
|
||||
|
||||
private static final String CLASSIFICATION = "classification";
|
||||
private static final String POR = "por";
|
||||
private static final String DOT = ".";
|
||||
|
||||
private static final String STATE = "state";
|
||||
private static final String PRIORITY = "priority";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String TENANT_ID = "tenantId";
|
||||
private static final String NAME = "name";
|
||||
private static final String OWNER = "owner";
|
||||
private static final String WORKBASKET_ID = "workbasketId";
|
||||
private static final String CUSTOM = "custom";
|
||||
private static final String IS_TRANSFERRED = "isTransferred";
|
||||
private static final String IS_READ = "isRead";
|
||||
|
||||
private static final String CLASSIFICATION_TENANT_ID = CLASSIFICATION + DOT + "tenantId";
|
||||
private static final String CLASSIFICATION_SERVICE_LEVEL = CLASSIFICATION + DOT + "serviceLevel";
|
||||
private static final String CLASSIFICATION_PRIORITY = CLASSIFICATION + DOT + "priority";
|
||||
private static final String CLASSIFICATION_DESCRIPTION = CLASSIFICATION + DOT + "description";
|
||||
private static final String CLASSIFICATION_NAME = CLASSIFICATION + DOT + "name";
|
||||
private static final String CLASSIFICATION_TYPE = CLASSIFICATION + DOT + "type";
|
||||
private static final String CLASSIFICATION_CATEGORY = CLASSIFICATION + DOT + "category";
|
||||
private static final String CLASSIFICATION_PARENT_ID = CLASSIFICATION + DOT + "parentClassificationId";
|
||||
|
||||
private static final String POR_VALUE = POR + DOT + "value";
|
||||
private static final String POR_TYPE = POR + DOT + "type";
|
||||
private static final String POR_SYSTEM_INSTANCE = POR + DOT + "systemInstance";
|
||||
private static final String POR_SYSTEM = POR + DOT + "system";
|
||||
private static final String POR_COMPANY = POR + DOT + "company";
|
||||
private static final String POR_TENANT_ID = POR + DOT + "tenantId";
|
||||
|
||||
private static final String CLAIMED = "CLAIMED";
|
||||
private static final String COMPLETED = "COMPLETED";
|
||||
private static final String READY = "READY";
|
||||
private static final String COMMA = ",";
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Autowired
|
||||
private ClassificationService classificationService;
|
||||
|
||||
public List<Task> getAll() throws NotAuthorizedException {
|
||||
return taskService.createTaskQuery().list();
|
||||
}
|
||||
|
||||
public List<Task> inspectPrams(MultiValueMap<String, String> params) throws NotAuthorizedException {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
|
||||
// apply filters
|
||||
if (params.containsKey(TENANT_ID)) {
|
||||
taskQuery.workbasketId(params.get(TENANT_ID).toArray(new String[0]));
|
||||
}
|
||||
if (params.containsKey(NAME)) {
|
||||
String[] names = extractCommaSeperatedFields(params.get(NAME));
|
||||
taskQuery.name(names);
|
||||
}
|
||||
if (params.containsKey(DESCRIPTION)) {
|
||||
taskQuery.descriptionLike(params.get(DESCRIPTION).get(0));
|
||||
}
|
||||
if (params.containsKey(PRIORITY)) {
|
||||
String[] prioritesInString = extractCommaSeperatedFields(params.get(PRIORITY));
|
||||
int[] priorites = extractPriorities(prioritesInString);
|
||||
taskQuery.priority(priorites);
|
||||
}
|
||||
if (params.containsKey(STATE)) {
|
||||
TaskState[] states = extractStates(params);
|
||||
taskQuery.state(states);
|
||||
}
|
||||
// classification
|
||||
if (params.keySet().stream().filter(s -> s.startsWith(CLASSIFICATION)).toArray().length > 0) {
|
||||
ClassificationQuery classificationQuery = classificationService.createClassificationQuery();
|
||||
if (params.containsKey(CLASSIFICATION_TENANT_ID)) {
|
||||
classificationQuery.tenantId(params.get(CLASSIFICATION_TENANT_ID).get(0));
|
||||
}
|
||||
if (params.containsKey(CLASSIFICATION_PARENT_ID)) {
|
||||
String[] parentClassifications = extractCommaSeperatedFields(params.get(CLASSIFICATION_PARENT_ID));
|
||||
classificationQuery.parentClassification(parentClassifications);
|
||||
}
|
||||
if (params.containsKey(CLASSIFICATION_CATEGORY)) {
|
||||
String[] categories = extractCommaSeperatedFields(params.get(CLASSIFICATION_CATEGORY));
|
||||
classificationQuery.category(categories);
|
||||
}
|
||||
if (params.containsKey(CLASSIFICATION_TYPE)) {
|
||||
String[] types = extractCommaSeperatedFields(params.get(CLASSIFICATION_TYPE));
|
||||
classificationQuery.type(types);
|
||||
}
|
||||
if (params.containsKey(CLASSIFICATION_NAME)) {
|
||||
String[] names = extractCommaSeperatedFields(params.get(CLASSIFICATION_NAME));
|
||||
classificationQuery.name(names);
|
||||
}
|
||||
if (params.containsKey(CLASSIFICATION_DESCRIPTION)) {
|
||||
classificationQuery.descriptionLike(params.get(CLASSIFICATION_DESCRIPTION).get(0));
|
||||
}
|
||||
if (params.containsKey(CLASSIFICATION_PRIORITY)) {
|
||||
String[] prioritesInString = extractCommaSeperatedFields(params.get(CLASSIFICATION_PRIORITY));
|
||||
int[] priorites = extractPriorities(prioritesInString);
|
||||
classificationQuery.priority(priorites);
|
||||
}
|
||||
if (params.containsKey(CLASSIFICATION_SERVICE_LEVEL)) {
|
||||
String[] serviceLevels = extractCommaSeperatedFields(params.get(CLASSIFICATION_SERVICE_LEVEL));
|
||||
classificationQuery.serviceLevel(serviceLevels);
|
||||
}
|
||||
taskQuery.classification(classificationQuery);
|
||||
}
|
||||
if (params.containsKey(WORKBASKET_ID)) {
|
||||
String[] workbaskets = extractCommaSeperatedFields(params.get(WORKBASKET_ID));
|
||||
taskQuery.workbasketId(workbaskets);
|
||||
}
|
||||
if (params.containsKey(OWNER)) {
|
||||
String[] owners = extractCommaSeperatedFields(params.get(OWNER));
|
||||
taskQuery.owner(owners);
|
||||
}
|
||||
// objectReference
|
||||
if (params.keySet().stream().filter(s -> s.startsWith(POR)).toArray().length > 0) {
|
||||
ObjectReferenceQuery objectReferenceQuery = taskQuery.createObjectReferenceQuery();
|
||||
if (params.containsKey(POR_TENANT_ID)) {
|
||||
objectReferenceQuery.tenantId(params.get(POR_TENANT_ID).get(0));
|
||||
}
|
||||
if (params.containsKey(POR_COMPANY)) {
|
||||
String[] companies = extractCommaSeperatedFields(params.get(POR_COMPANY));
|
||||
objectReferenceQuery.company(companies);
|
||||
}
|
||||
if (params.containsKey(POR_SYSTEM)) {
|
||||
String[] systems = extractCommaSeperatedFields(params.get(POR_SYSTEM));
|
||||
objectReferenceQuery.system(systems);
|
||||
}
|
||||
if (params.containsKey(POR_SYSTEM_INSTANCE)) {
|
||||
String[] systemInstances = extractCommaSeperatedFields(params.get(POR_SYSTEM_INSTANCE));
|
||||
objectReferenceQuery.systemInstance(systemInstances);
|
||||
}
|
||||
if (params.containsKey(POR_TYPE)) {
|
||||
String[] types = extractCommaSeperatedFields(params.get(POR_TYPE));
|
||||
objectReferenceQuery.type(types);
|
||||
}
|
||||
if (params.containsKey(POR_VALUE)) {
|
||||
String[] values = extractCommaSeperatedFields(params.get(POR_VALUE));
|
||||
objectReferenceQuery.value(values);
|
||||
}
|
||||
|
||||
taskQuery.objectReference(objectReferenceQuery);
|
||||
}
|
||||
if (params.containsKey(IS_READ)) {
|
||||
taskQuery.read(Boolean.getBoolean(params.get(IS_READ).get(0)));
|
||||
}
|
||||
if (params.containsKey(IS_TRANSFERRED)) {
|
||||
taskQuery.transferred(Boolean.getBoolean(params.get(IS_TRANSFERRED).get(0)));
|
||||
}
|
||||
if (params.containsKey(CUSTOM)) {
|
||||
String[] custom = extractCommaSeperatedFields(params.get(CUSTOM));
|
||||
taskQuery.customFields(custom);
|
||||
}
|
||||
return taskQuery.list();
|
||||
}
|
||||
|
||||
private int[] extractPriorities(String[] prioritesInString) {
|
||||
int[] priorites = new int[prioritesInString.length];
|
||||
for (int i = 0; i < prioritesInString.length; i++) {
|
||||
priorites[i] = Integer.getInteger(prioritesInString[i]);
|
||||
}
|
||||
return priorites;
|
||||
}
|
||||
|
||||
private String[] extractCommaSeperatedFields(List<String> list) {
|
||||
List<String> values = new ArrayList<>();
|
||||
list.stream().forEach(item -> {
|
||||
Arrays.asList(item.split(COMMA)).stream().forEach(subItem -> {
|
||||
values.add(subItem);
|
||||
});
|
||||
});
|
||||
return values.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private TaskState[] extractStates(MultiValueMap<String, String> params) {
|
||||
List<TaskState> states = new ArrayList<>();
|
||||
params.get(STATE).stream().forEach(item -> {
|
||||
Arrays.asList(item.split(COMMA)).stream().forEach(state -> {
|
||||
switch (state) {
|
||||
case READY:
|
||||
states.add(TaskState.READY);
|
||||
break;
|
||||
case COMPLETED:
|
||||
states.add(TaskState.COMPLETED);
|
||||
break;
|
||||
case CLAIMED:
|
||||
states.add(TaskState.CLAIMED);
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
return states.toArray(new TaskState[0]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue