diff --git a/lib/taskana-cdi/src/test/java/pro/taskana/TaskanaRestTest.java b/lib/taskana-cdi/src/test/java/pro/taskana/TaskanaRestTest.java index 89bc72a72..699446d53 100644 --- a/lib/taskana-cdi/src/test/java/pro/taskana/TaskanaRestTest.java +++ b/lib/taskana-cdi/src/test/java/pro/taskana/TaskanaRestTest.java @@ -40,9 +40,8 @@ public class TaskanaRestTest { public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, InvalidWorkbasketException, TaskAlreadyExistException, InvalidArgumentException { - Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key"); + Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key", "cdiDomain"); workbasket.setName("wb"); - workbasket.setDomain("cdiDomain"); workbasket.setType(WorkbasketType.PERSONAL); taskanaEjb.getWorkbasketService().createWorkbasket(workbasket); Classification classification = classificationService.newClassification("cdiDomain", "TEST", "t1"); diff --git a/lib/taskana-core/src/main/java/pro/taskana/KeyDomain.java b/lib/taskana-core/src/main/java/pro/taskana/KeyDomain.java new file mode 100644 index 000000000..8e8714f75 --- /dev/null +++ b/lib/taskana-core/src/main/java/pro/taskana/KeyDomain.java @@ -0,0 +1,45 @@ +package pro.taskana; + +/** + * This class encapsulates key - domain pairs for identification of workbaskets. + * + * @author bbr + */ +public class KeyDomain { + + private String key; + private String domain; + + public KeyDomain(String key, String domain) { + this.key = key; + this.domain = domain; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("KeyDomain [key="); + builder.append(key); + builder.append(", domain="); + builder.append(domain); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java b/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java index 075dae483..5a23d94d2 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java +++ b/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java @@ -110,42 +110,20 @@ public interface TaskQuery extends BaseQuery { /** * Add your workbasket key to the query. * - * @param workbasketKeys - * the workbasket keys as String + * @param workbasketIdentifiers + * the key - domain combinations that identify workbaskets * @return the query */ - TaskQuery workbasketKeyIn(String... workbasketKeys); + TaskQuery workbasketKeyDomainIn(KeyDomain... workbasketIdentifiers); /** - * Add your workbasketKey for pattern matching to your query. It will be compared in SQL with the LIKE operator. You - * may use a wildcard like % to specify the pattern. If you specify multiple arguments they are combined with the OR - * keyword. + * Add your workbasket key to the query. * - * @param workbasketKeys - * the workbasket keys + * @param workbasketIds + * the ids of workbaskets * @return the query */ - TaskQuery workbasketKeyLike(String... workbasketKeys); - - /** - * Add your domain to the query. - * - * @param domains - * the domain as String - * @return the query - */ - TaskQuery domainIn(String... domains); - - /** - * Add your domains for pattern matching to your query. It will be compared in SQL with the LIKE operator. You may - * use a wildcard like % to specify the pattern. If you specify multiple arguments they are combined with the OR - * keyword. - * - * @param domains - * the domains of the searched-for workbaskets - * @return the query - */ - TaskQuery domainLike(String... domains); + TaskQuery workbasketIdIn(String... workbasketIds); /** * Add the owners to your query. diff --git a/lib/taskana-core/src/main/java/pro/taskana/TaskService.java b/lib/taskana-core/src/main/java/pro/taskana/TaskService.java index fce77bfd9..70411ab9a 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/TaskService.java +++ b/lib/taskana-core/src/main/java/pro/taskana/TaskService.java @@ -163,8 +163,8 @@ public interface TaskService { * * @param taskId * The id of the {@link Task} to be transferred - * @param workbasketKey - * The key of the target work basket + * @param workbasketId + * The Id of the target work basket * @return the transferred task * @throws TaskNotFoundException * Thrown if the {@link Task} with taskId was not found. @@ -175,7 +175,29 @@ public interface TaskService { * @throws InvalidWorkbasketException * Thrown if either the source or the target workbasket has a missing required property */ - Task transfer(String taskId, String workbasketKey) + Task transfer(String taskId, String workbasketId) + throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException; + + /** + * Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag. + * + * @param taskId + * The id of the {@link Task} to be transferred + * @param workbasketKey + * The key of the target work basket + * @param domain + * The domain of the target work basket + * @return the transferred task + * @throws TaskNotFoundException + * Thrown if the {@link Task} with taskId was not found. + * @throws WorkbasketNotFoundException + * Thrown if the target work basket was not found. + * @throws NotAuthorizedException + * Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket + * @throws InvalidWorkbasketException + * Thrown if either the source or the target workbasket has a missing required property + */ + Task transfer(String taskId, String workbasketKey, String domain) throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException; /** @@ -201,11 +223,22 @@ public interface TaskService { /** * Returns a not persisted instance of {@link Task}. * - * @param workbasketKey - * the key of the workbasket to which the task belongs + * @param workbasketId + * the id of the workbasket to which the task belongs * @return an empty new Task */ - Task newTask(String workbasketKey); + Task newTask(String workbasketId); + + /** + * Returns a not persisted instance of {@link Task}. + * + * @param workbasketKey + * the key of the workbasket to which the task belongs + * @param domain + * the domain of the workbasket to which the task belongs + * @return an empty new Task + */ + Task newTask(String workbasketKey, String domain); /** * Returns a not persisted instance of {@link Attachment}. @@ -245,8 +278,8 @@ public interface TaskService { * Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on * the target or it doesn´t exist. Other Exceptions will be stored and returned in the end. * - * @param destinationWorkbasketKey - * target workbasket key + * @param destinationWorkbasketId + * target workbasket id * @param taskIds * source task which will be moved * @return Bulkresult with ID and Error in it for failed transactions. @@ -257,7 +290,29 @@ public interface TaskService { * @throws WorkbasketNotFoundException * if the target WB can´t be found. */ - BulkOperationResults transferTasks(String destinationWorkbasketKey, List taskIds) + BulkOperationResults transferTasks(String destinationWorkbasketId, List taskIds) + throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException; + + /** + * Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on + * the target or it doesn´t exist. Other Exceptions will be stored and returned in the end. + * + * @param destinationWorkbasketKey + * target workbasket key + * @param destinationWorkbasketDomain + * target workbasket domain + * @param taskIds + * source task which will be moved + * @return Bulkresult with ID and Error in it for failed transactions. + * @throws NotAuthorizedException + * if the caller hasn´t permissions on tarket WB. + * @throws InvalidArgumentException + * if the method paramesters are EMPTY or NULL. + * @throws WorkbasketNotFoundException + * if the target WB can´t be found. + */ + BulkOperationResults transferTasks(String destinationWorkbasketKey, + String destinationWorkbasketDomain, List taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException; /** diff --git a/lib/taskana-core/src/main/java/pro/taskana/Workbasket.java b/lib/taskana-core/src/main/java/pro/taskana/Workbasket.java index c647b6b9a..52b96930f 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/Workbasket.java +++ b/lib/taskana-core/src/main/java/pro/taskana/Workbasket.java @@ -37,14 +37,6 @@ public interface Workbasket { */ String getDomain(); - /** - * Set the domain of the workbasket. - * - * @param domain - * the domain of the workbasket - */ - void setDomain(String domain); - /** * Returns the type of the workbasket. * diff --git a/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItem.java b/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItem.java index ff92598aa..7812dc516 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItem.java +++ b/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItem.java @@ -15,11 +15,11 @@ public interface WorkbasketAccessItem { String getId(); /** - * Returns the key of the referenced workbasket. + * Returns the Id of the referenced workbasket. * - * @return the workbasket key + * @return the workbasket Id */ - String getWorkbasketKey(); + String getWorkbasketId(); /** * Returns the group id or user id for which this WorkbasketAccessItem controls access permissions. diff --git a/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItemQuery.java b/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItemQuery.java index b6ede1ab6..a9df9fc89 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItemQuery.java +++ b/lib/taskana-core/src/main/java/pro/taskana/WorkbasketAccessItemQuery.java @@ -6,13 +6,13 @@ package pro.taskana; public interface WorkbasketAccessItemQuery extends BaseQuery { /** - * Add your workbasket key to your query. + * Add your workbasket id to your query. * - * @param workbasketKey - * the workbasket key + * @param workbasketId + * the workbasket Id * @return the query */ - WorkbasketAccessItemQuery workbasketKeyIn(String... workbasketKey); + WorkbasketAccessItemQuery workbasketIdIn(String... workbasketId); /** * Add your accessIds to your query. @@ -24,14 +24,14 @@ public interface WorkbasketAccessItemQuery extends BaseQuery getWorkbasketAuthorizations(String workbasketKey); + List getWorkbasketAuthorizations(String workbasketId); /** * This method returns the workbaskets for which the current user has all permissions specified in the permissions @@ -167,18 +185,20 @@ public interface WorkbasketService { * * @param key * the workbasket key used to identify the workbasket + * @param domain + * the domain of the new workbasket * @return new Workbasket */ - Workbasket newWorkbasket(String key); + Workbasket newWorkbasket(String key, String domain); /** * Returns a set with all permissions of the current user at this workbasket. * - * @param workbasketKey - * the key of the referenced workbasket + * @param workbasketId + * the id of the referenced workbasket * @return a Set with all permissions */ - List getPermissionsForWorkbasket(String workbasketKey); + List getPermissionsForWorkbasket(String workbasketId); /** * Returns the distribution targets for a given workbasket. @@ -194,6 +214,22 @@ public interface WorkbasketService { List getDistributionTargets(String workbasketId) throws NotAuthorizedException, WorkbasketNotFoundException; + /** + * Returns the distribution targets for a given workbasket. + * + * @param workbasketKey + * the key of the referenced workbasket + * @param domain + * the domain of the referenced workbasket + * @return the distribution targets of the specified workbasket + * @throws NotAuthorizedException + * if the current user has no read permission for the specified workbasket + * @throws WorkbasketNotFoundException + * if the workbasket doesn't exist + */ + List getDistributionTargets(String workbasketKey, String domain) + throws NotAuthorizedException, WorkbasketNotFoundException; + /** * Set the distribution targets for a workbasket. * @@ -270,4 +306,20 @@ public interface WorkbasketService { List getDistributionSources(String workbasketId) throws NotAuthorizedException, WorkbasketNotFoundException; + /** + * Returns the distribution sources for a given workbasket. + * + * @param workbasketKey + * the key of the referenced workbasket + * @param domain + * the domain of the referenced workbasket + * @return the workbaskets that are distribution sources of the specified workbasket. + * @throws NotAuthorizedException + * if the current user has no read permission for the specified workbasket + * @throws WorkbasketNotFoundException + * if the workbasket doesn't exist + */ + List getDistributionSources(String workbasketKey, String domain) + throws NotAuthorizedException, WorkbasketNotFoundException; + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java index faca5179a..84b3f54fe 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java @@ -270,11 +270,11 @@ public class ClassificationServiceImpl implements ClassificationService { try { List classificationTasks = taskService.createTaskQuery() .classificationKeyIn(classificationKey) - .domainIn(domain) .list(); - if (!classificationTasks.isEmpty()) { - throw new ClassificationInUseException("There are " + classificationTasks.size() - + " Tasks which belong to this classification or a child classification. Please complete them and try again."); + if (classificationTasks.stream() + .anyMatch(t -> domain.equals(t.getClassificationSummary().getDomain()))) { + throw new ClassificationInUseException( + "There are Tasks that belong to this classification or a child classification. Please complete them and try again."); } } catch (NotAuthorizedToQueryWorkbasketException e) { LOGGER.error( diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/MinimalTaskSummary.java b/lib/taskana-core/src/main/java/pro/taskana/impl/MinimalTaskSummary.java index 207be3f30..6dbc9733f 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/MinimalTaskSummary.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/MinimalTaskSummary.java @@ -37,4 +37,17 @@ public class MinimalTaskSummary { this.taskState = taskState; } + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("MinimalTaskSummary [taskId="); + builder.append(taskId); + builder.append(", workbasketKey="); + builder.append(workbasketKey); + builder.append(", taskState="); + builder.append(taskState); + builder.append("]"); + return builder.toString(); + } + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java index d8fed57b8..66e970e0a 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java @@ -31,12 +31,10 @@ public class TaskImpl implements Task { private String note; private int priority; private TaskState state; - private String classificationKey; - private String classificationCategory; + // private String classificationKey; + // private String classificationCategory; private ClassificationSummary classificationSummary; private WorkbasketSummary workbasketSummary; - private String workbasketKey; - private String domain; private String businessProcessId; private String parentBusinessProcessId; private String owner; @@ -179,25 +177,35 @@ public class TaskImpl implements Task { @Override public void setClassificationKey(String classificationKey) { - this.classificationKey = classificationKey; + if (this.classificationSummary == null) { + this.classificationSummary = new ClassificationSummaryImpl(); + } + + ((ClassificationSummaryImpl) this.classificationSummary).setKey(classificationKey); } public void setClassificationCategory(String classificationCategory) { - this.classificationCategory = classificationCategory; + if (this.classificationSummary == null) { + this.classificationSummary = new ClassificationSummaryImpl(); + } + ((ClassificationSummaryImpl) this.classificationSummary).setCategory(classificationCategory); } @Override public String getClassificationCategory() { - return this.classificationCategory; + return this.classificationSummary == null ? null : this.classificationSummary.getCategory(); } @Override public String getWorkbasketKey() { - return workbasketKey; + return workbasketSummary == null ? null : workbasketSummary.getKey(); } public void setWorkbasketKey(String workbasketKey) { - this.workbasketKey = workbasketKey; + if (workbasketSummary == null) { + workbasketSummary = new WorkbasketSummaryImpl(); + } + ((WorkbasketSummaryImpl) this.workbasketSummary).setKey(workbasketKey); } @Override @@ -211,11 +219,14 @@ public class TaskImpl implements Task { @Override public String getDomain() { - return domain; + return workbasketSummary == null ? null : workbasketSummary.getDomain(); } public void setDomain(String domain) { - this.domain = domain; + if (workbasketSummary == null) { + workbasketSummary = new WorkbasketSummaryImpl(); + } + ((WorkbasketSummaryImpl) this.workbasketSummary).setDomain(domain); } @Override @@ -419,10 +430,6 @@ public class TaskImpl implements Task { taskSummary.setClaimed(claimed); if (classificationSummary != null) { taskSummary.setClassificationSummary(classificationSummary); - } else { - ClassificationSummaryImpl aClassificationSummary = new ClassificationSummaryImpl(); - aClassificationSummary.setKey(classificationKey); - taskSummary.setClassificationSummary(aClassificationSummary); } taskSummary.setCompleted(completed); taskSummary.setCreated(created); @@ -436,7 +443,6 @@ public class TaskImpl implements Task { taskSummary.setCustom8(custom8); taskSummary.setCustom9(custom9); taskSummary.setCustom10(custom10); - taskSummary.setDomain(domain); taskSummary.setDue(due); taskSummary.setTaskId(id); taskSummary.setModified(modified); @@ -464,7 +470,7 @@ public class TaskImpl implements Task { } public String getClassificationKey() { - return classificationKey; + return classificationSummary == null ? null : classificationSummary.getKey(); } public void setClassificationSummary(ClassificationSummary classificationSummary) { @@ -475,6 +481,10 @@ public class TaskImpl implements Task { return (ClassificationSummaryImpl) classificationSummary; } + public WorkbasketSummaryImpl getWorkbasketSummaryImpl() { + return (WorkbasketSummaryImpl) workbasketSummary; + } + public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) { this.classificationSummary = classificationSummary; } @@ -522,16 +532,10 @@ public class TaskImpl implements Task { builder.append(priority); builder.append(", state="); builder.append(state); - builder.append(", classificationKey="); - builder.append(classificationKey); builder.append(", classificationSummary="); builder.append(classificationSummary); builder.append(", workbasketSummary="); builder.append(workbasketSummary); - builder.append(", workbasketKey="); - builder.append(workbasketKey); - builder.append(", domain="); - builder.append(domain); builder.append(", businessProcessId="); builder.append(businessProcessId); builder.append(", parentBusinessProcessId="); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskQueryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskQueryImpl.java index 9bed238ed..85a796fbc 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskQueryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskQueryImpl.java @@ -9,6 +9,7 @@ import org.apache.ibatis.session.RowBounds; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import pro.taskana.KeyDomain; import pro.taskana.ObjectReferenceQuery; import pro.taskana.TaskQuery; import pro.taskana.TaskSummary; @@ -35,15 +36,13 @@ public class TaskQueryImpl implements TaskQuery { private String[] description; private String[] note; private int[] priority; - private TaskState[] states; + private KeyDomain[] workbasketKeyDomainIn; + private String[] workbasketIdIn; + private TaskState[] stateIn; private String[] classificationKeyIn; private String[] classificationKeyLike; private String[] classificationCategoryIn; private String[] classificationCategoryLike; - private String[] workbasketKeyIn; - private String[] workbasketKeyLike; - private String[] domainIn; - private String[] domainLike; private String[] ownerIn; private String[] ownerLike; private Boolean isRead; @@ -200,8 +199,14 @@ public class TaskQueryImpl implements TaskQuery { } @Override - public TaskQuery stateIn(TaskState... states) { - this.states = states; + public TaskQuery workbasketKeyDomainIn(KeyDomain... workbasketIdentifiers) { + this.workbasketKeyDomainIn = workbasketIdentifiers; + return this; + } + + @Override + public TaskQuery workbasketIdIn(String... workbasketIds) { + this.workbasketIdIn = workbasketIds; return this; } @@ -229,30 +234,6 @@ public class TaskQueryImpl implements TaskQuery { return this; } - @Override - public TaskQuery workbasketKeyIn(String... workbasketKeys) { - this.workbasketKeyIn = workbasketKeys; - return this; - } - - @Override - public TaskQuery workbasketKeyLike(String... workbasketKeys) { - this.workbasketKeyLike = toUpperCopy(workbasketKeys); - return this; - } - - @Override - public TaskQuery domainIn(String... domain) { - this.domainIn = domain; - return this; - } - - @Override - public TaskQuery domainLike(String... domains) { - this.domainLike = toUpperCopy(domains); - return this; - } - @Override public TaskQuery ownerIn(String... owners) { this.ownerIn = owners; @@ -367,6 +348,12 @@ public class TaskQueryImpl implements TaskQuery { return this; } + @Override + public TaskQuery stateIn(TaskState... states) { + this.stateIn = states; + return this; + } + @Override public TaskQuery custom1In(String... strings) { this.custom1In = strings; @@ -653,7 +640,7 @@ public class TaskQueryImpl implements TaskQuery { try { LOGGER.debug("entry to list(), this = {}", this); taskanaEngineImpl.openConnection(); - checkOpenPermissionForWorkbasketKey(); + checkOpenPermissionForSpecifiedWorkbaskets(); List tasks = new ArrayList<>(); tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this); result = taskService.augmentTaskSummariesByContainedSummaries(tasks); @@ -676,7 +663,7 @@ public class TaskQueryImpl implements TaskQuery { List result = new ArrayList<>(); try { taskanaEngineImpl.openConnection(); - checkOpenPermissionForWorkbasketKey(); + checkOpenPermissionForSpecifiedWorkbaskets(); RowBounds rowBounds = new RowBounds(offset, limit); List tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds); result = taskService.augmentTaskSummariesByContainedSummaries(tasks); @@ -707,7 +694,7 @@ public class TaskQueryImpl implements TaskQuery { TaskSummary result = null; try { taskanaEngineImpl.openConnection(); - checkOpenPermissionForWorkbasketKey(); + checkOpenPermissionForSpecifiedWorkbaskets(); TaskSummaryImpl taskSummaryImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this); if (taskSummaryImpl == null) { return null; @@ -732,7 +719,7 @@ public class TaskQueryImpl implements TaskQuery { Long rowCount = null; try { taskanaEngineImpl.openConnection(); - checkOpenPermissionForWorkbasketKey(); + checkOpenPermissionForSpecifiedWorkbaskets(); rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this); return (rowCount == null) ? 0L : rowCount; } finally { @@ -741,11 +728,18 @@ public class TaskQueryImpl implements TaskQuery { } } - private void checkOpenPermissionForWorkbasketKey() { + private void checkOpenPermissionForSpecifiedWorkbaskets() { try { - if (this.workbasketKeyIn != null && this.workbasketKeyIn.length > 0) { - for (String wbKey : this.workbasketKeyIn) { - taskanaEngineImpl.getWorkbasketService().checkAuthorization(wbKey, WorkbasketAuthorization.OPEN); + if (this.workbasketIdIn != null && this.workbasketIdIn.length > 0) { + for (String workbasketId : workbasketIdIn) { + taskanaEngineImpl.getWorkbasketService().checkAuthorization(workbasketId, + WorkbasketAuthorization.OPEN); + } + } + if (workbasketKeyDomainIn != null && workbasketKeyDomainIn.length > 0) { + for (KeyDomain keyDomain : workbasketKeyDomainIn) { + taskanaEngineImpl.getWorkbasketService().checkAuthorization(keyDomain.getKey(), + keyDomain.getDomain(), WorkbasketAuthorization.OPEN); } } } catch (NotAuthorizedException e) { @@ -773,8 +767,8 @@ public class TaskQueryImpl implements TaskQuery { return priority; } - public TaskState[] getStates() { - return states; + public TaskState[] getStateIn() { + return stateIn; } public String[] getOwnerIn() { @@ -981,20 +975,12 @@ public class TaskQueryImpl implements TaskQuery { return classificationKeyLike; } - public String[] getWorkbasketKeyIn() { - return workbasketKeyIn; + public KeyDomain[] getWorkbasketKeyDomainIn() { + return workbasketKeyDomainIn; } - public String[] getWorkbasketKeyLike() { - return workbasketKeyLike; - } - - public String[] getDomainIn() { - return domainIn; - } - - public String[] getDomainLike() { - return domainLike; + public String[] getWorkbasketIdIn() { + return workbasketIdIn; } private TaskQuery addOrderCriteria(String columnName, SortDirection sortDirection) { @@ -1029,8 +1015,12 @@ public class TaskQueryImpl implements TaskQuery { builder.append(Arrays.toString(note)); builder.append(", priority="); builder.append(Arrays.toString(priority)); - builder.append(", states="); - builder.append(Arrays.toString(states)); + builder.append(", workbasketKeyDomainIn="); + builder.append(Arrays.toString(workbasketKeyDomainIn)); + builder.append(", workbasketIdIn="); + builder.append(Arrays.toString(workbasketIdIn)); + builder.append(", stateIn="); + builder.append(Arrays.toString(stateIn)); builder.append(", classificationKeyIn="); builder.append(Arrays.toString(classificationKeyIn)); builder.append(", classificationKeyLike="); @@ -1039,14 +1029,6 @@ public class TaskQueryImpl implements TaskQuery { builder.append(Arrays.toString(classificationCategoryIn)); builder.append(", classificationCategoryLike="); builder.append(Arrays.toString(classificationCategoryLike)); - builder.append(", workbasketKeyIn="); - builder.append(Arrays.toString(workbasketKeyIn)); - builder.append(", workbasketKeyLike="); - builder.append(Arrays.toString(workbasketKeyLike)); - builder.append(", domainIn="); - builder.append(Arrays.toString(domainIn)); - builder.append(", domainLike="); - builder.append(Arrays.toString(domainLike)); builder.append(", ownerIn="); builder.append(Arrays.toString(ownerIn)); builder.append(", ownerLike="); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java index 72c6995c4..75e9a53b0 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java @@ -285,8 +285,18 @@ public class TaskServiceImpl implements TaskService { throw new TaskAlreadyExistException(taskToCreate.getId()); } else { LOGGER.debug("Task {} cannot be be found, so it can be created.", taskToCreate.getId()); - Workbasket workbasket = workbasketService.getWorkbasketByKey(task.getWorkbasketKey()); - workbasketService.checkAuthorization(task.getWorkbasketKey(), + Workbasket workbasket; + + if (taskToCreate.getWorkbasketSummary().getId() != null) { + workbasket = workbasketService.getWorkbasket(taskToCreate.getWorkbasketSummary().getId()); + } else if (taskToCreate.getWorkbasketKey() != null) { + workbasket = workbasketService.getWorkbasket(task.getWorkbasketKey(), task.getDomain()); + } else { + throw new InvalidArgumentException("Cannot create a task outside a workbasket"); + } + + task.setWorkbasketSummary(workbasket.asSummary()); + workbasketService.checkAuthorization(task.getWorkbasketSummary().getId(), WorkbasketAuthorization.APPEND); String classificationKey = task.getClassificationKey(); if (classificationKey == null || classificationKey.length() == 0) { @@ -294,10 +304,7 @@ public class TaskServiceImpl implements TaskService { } Classification classification = this.classificationService.getClassification(classificationKey, workbasket.getDomain()); - task.setClassificationKey(classificationKey); - task.setClassificationCategory(classification.getCategory()); task.setClassificationSummary(classification.asSummary()); - task.setWorkbasketSummary(workbasket.asSummary()); validateObjectReference(task.getPrimaryObjRef(), "primary ObjectReference", "Task"); validateAttachments(task); task.setDomain(workbasket.getDomain()); @@ -355,34 +362,33 @@ public class TaskServiceImpl implements TaskService { } @Override - public Task transfer(String taskId, String destinationWorkbasketKey) + public Task transfer(String taskId, String destinationWorkbasketId) throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException { - LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketKey = {})", taskId, destinationWorkbasketKey); + LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketId = {})", taskId, destinationWorkbasketId); TaskImpl task = null; try { taskanaEngineImpl.openConnection(); task = (TaskImpl) getTask(taskId); // transfer requires TRANSFER in source and APPEND on destination workbasket - workbasketService.checkAuthorization(destinationWorkbasketKey, WorkbasketAuthorization.APPEND); - workbasketService.checkAuthorization(task.getWorkbasketKey(), WorkbasketAuthorization.TRANSFER); + workbasketService.checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND); + workbasketService.checkAuthorization(task.getWorkbasketSummary().getId(), + WorkbasketAuthorization.TRANSFER); - Workbasket destinationWorkbasket = workbasketService.getWorkbasketByKey(destinationWorkbasketKey); + Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketId); // reset read flag and set transferred flag task.setRead(false); task.setTransferred(true); // transfer task from source to destination workbasket - task.setWorkbasketKey(destinationWorkbasketKey); task.setWorkbasketSummary(destinationWorkbasket.asSummary()); - task.setDomain(destinationWorkbasket.getDomain()); task.setModified(Instant.now()); task.setState(TaskState.READY); task.setOwner(null); taskMapper.update(task); LOGGER.debug("Method transfer() transferred Task '{}' to destination workbasket {}", taskId, - destinationWorkbasketKey); + destinationWorkbasketId); return task; } finally { taskanaEngineImpl.returnConnection(); @@ -391,83 +397,148 @@ public class TaskServiceImpl implements TaskService { } @Override - public BulkOperationResults transferTasks(String destinationWorkbasketKey, + public Task transfer(String taskId, String destinationWorkbasketKey, String domain) + throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException { + LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketKey = {}, domain = {})", taskId, + destinationWorkbasketKey, domain); + TaskImpl task = null; + try { + taskanaEngineImpl.openConnection(); + task = (TaskImpl) getTask(taskId); + + // transfer requires TRANSFER in source and APPEND on destination workbasket + workbasketService.checkAuthorization(destinationWorkbasketKey, domain, WorkbasketAuthorization.APPEND); + workbasketService.checkAuthorization(task.getWorkbasketSummary().getId(), + WorkbasketAuthorization.TRANSFER); + + Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketKey, domain); + + // reset read flag and set transferred flag + task.setRead(false); + task.setTransferred(true); + + // transfer task from source to destination workbasket + task.setWorkbasketSummary(destinationWorkbasket.asSummary()); + task.setModified(Instant.now()); + task.setState(TaskState.READY); + task.setOwner(null); + taskMapper.update(task); + LOGGER.debug("Method transfer() transferred Task '{}' to destination workbasket {}", taskId, + destinationWorkbasket.getId()); + return task; + } finally { + taskanaEngineImpl.returnConnection(); + LOGGER.debug("exit from transfer(). Returning result {} ", task); + } + } + + @Override + public BulkOperationResults transferTasks(String destinationWorkbasketId, List taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { try { taskanaEngineImpl.openConnection(); - LOGGER.debug("entry to transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketKey, taskIds); + LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds); // Check pre-conditions with trowing Exceptions - if (destinationWorkbasketKey == null || taskIds == null) { + if (destinationWorkbasketId == null || taskIds == null) { throw new InvalidArgumentException( - "DestinationWorkbasketKey or TaskIds can´t be used as NULL-Parameter."); + "DestinationWorkbasketId or TaskIds can´t be used as NULL-Parameter."); } - Workbasket destinationWorkbasket = workbasketService.getWorkbasketByKey(destinationWorkbasketKey); + Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketId); - BulkOperationResults bulkLog = new BulkOperationResults<>(); - - // check tasks Ids exist and not empty - log and remove - Iterator taskIdIterator = taskIds.iterator(); - while (taskIdIterator.hasNext()) { - String currentTaskId = taskIdIterator.next(); - if (currentTaskId == null || currentTaskId.equals("")) { - bulkLog.addError("", - new InvalidArgumentException("IDs with EMPTY or NULL value are not allowed.")); - taskIdIterator.remove(); - } - } - - // query for existing tasks. use taskMapper.findExistingTasks because this method - // returns only the required information. - List taskSummaries = taskMapper.findExistingTasks(taskIds); - - // check source WB (read)+transfer - Set workbasketKeys = new HashSet<>(); - taskSummaries.stream().forEach(t -> workbasketKeys.add(t.getWorkbasketKey())); - List sourceWorkbaskets = workbasketService.createWorkbasketQuery() - .callerHasPermission(WorkbasketAuthorization.TRANSFER) - .keyIn(workbasketKeys.toArray(new String[0])) - .list(); - taskIdIterator = taskIds.iterator(); - while (taskIdIterator.hasNext()) { - String currentTaskId = taskIdIterator.next(); - MinimalTaskSummary taskSummary = taskSummaries.stream() - .filter(t -> currentTaskId.equals(t.getTaskId())) - .findFirst() - .orElse(null); - if (taskSummary == null) { - bulkLog.addError(currentTaskId, new TaskNotFoundException(currentTaskId)); - taskIdIterator.remove(); - } else if (!sourceWorkbaskets.stream() - .anyMatch(wb -> taskSummary.getWorkbasketKey().equals(wb.getKey()))) { - bulkLog.addError(currentTaskId, - new NotAuthorizedException( - "The workbasket of this task got not TRANSFER permissions. TaskId=" + currentTaskId)); - taskIdIterator.remove(); - } - } - - // filter taskSummaries and update values - taskSummaries = taskSummaries.stream().filter(ts -> taskIds.contains(ts.getTaskId())).collect( - Collectors.toList()); - if (!taskSummaries.isEmpty()) { - Instant now = Instant.now(); - TaskSummaryImpl updateObject = new TaskSummaryImpl(); - updateObject.setRead(false); - updateObject.setTransferred(true); - updateObject.setWorkbasketSummary(destinationWorkbasket.asSummary()); - updateObject.setDomain(destinationWorkbasket.getDomain()); - updateObject.setModified(now); - updateObject.setState(TaskState.READY); - updateObject.setOwner(null); - taskMapper.updateTransfered(taskIds, updateObject); - } - return bulkLog; + return transferTasks(taskIds, destinationWorkbasket); } finally { - LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketKey, taskIds); + LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketId, taskIds); taskanaEngineImpl.returnConnection(); } } + @Override + public BulkOperationResults transferTasks(String destinationWorkbasketKey, + String destinationWorkbasketDomain, List taskIds) + throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { + try { + taskanaEngineImpl.openConnection(); + LOGGER.debug("entry to transferBulk(targetWbKey = {}, domain = {}, taskIds = {})", destinationWorkbasketKey, + destinationWorkbasketDomain, taskIds); + // Check pre-conditions with trowing Exceptions + if (destinationWorkbasketKey == null || destinationWorkbasketDomain == null || taskIds == null) { + throw new InvalidArgumentException( + "DestinationWorkbasketKey or domain or TaskIds can´t be used as NULL-Parameter."); + } + Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketKey, + destinationWorkbasketDomain); + + return transferTasks(taskIds, destinationWorkbasket); + } finally { + LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketKey, + destinationWorkbasketDomain, taskIds); + taskanaEngineImpl.returnConnection(); + } + } + + private BulkOperationResults transferTasks(List taskIds, + Workbasket destinationWorkbasket) throws InvalidArgumentException { + BulkOperationResults bulkLog = new BulkOperationResults<>(); + + // check tasks Ids exist and not empty - log and remove + Iterator taskIdIterator = taskIds.iterator(); + while (taskIdIterator.hasNext()) { + String currentTaskId = taskIdIterator.next(); + if (currentTaskId == null || currentTaskId.equals("")) { + bulkLog.addError("", + new InvalidArgumentException("IDs with EMPTY or NULL value are not allowed.")); + taskIdIterator.remove(); + } + } + + // query for existing tasks. use taskMapper.findExistingTasks because this method + // returns only the required information. + List taskSummaries = taskMapper.findExistingTasks(taskIds); + + // check source WB (read)+transfer + Set workbasketKeys = new HashSet<>(); + taskSummaries.stream().forEach(t -> workbasketKeys.add(t.getWorkbasketKey())); + List sourceWorkbaskets = workbasketService.createWorkbasketQuery() + .callerHasPermission(WorkbasketAuthorization.TRANSFER) + .keyIn(workbasketKeys.toArray(new String[0])) + .list(); + taskIdIterator = taskIds.iterator(); + while (taskIdIterator.hasNext()) { + String currentTaskId = taskIdIterator.next(); + MinimalTaskSummary taskSummary = taskSummaries.stream() + .filter(t -> currentTaskId.equals(t.getTaskId())) + .findFirst() + .orElse(null); + if (taskSummary == null) { + bulkLog.addError(currentTaskId, new TaskNotFoundException(currentTaskId)); + taskIdIterator.remove(); + } else if (!sourceWorkbaskets.stream() + .anyMatch(wb -> taskSummary.getWorkbasketKey().equals(wb.getKey()))) { + bulkLog.addError(currentTaskId, + new NotAuthorizedException( + "The workbasket of this task got not TRANSFER permissions. TaskId=" + currentTaskId)); + taskIdIterator.remove(); + } + } + + // filter taskSummaries and update values + taskSummaries = taskSummaries.stream().filter(ts -> taskIds.contains(ts.getTaskId())).collect( + Collectors.toList()); + if (!taskSummaries.isEmpty()) { + Instant now = Instant.now(); + TaskSummaryImpl updateObject = new TaskSummaryImpl(); + updateObject.setRead(false); + updateObject.setTransferred(true); + updateObject.setWorkbasketSummary(destinationWorkbasket.asSummary()); + updateObject.setDomain(destinationWorkbasket.getDomain()); + updateObject.setModified(now); + updateObject.setState(TaskState.READY); + updateObject.setOwner(null); + taskMapper.updateTransfered(taskIds, updateObject); + } + return bulkLog; + } + @Override public Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException { @@ -809,9 +880,21 @@ public class TaskServiceImpl implements TaskService { } @Override - public Task newTask(String workbasketKey) { + public Task newTask(String workbasketId) { TaskImpl task = new TaskImpl(); - task.setWorkbasketKey(workbasketKey); + WorkbasketSummaryImpl wb = new WorkbasketSummaryImpl(); + wb.setId(workbasketId); + task.setWorkbasketSummary(wb); + return task; + } + + @Override + public Task newTask(String workbasketKey, String domain) { + TaskImpl task = new TaskImpl(); + WorkbasketSummaryImpl wb = new WorkbasketSummaryImpl(); + wb.setKey(workbasketKey); + wb.setDomain(domain); + task.setWorkbasketSummary(wb); return task; } @@ -976,7 +1059,7 @@ public class TaskServiceImpl implements TaskService { Classification newClassification = null; if (newClassificationKey != null && !newClassificationKey.equals(oldClassificationSummary.getKey())) { - Workbasket workbasket = workbasketService.getWorkbasketByKey(newTaskImpl.getWorkbasketSummary().getKey()); + Workbasket workbasket = workbasketService.getWorkbasket(newTaskImpl.getWorkbasketSummary().getId()); // set new classification newClassification = this.classificationService.getClassification(newClassificationKey, workbasket.getDomain()); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java index 2cff91053..da2687c27 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java @@ -27,7 +27,6 @@ public class TaskSummaryImpl implements TaskSummary { private TaskState state; private ClassificationSummary classificationSummary; private WorkbasketSummary workbasketSummary; - private String domain; private String businessProcessId; private String parentBusinessProcessId; private String owner; @@ -236,11 +235,14 @@ public class TaskSummaryImpl implements TaskSummary { */ @Override public String getDomain() { - return domain; + return workbasketSummary == null ? null : workbasketSummary.getDomain(); } public void setDomain(String domain) { - this.domain = domain; + if (workbasketSummary == null) { + workbasketSummary = new WorkbasketSummaryImpl(); + } + ((WorkbasketSummaryImpl) this.workbasketSummary).setDomain(domain); } /* @@ -496,7 +498,6 @@ public class TaskSummaryImpl implements TaskSummary { result = prime * result + ((custom7 == null) ? 0 : custom7.hashCode()); result = prime * result + ((custom8 == null) ? 0 : custom8.hashCode()); result = prime * result + ((custom9 == null) ? 0 : custom9.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); result = prime * result + ((due == null) ? 0 : due.hashCode()); result = prime * result + ((taskId == null) ? 0 : taskId.hashCode()); result = prime * result + (isRead ? 1231 : 1237); @@ -638,13 +639,6 @@ public class TaskSummaryImpl implements TaskSummary { } else if (!custom9.equals(other.custom9)) { return false; } - if (domain == null) { - if (other.domain != null) { - return false; - } - } else if (!domain.equals(other.domain)) { - return false; - } if (due == null) { if (other.due != null) { return false; @@ -759,8 +753,6 @@ public class TaskSummaryImpl implements TaskSummary { builder.append(classificationSummary); builder.append(", workbasketSummary="); builder.append(workbasketSummary); - builder.append(", domain="); - builder.append(domain); builder.append(", businessProcessId="); builder.append(businessProcessId); builder.append(", parentBusinessProcessId="); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java index 8902440bb..445655ad8 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java @@ -9,7 +9,7 @@ import pro.taskana.configuration.TaskanaEngineConfiguration; public class WorkbasketAccessItemImpl implements WorkbasketAccessItem { private String id; - private String workbasketKey; + private String workbasketId; private String accessId; private boolean permRead; private boolean permOpen; @@ -51,12 +51,12 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem { * @see pro.taskana.impl.WorkbasketAccessItem#getWorkbasketKey() */ @Override - public String getWorkbasketKey() { - return workbasketKey; + public String getWorkbasketId() { + return workbasketId; } - public void setWorkbasketKey(String workbasketKey) { - this.workbasketKey = workbasketKey; + public void setWorkbasketId(String workbasketId) { + this.workbasketId = workbasketId; } /* @@ -387,8 +387,8 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem { StringBuilder builder = new StringBuilder(); builder.append("WorkbasketAccessItem [id="); builder.append(id); - builder.append(", workbasketKey="); - builder.append(workbasketKey); + builder.append(", workbasketId="); + builder.append(workbasketId); builder.append(", accessId="); builder.append(accessId); builder.append(", permRead="); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemQueryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemQueryImpl.java index 55561cfa1..e2099be1c 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemQueryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemQueryImpl.java @@ -26,7 +26,7 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryWorkbasketAccessItems"; private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketQueryImpl.class); private String[] accessIdIn; - private String[] workbasketKeyIn; + private String[] workbasketIdIn; private TaskanaEngineImpl taskanaEngineImpl; private List orderBy; @@ -37,8 +37,8 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery } @Override - public WorkbasketAccessItemQuery workbasketKeyIn(String... key) { - this.workbasketKeyIn = key; + public WorkbasketAccessItemQuery workbasketIdIn(String... id) { + this.workbasketIdIn = id; return this; } @@ -50,8 +50,8 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery } @Override - public WorkbasketAccessItemQuery orderByWorkbasketKey(SortDirection sortDirection) { - return addOrderCriteria("WORKBASKET_KEY", sortDirection); + public WorkbasketAccessItemQuery orderByWorkbasketId(SortDirection sortDirection) { + return addOrderCriteria("WORKBASKET_ID", sortDirection); } @Override @@ -149,8 +149,8 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery return accessIdIn; } - public String[] getWorkbasketKeyIn() { - return workbasketKeyIn; + public String[] getWorkbasketIdIn() { + return workbasketIdIn; } public List getOrderBy() { @@ -162,8 +162,8 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery StringBuilder builder = new StringBuilder(); builder.append("WorkbasketAccessItemQueryImpl [accessIdIn="); builder.append(Arrays.toString(accessIdIn)); - builder.append(", workbasketKeyIn="); - builder.append(Arrays.toString(workbasketKeyIn)); + builder.append(", workbasketIdIn="); + builder.append(Arrays.toString(workbasketIdIn)); builder.append(", orderBy="); builder.append(orderBy); builder.append("]"); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java index 6f34e6424..e081cd0bf 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java @@ -102,11 +102,6 @@ public class WorkbasketImpl implements Workbasket { return domain; } - @Override - public void setDomain(String domain) { - this.domain = domain; - } - @Override public WorkbasketType getType() { return type; @@ -197,6 +192,10 @@ public class WorkbasketImpl implements Workbasket { this.orgLevel4 = orgLevel4; } + public void setDomain(String domain) { + this.domain = domain; + } + @Override public WorkbasketSummary asSummary() { WorkbasketSummaryImpl result = new WorkbasketSummaryImpl(); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java index 83494457e..b33c51e34 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketServiceImpl.java @@ -68,7 +68,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { workbasketId); throw new WorkbasketNotFoundException(workbasketId); } - this.checkAuthorization(result.getKey(), WorkbasketAuthorization.READ); + this.checkAuthorization(workbasketId, WorkbasketAuthorization.READ); return result; } finally { taskanaEngine.returnConnection(); @@ -77,20 +77,20 @@ public class WorkbasketServiceImpl implements WorkbasketService { } @Override - public Workbasket getWorkbasketByKey(String workbasketKey) + public Workbasket getWorkbasket(String workbasketKey, String domain) throws WorkbasketNotFoundException, NotAuthorizedException { LOGGER.debug("entry to getWorkbasketByKey(workbasketKey = {})", workbasketKey); Workbasket result = null; try { taskanaEngine.openConnection(); - result = workbasketMapper.findByKey(workbasketKey); + result = workbasketMapper.findByKeyAndDomain(workbasketKey, domain); if (result == null) { LOGGER.error( "Method getWorkbasketByKey() didn't find workbasket with key {}. Throwing WorkbasketNotFoundException", workbasketKey); throw new WorkbasketNotFoundException(workbasketKey); } - this.checkAuthorization(workbasketKey, WorkbasketAuthorization.READ); + this.checkAuthorization(workbasketKey, domain, WorkbasketAuthorization.READ); return result; } finally { taskanaEngine.returnConnection(); @@ -192,9 +192,9 @@ public class WorkbasketServiceImpl implements WorkbasketService { } @Override - public WorkbasketAccessItem newWorkbasketAccessItem(String workbasketKey, String accessId) { + public WorkbasketAccessItem newWorkbasketAccessItem(String workbasketId, String accessId) { WorkbasketAccessItemImpl accessItem = new WorkbasketAccessItemImpl(); - accessItem.setWorkbasketKey(workbasketKey); + accessItem.setWorkbasketId(workbasketId); accessItem.setAccessId(accessId); return accessItem; } @@ -231,10 +231,16 @@ public class WorkbasketServiceImpl implements WorkbasketService { } @Override - public void checkAuthorization(String workbasketKey, WorkbasketAuthorization workbasketAuthorization) - throws NotAuthorizedException { + public void checkAuthorization(String workbasketId, + WorkbasketAuthorization workbasketAuthorization) throws NotAuthorizedException { + checkAuthorization(null, null, workbasketId, workbasketAuthorization); + } - checkAuthorization(workbasketKey, null, workbasketAuthorization); + @Override + public void checkAuthorization(String workbasketKey, String domain, + WorkbasketAuthorization workbasketAuthorization) + throws NotAuthorizedException { + checkAuthorization(workbasketKey, domain, null, workbasketAuthorization); } @Override @@ -247,10 +253,10 @@ public class WorkbasketServiceImpl implements WorkbasketService { WorkbasketAccessItem originalItem = workbasketAccessMapper.findById(accessItem.getId()); if ((originalItem.getAccessId() != null && !originalItem.getAccessId().equals(accessItem.getAccessId())) - || (originalItem.getWorkbasketKey() != null - && !originalItem.getWorkbasketKey().equals(accessItem.getWorkbasketKey()))) { + || (originalItem.getWorkbasketId() != null + && !originalItem.getWorkbasketId().equals(accessItem.getWorkbasketId()))) { throw new InvalidArgumentException( - "AccessId and Workbasketkey must not be changed in updateWorkbasketAuthorization calls"); + "AccessId and WorkbasketId must not be changed in updateWorkbasketAuthorization calls"); } workbasketAccessMapper.update(accessItem); @@ -265,12 +271,12 @@ public class WorkbasketServiceImpl implements WorkbasketService { } @Override - public List getWorkbasketAuthorizations(String workbasketKey) { - LOGGER.debug("entry to getWorkbasketAuthorizations(workbasketId = {})", workbasketKey); + public List getWorkbasketAuthorizations(String workbasketId) { + LOGGER.debug("entry to getWorkbasketAuthorizations(workbasketId = {})", workbasketId); List result = new ArrayList<>(); try { taskanaEngine.openConnection(); - List queryResult = workbasketAccessMapper.findByWorkbasketKey(workbasketKey); + List queryResult = workbasketAccessMapper.findByWorkbasketId(workbasketId); result.addAll(queryResult); return result; } finally { @@ -284,9 +290,9 @@ public class WorkbasketServiceImpl implements WorkbasketService { } @Override - public List getPermissionsForWorkbasket(String workbasketKey) { + public List getPermissionsForWorkbasket(String workbasketId) { List permissions = new ArrayList<>(); - WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketAndAccessId(workbasketKey, + WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketAndAccessId(workbasketId, CurrentUserContext.getAccessIds()); this.addWorkbasketAccessItemValuesToPermissionSet(wbAcc, permissions); return permissions; @@ -371,8 +377,9 @@ public class WorkbasketServiceImpl implements WorkbasketService { } @Override - public Workbasket newWorkbasket(String key) { + public Workbasket newWorkbasket(String key, String domain) { WorkbasketImpl wb = new WorkbasketImpl(); + wb.setDomain(domain); wb.setKey(key); return wb; } @@ -386,7 +393,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { taskanaEngine.openConnection(); // check that source workbasket exists getWorkbasket(workbasketId); - checkAuthorizationByWorkbasketId(workbasketId, WorkbasketAuthorization.READ); + checkAuthorization(workbasketId, WorkbasketAuthorization.READ); List distributionTargets = workbasketMapper .findByDistributionTargets(workbasketId); result.addAll(distributionTargets); @@ -401,6 +408,31 @@ public class WorkbasketServiceImpl implements WorkbasketService { } } + @Override + public List getDistributionTargets(String workbasketKey, String domain) + throws NotAuthorizedException, WorkbasketNotFoundException { + LOGGER.debug("entry to getDistributionTargets(workbasketKey = {}, domain = {})", workbasketKey, domain); + List result = new ArrayList<>(); + try { + taskanaEngine.openConnection(); + // check that source workbasket exists + Workbasket workbasket = getWorkbasket(workbasketKey, domain); + checkAuthorization(workbasket.getId(), WorkbasketAuthorization.READ); + List distributionTargets = workbasketMapper + .findByDistributionTargets(workbasket.getId()); + result.addAll(distributionTargets); + return result; + } finally { + taskanaEngine.returnConnection(); + if (LOGGER.isDebugEnabled()) { + int numberOfResultObjects = result.size(); + LOGGER.debug("exit from getDistributionTargets(workbasketId). Returning {} resulting Objects: {} ", + numberOfResultObjects, LoggerUtils.listToString(result)); + } + } + + } + @Override public List getDistributionSources(String workbasketId) throws NotAuthorizedException, WorkbasketNotFoundException { @@ -410,7 +442,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { taskanaEngine.openConnection(); // check that source workbasket exists getWorkbasket(workbasketId); - checkAuthorizationByWorkbasketId(workbasketId, WorkbasketAuthorization.READ); + checkAuthorization(workbasketId, WorkbasketAuthorization.READ); List distributionSources = workbasketMapper .findDistributionSources(workbasketId); result.addAll(distributionSources); @@ -425,6 +457,30 @@ public class WorkbasketServiceImpl implements WorkbasketService { } } + @Override + public List getDistributionSources(String workbasketKey, String domain) + throws NotAuthorizedException, WorkbasketNotFoundException { + LOGGER.debug("entry to getDistributionSources(workbasketKey = {}, domain = {})", workbasketKey, domain); + List result = new ArrayList<>(); + try { + taskanaEngine.openConnection(); + // check that source workbasket exists + Workbasket workbasket = getWorkbasket(workbasketKey, domain); + checkAuthorization(workbasket.getId(), WorkbasketAuthorization.READ); + List distributionSources = workbasketMapper + .findDistributionSources(workbasket.getId()); + result.addAll(distributionSources); + return result; + } finally { + taskanaEngine.returnConnection(); + if (LOGGER.isDebugEnabled()) { + int numberOfResultObjects = result.size(); + LOGGER.debug("exit from getDistributionSources(workbasketId). Returning {} resulting Objects: {} ", + numberOfResultObjects, LoggerUtils.listToString(result)); + } + } + } + @Override public void setDistributionTargets(String sourceWorkbasketId, List targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException { @@ -437,7 +493,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { taskanaEngine.openConnection(); // check existence of source workbasket WorkbasketImpl sourceWorkbasket = (WorkbasketImpl) getWorkbasket(sourceWorkbasketId); - checkAuthorizationByWorkbasketId(sourceWorkbasketId, WorkbasketAuthorization.READ); + checkAuthorization(sourceWorkbasketId, WorkbasketAuthorization.READ); distributionTargetMapper.deleteAllDistributionTargetsBySourceId(sourceWorkbasketId); sourceWorkbasket.setModified(Instant.now()); @@ -474,7 +530,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { WorkbasketImpl sourceWorkbasket = (WorkbasketImpl) getWorkbasket(sourceWorkbasketId); // check esistence of target workbasket getWorkbasket(targetWorkbasketId); - checkAuthorizationByWorkbasketId(sourceWorkbasketId, WorkbasketAuthorization.READ); + checkAuthorization(sourceWorkbasketId, WorkbasketAuthorization.READ); // check whether the target is already set as target int numOfDistTargets = distributionTargetMapper.getNumberOfDistributionTargets(sourceWorkbasketId, targetWorkbasketId); @@ -504,7 +560,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { try { taskanaEngine.openConnection(); // don't check existence of source / target workbasket to enable cleanup even if the db is corrupted - checkAuthorizationByWorkbasketId(sourceWorkbasketId, WorkbasketAuthorization.READ); + checkAuthorization(sourceWorkbasketId, WorkbasketAuthorization.READ); // check whether the target is set as target int numberOfDistTargets = distributionTargetMapper.getNumberOfDistributionTargets(sourceWorkbasketId, targetWorkbasketId); @@ -547,7 +603,7 @@ public class WorkbasketServiceImpl implements WorkbasketService { Workbasket wb = this.getWorkbasket(workbasketId); List taskUsages = taskanaEngine.getTaskService() .createTaskQuery() - .workbasketKeyIn(wb.getKey()) + .workbasketIdIn(wb.getId()) .list(); if (taskUsages == null || taskUsages.size() > 0) { throw new WorkbasketInUseException( @@ -570,17 +626,12 @@ public class WorkbasketServiceImpl implements WorkbasketService { return new WorkbasketAccessItemQueryImpl(this.taskanaEngine); } - private void checkAuthorizationByWorkbasketId(String workbasketId, - WorkbasketAuthorization workbasketAuthorization) throws NotAuthorizedException { - checkAuthorization(null, workbasketId, workbasketAuthorization); - } - - private void checkAuthorization(String workbasketKey, String workbasketId, + private void checkAuthorization(String workbasketKey, String domain, String workbasketId, WorkbasketAuthorization workbasketAuthorization) throws NotAuthorizedException { LOGGER.debug("entry to checkAuthorization(workbasketId = {}, workbasketAuthorization = {})", workbasketKey, workbasketAuthorization); - if ((workbasketAuthorization == null && workbasketKey == null) || workbasketAuthorization == null) { + if (workbasketAuthorization == null) { throw new SystemException("checkAuthorization was called with an invalid parameter combination"); } boolean isAuthorized = false; @@ -596,13 +647,13 @@ public class WorkbasketServiceImpl implements WorkbasketService { List accessIds = CurrentUserContext.getAccessIds(); LOGGER.debug("checkAuthorization: Verifying that {} has the permission {} on workbasket {}", CurrentUserContext.getUserid(), - workbasketAuthorization == null ? "null" : workbasketAuthorization.name(), workbasketKey); + workbasketAuthorization.name(), workbasketKey); List accessItems; if (workbasketKey != null) { accessItems = workbasketAccessMapper - .findByWorkbasketAndAccessIdAndAuthorization(workbasketKey, accessIds, + .findByWorkbasketAccessByWorkbasketKeyDomainAndAuthorization(workbasketKey, domain, accessIds, workbasketAuthorization.name()); } else if (workbasketId != null) { accessItems = workbasketAccessMapper diff --git a/lib/taskana-core/src/main/java/pro/taskana/mappings/AttachmentMapper.java b/lib/taskana-core/src/main/java/pro/taskana/mappings/AttachmentMapper.java index f5502fea5..e80ba679d 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/mappings/AttachmentMapper.java +++ b/lib/taskana-core/src/main/java/pro/taskana/mappings/AttachmentMapper.java @@ -21,12 +21,12 @@ import pro.taskana.impl.persistence.MapTypeHandler; */ public interface AttachmentMapper { - @Insert("INSERT INTO ATTACHMENT (ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES) " - + "VALUES (#{att.id}, #{att.taskId}, #{att.created}, #{att.modified}, #{att.classificationSummary.key}, #{att.objectReference.company}, #{att.objectReference.system}, #{att.objectReference.systemInstance}, " + @Insert("INSERT INTO ATTACHMENT (ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, CLASSIFICATION_ID, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES) " + + "VALUES (#{att.id}, #{att.taskId}, #{att.created}, #{att.modified}, #{att.classificationSummary.key}, #{att.classificationSummary.id}, #{att.objectReference.company}, #{att.objectReference.system}, #{att.objectReference.systemInstance}, " + " #{att.objectReference.type}, #{att.objectReference.value}, #{att.channel}, #{att.received}, #{att.customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler} )") void insert(@Param("att") AttachmentImpl att); - @Select("SELECT ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES " + @Select("SELECT ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, CLASSIFICATION_ID, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES " + "FROM ATTACHMENT " + "WHERE TASK_ID = #{taskId}") @Results(value = { @@ -35,6 +35,7 @@ public interface AttachmentMapper { @Result(property = "created", column = "CREATED"), @Result(property = "modified", column = "MODIFIED"), @Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"), + @Result(property = "classificationSummaryImpl.id", column = "CLASSIFICATION_ID"), @Result(property = "objectReference.company", column = "REF_COMPANY"), @Result(property = "objectReference.system", column = "REF_SYSTEM"), @Result(property = "objectReference.systemInstance", column = "REF_INSTANCE"), @@ -47,7 +48,7 @@ public interface AttachmentMapper { }) List findAttachmentsByTaskId(@Param("taskId") String taskId); - @Select("SELECT ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES " + @Select("SELECT ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, CLASSIFICATION_ID, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES " + "FROM ATTACHMENT " + "WHERE ID = #{attachmentId}") @Results(value = { @@ -56,6 +57,7 @@ public interface AttachmentMapper { @Result(property = "created", column = "CREATED"), @Result(property = "modified", column = "MODIFIED"), @Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"), + @Result(property = "classificationSummaryImpl.id", column = "CLASSIFICATION_ID"), @Result(property = "objectReference.company", column = "REF_COMPANY"), @Result(property = "objectReference.system", column = "REF_SYSTEM"), @Result(property = "objectReference.systemInstance", column = "REF_INSTANCE"), @@ -68,7 +70,7 @@ public interface AttachmentMapper { }) AttachmentImpl getAttachment(@Param("attachmentId") String attachmentId); - @Select("") @Results({ @Result(property = "id", column = "ID"), - @Result(property = "workbasketKey", column = "WORKBASKET_KEY"), + @Result(property = "workbasketId", column = "WORKBASKET_ID"), @Result(property = "accessId", column = "ACCESS_ID"), @Result(property = "permRead", column = "PERM_READ"), @Result(property = "permOpen", column = "PERM_OPEN"), @@ -313,15 +312,13 @@ public interface QueryMapper { + "AND (t.DESCRIPTION LIKE #{item}) " + "AND (t.NOTE LIKE #{item}) " + "AND t.PRIORITY IN(#{item}) " - + "AND t.STATE IN(#{item}) " - + "AND t.WORKBASKET_KEY IN(#{item}) " - + "AND (UPPER(t.WORKBASKET_KEY) LIKE #{item}) " + + "AND t.STATE IN(#{item}) " + + "AND t.WORKBASKET_ID IN(#{item}) " + + "AND ((t.WORKBASKET_KEY = #{item.key} AND t.DOMAIN = #{item.domain})) " + "AND t.CLASSIFICATION_KEY IN(#{item}) " + "AND (UPPER(t.CLASSIFICATION_KEY) LIKE #{item}) " + "AND t.CLASSIFICATION_CATEGORY IN(#{item}) " + "AND (UPPER(t.CLASSIFICATION_CATEGORY) LIKE #{item}) " - + "AND t.DOMAIN IN(#{item}) " - + "AND (UPPER(t.DOMAIN) LIKE #{item}) " + "AND t.OWNER IN(#{item}) " + "AND (UPPER(t.OWNER) LIKE #{item}) " + "AND t.IS_READ = #{isRead} " @@ -416,7 +413,7 @@ public interface QueryMapper { @Select("") diff --git a/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMapper.java b/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMapper.java index e307e1021..5e8e7c5d8 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMapper.java +++ b/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMapper.java @@ -27,11 +27,10 @@ import pro.taskana.impl.persistence.MapTypeHandler; public interface TaskMapper { String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.mappings.ObjectReferenceMapper.findById"; - String CLASSIFICATION_FINDBYKEYANDDOMAIN = "pro.taskana.mappings.ClassificationMapper.findByKeyAndDomain"; - String WORKBASKET_FINDSUMMARYBYKEY = "pro.taskana.mappings.WorkbasketMapper.findSummaryByKey"; + String WORKBASKET_FINDSUMMARYBYID = "pro.taskana.mappings.WorkbasketMapper.findSummaryById"; String CLASSIFICATION_FINDBYID = "pro.taskana.mappings.ClassificationMapper.findById"; - @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, NOTE, PRIORITY, STATE, CLASSIFICATION_CATEGORY, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 " + @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, NOTE, PRIORITY, STATE, CLASSIFICATION_CATEGORY, CLASSIFICATION_KEY, CLASSIFICATION_ID, WORKBASKET_ID, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 " + "FROM TASK " + "WHERE ID = #{id}") @Results(value = { @@ -47,11 +46,10 @@ public interface TaskMapper { @Result(property = "note", column = "NOTE"), @Result(property = "priority", column = "PRIORITY"), @Result(property = "state", column = "STATE"), - @Result(property = "workbasketKey", column = "WORKBASKET_KEY"), - @Result(property = "workbasketSummary", column = "WORKBASKET_KEY", javaType = WorkbasketSummaryImpl.class, - one = @One(select = WORKBASKET_FINDSUMMARYBYKEY)), - @Result(property = "classificationKey", column = "CLASSIFICATION_KEY"), - @Result(property = "classificationCategory", column = "CLASSIFICATION_CATEGORY"), + @Result(property = "workbasketSummary", column = "WORKBASKET_ID", javaType = WorkbasketSummaryImpl.class, + one = @One(select = WORKBASKET_FINDSUMMARYBYID)), + @Result(property = "classificationSummaryImpl.category", column = "CLASSIFICATION_CATEGORY"), + @Result(property = "classificationSummaryImpl.id", column = "CLASSIFICATION_ID"), @Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"), @Result(property = "domain", column = "DOMAIN"), @Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"), @@ -79,12 +77,23 @@ public interface TaskMapper { }) TaskImpl findById(@Param("id") String id); - @Insert("INSERT INTO TASK(ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, NOTE, PRIORITY, STATE, CLASSIFICATION_KEY, CLASSIFICATION_CATEGORY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10) " - + "VALUES(#{id}, #{created}, #{claimed}, #{completed}, #{modified}, #{planned}, #{due}, #{name}, #{description}, #{note}, #{priority}, #{state}, #{classificationKey}, #{classificationCategory}, #{workbasketKey}, #{domain}, #{businessProcessId}, #{parentBusinessProcessId}, #{owner}, #{primaryObjRef.company},#{primaryObjRef.system},#{primaryObjRef.systemInstance},#{primaryObjRef.type},#{primaryObjRef.value}, #{isRead}, #{isTransferred}, #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, #{custom1}, #{custom2}, #{custom3}, #{custom4}, #{custom5}, #{custom6}, #{custom7}, #{custom8}, #{custom9}, #{custom10})") + @Insert("INSERT INTO TASK(ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, NOTE, PRIORITY, STATE, CLASSIFICATION_CATEGORY, CLASSIFICATION_KEY, CLASSIFICATION_ID, WORKBASKET_ID, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, " + + "POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10) " + + "VALUES(#{id}, #{created}, #{claimed}, #{completed}, #{modified}, #{planned}, #{due}, #{name}, #{description}, #{note}, #{priority}, #{state}, #{classificationSummary.category}, " + + "#{classificationSummary.key}, #{classificationSummary.id}, #{workbasketSummary.id}, #{workbasketSummary.key}, #{workbasketSummary.domain}, #{businessProcessId}, " + + "#{parentBusinessProcessId}, #{owner}, #{primaryObjRef.company}, #{primaryObjRef.system}, #{primaryObjRef.systemInstance}, #{primaryObjRef.type}, #{primaryObjRef.value}, " + + "#{isRead}, #{isTransferred}, #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, " + + "#{custom1}, #{custom2}, #{custom3}, #{custom4}, #{custom5}, #{custom6}, #{custom7}, #{custom8}, #{custom9}, #{custom10})") @Options(keyProperty = "id", keyColumn = "ID") void insert(TaskImpl task); - @Update("UPDATE TASK SET CLAIMED = #{claimed}, COMPLETED = #{completed}, MODIFIED = #{modified}, PLANNED = #{planned}, DUE = #{due}, NAME = #{name}, DESCRIPTION = #{description}, NOTE = #{note}, PRIORITY = #{priority}, STATE = #{state}, CLASSIFICATION_CATEGORY = #{classificationCategory}, CLASSIFICATION_KEY = #{classificationKey}, WORKBASKET_KEY = #{workbasketKey}, DOMAIN = #{domain}, BUSINESS_PROCESS_ID = #{businessProcessId}, PARENT_BUSINESS_PROCESS_ID = #{parentBusinessProcessId}, OWNER = #{owner}, POR_COMPANY = #{primaryObjRef.company}, POR_SYSTEM = #{primaryObjRef.system}, POR_INSTANCE = #{primaryObjRef.systemInstance}, POR_TYPE = #{primaryObjRef.type}, POR_VALUE = #{primaryObjRef.value}, IS_READ = #{isRead}, IS_TRANSFERRED = #{isTransferred}, CUSTOM_ATTRIBUTES = #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, CUSTOM_1 = #{custom1}, CUSTOM_2 = #{custom2}, CUSTOM_3 = #{custom3}, CUSTOM_4 = #{custom4}, CUSTOM_5 = #{custom5}, CUSTOM_6 = #{custom6}, CUSTOM_7 = #{custom7}, CUSTOM_8 = #{custom8}, CUSTOM_9 = #{custom9}, CUSTOM_10 = #{custom10} " + @Update("UPDATE TASK SET CLAIMED = #{claimed}, COMPLETED = #{completed}, MODIFIED = #{modified}, PLANNED = #{planned}, DUE = #{due}, NAME = #{name}, DESCRIPTION = #{description}, NOTE = #{note}, " + + " PRIORITY = #{priority}, STATE = #{state}, CLASSIFICATION_CATEGORY = #{classificationSummary.category}, CLASSIFICATION_KEY = #{classificationSummary.key}, CLASSIFICATION_ID = #{classificationSummary.id}, " + + "WORKBASKET_ID = #{workbasketSummary.id}, WORKBASKET_KEY = #{workbasketSummary.key}, DOMAIN = #{workbasketSummary.domain}, " + + "BUSINESS_PROCESS_ID = #{businessProcessId}, PARENT_BUSINESS_PROCESS_ID = #{parentBusinessProcessId}, OWNER = #{owner}, POR_COMPANY = #{primaryObjRef.company}, POR_SYSTEM = #{primaryObjRef.system}, " + + "POR_INSTANCE = #{primaryObjRef.systemInstance}, POR_TYPE = #{primaryObjRef.type}, POR_VALUE = #{primaryObjRef.value}, IS_READ = #{isRead}, IS_TRANSFERRED = #{isTransferred}, " + + "CUSTOM_ATTRIBUTES = #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, CUSTOM_1 = #{custom1}, CUSTOM_2 = #{custom2}, " + + "CUSTOM_3 = #{custom3}, CUSTOM_4 = #{custom4}, CUSTOM_5 = #{custom5}, CUSTOM_6 = #{custom6}, CUSTOM_7 = #{custom7}, CUSTOM_8 = #{custom8}, CUSTOM_9 = #{custom9}, CUSTOM_10 = #{custom10} " + "WHERE ID = #{id}") void update(TaskImpl task); @@ -94,9 +103,9 @@ public interface TaskMapper { @Delete("") void deleteMultiple(@Param("ids") List ids); - @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_CATEGORY, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 " + @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_CATEGORY, CLASSIFICATION_KEY, CLASSIFICATION_ID, WORKBASKET_ID, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 " + "FROM TASK " - + "WHERE WORKBASKET_KEY = #{workbasketKey} " + + "WHERE WORKBASKET_KEY = #{workbasketSummaryImpl.key} and DOMAIN = #{workbasketSummaryImpl.domain " + "AND STATE = #{taskState}") @Results(value = { @Result(property = "taskId", column = "ID"), @@ -110,10 +119,12 @@ public interface TaskMapper { @Result(property = "note", column = "NOTE"), @Result(property = "priority", column = "PRIORITY"), @Result(property = "state", column = "STATE"), - @Result(property = "workbasketKey", column = "WORKBASKET_KEY"), @Result(property = "classificationSummaryImpl.category", column = "CLASSIFICATION_CATEGORY"), @Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"), + @Result(property = "classificationSummaryImpl.id", column = "CLASSIFICATION_ID"), + @Result(property = "workbasketSummaryImpl.id", column = "WORKBASKET_ID"), @Result(property = "workbasketSummaryImpl.key", column = "WORKBASKET_KEY"), + @Result(property = "workbasketSummaryImpl.domain", column = "DOMAIN"), @Result(property = "domain", column = "DOMAIN"), @Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"), @Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"), @@ -180,7 +191,8 @@ public interface TaskMapper { List findTaskSummariesByWorkbasketKey(@Param("workbasketKey") String workbasketKey); @Update("") void updateTransfered(@Param("taskIds") List taskIds, diff --git a/lib/taskana-core/src/main/java/pro/taskana/mappings/WorkbasketAccessMapper.java b/lib/taskana-core/src/main/java/pro/taskana/mappings/WorkbasketAccessMapper.java index a9a78a045..0c4fca886 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/mappings/WorkbasketAccessMapper.java +++ b/lib/taskana-core/src/main/java/pro/taskana/mappings/WorkbasketAccessMapper.java @@ -18,11 +18,11 @@ import pro.taskana.impl.WorkbasketAccessItemImpl; */ public interface WorkbasketAccessMapper { - @Select("SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 " + @Select("SELECT ID, WORKBASKET_ID, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 " + "FROM WORKBASKET_ACCESS_LIST WHERE ID = #{id}") @Results(value = { @Result(property = "id", column = "ID"), - @Result(property = "workbasketKey", column = "WORKBASKET_KEY"), + @Result(property = "workbasketId", column = "WORKBASKET_ID"), @Result(property = "accessId", column = "ACCESS_ID"), @Result(property = "permRead", column = "PERM_READ"), @Result(property = "permOpen", column = "PERM_OPEN"), @@ -43,11 +43,38 @@ public interface WorkbasketAccessMapper { @Result(property = "permCustom12", column = "PERM_CUSTOM_12")}) WorkbasketAccessItemImpl findById(@Param("id") String id); - @Select("SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 " - + "FROM WORKBASKET_ACCESS_LIST WHERE ACCESS_ID = #{accessId}") + // @Select("SELECT ID, WORKBASKET_ID, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, + // PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, + // PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 " + // + "FROM WORKBASKET_ACCESS_LIST WHERE ACCESS_ID = #{accessId}") + // @Results(value = { + // @Result(property = "id", column = "ID"), + // @Result(property = "workbasketId", column = "WORKBASKET_ID"), + // @Result(property = "accessId", column = "ACCESS_ID"), + // @Result(property = "permRead", column = "PERM_READ"), + // @Result(property = "permOpen", column = "PERM_OPEN"), + // @Result(property = "permAppend", column = "PERM_APPEND"), + // @Result(property = "permTransfer", column = "PERM_TRANSFER"), + // @Result(property = "permDistribute", column = "PERM_DISTRIBUTE"), + // @Result(property = "permCustom1", column = "PERM_CUSTOM_1"), + // @Result(property = "permCustom2", column = "PERM_CUSTOM_2"), + // @Result(property = "permCustom3", column = "PERM_CUSTOM_3"), + // @Result(property = "permCustom4", column = "PERM_CUSTOM_4"), + // @Result(property = "permCustom5", column = "PERM_CUSTOM_5"), + // @Result(property = "permCustom6", column = "PERM_CUSTOM_6"), + // @Result(property = "permCustom7", column = "PERM_CUSTOM_7"), + // @Result(property = "permCustom8", column = "PERM_CUSTOM_8"), + // @Result(property = "permCustom9", column = "PERM_CUSTOM_9"), + // @Result(property = "permCustom10", column = "PERM_CUSTOM_10"), + // @Result(property = "permCustom11", column = "PERM_CUSTOM_11"), + // @Result(property = "permCustom12", column = "PERM_CUSTOM_12")}) + // List findByAccessId(@Param("accessId") String accessId); + + @Select("SELECT ID, WORKBASKET_ID, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 " + + "FROM WORKBASKET_ACCESS_LIST WHERE WORKBASKET_ID = #{id}") @Results(value = { @Result(property = "id", column = "ID"), - @Result(property = "workbasketKey", column = "WORKBASKET_KEY"), + @Result(property = "workbasketId", column = "WORKBASKET_ID"), @Result(property = "accessId", column = "ACCESS_ID"), @Result(property = "permRead", column = "PERM_READ"), @Result(property = "permOpen", column = "PERM_OPEN"), @@ -66,54 +93,32 @@ public interface WorkbasketAccessMapper { @Result(property = "permCustom10", column = "PERM_CUSTOM_10"), @Result(property = "permCustom11", column = "PERM_CUSTOM_11"), @Result(property = "permCustom12", column = "PERM_CUSTOM_12")}) - List findByAccessId(@Param("accessId") String accessId); + List findByWorkbasketId(@Param("id") String id); - @Select("SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 " - + "FROM WORKBASKET_ACCESS_LIST WHERE WORKBASKET_KEY = #{key}") - @Results(value = { - @Result(property = "id", column = "ID"), - @Result(property = "workbasketKey", column = "WORKBASKET_KEY"), - @Result(property = "accessId", column = "ACCESS_ID"), - @Result(property = "permRead", column = "PERM_READ"), - @Result(property = "permOpen", column = "PERM_OPEN"), - @Result(property = "permAppend", column = "PERM_APPEND"), - @Result(property = "permTransfer", column = "PERM_TRANSFER"), - @Result(property = "permDistribute", column = "PERM_DISTRIBUTE"), - @Result(property = "permCustom1", column = "PERM_CUSTOM_1"), - @Result(property = "permCustom2", column = "PERM_CUSTOM_2"), - @Result(property = "permCustom3", column = "PERM_CUSTOM_3"), - @Result(property = "permCustom4", column = "PERM_CUSTOM_4"), - @Result(property = "permCustom5", column = "PERM_CUSTOM_5"), - @Result(property = "permCustom6", column = "PERM_CUSTOM_6"), - @Result(property = "permCustom7", column = "PERM_CUSTOM_7"), - @Result(property = "permCustom8", column = "PERM_CUSTOM_8"), - @Result(property = "permCustom9", column = "PERM_CUSTOM_9"), - @Result(property = "permCustom10", column = "PERM_CUSTOM_10"), - @Result(property = "permCustom11", column = "PERM_CUSTOM_11"), - @Result(property = "permCustom12", column = "PERM_CUSTOM_12")}) - List findByWorkbasketKey(@Param("key") String key); - - @Insert("INSERT INTO WORKBASKET_ACCESS_LIST (ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12) " - + "VALUES (#{workbasketAccessItem.id}, #{workbasketAccessItem.workbasketKey}, #{workbasketAccessItem.accessId}, #{workbasketAccessItem.permRead}, #{workbasketAccessItem.permOpen}, #{workbasketAccessItem.permAppend}, #{workbasketAccessItem.permTransfer}, #{workbasketAccessItem.permDistribute}, #{workbasketAccessItem.permCustom1}, #{workbasketAccessItem.permCustom2}, #{workbasketAccessItem.permCustom3}, #{workbasketAccessItem.permCustom4}, #{workbasketAccessItem.permCustom5}, #{workbasketAccessItem.permCustom6}, #{workbasketAccessItem.permCustom7}, #{workbasketAccessItem.permCustom8}, #{workbasketAccessItem.permCustom9}, #{workbasketAccessItem.permCustom10}, #{workbasketAccessItem.permCustom11}, #{workbasketAccessItem.permCustom12})") + @Insert("INSERT INTO WORKBASKET_ACCESS_LIST (ID, WORKBASKET_ID, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12) " + + "VALUES (#{workbasketAccessItem.id}, #{workbasketAccessItem.workbasketId}, #{workbasketAccessItem.accessId}, #{workbasketAccessItem.permRead}, #{workbasketAccessItem.permOpen}, #{workbasketAccessItem.permAppend}, #{workbasketAccessItem.permTransfer}, #{workbasketAccessItem.permDistribute}, #{workbasketAccessItem.permCustom1}, #{workbasketAccessItem.permCustom2}, #{workbasketAccessItem.permCustom3}, #{workbasketAccessItem.permCustom4}, #{workbasketAccessItem.permCustom5}, #{workbasketAccessItem.permCustom6}, #{workbasketAccessItem.permCustom7}, #{workbasketAccessItem.permCustom8}, #{workbasketAccessItem.permCustom9}, #{workbasketAccessItem.permCustom10}, #{workbasketAccessItem.permCustom11}, #{workbasketAccessItem.permCustom12})") @Options(keyProperty = "id", keyColumn = "ID") void insert(@Param("workbasketAccessItem") WorkbasketAccessItemImpl workbasketAccessItem); - @Update("UPDATE WORKBASKET_ACCESS_LIST SET WORKBASKET_KEY = #{workbasketAccessItem.workbasketKey}, ACCESS_ID = #{workbasketAccessItem.accessId}, PERM_READ = #{workbasketAccessItem.permRead}, PERM_OPEN = #{workbasketAccessItem.permOpen}, PERM_APPEND = #{workbasketAccessItem.permAppend}, PERM_TRANSFER = #{workbasketAccessItem.permTransfer}, PERM_DISTRIBUTE = #{workbasketAccessItem.permDistribute}, PERM_CUSTOM_1 = #{workbasketAccessItem.permCustom1}, PERM_CUSTOM_2 = #{workbasketAccessItem.permCustom2}, PERM_CUSTOM_3 = #{workbasketAccessItem.permCustom3}, PERM_CUSTOM_4 = #{workbasketAccessItem.permCustom4}, PERM_CUSTOM_5 = #{workbasketAccessItem.permCustom5}, PERM_CUSTOM_6 = #{workbasketAccessItem.permCustom6}, PERM_CUSTOM_7 = #{workbasketAccessItem.permCustom7}, PERM_CUSTOM_8 = #{workbasketAccessItem.permCustom8}, PERM_CUSTOM_9 = #{workbasketAccessItem.permCustom9}, PERM_CUSTOM_10 = #{workbasketAccessItem.permCustom10}, PERM_CUSTOM_11 = #{workbasketAccessItem.permCustom11}, PERM_CUSTOM_12 = #{workbasketAccessItem.permCustom12} " + @Update("UPDATE WORKBASKET_ACCESS_LIST SET WORKBASKET_ID = #{workbasketAccessItem.workbasketId}, ACCESS_ID = #{workbasketAccessItem.accessId}, PERM_READ = #{workbasketAccessItem.permRead}, PERM_OPEN = #{workbasketAccessItem.permOpen}, PERM_APPEND = #{workbasketAccessItem.permAppend}, PERM_TRANSFER = #{workbasketAccessItem.permTransfer}, PERM_DISTRIBUTE = #{workbasketAccessItem.permDistribute}, PERM_CUSTOM_1 = #{workbasketAccessItem.permCustom1}, PERM_CUSTOM_2 = #{workbasketAccessItem.permCustom2}, PERM_CUSTOM_3 = #{workbasketAccessItem.permCustom3}, PERM_CUSTOM_4 = #{workbasketAccessItem.permCustom4}, PERM_CUSTOM_5 = #{workbasketAccessItem.permCustom5}, PERM_CUSTOM_6 = #{workbasketAccessItem.permCustom6}, PERM_CUSTOM_7 = #{workbasketAccessItem.permCustom7}, PERM_CUSTOM_8 = #{workbasketAccessItem.permCustom8}, PERM_CUSTOM_9 = #{workbasketAccessItem.permCustom9}, PERM_CUSTOM_10 = #{workbasketAccessItem.permCustom10}, PERM_CUSTOM_11 = #{workbasketAccessItem.permCustom11}, PERM_CUSTOM_12 = #{workbasketAccessItem.permCustom12} " + "WHERE id = #{workbasketAccessItem.id}") void update(@Param("workbasketAccessItem") WorkbasketAccessItemImpl workbasketAccessItem); @Delete("DELETE FROM WORKBASKET_ACCESS_LIST where id = #{id}") void delete(@Param("id") String id); - @Delete("DELETE FROM WORKBASKET_ACCESS_LIST where WORKBASKET_KEY = #{workbasketKey}") - void deleteAllForWorkbasketkey(@Param("workbasketKey") String workbasketKey); + @Delete("DELETE FROM WORKBASKET_ACCESS_LIST where WORKBASKET_ID = #{workbasketId}") + void deleteAllForWorkbasketkey(@Param("workbasketId") String workbasketId); @Select("") @Results(value = { + @Result(property = "id", column = "ID"), + @Result(property = "workbasketId", column = "WORKBASKET_ID"), + @Result(property = "accessId", column = "ACCESS_ID"), @Result(property = "permRead", column = "P_READ"), @Result(property = "permOpen", column = "P_OPEN"), @Result(property = "permAppend", column = "P_APPEND"), @@ -132,32 +137,32 @@ public interface WorkbasketAccessMapper { @Result(property = "permCustom11", column = "P_CUSTOM_11"), @Result(property = "permCustom12", column = "P_CUSTOM_12")}) WorkbasketAccessItemImpl findByWorkbasketAndAccessId( - @Param("workbasketKey") String workbasketKey, @Param("accessIds") List accessIds); + @Param("workbasketId") String workbasketId, @Param("accessIds") List accessIds); - @Select("") + + "AND a.PERM_OPEN" + + "a.PERM_READ" + + "a.PERM_APPEND" + + "a.PERM_TRANSFER" + + "a.PERM_DISTRIBUTE" + + "a.PERM_CUSTOM_1" + + "a.PERM_CUSTOM_2" + + "a.PERM_CUSTOM_3" + + "a.PERM_CUSTOM_4" + + "a.PERM_CUSTOM_5" + + "a.PERM_CUSTOM_6" + + "a.PERM_CUSTOM_7" + + "a.PERM_CUSTOM_8" + + "a.PERM_CUSTOM_9" + + "a.PERM_CUSTOM_10" + + "a.PERM_CUSTOM_11" + + "a.PERM_CUSTOM_12 = 1") @Results(value = { @Result(property = "id", column = "ID"), - @Result(property = "workbasketKey", column = "WORKBASKET_KEY"), + @Result(property = "workbasketId", column = "WORKBASKET_ID"), @Result(property = "accessId", column = "ACCESS_ID"), @Result(property = "permRead", column = "PERM_READ"), @Result(property = "permOpen", column = "PERM_OPEN"), @@ -176,15 +181,14 @@ public interface WorkbasketAccessMapper { @Result(property = "permCustom10", column = "PERM_CUSTOM_10"), @Result(property = "permCustom11", column = "PERM_CUSTOM_11"), @Result(property = "permCustom12", column = "PERM_CUSTOM_12")}) - List findByWorkbasketAndAccessIdAndAuthorization( - @Param("workbasketKey") String workbasketKey, @Param("accessIds") List accessIds, - @Param("authorization") String authorization); + List findByWorkbasketAccessByWorkbasketKeyDomainAndAuthorization( + @Param("workbasketKey") String workbasketKey, @Param("domain") String domain, + @Param("accessIds") List accessIds, @Param("authorization") String authorization); - @Select("