From a7c7dec43cb5abeb6e24b8af34c2c129aa1b6c71 Mon Sep 17 00:00:00 2001 From: BerndBreier <33351391+BerndBreier@users.noreply.github.com> Date: Tue, 13 Mar 2018 14:53:40 +0100 Subject: [PATCH] TSK-353 Extend the number of available custom attributes on the task --- .../src/main/java/pro/taskana/Task.java | 162 ++------- .../src/main/java/pro/taskana/TaskQuery.java | 214 ++--------- .../main/java/pro/taskana/TaskSummary.java | 76 +--- .../main/java/pro/taskana/impl/TaskImpl.java | 207 ++++++----- .../java/pro/taskana/impl/TaskQueryImpl.java | 335 ++++++++++++------ .../pro/taskana/impl/TaskSummaryImpl.java | 272 +++++++------- .../pro/taskana/mappings/QueryMapper.java | 20 +- .../java/pro/taskana/mappings/TaskMapper.java | 70 ++-- .../src/main/resources/sql/taskana-schema.sql | 6 + .../acceptance/task/QueryTasksAccTest.java | 140 ++++++-- .../acceptance/task/UpdateTaskAccTest.java | 6 +- .../resources/sql/monitor-sample-data.sql | 102 +++--- .../src/test/resources/sql/task.sql | 142 ++++---- .../sql/sample-data/classification.sql | 30 +- .../main/resources/sql/sample-data/task.sql | 142 ++++---- .../resources/sql/sample-data/workbasket.sql | 3 + .../target/classes/sql/sample-data/task.sql | 142 ++++---- .../classes/sql/sample-data/workbasket.sql | 3 + 18 files changed, 986 insertions(+), 1086 deletions(-) diff --git a/lib/taskana-core/src/main/java/pro/taskana/Task.java b/lib/taskana-core/src/main/java/pro/taskana/Task.java index 6a4e8eea8..66bd6adf0 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/Task.java +++ b/lib/taskana-core/src/main/java/pro/taskana/Task.java @@ -4,6 +4,7 @@ import java.time.Instant; import java.util.List; import java.util.Map; +import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.impl.ObjectReference; /** @@ -230,154 +231,31 @@ public interface Task { void setCustomAttributes(Map customAttributes); /** - * Return the value for the 1. customAttribute. + * Return the value for custom Attribute number num. * - * @return custom1 + * @param num + * identifies which custom attribute is requested. 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" + * @return the value of custom attribute number num + * @throws InvalidArgumentException + * if num has not a value of "1", "2" ... "16" */ - String getCustom1(); + String getCustomAttribute(String num) throws InvalidArgumentException; /** - * Sets the value for customAttribute1. + * Sets the value for custom Attribute number num. * - * @param custom1 - * the custom1 property of the task + * @param num + * identifies which custom attribute is to be set. 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 value + * the value of the custom attribute to be set + * @throws InvalidArgumentException + * if num has not a value of "1", "2" ... "16" */ - void setCustom1(String custom1); - - /** - * Return the value for the 2. customAttribute. - * - * @return custom2 - */ - String getCustom2(); - - /** - * Sets the value for customAttribute2. - * - * @param custom2 - * the custom2 property of the task - */ - void setCustom2(String custom2); - - /** - * Return the value for the 3. customAttribute. - * - * @return custom3 - */ - String getCustom3(); - - /** - * Sets the value for customAttribute3. - * - * @param custom3 - * the custom3 property of the task - */ - void setCustom3(String custom3); - - /** - * Return the value for the 4. customAttribute. - * - * @return custom4 - */ - String getCustom4(); - - /** - * Sets the value for customAttribute4. - * - * @param custom4 - * the custom4 property of the task - */ - void setCustom4(String custom4); - - /** - * Return the value for the 5. customAttribute. - * - * @return custom5 - */ - String getCustom5(); - - /** - * Sets the value for customAttribute25. - * - * @param custom5 - * the custom5 property of the task - */ - void setCustom5(String custom5); - - /** - * Return the value for the 6. customAttribute. - * - * @return custom6 - */ - String getCustom6(); - - /** - * Sets the value for customAttribute6. - * - * @param custom6 - * the custom6 property of the task - */ - void setCustom6(String custom6); - - /** - * Return the value for the 7. customAttribute. - * - * @return custom7 - */ - String getCustom7(); - - /** - * Sets the value for customAttribute7. - * - * @param custom7 - * the custom7 property of the task - */ - void setCustom7(String custom7); - - /** - * Return the value for the 8. customAttribute. - * - * @return custom8 - */ - String getCustom8(); - - /** - * Sets the value for customAttribute8. - * - * @param custom8 - * the custom8 property of the task - */ - void setCustom8(String custom8); - - /** - * Return the value for the 9. customAttribute. - * - * @return custom9 - */ - String getCustom9(); - - /** - * Sets the value for customAttribute9. - * - * @param custom9 - * the custom9 property of the task - */ - void setCustom9(String custom9); - - /** - * Return the value for the 10. customAttribute. - * - * @return custom10 - */ - String getCustom10(); - - /** - * Sets the value for customAttribute10. - * - * @param custom10 - * the custom10 property of the task - */ - void setCustom10(String custom10); + void setCustomAttribute(String num, String value) throws InvalidArgumentException; /** * Add an attachment.
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 1516670a1..c2fe5e4b4 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java +++ b/lib/taskana-core/src/main/java/pro/taskana/TaskQuery.java @@ -1,5 +1,7 @@ package pro.taskana; +import pro.taskana.exceptions.InvalidArgumentException; + /** * TaskQuery for generating dynamic sql. */ @@ -403,204 +405,36 @@ public interface TaskQuery extends BaseQuery { TaskQuery customFieldsIn(String... customFields); /** - * Add the custom_1 values for exact matching to your query. + * Add the values of custom attribute number num for exact matching to your query. * - * @param strings - * the custom_1 values of the searched for tasks + * @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 searchArguments + * the custom_num values of the searched for tasks * @return the query + * @throws InvalidArgumentException + * if num has not a value of "1", "2" ... "16" */ - TaskQuery custom1In(String... strings); + TaskQuery customAttributeIn(String num, String... searchArguments) throws InvalidArgumentException; /** - * Add the custom_1 value 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 the values of custom attribute number num for pattern matching to your query. They 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 strings - * the custom_1 values of the searched-for tasks + * @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 searchArguments + * the custom_num values of the searched-for tasks * @return the query + * @throws InvalidArgumentException + * if num has not a value of "1", "2" ... "16" */ - TaskQuery custom1Like(String... strings); - - /** - * Add the custom_2 values for exact matching to your query. - * - * @param strings - * the custom_2 values of the searched for tasks - * @return the query - */ - TaskQuery custom2In(String... strings); - - /** - * Add the custom_2 value 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 strings - * the custom_2 values of the searched-for tasks - * @return the query - */ - TaskQuery custom2Like(String... strings); - - /** - * Add the custom_3 values for exact matching to your query. - * - * @param strings - * the custom_3 values of the searched for tasks - * @return the query - */ - TaskQuery custom3In(String... strings); - - /** - * Add the custom_3 value 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 strings - * the custom_3 values of the searched-for tasks - * @return the query - */ - TaskQuery custom3Like(String... strings); - - /** - * Add the custom_4 values for exact matching to your query. - * - * @param strings - * the custom_4 values of the searched for tasks - * @return the query - */ - TaskQuery custom4In(String... strings); - - /** - * Add the custom_4 value 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 strings - * the custom_4 values of the searched-for tasks - * @return the query - */ - TaskQuery custom4Like(String... strings); - - /** - * Add the custom_5 values for exact matching to your query. - * - * @param strings - * the custom_5 values of the searched for tasks - * @return the query - */ - TaskQuery custom5In(String... strings); - - /** - * Add the custom_5 value 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 strings - * the custom_5 values of the searched-for tasks - * @return the query - */ - TaskQuery custom5Like(String... strings); - - /** - * Add the custom_6 values for exact matching to your query. - * - * @param strings - * the custom_6 values of the searched for tasks - * @return the query - */ - TaskQuery custom6In(String... strings); - - /** - * Add the custom_6 value 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 strings - * the custom_6 values of the searched-for tasks - * @return the query - */ - TaskQuery custom6Like(String... strings); - - /** - * Add the custom_7 values for exact matching to your query. - * - * @param strings - * the custom_7 values of the searched for tasks - * @return the query - */ - TaskQuery custom7In(String... strings); - - /** - * Add the custom_7 value 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 strings - * the custom_7 values of the searched-for tasks - * @return the query - */ - TaskQuery custom7Like(String... strings); - - /** - * Add the custom_8 values for exact matching to your query. - * - * @param strings - * the custom_8 values of the searched for tasks - * @return the query - */ - TaskQuery custom8In(String... strings); - - /** - * Add the custom_8 value 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 strings - * the custom_8 values of the searched-for tasks - * @return the query - */ - TaskQuery custom8Like(String... strings); - - /** - * Add the custom_9 values for exact matching to your query. - * - * @param strings - * the custom_9 values of the searched for tasks - * @return the query - */ - TaskQuery custom9In(String... strings); - - /** - * Add the custom_9 value 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 strings - * the custom_9 values of the searched-for tasks - * @return the query - */ - TaskQuery custom9Like(String... strings); - - /** - * Add the custom_10 values for exact matching to your query. - * - * @param strings - * the custom_10 values of the searched for tasks - * @return the query - */ - TaskQuery custom10In(String... strings); - - /** - * Add the custom_10 value 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 strings - * the custom_10 values of the searched-for tasks - * @return the query - */ - TaskQuery custom10Like(String... strings); + TaskQuery customAttributeLike(String num, String... searchArguments) throws InvalidArgumentException; /** * This method provides a query builder for quering the database. diff --git a/lib/taskana-core/src/main/java/pro/taskana/TaskSummary.java b/lib/taskana-core/src/main/java/pro/taskana/TaskSummary.java index 029a095c1..fcdbd0509 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/TaskSummary.java +++ b/lib/taskana-core/src/main/java/pro/taskana/TaskSummary.java @@ -3,6 +3,7 @@ package pro.taskana; import java.time.Instant; import java.util.List; +import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.impl.ObjectReference; /** @@ -165,73 +166,16 @@ public interface TaskSummary { boolean isTransferred(); /** - * Gets the custom1 property of the task. + * Gets the custom attribute number num of the task. * - * @return the task's custom1 property + * @param num + * identifies which custom attribute is requested. 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" + * @return the value of custom attribute number num + * @throws InvalidArgumentException + * if num has not a value of "1", "2" ... "16" */ - String getCustom1(); - - /** - * Gets the custom2 property of the task. - * - * @return the task's custom2 property - */ - String getCustom2(); - - /** - * Gets the custom3 property of the task. - * - * @return the task's custom3 property - */ - String getCustom3(); - - /** - * Gets the custom4 property of the task. - * - * @return the task's custom4 property - */ - String getCustom4(); - - /** - * Gets the custom5 property of the task. - * - * @return the task's custom5 property - */ - String getCustom5(); - - /** - * Gets the custom6 property of the task. - * - * @return the task's custom6 property - */ - String getCustom6(); - - /** - * Gets the custom7 property of the task. - * - * @return the task's custom7 property - */ - String getCustom7(); - - /** - * Gets the custom8 property of the task. - * - * @return the task's custom8 property - */ - String getCustom8(); - - /** - * Gets the custom9 property of the task. - * - * @return the task's custom9 property - */ - String getCustom9(); - - /** - * Gets the custom10 property of the task. - * - * @return the task's custom10 property - */ - String getCustom10(); + String getCustomAttribute(String num) throws InvalidArgumentException; } 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 06067d295..892dd136a 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 @@ -14,6 +14,7 @@ import pro.taskana.Task; import pro.taskana.TaskState; import pro.taskana.TaskSummary; import pro.taskana.WorkbasketSummary; +import pro.taskana.exceptions.InvalidArgumentException; /** * Task entity. @@ -54,6 +55,12 @@ public class TaskImpl implements Task { private String custom8; private String custom9; private String custom10; + private String custom11; + private String custom12; + private String custom13; + private String custom14; + private String custom15; + private String custom16; TaskImpl() { } @@ -305,103 +312,119 @@ public class TaskImpl implements Task { } @Override - public String getCustom1() { - return custom1; + public String getCustomAttribute(String number) 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"); + } + + switch (num) { + case 1: + return custom1; + case 2: + return custom2; + case 3: + return custom3; + case 4: + return custom4; + case 5: + return custom5; + case 6: + return custom6; + case 7: + return custom7; + case 8: + return custom8; + case 9: + return custom9; + case 10: + return custom10; + case 11: + return custom10; + case 12: + return custom12; + case 13: + return custom13; + case 14: + return custom14; + case 15: + return custom15; + case 16: + return custom16; + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } + } @Override - public void setCustom1(String custom1) { - this.custom1 = custom1; - } + public void setCustomAttribute(String number, String value) 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"); + } - @Override - public String getCustom2() { - return custom2; - } + switch (num) { + case 1: + custom1 = value; + break; + case 2: + custom2 = value; + break; + case 3: + custom3 = value; + break; + case 4: + custom4 = value; + break; + case 5: + custom5 = value; + break; + case 6: + custom6 = value; + break; + case 7: + custom7 = value; + break; + case 8: + custom8 = value; + break; + case 9: + custom9 = value; + break; + case 10: + custom10 = value; + break; + case 11: + custom11 = value; + break; + case 12: + custom12 = value; + break; + case 13: + custom13 = value; + break; + case 14: + custom14 = value; + break; + case 15: + custom15 = value; + break; + case 16: + custom16 = value; + break; + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } - @Override - public void setCustom2(String custom2) { - this.custom2 = custom2; - } - - @Override - public String getCustom3() { - return custom3; - } - - @Override - public void setCustom3(String custom3) { - this.custom3 = custom3; - } - - @Override - public String getCustom4() { - return custom4; - } - - @Override - public void setCustom4(String custom4) { - this.custom4 = custom4; - } - - @Override - public String getCustom5() { - return custom5; - } - - @Override - public void setCustom5(String custom5) { - this.custom5 = custom5; - } - - @Override - public String getCustom6() { - return custom6; - } - - @Override - public void setCustom6(String custom6) { - this.custom6 = custom6; - } - - @Override - public String getCustom7() { - return custom7; - } - - @Override - public void setCustom7(String custom7) { - this.custom7 = custom7; - } - - @Override - public String getCustom8() { - return custom8; - } - - @Override - public void setCustom8(String custom8) { - this.custom8 = custom8; - } - - @Override - public String getCustom9() { - return custom9; - } - - @Override - public void setCustom9(String custom9) { - this.custom9 = custom9; - } - - @Override - public String getCustom10() { - return custom10; - } - - @Override - public void setCustom10(String custom10) { - this.custom10 = custom10; } @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 01499b49e..8c1b6c6ac 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 @@ -18,6 +18,7 @@ import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaRole; import pro.taskana.TimeInterval; import pro.taskana.WorkbasketPermission; +import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException; import pro.taskana.exceptions.TaskanaRuntimeException; @@ -92,6 +93,18 @@ public class TaskQueryImpl implements TaskQuery { private String[] custom9Like; private String[] custom10In; private String[] custom10Like; + private String[] custom11In; + private String[] custom11Like; + private String[] custom12In; + private String[] custom12Like; + private String[] custom13In; + private String[] custom13Like; + private String[] custom14In; + private String[] custom14Like; + private String[] custom15In; + private String[] custom15Like; + private String[] custom16In; + private String[] custom16Like; private TimeInterval[] createdIn; private TimeInterval[] claimedIn; private TimeInterval[] completedIn; @@ -377,122 +390,136 @@ public class TaskQueryImpl implements TaskQuery { } @Override - public TaskQuery custom1In(String... strings) { - this.custom1In = strings; + public TaskQuery customAttributeIn(String number, String... strings) 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"); + } + + switch (num) { + case 1: + this.custom1In = strings; + break; + case 2: + this.custom2In = strings; + break; + case 3: + this.custom3In = strings; + break; + case 4: + this.custom4In = strings; + break; + case 5: + this.custom5In = strings; + break; + case 6: + this.custom6In = strings; + break; + case 7: + this.custom7In = strings; + break; + case 8: + this.custom8In = strings; + break; + case 9: + this.custom9In = strings; + break; + case 10: + this.custom10In = strings; + break; + case 11: + this.custom11In = strings; + break; + case 12: + this.custom12In = strings; + break; + case 13: + this.custom13In = strings; + break; + case 14: + this.custom14In = strings; + break; + case 15: + this.custom15In = strings; + break; + case 16: + this.custom16In = strings; + break; + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } + return this; } @Override - public TaskQuery custom1Like(String... strings) { - this.custom1Like = toUpperCopy(strings); - return this; - } + public TaskQuery customAttributeLike(String number, String... strings) 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"); + } - @Override - public TaskQuery custom2In(String... strings) { - this.custom2In = strings; - return this; - } + switch (num) { + case 1: + this.custom1Like = toUpperCopy(strings); + break; + case 2: + this.custom2Like = toUpperCopy(strings); + break; + case 3: + this.custom3Like = toUpperCopy(strings); + break; + case 4: + this.custom4Like = toUpperCopy(strings); + break; + case 5: + this.custom5Like = toUpperCopy(strings); + break; + case 6: + this.custom6Like = toUpperCopy(strings); + break; + case 7: + this.custom7Like = toUpperCopy(strings); + break; + case 8: + this.custom8Like = toUpperCopy(strings); + break; + case 9: + this.custom9Like = toUpperCopy(strings); + break; + case 10: + this.custom10Like = toUpperCopy(strings); + break; + case 11: + this.custom11Like = toUpperCopy(strings); + break; + case 12: + this.custom12Like = toUpperCopy(strings); + break; + case 13: + this.custom13Like = toUpperCopy(strings); + break; + case 14: + this.custom14Like = toUpperCopy(strings); + break; + case 15: + this.custom15Like = toUpperCopy(strings); + break; + case 16: + this.custom16Like = toUpperCopy(strings); + break; + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } - @Override - public TaskQuery custom2Like(String... strings) { - this.custom2Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom3In(String... strings) { - this.custom3In = strings; - return this; - } - - @Override - public TaskQuery custom3Like(String... strings) { - this.custom3Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom4In(String... strings) { - this.custom4In = strings; - return this; - } - - @Override - public TaskQuery custom4Like(String... strings) { - this.custom4Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom5In(String... strings) { - this.custom5In = strings; - return this; - } - - @Override - public TaskQuery custom5Like(String... strings) { - this.custom5Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom6In(String... strings) { - this.custom6In = strings; - return this; - } - - @Override - public TaskQuery custom6Like(String... strings) { - this.custom6Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom7In(String... strings) { - this.custom7In = strings; - return this; - } - - @Override - public TaskQuery custom7Like(String... strings) { - this.custom7Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom8In(String... strings) { - this.custom8In = strings; - return this; - } - - @Override - public TaskQuery custom8Like(String... strings) { - this.custom8Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom9In(String... strings) { - this.custom9In = strings; - return this; - } - - @Override - public TaskQuery custom9Like(String... strings) { - this.custom9Like = toUpperCopy(strings); - return this; - } - - @Override - public TaskQuery custom10In(String... strings) { - this.custom10In = strings; - return this; - } - - @Override - public TaskQuery custom10Like(String... strings) { - this.custom10Like = toUpperCopy(strings); return this; } @@ -1029,6 +1056,62 @@ public class TaskQueryImpl implements TaskQuery { return custom10Like; } + public String[] getCustom11In() { + return custom11In; + } + + public String[] getCustom11Like() { + return custom11Like; + } + + public String[] getCustom12In() { + return custom12In; + } + + public String[] getCustom12Like() { + return custom12Like; + } + + public String[] getCustom13In() { + return custom13In; + } + + public String[] getCustom13Like() { + return custom13Like; + } + + public String[] getCustom14In() { + return custom14In; + } + + public String[] getCustom14Like() { + return custom14Like; + } + + public String[] getCustom15In() { + return custom15In; + } + + public String[] getCustom15Like() { + return custom15Like; + } + + public String[] getCustom16In() { + return custom16In; + } + + public String[] getCustom16Like() { + return custom16Like; + } + + public String[] getClassificationCategoryIn() { + return classificationCategoryIn; + } + + public String[] getClassificationCategoryLike() { + return classificationCategoryLike; + } + public TimeInterval[] getClaimedIn() { return claimedIn; } @@ -1093,7 +1176,13 @@ public class TaskQueryImpl implements TaskQuery { @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("TaskQueryImpl [nameIn="); + builder.append("TaskQueryImpl [taskanaEngine="); + builder.append(taskanaEngine); + builder.append(", taskService="); + builder.append(taskService); + builder.append(", columnName="); + builder.append(columnName); + builder.append(", nameIn="); builder.append(Arrays.toString(nameIn)); builder.append(", nameLike="); builder.append(Arrays.toString(nameLike)); @@ -1201,6 +1290,30 @@ public class TaskQueryImpl implements TaskQuery { builder.append(Arrays.toString(custom10In)); builder.append(", custom10Like="); builder.append(Arrays.toString(custom10Like)); + builder.append(", custom11In="); + builder.append(Arrays.toString(custom11In)); + builder.append(", custom11Like="); + builder.append(Arrays.toString(custom11Like)); + builder.append(", custom12In="); + builder.append(Arrays.toString(custom12In)); + builder.append(", custom12Like="); + builder.append(Arrays.toString(custom12Like)); + builder.append(", custom13In="); + builder.append(Arrays.toString(custom13In)); + builder.append(", custom13Like="); + builder.append(Arrays.toString(custom13Like)); + builder.append(", custom14In="); + builder.append(Arrays.toString(custom14In)); + builder.append(", custom14Like="); + builder.append(Arrays.toString(custom14Like)); + builder.append(", custom15In="); + builder.append(Arrays.toString(custom15In)); + builder.append(", custom15Like="); + builder.append(Arrays.toString(custom15Like)); + builder.append(", custom16In="); + builder.append(Arrays.toString(custom16In)); + builder.append(", custom16Like="); + builder.append(Arrays.toString(custom16Like)); builder.append(", createdIn="); builder.append(Arrays.toString(createdIn)); builder.append(", claimedIn="); 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 b6fddf86d..18e9ce8e8 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 @@ -9,6 +9,7 @@ import pro.taskana.ClassificationSummary; import pro.taskana.TaskState; import pro.taskana.TaskSummary; import pro.taskana.WorkbasketSummary; +import pro.taskana.exceptions.InvalidArgumentException; /** * Entity which contains the most important informations about a Task. @@ -47,6 +48,12 @@ public class TaskSummaryImpl implements TaskSummary { private String custom8; private String custom9; private String custom10; + private String custom11; + private String custom12; + private String custom13; + private String custom14; + private String custom15; + private String custom16; TaskSummaryImpl() { } @@ -355,132 +362,56 @@ public class TaskSummaryImpl implements TaskSummary { /* * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom1() + * @see pro.taskana.impl.TaskSummary#getCustomAttribute(String number) */ @Override - public String getCustom1() { - return custom1; - } + public String getCustomAttribute(String number) 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"); + } - public void setCustom1(String custom1) { - this.custom1 = custom1; - } + switch (num) { + case 1: + return custom1; + case 2: + return custom2; + case 3: + return custom3; + case 4: + return custom4; + case 5: + return custom5; + case 6: + return custom6; + case 7: + return custom7; + case 8: + return custom8; + case 9: + return custom9; + case 10: + return custom10; + case 11: + return custom10; + case 12: + return custom12; + case 13: + return custom13; + case 14: + return custom14; + case 15: + return custom15; + case 16: + return custom16; + default: + throw new InvalidArgumentException( + "Argument '" + number + "' to getCustomAttribute does not represent a number between 1 and 16"); + } - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom2() - */ - @Override - public String getCustom2() { - return custom2; - } - - public void setCustom2(String custom2) { - this.custom2 = custom2; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom3() - */ - @Override - public String getCustom3() { - return custom3; - } - - public void setCustom3(String custom3) { - this.custom3 = custom3; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom4() - */ - @Override - public String getCustom4() { - return custom4; - } - - public void setCustom4(String custom4) { - this.custom4 = custom4; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom5() - */ - @Override - public String getCustom5() { - return custom5; - } - - public void setCustom5(String custom5) { - this.custom5 = custom5; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom6() - */ - @Override - public String getCustom6() { - return custom6; - } - - public void setCustom6(String custom6) { - this.custom6 = custom6; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom7() - */ - @Override - public String getCustom7() { - return custom7; - } - - public void setCustom7(String custom7) { - this.custom7 = custom7; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom8() - */ - @Override - public String getCustom8() { - return custom8; - } - - public void setCustom8(String custom8) { - this.custom8 = custom8; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom9() - */ - @Override - public String getCustom9() { - return custom9; - } - - public void setCustom9(String custom9) { - this.custom9 = custom9; - } - - /* - * (non-Javadoc) - * @see pro.taskana.impl.TaskSummary#getCustom10() - */ - @Override - public String getCustom10() { - return custom10; - } - - public void setCustom10(String custom10) { - this.custom10 = custom10; } // auxiliary Method to enable Mybatis to access classificationSummary @@ -493,6 +424,86 @@ public class TaskSummaryImpl implements TaskSummary { this.classificationSummary = classificationSummary; } + // auxiliary Method needed by Mybatis + public void setCustom1(String custom1) { + this.custom1 = custom1; + } + + // auxiliary Method needed by Mybatis + public void setCustom2(String custom2) { + this.custom2 = custom2; + } + + // auxiliary Method needed by Mybatis + public void setCustom3(String custom3) { + this.custom3 = custom3; + } + + // auxiliary Method needed by Mybatis + public void setCustom4(String custom4) { + this.custom4 = custom4; + } + + // auxiliary Method needed by Mybatis + public void setCustom5(String custom5) { + this.custom5 = custom5; + } + + // auxiliary Method needed by Mybatis + public void setCustom6(String custom6) { + this.custom6 = custom6; + } + + // auxiliary Method needed by Mybatis + public void setCustom7(String custom7) { + this.custom7 = custom7; + } + + // auxiliary Method needed by Mybatis + public void setCustom8(String custom8) { + this.custom8 = custom8; + } + + // auxiliary Method needed by Mybatis + public void setCustom9(String custom9) { + this.custom9 = custom9; + } + + // auxiliary Method needed by Mybatis + public void setCustom10(String custom10) { + this.custom10 = custom10; + } + + // auxiliary Method needed by Mybatis + public void setCustom11(String custom11) { + this.custom11 = custom11; + } + + // auxiliary Method needed by Mybatis + public void setCustom12(String custom12) { + this.custom12 = custom12; + } + + // auxiliary Method needed by Mybatis + public void setCustom13(String custom13) { + this.custom13 = custom13; + } + + // auxiliary Method needed by Mybatis + public void setCustom14(String custom14) { + this.custom14 = custom14; + } + + // auxiliary Method needed by Mybatis + public void setCustom15(String custom15) { + this.custom15 = custom15; + } + + // auxiliary Method needed by Mybatis + public void setCustom16(String custom16) { + this.custom16 = custom16; + } + @Override public int hashCode() { final int prime = 31; @@ -767,8 +778,8 @@ public class TaskSummaryImpl implements TaskSummary { builder.append(", name="); builder.append(name); builder.append(", creator="); - builder.append(name); - builder.append(", creator="); + builder.append(creator); + builder.append(", note="); builder.append(note); builder.append(", priority="); builder.append(priority); @@ -812,7 +823,20 @@ public class TaskSummaryImpl implements TaskSummary { builder.append(custom9); builder.append(", custom10="); builder.append(custom10); + builder.append(", custom11="); + builder.append(custom11); + builder.append(", custom12="); + builder.append(custom12); + builder.append(", custom13="); + builder.append(custom13); + builder.append(", custom14="); + builder.append(custom14); + builder.append(", custom15="); + builder.append(custom15); + builder.append(", custom16="); + builder.append(custom16); builder.append("]"); return builder.toString(); } + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/mappings/QueryMapper.java b/lib/taskana-core/src/main/java/pro/taskana/mappings/QueryMapper.java index f58cf06bd..a6bbf4d85 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/mappings/QueryMapper.java +++ b/lib/taskana-core/src/main/java/pro/taskana/mappings/QueryMapper.java @@ -89,6 +89,18 @@ public interface QueryMapper { + "AND (UPPER(t.CUSTOM_9) LIKE #{item}) " + "AND t.CUSTOM_10 IN(#{item}) " + "AND (UPPER(t.CUSTOM_10) LIKE #{item}) " + + "AND t.CUSTOM_10 IN(#{item}) " + + "AND (UPPER(t.CUSTOM_10) LIKE #{item}) " + + "AND t.CUSTOM_10 IN(#{item}) " + + "AND (UPPER(t.CUSTOM_10) LIKE #{item}) " + + "AND t.CUSTOM_10 IN(#{item}) " + + "AND (UPPER(t.CUSTOM_10) LIKE #{item}) " + + "AND t.CUSTOM_10 IN(#{item}) " + + "AND (UPPER(t.CUSTOM_10) LIKE #{item}) " + + "AND t.CUSTOM_10 IN(#{item}) " + + "AND (UPPER(t.CUSTOM_10) LIKE #{item}) " + + "AND t.CUSTOM_10 IN(#{item}) " + + "AND (UPPER(t.CUSTOM_10) LIKE #{item}) " + "AND (t.CUSTOM_1 IN(#{item}) OR t.CUSTOM_2 IN(#{item}) OR t.CUSTOM_3 IN(#{item}) OR t.CUSTOM_4 IN(#{item}) OR t.CUSTOM_5 IN(#{item}) OR t.CUSTOM_6 IN(#{item}) OR t.CUSTOM_7 IN(#{item}) OR t.CUSTOM_8 IN(#{item}) OR t.CUSTOM_9 IN(#{item}) OR t.CUSTOM_10 IN(#{item})) " + "" + "ORDER BY ${item} " @@ -129,7 +141,13 @@ public interface QueryMapper { @Result(property = "custom7", column = "CUSTOM_7"), @Result(property = "custom8", column = "CUSTOM_8"), @Result(property = "custom9", column = "CUSTOM_9"), - @Result(property = "custom10", column = "CUSTOM_10")}) + @Result(property = "custom10", column = "CUSTOM_10"), + @Result(property = "custom11", column = "CUSTOM_11"), + @Result(property = "custom12", column = "CUSTOM_12"), + @Result(property = "custom13", column = "CUSTOM_13"), + @Result(property = "custom14", column = "CUSTOM_14"), + @Result(property = "custom15", column = "CUSTOM_15"), + @Result(property = "custom16", column = "CUSTOM_16")}) List queryTaskSummaries(TaskQueryImpl taskQuery); @Select("") void deleteMultiple(@Param("ids") List ids); - @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, CREATOR, 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 " + @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, CREATOR, 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, CUSTOM_11, CUSTOM_12, CUSTOM_13, CUSTOM_14, CUSTOM_15, CUSTOM_16 " + "FROM TASK " + "WHERE WORKBASKET_KEY = #{workbasketSummaryImpl.key} and DOMAIN = #{workbasketSummaryImpl.domain " + "AND STATE = #{taskState}") @@ -141,52 +151,16 @@ public interface TaskMapper { @Result(property = "custom7", column = "CUSTOM_7"), @Result(property = "custom8", column = "CUSTOM_8"), @Result(property = "custom9", column = "CUSTOM_9"), - @Result(property = "custom10", column = "CUSTOM_10")}) + @Result(property = "custom10", column = "CUSTOM_10"), + @Result(property = "custom11", column = "CUSTOM_11"), + @Result(property = "custom12", column = "CUSTOM_12"), + @Result(property = "custom13", column = "CUSTOM_13"), + @Result(property = "custom14", column = "CUSTOM_14"), + @Result(property = "custom15", column = "CUSTOM_15"), + @Result(property = "custom16", column = "CUSTOM_16")}) List findTasksByWorkbasketIdAndState(@Param("workbasketKey") String workbasketKey, @Param("taskState") TaskState taskState); - @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, CREATOR, 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 " - + "FROM TASK " - + "WHERE WORKBASKET_KEY = #{workbasketKey} ") - @Results(value = { - @Result(property = "taskId", column = "ID"), - @Result(property = "created", column = "CREATED"), - @Result(property = "claimed", column = "CLAIMED"), - @Result(property = "completed", column = "COMPLETED"), - @Result(property = "modified", column = "MODIFIED"), - @Result(property = "planned", column = "PLANNED"), - @Result(property = "due", column = "DUE"), - @Result(property = "name", column = "NAME"), - @Result(property = "creator", column = "CREATOR"), - @Result(property = "note", column = "NOTE"), - @Result(property = "priority", column = "PRIORITY"), - @Result(property = "state", column = "STATE"), - @Result(property = "classificationSummaryImpl.category", column = "CLASSIFICATION_CATEGORY"), - @Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"), - @Result(property = "workbasketSummaryImpl.key", column = "WORKBASKET_KEY"), - @Result(property = "domain", column = "DOMAIN"), - @Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"), - @Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"), - @Result(property = "owner", column = "OWNER"), - @Result(property = "primaryObjRef.company", column = "POR_COMPANY"), - @Result(property = "primaryObjRef.system", column = "POR_SYSTEM"), - @Result(property = "primaryObjRef.systemInstance", column = "POR_INSTANCE"), - @Result(property = "primaryObjRef.type", column = "POR_TYPE"), - @Result(property = "primaryObjRef.value", column = "POR_VALUE"), - @Result(property = "isRead", column = "IS_READ"), - @Result(property = "isTransferred", column = "IS_TRANSFERRED"), - @Result(property = "custom1", column = "CUSTOM_1"), - @Result(property = "custom2", column = "CUSTOM_2"), - @Result(property = "custom3", column = "CUSTOM_3"), - @Result(property = "custom4", column = "CUSTOM_4"), - @Result(property = "custom5", column = "CUSTOM_5"), - @Result(property = "custom6", column = "CUSTOM_6"), - @Result(property = "custom7", column = "CUSTOM_7"), - @Result(property = "custom8", column = "CUSTOM_8"), - @Result(property = "custom9", column = "CUSTOM_9"), - @Result(property = "custom10", column = "CUSTOM_10")}) - List findTaskSummariesByWorkbasketKey(@Param("workbasketKey") String workbasketKey); - @Update("