From 6a122c5afd634c262281e625b9f1d5875b71f07c Mon Sep 17 00:00:00 2001 From: BVier <26220150+BVier@users.noreply.github.com> Date: Wed, 25 Jul 2018 14:39:52 +0200 Subject: [PATCH] TSK-643: Summarize all custom-querys in task and classification --- .../java/pro/taskana/ClassificationQuery.java | 230 ++--------------- .../src/main/java/pro/taskana/TaskQuery.java | 100 +------- .../taskana/impl/ClassificationQueryImpl.java | 239 +++++++++--------- .../java/pro/taskana/impl/TaskQueryImpl.java | 92 +++---- .../QueryClassificationAccTest.java | 100 ++++---- .../acceptance/task/QueryTasksAccTest.java | 97 ++++++- .../taskana/impl/TestClassificationQuery.java | 111 +------- ...ificationServiceImplIntAutoCommitTest.java | 4 +- ...ssificationServiceImplIntExplicitTest.java | 4 +- .../rest/ClassificationController.java | 18 +- 10 files changed, 348 insertions(+), 647 deletions(-) diff --git a/lib/taskana-core/src/main/java/pro/taskana/ClassificationQuery.java b/lib/taskana-core/src/main/java/pro/taskana/ClassificationQuery.java index 302922ce1..0451718b3 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/ClassificationQuery.java +++ b/lib/taskana-core/src/main/java/pro/taskana/ClassificationQuery.java @@ -1,5 +1,7 @@ package pro.taskana; +import pro.taskana.exceptions.InvalidArgumentException; + /** * ClassificationQuery for generating dynamic sql. */ @@ -169,148 +171,30 @@ public interface ClassificationQuery extends BaseQuery { ClassificationQuery applicationEntryPointLike(String... applicationEntryPointLike); /** - * Add custom1 to your query. + * Add a custom to your query. * - * @param custom1In - * filter for custom1 + * @param num + * the number of the custom as String (eg "4") + * @param customIn + * filter for this custom * @return the query + * @throws InvalidArgumentException + * when the number of the custom is incorrect. */ - ClassificationQuery custom1In(String... custom1In); + ClassificationQuery customAttributeIn(String num, String... customIn) throws InvalidArgumentException; /** - * Add custom1 to your query. + * Add a custom to your query. * - * @param custom1Like - * filter for custom1 with a LIKE-query + * @param num + * the number of the custom as String (eg "4") + * @param customLike + * filter for this custom with a LIKE-query * @return the query + * @throws InvalidArgumentException + * when the number of the custom is incorrect. */ - ClassificationQuery custom1Like(String... custom1Like); - - /** - * Add custom2 to your query. - * - * @param custom2In - * filter for custom2 - * @return the query - */ - ClassificationQuery custom2In(String... custom2In); - - /** - * Add custom2 to your query. - * - * @param custom2Like - * filter for custom2 with a LIKE-query - * @return the query - */ - ClassificationQuery custom2Like(String... custom2Like); - - /** - * Add custom3 to your query. - * - * @param custom3In - * filter for custom3 - * @return the query - */ - ClassificationQuery custom3In(String... custom3In); - - /** - * Add custom3 to your query. - * - * @param custom3Like - * filter for custom3 with a LIKE-query - * @return the query - */ - ClassificationQuery custom3Like(String... custom3Like); - - /** - * Add custom4 to your query. - * - * @param custom4In - * filter for custom4 - * @return the query - */ - ClassificationQuery custom4In(String... custom4In); - - /** - * Add custom4 to your query. - * - * @param custom4Like - * filter for custom4 with a LIKE-query - * @return the query - */ - ClassificationQuery custom4Like(String... custom4Like); - - /** - * Add custom5 to your query. - * - * @param custom5In - * filter for custom5 - * @return the query - */ - ClassificationQuery custom5In(String... custom5In); - - /** - * Add custom5 to your query. - * - * @param custom5Like - * filter for custom5 with a LIKE-query - * @return the query - */ - ClassificationQuery custom5Like(String... custom5Like); - - /** - * Add custom6 to your query. - * - * @param custom6In - * filter for custom6 - * @return the query - */ - ClassificationQuery custom6In(String... custom6In); - - /** - * Add custom6 to your query. - * - * @param custom6Like - * filter for custom6 with a LIKE-query - * @return the query - */ - ClassificationQuery custom6Like(String... custom6Like); - - /** - * Add custom7 to your query. - * - * @param custom7In - * filter for custom7 - * @return the query - */ - ClassificationQuery custom7In(String... custom7In); - - /** - * Add custom7 to your query. - * - * @param custom7Like - * filter for custom7 with a LIKE-query - * @return the query - */ - ClassificationQuery custom7Like(String... custom7Like); - - /** - * Add custom8 to your query. - * - * @param custom8In - * filter for custom8 - * @return the query - */ - ClassificationQuery custom8In(String... custom8In); - - /** - * Add custom8 to your query. - * - * @param custom8Like - * filter for custom8 with a LIKE-query - * @return the query - */ - ClassificationQuery custom8Like(String... custom8Like); + ClassificationQuery customAttributeLike(String num, String... customLike) throws InvalidArgumentException; /** * Sort the query result by key. @@ -403,82 +287,16 @@ public interface ClassificationQuery extends BaseQuery { ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection); /** - * Sort the query result by custom property 1. + * Sort the query result by a custom. * + * @param num + * the number of the custom as String (eg "4") * @param sortDirection * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, * the result is sorted in ascending order * @return the query + * @throws InvalidArgumentException + * when the number of the custom is incorrect. */ - ClassificationQuery orderByCustom1(SortDirection sortDirection); - - /** - * Sort the query result by custom property 2. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - ClassificationQuery orderByCustom2(SortDirection sortDirection); - - /** - * Sort the query result by custom property 3. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - ClassificationQuery orderByCustom3(SortDirection sortDirection); - - /** - * Sort the query result by custom property 4. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - ClassificationQuery orderByCustom4(SortDirection sortDirection); - - /** - * Sort the query result by custom property 5. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - ClassificationQuery orderByCustom5(SortDirection sortDirection); - - /** - * Sort the query result by custom property 6. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - ClassificationQuery orderByCustom6(SortDirection sortDirection); - - /** - * Sort the query result by custom property 7. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - ClassificationQuery orderByCustom7(SortDirection sortDirection); - - /** - * Sort the query result by custom property 8. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - ClassificationQuery orderByCustom8(SortDirection sortDirection); + ClassificationQuery orderByCustomAttribute(String num, SortDirection sortDirection) throws InvalidArgumentException; } 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 a664ca5b0..f8ff18815 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java +++ b/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java @@ -682,104 +682,20 @@ public interface TaskQuery extends BaseQuery { TaskQuery orderByWorkbasketKey(SortDirection sortDirection); /** - * This method sorts the query result according to the custom1 value. + * This method sorts the query result according to the value of a custom field. + * The custom field is choosen by parameter num. * + * @param num + * identifies which custom attribute is affected. Taskana concatenates "custom_" with num and the + * resulting String must match the name of the database column that contains the custom attribute. Valid + * values are "1", "2" .. "16" * @param sortDirection * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, * the result is sorted in ascending order * @return the query + * @throws InvalidArgumentException when number is not a valid number between 1 and 16 */ - TaskQuery orderByCustom1(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom2 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom2(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom3 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom3(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom4 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom4(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom5 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom5(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom6 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom6(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom7 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom7(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom8 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom8(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom9 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom9(SortDirection sortDirection); - - /** - * This method sorts the query result according to the custom10 value. - * - * @param sortDirection - * Determines whether the result is sorted in ascending or descending order. If sortDirection is null, - * the result is sorted in ascending order - * @return the query - */ - TaskQuery orderByCustom10(SortDirection sortDirection); + TaskQuery orderByCustomAttribute(String num, SortDirection sortDirection) throws InvalidArgumentException; /** * Filter for summaries which are containing one of the given taskIds. diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationQueryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationQueryImpl.java index 4d224b3c7..78e042a7b 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationQueryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationQueryImpl.java @@ -13,6 +13,7 @@ import pro.taskana.ClassificationQuery; import pro.taskana.ClassificationSummary; import pro.taskana.TaskanaEngine; import pro.taskana.TimeInterval; +import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.TaskanaRuntimeException; import pro.taskana.impl.util.LoggerUtils; @@ -191,98 +192,98 @@ public class ClassificationQueryImpl implements ClassificationQuery { } @Override - public ClassificationQuery custom1In(String... custom1In) { - this.custom1In = custom1In; + public ClassificationQuery customAttributeIn(String number, String... customIn) throws InvalidArgumentException { + int num = 0; + try { + num = Integer.parseInt(number); + } catch (NumberFormatException e) { + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16", + e.getCause()); + } + if (customIn.length == 0) { + throw new InvalidArgumentException( + "At least one string has to be provided as a search parameter"); + } + + switch (num) { + case 1: + this.custom1In = customIn; + break; + case 2: + this.custom2In = customIn; + break; + case 3: + this.custom3In = customIn; + break; + case 4: + this.custom4In = customIn; + break; + case 5: + this.custom5In = customIn; + break; + case 6: + this.custom6In = customIn; + break; + case 7: + this.custom7In = customIn; + break; + case 8: + this.custom8In = customIn; + break; + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 8"); + } + return this; } @Override - public ClassificationQuery custom1Like(String... custom1Like) { - this.custom1Like = toUpperCopy(custom1Like); - return this; - } + public ClassificationQuery customAttributeLike(String number, String... customLike) throws InvalidArgumentException { + int num = 0; + try { + num = Integer.parseInt(number); + } catch (NumberFormatException e) { + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16", + e.getCause()); + } + if (customLike.length == 0) { + throw new InvalidArgumentException( + "At least one string has to be provided as a search parameter"); + } - @Override - public ClassificationQuery custom2In(String... custom2In) { - this.custom2In = custom2In; - return this; - } + switch (num) { + case 1: + this.custom1Like = toUpperCopy(customLike); + break; + case 2: + this.custom2Like = toUpperCopy(customLike); + break; + case 3: + this.custom3Like = toUpperCopy(customLike); + break; + case 4: + this.custom4Like = toUpperCopy(customLike); + break; + case 5: + this.custom5Like = toUpperCopy(customLike); + break; + case 6: + this.custom6Like = toUpperCopy(customLike); + break; + case 7: + this.custom7Like = toUpperCopy(customLike); + break; + case 8: + this.custom8Like = toUpperCopy(customLike); + break; + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } - @Override - public ClassificationQuery custom2Like(String... custom2Like) { - this.custom2Like = toUpperCopy(custom2Like); - return this; - } - - @Override - public ClassificationQuery custom3In(String... custom3In) { - this.custom3In = custom3In; - return this; - } - - @Override - public ClassificationQuery custom3Like(String... custom3Like) { - this.custom3Like = toUpperCopy(custom3Like); - return this; - } - - @Override - public ClassificationQuery custom4In(String... custom4In) { - this.custom4In = custom4In; - return this; - } - - @Override - public ClassificationQuery custom4Like(String... custom4Like) { - this.custom4Like = toUpperCopy(custom4Like); - return this; - } - - @Override - public ClassificationQuery custom5In(String... custom5In) { - this.custom5In = custom5In; - return this; - } - - @Override - public ClassificationQuery custom5Like(String... custom5Like) { - this.custom5Like = toUpperCopy(custom5Like); - return this; - } - - @Override - public ClassificationQuery custom6In(String... custom6In) { - this.custom6In = custom6In; - return this; - } - - @Override - public ClassificationQuery custom6Like(String... custom6Like) { - this.custom6Like = toUpperCopy(custom6Like); - return this; - } - - @Override - public ClassificationQuery custom7In(String... custom7In) { - this.custom7In = custom7In; - return this; - } - - @Override - public ClassificationQuery custom7Like(String... custom7Like) { - this.custom7Like = toUpperCopy(custom7Like); - return this; - } - - @Override - public ClassificationQuery custom8In(String... custom8In) { - this.custom8In = custom8In; - return this; - } - - @Override - public ClassificationQuery custom8Like(String... custom8Like) { - this.custom8Like = toUpperCopy(custom8Like); return this; } @@ -332,43 +333,37 @@ public class ClassificationQueryImpl implements ClassificationQuery { } @Override - public ClassificationQuery orderByCustom1(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_1", sortDirection); - } + public ClassificationQuery orderByCustomAttribute(String number, SortDirection sortDirection) throws InvalidArgumentException { + int num = 0; + try { + num = Integer.parseInt(number); + } catch (NumberFormatException e) { + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16", + e.getCause()); + } - @Override - public ClassificationQuery orderByCustom2(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_2", sortDirection); - } - - @Override - public ClassificationQuery orderByCustom3(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_3", sortDirection); - } - - @Override - public ClassificationQuery orderByCustom4(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_4", sortDirection); - } - - @Override - public ClassificationQuery orderByCustom5(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_5", sortDirection); - } - - @Override - public ClassificationQuery orderByCustom6(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_6", sortDirection); - } - - @Override - public ClassificationQuery orderByCustom7(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_7", sortDirection); - } - - @Override - public ClassificationQuery orderByCustom8(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_8", sortDirection); + switch (num) { + case 1: + return addOrderCriteria("CUSTOM_1", sortDirection); + case 2: + return addOrderCriteria("CUSTOM_2", sortDirection); + case 3: + return addOrderCriteria("CUSTOM_3", sortDirection); + case 4: + return addOrderCriteria("CUSTOM_4", sortDirection); + case 5: + return addOrderCriteria("CUSTOM_5", sortDirection); + case 6: + return addOrderCriteria("CUSTOM_6", sortDirection); + case 7: + return addOrderCriteria("CUSTOM_7", sortDirection); + case 8: + return addOrderCriteria("CUSTOM_8", sortDirection); + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } } @Override 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 2dc4ea85d..d03dbc6d9 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 @@ -649,53 +649,53 @@ public class TaskQueryImpl implements TaskQuery { } @Override - public TaskQuery orderByCustom1(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_1", sortDirection); - } + public TaskQuery orderByCustomAttribute(String number, SortDirection sortDirection) throws InvalidArgumentException { + int num = 0; + try { + num = Integer.parseInt(number); + } catch (NumberFormatException e) { + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16", + e.getCause()); + } - @Override - public TaskQuery orderByCustom2(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_2", sortDirection); - } - - @Override - public TaskQuery orderByCustom3(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_3", sortDirection); - } - - @Override - public TaskQuery orderByCustom4(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_4", sortDirection); - } - - @Override - public TaskQuery orderByCustom5(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_5", sortDirection); - } - - @Override - public TaskQuery orderByCustom6(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_6", sortDirection); - } - - @Override - public TaskQuery orderByCustom7(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_7", sortDirection); - } - - @Override - public TaskQuery orderByCustom8(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_8", sortDirection); - } - - @Override - public TaskQuery orderByCustom9(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_9", sortDirection); - } - - @Override - public TaskQuery orderByCustom10(SortDirection sortDirection) { - return addOrderCriteria("CUSTOM_10", sortDirection); + switch (num) { + case 1: + return addOrderCriteria("CUSTOM_1", sortDirection); + case 2: + return addOrderCriteria("CUSTOM_2", sortDirection); + case 3: + return addOrderCriteria("CUSTOM_3", sortDirection); + case 4: + return addOrderCriteria("CUSTOM_4", sortDirection); + case 5: + return addOrderCriteria("CUSTOM_5", sortDirection); + case 6: + return addOrderCriteria("CUSTOM_6", sortDirection); + case 7: + return addOrderCriteria("CUSTOM_7", sortDirection); + case 8: + return addOrderCriteria("CUSTOM_8", sortDirection); + case 9: + return addOrderCriteria("CUSTOM_9", sortDirection); + case 10: + return addOrderCriteria("CUSTOM_10", sortDirection); + case 11: + return addOrderCriteria("CUSTOM_11", sortDirection); + case 12: + return addOrderCriteria("CUSTOM_12", sortDirection); + case 13: + return addOrderCriteria("CUSTOM_13", sortDirection); + case 14: + return addOrderCriteria("CUSTOM_14", sortDirection); + case 15: + return addOrderCriteria("CUSTOM_15", sortDirection); + case 16: + return addOrderCriteria("CUSTOM_16", sortDirection); + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } } @Override diff --git a/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java b/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java index cd1f67df1..93f1e0b75 100644 --- a/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java +++ b/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java @@ -185,10 +185,10 @@ public class QueryClassificationAccTest extends AbstractAccTest { } @Test - public void testGetClassificationsWithCustom1() { + public void testGetClassificationsWithCustom1() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List classifications = classificationService.createClassificationQuery() - .custom1Like("VNR,RVNR,KOLVNR", "VNR") + .customAttributeIn("1", "VNR,RVNR,KOLVNR", "VNR") .domainIn("DOMAIN_A") .list(); assertNotNull(classifications); @@ -196,10 +196,10 @@ public class QueryClassificationAccTest extends AbstractAccTest { } @Test - public void testGetClassificationsWithCustom1Like() { + public void testGetClassificationsWithCustom1Like() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List classifications = classificationService.createClassificationQuery() - .custom1Like("%RVNR%") + .customAttributeLike("1", "%RVNR%") .domainIn("DOMAIN_A") .typeIn("TASK") .list(); @@ -208,11 +208,11 @@ public class QueryClassificationAccTest extends AbstractAccTest { } @Test - public void testGetClassificationsWithParentAndCustom2() { + public void testGetClassificationsWithParentAndCustom2() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List classifications = classificationService.createClassificationQuery() .parentIdIn("CLI:100000000000000000000000000000000004") - .custom2Like("TEXT_1", "TEXT_2") + .customAttributeIn("2", "TEXT_1", "TEXT_2") .list(); // zwei tests assertNotNull(classifications); @@ -323,127 +323,127 @@ public class QueryClassificationAccTest extends AbstractAccTest { } @Test - public void testQueryForCustom1In() { + public void testQueryForCustom1In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom1In("VNR,RVNR,KOLVNR, ANR", "VNR") + .customAttributeIn("1", "VNR,RVNR,KOLVNR, ANR", "VNR") .list(); assertEquals(17, results.size()); } @Test - public void testQueryForCustom2In() { + public void testQueryForCustom2In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom2In("CUSTOM2", "custom2") + .customAttributeIn("2", "CUSTOM2", "custom2") .list(); assertEquals(3, results.size()); } @Test - public void testQueryForCustom3In() { + public void testQueryForCustom3In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom3In("Custom3", "custom3") + .customAttributeIn("3", "Custom3", "custom3") .list(); assertEquals(3, results.size()); } @Test - public void testQueryForCustom4In() { + public void testQueryForCustom4In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom4In("custom4") + .customAttributeIn("4", "custom4") .list(); assertEquals(3, results.size()); } @Test - public void testQueryForCustom5In() { + public void testQueryForCustom5In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom5In("custom5") + .customAttributeIn("5", "custom5") .list(); assertEquals(3, results.size()); } @Test - public void testQueryForCustom6In() { + public void testQueryForCustom6In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom6In("custom6") + .customAttributeIn("6", "custom6") .list(); assertEquals(3, results.size()); } @Test - public void testQueryForCustom7In() { + public void testQueryForCustom7In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom7In("custom7", "custom_7") + .customAttributeIn("7", "custom7", "custom_7") .list(); assertEquals(3, results.size()); } @Test - public void testQueryForCustom8In() { + public void testQueryForCustom8In() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom8In("custom_8", "custom8") + .customAttributeIn("8", "custom_8", "custom8") .list(); assertEquals(3, results.size()); } @Test - public void testQueryForCustom3Like() { + public void testQueryForCustom3Like() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom3Like("cus%") + .customAttributeLike("3", "cus%") .list(); assertEquals(4, results.size()); } @Test - public void testQueryForCustom4Like() { + public void testQueryForCustom4Like() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom4Like("cus%") + .customAttributeLike("4", "cus%") .list(); assertEquals(4, results.size()); } @Test - public void testQueryForCustom5Like() { + public void testQueryForCustom5Like() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom5Like("cus%") + .customAttributeLike("5", "cus%") .list(); assertEquals(4, results.size()); } @Test - public void testQueryForCustom6Like() { + public void testQueryForCustom6Like() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom6Like("cus%") + .customAttributeLike("6", "cus%") .list(); assertEquals(4, results.size()); } @Test - public void testQueryForCustom7Like() { + public void testQueryForCustom7Like() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom7Like("cus%") + .customAttributeLike("7", "cus%") .list(); assertEquals(4, results.size()); } @Test - public void testQueryForCustom8Like() { + public void testQueryForCustom8Like() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .custom8Like("cus%") + .customAttributeLike("8", "cus%") .list(); assertEquals(4, results.size()); } @@ -542,10 +542,10 @@ public class QueryClassificationAccTest extends AbstractAccTest { } @Test - public void testQueryForOrderByCustom1Desc() { + public void testQueryForOrderByCustom1Desc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom1(desc) + .orderByCustomAttribute("1", desc) .orderByDomain(asc) .orderByServiceLevel(desc) .list(); @@ -553,10 +553,10 @@ public class QueryClassificationAccTest extends AbstractAccTest { } @Test - public void testQueryForOrderByCustom2Asc() { + public void testQueryForOrderByCustom2Asc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom2(asc) + .orderByCustomAttribute("2", asc) .orderByName(asc) .orderByParentKey(asc) .orderByDomain(asc) @@ -565,60 +565,60 @@ public class QueryClassificationAccTest extends AbstractAccTest { } @Test - public void testQueryForOrderByCustom3Desc() { + public void testQueryForOrderByCustom3Desc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom3(desc) + .orderByCustomAttribute("3", desc) .orderByName(asc) .list(); assertEquals("CLI:100000000000000000000000000000000014", results.get(0).getId()); } @Test - public void testQueryForOrderByCustom4Asc() { + public void testQueryForOrderByCustom4Asc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom4(asc) + .orderByCustomAttribute("4", asc) .orderByName(asc) .list(); assertEquals("CLI:100000000000000000000000000000000010", results.get(results.size() - 5).getId()); } @Test - public void testQueryForOrderByCustom5Desc() { + public void testQueryForOrderByCustom5Desc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom5(desc) + .orderByCustomAttribute("5", desc) .orderByName(asc) .list(); assertEquals("CLI:100000000000000000000000000000000011", results.get(0).getId()); } @Test - public void testQueryForOrderByCustom6Asc() { + public void testQueryForOrderByCustom6Asc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom6(asc) + .orderByCustomAttribute("6", asc) .orderByName(asc) .list(); assertEquals("CLI:100000000000000000000000000000000010", results.get(results.size() - 4).getId()); } @Test - public void testQueryForOrderByCustom7Desc() { + public void testQueryForOrderByCustom7Desc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom7(desc) + .orderByCustomAttribute("7", desc) .orderByName(asc) .list(); assertEquals("CLI:100000000000000000000000000000000011", results.get(0).getId()); } @Test - public void testQueryForOrderByCustom8Asc() { + public void testQueryForOrderByCustom8Asc() throws InvalidArgumentException { ClassificationService classificationService = taskanaEngine.getClassificationService(); List results = classificationService.createClassificationQuery() - .orderByCustom8(asc) + .orderByCustomAttribute("8", asc) .orderByName(asc) .list(); assertEquals("CLI:100000000000000000000000000000000010", results.get(results.size() - 4).getId()); diff --git a/lib/taskana-core/src/test/java/acceptance/task/QueryTasksAccTest.java b/lib/taskana-core/src/test/java/acceptance/task/QueryTasksAccTest.java index 90783b06c..3e5c04f05 100644 --- a/lib/taskana-core/src/test/java/acceptance/task/QueryTasksAccTest.java +++ b/lib/taskana-core/src/test/java/acceptance/task/QueryTasksAccTest.java @@ -989,7 +989,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom1Asc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom1(asc) + .orderByCustomAttribute("1", asc) .list(); assertEquals("custom1", results.get(0).getCustomAttribute("1")); } @@ -1000,7 +1000,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom2Desc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom2(desc) + .orderByCustomAttribute("2", desc) .list(); assertEquals("custom2", results.get(0).getCustomAttribute("2")); } @@ -1011,7 +1011,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom3Asc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom3(asc) + .orderByCustomAttribute("3", asc) .list(); assertEquals("custom3", results.get(0).getCustomAttribute("3")); } @@ -1022,7 +1022,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom4Desc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom4(desc) + .orderByCustomAttribute("4", desc) .list(); assertEquals("rty", results.get(0).getCustomAttribute("4")); } @@ -1033,7 +1033,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom5Asc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom5(asc) + .orderByCustomAttribute("5", asc) .list(); assertEquals("al", results.get(0).getCustomAttribute("5")); } @@ -1044,7 +1044,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom6Desc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom6(desc) + .orderByCustomAttribute("6", desc) .list(); assertEquals("vvg", results.get(0).getCustomAttribute("6")); } @@ -1055,7 +1055,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom7Asc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom7(asc) + .orderByCustomAttribute("7", asc) .list(); assertEquals("custom7", results.get(0).getCustomAttribute("7")); } @@ -1066,7 +1066,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom8Desc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom8(desc) + .orderByCustomAttribute("8", desc) .list(); assertEquals("lnp", results.get(0).getCustomAttribute("8")); } @@ -1077,7 +1077,7 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom9Asc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom9(asc) + .orderByCustomAttribute("9", asc) .list(); assertEquals("bbq", results.get(0).getCustomAttribute("9")); } @@ -1088,8 +1088,85 @@ public class QueryTasksAccTest extends AbstractAccTest { public void testQueryForOrderByCustom10Desc() throws InvalidArgumentException { TaskService taskService = taskanaEngine.getTaskService(); List results = taskService.createTaskQuery() - .orderByCustom10(desc) + .orderByCustomAttribute("10", desc) .list(); assertEquals("ert", results.get(0).getCustomAttribute("10")); } + + @WithAccessId( + userName = "admin") + @Test + public void testQueryForOrderByCustom11Desc() throws InvalidArgumentException { + TaskService taskService = taskanaEngine.getTaskService(); + List results = taskService.createTaskQuery() + .orderByCustomAttribute("11", desc) + .list(); + assertEquals("ert", results.get(0).getCustomAttribute("11")); + } + + @WithAccessId( + userName = "admin") + @Test + public void testQueryForOrderByCustom12Asc() throws InvalidArgumentException { + TaskService taskService = taskanaEngine.getTaskService(); + List results = taskService.createTaskQuery() + .orderByCustomAttribute("12", asc) + .list(); + assertEquals("custom12", results.get(0).getCustomAttribute("12")); + } + + @WithAccessId( + userName = "admin") + @Test + public void testQueryForOrderByCustom13Desc() throws InvalidArgumentException { + TaskService taskService = taskanaEngine.getTaskService(); + List results = taskService.createTaskQuery() + .orderByCustomAttribute("13", desc) + .list(); + assertEquals("ert", results.get(0).getCustomAttribute("13")); + } + + @WithAccessId( + userName = "admin") + @Test + public void testQueryForOrderByCustom14Asc() throws InvalidArgumentException { + TaskService taskService = taskanaEngine.getTaskService(); + List results = taskService.createTaskQuery() + .orderByCustomAttribute("14", asc) + .list(); + assertEquals("abc", results.get(0).getCustomAttribute("14")); + } + + @WithAccessId( + userName = "admin") + @Test + public void testQueryForOrderByCustom15Desc() throws InvalidArgumentException { + TaskService taskService = taskanaEngine.getTaskService(); + List results = taskService.createTaskQuery() + .orderByCustomAttribute("15", desc) + .list(); + assertEquals("ert", results.get(0).getCustomAttribute("15")); + } + + @WithAccessId( + userName = "admin") + @Test + public void testQueryForOrderByCustom16Asc() throws InvalidArgumentException { + TaskService taskService = taskanaEngine.getTaskService(); + List results = taskService.createTaskQuery() + .orderByCustomAttribute("16", asc) + .list(); + assertEquals("custom16", results.get(0).getCustomAttribute("16")); + } + + @WithAccessId( + userName = "admin") + @Test + public void testQueryForOrderWithDirectionNull() throws InvalidArgumentException { + TaskService taskService = taskanaEngine.getTaskService(); + List results = taskService.createTaskQuery() + .orderByPrimaryObjectReferenceSystemInstance(null) + .list(); + assertEquals("00", results.get(0).getPrimaryObjRef().getSystemInstance()); + } } diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/TestClassificationQuery.java b/lib/taskana-core/src/test/java/pro/taskana/impl/TestClassificationQuery.java index 10e698d3f..76b8fe360 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/TestClassificationQuery.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/TestClassificationQuery.java @@ -109,82 +109,12 @@ public class TestClassificationQuery implements ClassificationQuery { } @Override - public ClassificationQuery custom1In(String... customFields) { + public ClassificationQuery customAttributeIn(String num, String... customFields) { return this; } @Override - public ClassificationQuery custom1Like(String... custom1Like) { - return this; - } - - @Override - public ClassificationQuery custom2In(String... custom2In) { - return this; - } - - @Override - public ClassificationQuery custom2Like(String... custom2Like) { - return this; - } - - @Override - public ClassificationQuery custom3In(String... custom3In) { - return this; - } - - @Override - public ClassificationQuery custom3Like(String... custom3Like) { - return this; - } - - @Override - public ClassificationQuery custom4In(String... custom4In) { - return this; - } - - @Override - public ClassificationQuery custom4Like(String... custom4Like) { - return this; - } - - @Override - public ClassificationQuery custom5In(String... custom5In) { - return this; - } - - @Override - public ClassificationQuery custom5Like(String... custom5Like) { - return this; - } - - @Override - public ClassificationQuery custom6In(String... custom6In) { - return this; - } - - @Override - public ClassificationQuery custom6Like(String... custom6Like) { - return this; - } - - @Override - public ClassificationQuery custom7In(String... custom7In) { - return this; - } - - @Override - public ClassificationQuery custom7Like(String... custom7Like) { - return this; - } - - @Override - public ClassificationQuery custom8In(String... custom8In) { - return this; - } - - @Override - public ClassificationQuery custom8Like(String... custom8Like) { + public ClassificationQuery customAttributeLike(String num, String... custom1Like) { return this; } @@ -256,42 +186,7 @@ public class TestClassificationQuery implements ClassificationQuery { } @Override - public ClassificationQuery orderByCustom1(SortDirection sortDirection) { - return this; - } - - @Override - public ClassificationQuery orderByCustom2(SortDirection sortDirection) { - return this; - } - - @Override - public ClassificationQuery orderByCustom3(SortDirection sortDirection) { - return this; - } - - @Override - public ClassificationQuery orderByCustom4(SortDirection sortDirection) { - return this; - } - - @Override - public ClassificationQuery orderByCustom5(SortDirection sortDirection) { - return this; - } - - @Override - public ClassificationQuery orderByCustom6(SortDirection sortDirection) { - return this; - } - - @Override - public ClassificationQuery orderByCustom7(SortDirection sortDirection) { - return this; - } - - @Override - public ClassificationQuery orderByCustom8(SortDirection sortDirection) { + public ClassificationQuery orderByCustomAttribute(String num, SortDirection sortDirection) { return this; } diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java index 090149e28..344f183c6 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java @@ -268,10 +268,10 @@ public class ClassificationServiceImplIntAutoCommitTest { List list = classificationService.createClassificationQuery() .descriptionLike("DESC1") - .custom1In("custom1") + .customAttributeIn("1", "custom1") .list(); Assert.assertEquals(1, list.size()); - list = classificationService.createClassificationQuery().custom1In("custom2").list(); + list = classificationService.createClassificationQuery().customAttributeIn("2", "custom1").list(); Assert.assertEquals(1, list.size()); list = classificationService.createClassificationQuery() .descriptionLike("DESC1") diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java index a16ca726b..c7ae440b7 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java @@ -301,10 +301,10 @@ public class ClassificationServiceImplIntExplicitTest { List list = classificationService.createClassificationQuery() .descriptionLike("DESC1") - .custom1In("custom1") + .customAttributeIn("1", "custom1") .list(); Assert.assertEquals(1, list.size()); - list = classificationService.createClassificationQuery().custom1In("custom2").list(); + list = classificationService.createClassificationQuery().customAttributeIn("1", "custom2").list(); Assert.assertEquals(1, list.size()); list = classificationService.createClassificationQuery() .descriptionLike("DESC1") diff --git a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java index 50df07f3b..b4e4a1e1d 100644 --- a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java +++ b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java @@ -194,7 +194,7 @@ public class ClassificationController extends AbstractPagingController { } private ClassificationQuery applyFilterParams(ClassificationQuery query, - MultiValueMap params) { + MultiValueMap params) throws InvalidArgumentException { if (params.containsKey(NAME)) { String[] names = extractCommaSeparatedFields(params.get(NAME)); query.nameIn(names); @@ -225,35 +225,35 @@ public class ClassificationController extends AbstractPagingController { params.remove(TYPE); } if (params.containsKey(CUSTOM_1_LIKE)) { - query.custom1Like(LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE); + query.customAttributeLike("1", LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE); params.remove(CUSTOM_1_LIKE); } if (params.containsKey(CUSTOM_2_LIKE)) { - query.custom2Like(LIKE + params.get(CUSTOM_2_LIKE).get(0) + LIKE); + query.customAttributeLike("2", LIKE + params.get(CUSTOM_2_LIKE).get(0) + LIKE); params.remove(CUSTOM_2_LIKE); } if (params.containsKey(CUSTOM_3_LIKE)) { - query.custom3Like(LIKE + params.get(CUSTOM_3_LIKE).get(0) + LIKE); + query.customAttributeLike("3", LIKE + params.get(CUSTOM_3_LIKE).get(0) + LIKE); params.remove(CUSTOM_3_LIKE); } if (params.containsKey(CUSTOM_4_LIKE)) { - query.custom4Like(LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE); + query.customAttributeLike("4", LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE); params.remove(CUSTOM_4_LIKE); } if (params.containsKey(CUSTOM_5_LIKE)) { - query.custom5Like(LIKE + params.get(CUSTOM_5_LIKE).get(0) + LIKE); + query.customAttributeLike("5", LIKE + params.get(CUSTOM_5_LIKE).get(0) + LIKE); params.remove(CUSTOM_5_LIKE); } if (params.containsKey(CUSTOM_6_LIKE)) { - query.custom6Like(LIKE + params.get(CUSTOM_6_LIKE).get(0) + LIKE); + query.customAttributeLike("6", LIKE + params.get(CUSTOM_6_LIKE).get(0) + LIKE); params.remove(CUSTOM_6_LIKE); } if (params.containsKey(CUSTOM_7_LIKE)) { - query.custom7Like(LIKE + params.get(CUSTOM_7_LIKE).get(0) + LIKE); + query.customAttributeLike("7", LIKE + params.get(CUSTOM_7_LIKE).get(0) + LIKE); params.remove(CUSTOM_7_LIKE); } if (params.containsKey(CUSTOM_8_LIKE)) { - query.custom8Like(LIKE + params.get(CUSTOM_8_LIKE).get(0) + LIKE); + query.customAttributeLike("8", LIKE + params.get(CUSTOM_8_LIKE).get(0) + LIKE); params.remove(CUSTOM_8_LIKE); } return query;