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 d3da95f00..542c66561 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 @@ -315,4 +315,199 @@ public class ClassificationImpl implements Classification { builder.append("]"); return builder.toString(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((applicationEntryPoint == null) ? 0 : applicationEntryPoint.hashCode()); + result = prime * result + ((category == null) ? 0 : category.hashCode()); + result = prime * result + ((created == null) ? 0 : created.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()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((domain == null) ? 0 : domain.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((isValidInDomain == null) ? 0 : isValidInDomain.hashCode()); + result = prime * result + ((key == null) ? 0 : key.hashCode()); + 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 + priority; + result = prime * result + ((serviceLevel == null) ? 0 : serviceLevel.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ClassificationImpl other = (ClassificationImpl) obj; + if (applicationEntryPoint == null) { + if (other.applicationEntryPoint != null) { + return false; + } + } else if (!applicationEntryPoint.equals(other.applicationEntryPoint)) { + return false; + } + if (category == null) { + if (other.category != null) { + return false; + } + } else if (!category.equals(other.category)) { + return false; + } + if (created == null) { + if (other.created != null) { + return false; + } + } else if (!created.equals(other.created)) { + 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; + } + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (domain == null) { + if (other.domain != null) { + return false; + } + } else if (!domain.equals(other.domain)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (isValidInDomain == null) { + if (other.isValidInDomain != null) { + return false; + } + } else if (!isValidInDomain.equals(other.isValidInDomain)) { + return false; + } + if (key == null) { + if (other.key != null) { + return false; + } + } else if (!key.equals(other.key)) { + return false; + } + if (modified == null) { + if (other.modified != null) { + return false; + } + } else if (!modified.equals(other.modified)) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (parentId == null) { + if (other.parentId != null) { + return false; + } + } else if (!parentId.equals(other.parentId)) { + return false; + } + if (priority != other.priority) { + return false; + } + if (serviceLevel == null) { + if (other.serviceLevel != null) { + return false; + } + } else if (!serviceLevel.equals(other.serviceLevel)) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + return true; + } + } 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 14d264bf7..011475e2c 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 @@ -756,4 +756,322 @@ public class TaskImpl implements Task { return builder.toString(); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((attachments == null) ? 0 : attachments.hashCode()); + result = prime * result + ((businessProcessId == null) ? 0 : businessProcessId.hashCode()); + result = prime * result + ((claimed == null) ? 0 : claimed.hashCode()); + result = prime * result + ((classificationSummary == null) ? 0 : classificationSummary.hashCode()); + result = prime * result + ((completed == null) ? 0 : completed.hashCode()); + result = prime * result + ((created == null) ? 0 : created.hashCode()); + result = prime * result + ((creator == null) ? 0 : creator.hashCode()); + result = prime * result + ((custom1 == null) ? 0 : custom1.hashCode()); + result = prime * result + ((custom10 == null) ? 0 : custom10.hashCode()); + result = prime * result + ((custom11 == null) ? 0 : custom11.hashCode()); + result = prime * result + ((custom12 == null) ? 0 : custom12.hashCode()); + result = prime * result + ((custom13 == null) ? 0 : custom13.hashCode()); + result = prime * result + ((custom14 == null) ? 0 : custom14.hashCode()); + result = prime * result + ((custom15 == null) ? 0 : custom15.hashCode()); + result = prime * result + ((custom16 == null) ? 0 : custom16.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()); + result = prime * result + ((custom9 == null) ? 0 : custom9.hashCode()); + result = prime * result + ((customAttributes == null) ? 0 : customAttributes.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((due == null) ? 0 : due.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + (isRead ? 1231 : 1237); + result = prime * result + (isTransferred ? 1231 : 1237); + result = prime * result + ((modified == null) ? 0 : modified.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((note == null) ? 0 : note.hashCode()); + result = prime * result + ((owner == null) ? 0 : owner.hashCode()); + result = prime * result + ((parentBusinessProcessId == null) ? 0 : parentBusinessProcessId.hashCode()); + result = prime * result + ((planned == null) ? 0 : planned.hashCode()); + result = prime * result + ((primaryObjRef == null) ? 0 : primaryObjRef.hashCode()); + result = prime * result + priority; + result = prime * result + ((state == null) ? 0 : state.hashCode()); + result = prime * result + ((workbasketSummary == null) ? 0 : workbasketSummary.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + TaskImpl other = (TaskImpl) obj; + if (attachments == null) { + if (other.attachments != null) { + return false; + } + } else if (!attachments.equals(other.attachments)) { + return false; + } + if (businessProcessId == null) { + if (other.businessProcessId != null) { + return false; + } + } else if (!businessProcessId.equals(other.businessProcessId)) { + return false; + } + if (claimed == null) { + if (other.claimed != null) { + return false; + } + } else if (!claimed.equals(other.claimed)) { + return false; + } + if (classificationSummary == null) { + if (other.classificationSummary != null) { + return false; + } + } else if (!classificationSummary.equals(other.classificationSummary)) { + return false; + } + if (completed == null) { + if (other.completed != null) { + return false; + } + } else if (!completed.equals(other.completed)) { + return false; + } + if (created == null) { + if (other.created != null) { + return false; + } + } else if (!created.equals(other.created)) { + return false; + } + if (creator == null) { + if (other.creator != null) { + return false; + } + } else if (!creator.equals(other.creator)) { + return false; + } + if (custom1 == null) { + if (other.custom1 != null) { + return false; + } + } else if (!custom1.equals(other.custom1)) { + return false; + } + if (custom10 == null) { + if (other.custom10 != null) { + return false; + } + } else if (!custom10.equals(other.custom10)) { + return false; + } + if (custom11 == null) { + if (other.custom11 != null) { + return false; + } + } else if (!custom11.equals(other.custom11)) { + return false; + } + if (custom12 == null) { + if (other.custom12 != null) { + return false; + } + } else if (!custom12.equals(other.custom12)) { + return false; + } + if (custom13 == null) { + if (other.custom13 != null) { + return false; + } + } else if (!custom13.equals(other.custom13)) { + return false; + } + if (custom14 == null) { + if (other.custom14 != null) { + return false; + } + } else if (!custom14.equals(other.custom14)) { + return false; + } + if (custom15 == null) { + if (other.custom15 != null) { + return false; + } + } else if (!custom15.equals(other.custom15)) { + return false; + } + if (custom16 == null) { + if (other.custom16 != null) { + return false; + } + } else if (!custom16.equals(other.custom16)) { + 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; + } + if (custom9 == null) { + if (other.custom9 != null) { + return false; + } + } else if (!custom9.equals(other.custom9)) { + return false; + } + if (customAttributes == null) { + if (other.customAttributes != null) { + return false; + } + } else if (!customAttributes.equals(other.customAttributes)) { + return false; + } + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (due == null) { + if (other.due != null) { + return false; + } + } else if (!due.equals(other.due)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (isRead != other.isRead) { + return false; + } + if (isTransferred != other.isTransferred) { + return false; + } + if (modified == null) { + if (other.modified != null) { + return false; + } + } else if (!modified.equals(other.modified)) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (note == null) { + if (other.note != null) { + return false; + } + } else if (!note.equals(other.note)) { + return false; + } + if (owner == null) { + if (other.owner != null) { + return false; + } + } else if (!owner.equals(other.owner)) { + return false; + } + if (parentBusinessProcessId == null) { + if (other.parentBusinessProcessId != null) { + return false; + } + } else if (!parentBusinessProcessId.equals(other.parentBusinessProcessId)) { + return false; + } + if (planned == null) { + if (other.planned != null) { + return false; + } + } else if (!planned.equals(other.planned)) { + return false; + } + if (primaryObjRef == null) { + if (other.primaryObjRef != null) { + return false; + } + } else if (!primaryObjRef.equals(other.primaryObjRef)) { + return false; + } + if (priority != other.priority) { + return false; + } + if (state != other.state) { + return false; + } + if (workbasketSummary == null) { + if (other.workbasketSummary != null) { + return false; + } + } else if (!workbasketSummary.equals(other.workbasketSummary)) { + return false; + } + return true; + } + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java index 445655ad8..752083c1e 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java @@ -428,4 +428,119 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem { builder.append("]"); return builder.toString(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((accessId == null) ? 0 : accessId.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + (permAppend ? 1231 : 1237); + result = prime * result + (permCustom1 ? 1231 : 1237); + result = prime * result + (permCustom10 ? 1231 : 1237); + result = prime * result + (permCustom11 ? 1231 : 1237); + result = prime * result + (permCustom12 ? 1231 : 1237); + result = prime * result + (permCustom2 ? 1231 : 1237); + result = prime * result + (permCustom3 ? 1231 : 1237); + result = prime * result + (permCustom4 ? 1231 : 1237); + result = prime * result + (permCustom5 ? 1231 : 1237); + result = prime * result + (permCustom6 ? 1231 : 1237); + result = prime * result + (permCustom7 ? 1231 : 1237); + result = prime * result + (permCustom8 ? 1231 : 1237); + result = prime * result + (permCustom9 ? 1231 : 1237); + result = prime * result + (permDistribute ? 1231 : 1237); + result = prime * result + (permOpen ? 1231 : 1237); + result = prime * result + (permRead ? 1231 : 1237); + result = prime * result + (permTransfer ? 1231 : 1237); + result = prime * result + ((workbasketId == null) ? 0 : workbasketId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + WorkbasketAccessItemImpl other = (WorkbasketAccessItemImpl) obj; + if (accessId == null) { + if (other.accessId != null) { + return false; + } + } else if (!accessId.equals(other.accessId)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (permAppend != other.permAppend) { + return false; + } + if (permCustom1 != other.permCustom1) { + return false; + } + if (permCustom10 != other.permCustom10) { + return false; + } + if (permCustom11 != other.permCustom11) { + return false; + } + if (permCustom12 != other.permCustom12) { + return false; + } + if (permCustom2 != other.permCustom2) { + return false; + } + if (permCustom3 != other.permCustom3) { + return false; + } + if (permCustom4 != other.permCustom4) { + return false; + } + if (permCustom5 != other.permCustom5) { + return false; + } + if (permCustom6 != other.permCustom6) { + return false; + } + if (permCustom7 != other.permCustom7) { + return false; + } + if (permCustom8 != other.permCustom8) { + return false; + } + if (permCustom9 != other.permCustom9) { + return false; + } + if (permDistribute != other.permDistribute) { + return false; + } + if (permOpen != other.permOpen) { + return false; + } + if (permRead != other.permRead) { + return false; + } + if (permTransfer != other.permTransfer) { + return false; + } + if (workbasketId == null) { + if (other.workbasketId != null) { + return false; + } + } else if (!workbasketId.equals(other.workbasketId)) { + return false; + } + return true; + } + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java index 77fa32508..6ecc1a4bc 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java @@ -5,8 +5,6 @@ import pro.taskana.WorkbasketType; /** * This entity contains the most important information about a workbasket. - * - * @author bbr */ public class WorkbasketSummaryImpl implements WorkbasketSummary { @@ -23,7 +21,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { private String orgLevel4; WorkbasketSummaryImpl() { - } /* @@ -195,7 +192,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { if (obj == null) { return false; } - if (!(obj instanceof WorkbasketSummaryImpl)) { + if (getClass() != obj.getClass()) { return false; } WorkbasketSummaryImpl other = (WorkbasketSummaryImpl) obj; diff --git a/lib/taskana-core/src/test/java/acceptance/task/CreateTaskAccTest.java b/lib/taskana-core/src/test/java/acceptance/task/CreateTaskAccTest.java index 4d33c7b40..5deaf5c26 100644 --- a/lib/taskana-core/src/test/java/acceptance/task/CreateTaskAccTest.java +++ b/lib/taskana-core/src/test/java/acceptance/task/CreateTaskAccTest.java @@ -545,4 +545,32 @@ public class CreateTaskAccTest extends AbstractAccTest { assertEquals(workbasket.getDomain(), createdTask.getDomain()); } + @WithAccessId( + userName = "user_1_1", + groupNames = {"group_1"}) + @Test + public void testCreatedTaskObjectEqualsReadTaskObject() + throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, + WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException { + + TaskService taskService = taskanaEngine.getTaskService(); + Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A"); + newTask.setClassificationKey("T2100"); + newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); + for (int i = 1; i < 16; i++) { + newTask.setCustomAttribute(Integer.toString(i), "VALUE " + i); + } + newTask.setCustomAttributes(createSimpleCustomProperties(5)); + newTask.setDescription("Description of test task"); + newTask.setNote("My note"); + newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", + createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", + "12345678901234567890123456789012345678901234567890"), + "E-MAIL", "2018-01-15", createSimpleCustomProperties(3))); + Task createdTask = taskService.createTask(newTask); + Task readTask = taskService.getTask(createdTask.getId()); + + assertEquals(createdTask, readTask); + } + }