diff --git a/lib/taskana-core/src/main/java/pro/taskana/Classification.java b/lib/taskana-core/src/main/java/pro/taskana/Classification.java index 32d2fd056..79ec45a18 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/Classification.java +++ b/lib/taskana-core/src/main/java/pro/taskana/Classification.java @@ -32,6 +32,21 @@ public interface Classification { */ void setParentId(String parentId); + /** + * Used to get the key of the parent classification. + * + * @return key of the parent classification or null if there is no parent. + */ + String getParentKey(); + + /** + * Set/Change a reference to the current parent classification via key. EMPTY if there is no parent. + * + * @param parentKey + * The key of the parent classification. + */ + void setParentKey(String parentKey); + /** * @return category of this classification. */ 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 8f51edbe9..302922ce1 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/ClassificationQuery.java +++ b/lib/taskana-core/src/main/java/pro/taskana/ClassificationQuery.java @@ -32,6 +32,15 @@ public interface ClassificationQuery extends BaseQuery { */ ClassificationQuery parentIdIn(String... parentId); + /** + * Add your parentKeys to your query. + * + * @param parentKey + * as an array of Strings + * @return the query + */ + ClassificationQuery parentKeyIn(String... parentKey); + /** * Add your category to your query. * @@ -323,6 +332,16 @@ public interface ClassificationQuery extends BaseQuery { */ ClassificationQuery orderByParentId(SortDirection sortDirection); + /** + * Sort the query result by the parent classification key. + * + * @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 orderByParentKey(SortDirection sortDirection); + /** * Sort the query result by category. * diff --git a/lib/taskana-core/src/main/java/pro/taskana/ClassificationSummary.java b/lib/taskana-core/src/main/java/pro/taskana/ClassificationSummary.java index 8113ab8b0..a390cc86d 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/ClassificationSummary.java +++ b/lib/taskana-core/src/main/java/pro/taskana/ClassificationSummary.java @@ -55,6 +55,13 @@ public interface ClassificationSummary { */ String getParentId(); + /** + * Gets the key of the parent classification. + * + * @return parentKey + */ + String getParentKey(); + /** * Gets the service level of the parent classification. It is a String in ISO-8601 duration format. See the parse() * method of {@code Duration} for details. @@ -64,9 +71,130 @@ public interface ClassificationSummary { String getServiceLevel(); /** - * Gets the priority of the lassification. + * Gets the priority of the classification. * * @return the priority */ int getPriority(); + + /** + * Get the 1. custom-attribute. + * + * @return custom1 + */ + String getCustom1(); + + /** + * Set/Change the 1. custom-attribute. + * + * @param custom1 + * the first custom attribute + */ + void setCustom1(String custom1); + + /** + * Get the 2. custom-attribute. + * + * @return custom2 + */ + String getCustom2(); + + /** + * Set/Change the 2. custom-attribute. + * + * @param custom2 + * the second custom attribute + */ + void setCustom2(String custom2); + + /** + * Get the 3. custom-attribute. + * + * @return custom3 + */ + String getCustom3(); + + /** + * Set/Change the 3. custom-attribute. + * + * @param custom3 + * the third custom attribute + */ + void setCustom3(String custom3); + + /** + * Get the 4. custom-attribute. + * + * @return custom4 + */ + String getCustom4(); + + /** + * Set/Change the 4. custom-attribute. + * + * @param custom4 + * the fourth custom attribute + */ + void setCustom4(String custom4); + + /** + * Get the 5. custom-attribute. + * + * @return custom5 + */ + String getCustom5(); + + /** + * Set/Change the 5. custom-attribute. + * + * @param custom5 + * the fifth custom attribute + */ + void setCustom5(String custom5); + + /** + * Get the 6. custom-attribute. + * + * @return custom6 + */ + String getCustom6(); + + /** + * Set/Change the 6. custom-attribute. + * + * @param custom6 + * the sixth custom attribute + */ + void setCustom6(String custom6); + + /** + * Get the 7. custom-attribute. + * + * @return custom7 + */ + String getCustom7(); + + /** + * Set/Change the 7. custom-attribute. + * + * @param custom7 + * the seventh custom attribute + */ + void setCustom7(String custom7); + + /** + * Get the 8. custom-attribute. + * + * @return custom8 + */ + String getCustom8(); + + /** + * Set/Change the 8. custom-attribute. + * + * @param custom8 + * the eight custom attribute + */ + void setCustom8(String custom8); + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java index 542c66561..d3fc05ec2 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java @@ -13,6 +13,7 @@ public class ClassificationImpl implements Classification { private String id; private String key; private String parentId; + private String parentKey; private String category; private String type; private String domain; @@ -64,6 +65,16 @@ public class ClassificationImpl implements Classification { this.parentId = parentId; } + @Override + public String getParentKey() { + return parentKey; + } + + @Override + public void setParentKey(String parentKey) { + this.parentKey = parentKey; + } + @Override public String getType() { return type; @@ -260,8 +271,17 @@ public class ClassificationImpl implements Classification { summary.setName(this.name); summary.setType(this.type); summary.setParentId(this.parentId); + summary.setParentKey(this.parentKey); summary.setPriority(this.priority); summary.setServiceLevel(this.serviceLevel); + summary.setCustom1(custom1); + summary.setCustom2(custom2); + summary.setCustom3(custom3); + summary.setCustom4(custom4); + summary.setCustom5(custom5); + summary.setCustom6(custom6); + summary.setCustom7(custom7); + summary.setCustom8(custom8); return summary; } @@ -274,6 +294,8 @@ public class ClassificationImpl implements Classification { builder.append(key); builder.append(", parentId="); builder.append(parentId); + builder.append(", parentKey="); + builder.append(parentKey); builder.append(", category="); builder.append(category); builder.append(", type="); @@ -339,6 +361,7 @@ public class ClassificationImpl implements Classification { result = prime * result + ((modified == null) ? 0 : modified.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((parentId == null) ? 0 : parentId.hashCode()); + result = prime * result + ((parentKey == null) ? 0 : parentKey.hashCode()); result = prime * result + priority; result = prime * result + ((serviceLevel == null) ? 0 : serviceLevel.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); @@ -490,6 +513,13 @@ public class ClassificationImpl implements Classification { } else if (!parentId.equals(other.parentId)) { return false; } + if (parentKey == null) { + if (other.parentKey != null) { + return false; + } + } else if (!parentKey.equals(other.parentKey)) { + return false; + } if (priority != other.priority) { return false; } 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 5c1b9d7f8..2e1331354 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 @@ -32,6 +32,7 @@ public class ClassificationQueryImpl implements ClassificationQuery { private String[] key; private String[] idIn; private String[] parentId; + private String[] parentKey; private String[] category; private String[] type; private String[] domain; @@ -87,6 +88,12 @@ public class ClassificationQueryImpl implements ClassificationQuery { return this; } + @Override + public ClassificationQuery parentKeyIn(String... parentKey) { + this.parentKey = parentKey; + return this; + } + @Override public ClassificationQuery categoryIn(String... category) { this.category = category; @@ -287,6 +294,11 @@ public class ClassificationQueryImpl implements ClassificationQuery { return addOrderCriteria("PARENT_ID", sortDirection); } + @Override + public ClassificationQuery orderByParentKey(SortDirection sortDirection) { + return addOrderCriteria("PARENT_KEY", sortDirection); + } + @Override public ClassificationQuery orderByCategory(SortDirection sortDirection) { return addOrderCriteria("CATEGORY", sortDirection); @@ -474,6 +486,10 @@ public class ClassificationQueryImpl implements ClassificationQuery { return parentId; } + public String[] getparentKey() { + return parentKey; + } + public String[] getCategory() { return category; } @@ -609,6 +625,8 @@ public class ClassificationQueryImpl implements ClassificationQuery { builder.append(Arrays.toString(idIn)); builder.append(", parentId="); builder.append(Arrays.toString(parentId)); + builder.append(", parentKey="); + builder.append(Arrays.toString(parentKey)); builder.append(", category="); builder.append(Arrays.toString(category)); builder.append(", type="); diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java index 4c68453a9..90938fadf 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java @@ -79,6 +79,9 @@ public class ClassificationServiceImpl implements ClassificationService { if (classificationImpl.getParentId() != null && !classificationImpl.getParentId().isEmpty()) { this.getClassification(classificationImpl.getParentId()); } + if (classificationImpl.getParentKey() != null && !classificationImpl.getParentKey().isEmpty()) { + this.getClassification(classificationImpl.getParentKey(), classificationImpl.getDomain()); + } classificationMapper.insert(classificationImpl); LOGGER.debug("Method createClassification created classification {}.", classificationImpl); @@ -177,6 +180,14 @@ public class ClassificationServiceImpl implements ClassificationService { this.getClassification(classificationImpl.getParentId()); } } + + // Check if parentKey changed and object does exist + if (!oldClassification.getParentKey().equals(classificationImpl.getParentKey())) { + if (classificationImpl.getParentKey() != null && !classificationImpl.getParentKey().isEmpty()) { + this.getClassification(classificationImpl.getParentKey(), classificationImpl.getDomain()); + } + } + classificationMapper.update(classificationImpl); boolean priorityChanged = oldClassification.getPriority() != classification.getPriority(); @@ -247,6 +258,10 @@ public class ClassificationServiceImpl implements ClassificationService { classification.setParentId(""); } + if (classification.getParentKey() == null) { + classification.setParentKey(""); + } + if (classification.getType() != null && !taskanaEngine.getConfiguration().getClassificationTypes().contains(classification.getType())) { throw new InvalidArgumentException("Given classification type " + classification.getType() diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java index 51771b462..de9a91129 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java @@ -14,8 +14,17 @@ public class ClassificationSummaryImpl implements ClassificationSummary { private String domain; private String name; private String parentId; + private String parentKey; private int priority; private String serviceLevel; // PddDThhHmmM + private String custom1; + private String custom2; + private String custom3; + private String custom4; + private String custom5; + private String custom6; + private String custom7; + private String custom8; @Override public int getPriority() { @@ -101,6 +110,95 @@ public class ClassificationSummaryImpl implements ClassificationSummary { this.parentId = parentId; } + @Override + public String getParentKey() { + return parentKey; + } + + public void setParentKey(String parentKey) { + this.parentKey = parentKey; + } + + @Override + public String getCustom1() { + return custom1; + } + + @Override + public void setCustom1(String custom1) { + this.custom1 = custom1; + } + + @Override + public String getCustom2() { + return custom2; + } + + @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 int hashCode() { final int prime = 31; @@ -111,7 +209,16 @@ public class ClassificationSummaryImpl implements ClassificationSummary { result = prime * result + ((key == null) ? 0 : key.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((parentId == null) ? 0 : parentId.hashCode()); + result = prime * result + ((parentKey == null) ? 0 : parentKey.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((custom1 == null) ? 0 : custom1.hashCode()); + result = prime * result + ((custom2 == null) ? 0 : custom2.hashCode()); + result = prime * result + ((custom3 == null) ? 0 : custom3.hashCode()); + result = prime * result + ((custom4 == null) ? 0 : custom4.hashCode()); + result = prime * result + ((custom5 == null) ? 0 : custom5.hashCode()); + result = prime * result + ((custom6 == null) ? 0 : custom6.hashCode()); + result = prime * result + ((custom7 == null) ? 0 : custom7.hashCode()); + result = prime * result + ((custom8 == null) ? 0 : custom8.hashCode()); return result; } @@ -169,6 +276,13 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } else if (!parentId.equals(other.parentId)) { return false; } + if (parentKey == null) { + if (other.parentKey != null) { + return false; + } + } else if (!parentKey.equals(other.parentKey)) { + return false; + } if (type == null) { if (other.type != null) { return false; @@ -176,6 +290,62 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } else if (!type.equals(other.type)) { return false; } + if (custom1 == null) { + if (other.custom1 != null) { + return false; + } + } else if (!custom1.equals(other.custom1)) { + return false; + } + if (custom2 == null) { + if (other.custom2 != null) { + return false; + } + } else if (!custom2.equals(other.custom2)) { + return false; + } + if (custom3 == null) { + if (other.custom3 != null) { + return false; + } + } else if (!custom3.equals(other.custom3)) { + return false; + } + if (custom4 == null) { + if (other.custom4 != null) { + return false; + } + } else if (!custom4.equals(other.custom4)) { + return false; + } + if (custom5 == null) { + if (other.custom5 != null) { + return false; + } + } else if (!custom5.equals(other.custom5)) { + return false; + } + if (custom6 == null) { + if (other.custom6 != null) { + return false; + } + } else if (!custom6.equals(other.custom6)) { + return false; + } + if (custom7 == null) { + if (other.custom7 != null) { + return false; + } + } else if (!custom7.equals(other.custom7)) { + return false; + } + if (custom8 == null) { + if (other.custom8 != null) { + return false; + } + } else if (!custom8.equals(other.custom8)) { + return false; + } return true; } @@ -196,10 +366,28 @@ public class ClassificationSummaryImpl implements ClassificationSummary { builder.append(name); builder.append(", parentId="); builder.append(parentId); + builder.append(", parentKey="); + builder.append(parentKey); builder.append(", priority="); builder.append(priority); builder.append(", serviceLevel="); builder.append(serviceLevel); + builder.append(", custom1="); + builder.append(custom1); + builder.append(", custom2="); + builder.append(custom2); + builder.append(", custom3="); + builder.append(custom3); + builder.append(", custom4="); + builder.append(custom4); + builder.append(", custom5="); + builder.append(custom5); + builder.append(", custom6="); + builder.append(custom6); + builder.append(", custom7="); + builder.append(custom7); + builder.append(", custom8="); + builder.append(custom8); builder.append("]"); return builder.toString(); } diff --git a/lib/taskana-core/src/main/java/pro/taskana/mappings/ClassificationMapper.java b/lib/taskana-core/src/main/java/pro/taskana/mappings/ClassificationMapper.java index c5d06c0f1..51304c10d 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/mappings/ClassificationMapper.java +++ b/lib/taskana-core/src/main/java/pro/taskana/mappings/ClassificationMapper.java @@ -18,7 +18,7 @@ import pro.taskana.impl.ClassificationSummaryImpl; */ public interface ClassificationMapper { - @Select("