TSK-149 Use embedded primary ObjectReference without helper fields

This commit is contained in:
BerndBreier 2018-01-16 10:19:51 +01:00 committed by Marcel Lengl
parent edddcce2a0
commit 9a9c8aa5e8
7 changed files with 37 additions and 170 deletions

View File

@ -21,11 +21,6 @@ public class AttachmentImpl implements Attachment {
private Timestamp modified;
private Classification classification;
private ObjectReference objectReference;
private String porCompany;
private String porSystem;
private String porSystemInstance;
private String porType;
private String porValue;
private String channel;
private Timestamp received;
private Map<String, Object> customAttributes = Collections.emptyMap();;
@ -119,46 +114,6 @@ public class AttachmentImpl implements Attachment {
this.customAttributes = customAttributes;
}
public String getPorCompany() {
return porCompany;
}
public void setPorCompany(String porCompany) {
this.porCompany = porCompany;
}
public String getPorSystem() {
return porSystem;
}
public void setPorSystem(String porSystem) {
this.porSystem = porSystem;
}
public String getPorSystemInstance() {
return porSystemInstance;
}
public void setPorSystemInstance(String porSystemInstance) {
this.porSystemInstance = porSystemInstance;
}
public String getPorType() {
return porType;
}
public void setPorType(String porType) {
this.porType = porType;
}
public String getPorValue() {
return porValue;
}
public void setPorValue(String porValue) {
this.porValue = porValue;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -172,16 +127,6 @@ public class AttachmentImpl implements Attachment {
builder.append(modified);
builder.append(", classification=");
builder.append(classification);
builder.append(", porCompany=");
builder.append(porCompany);
builder.append(", porSystem=");
builder.append(porSystem);
builder.append(", porSystemInstance=");
builder.append(porSystemInstance);
builder.append(", porType=");
builder.append(porType);
builder.append(", porValue=");
builder.append(porValue);
builder.append(", objectReference=");
builder.append(objectReference);
builder.append(", channel=");

View File

@ -41,11 +41,6 @@ public class TaskImpl implements Task {
private boolean isTransferred;
// All objects have to be serializable
private Map<String, Object> customAttributes = Collections.emptyMap();
private String porCompany; // auxiliary field needed to avoid 2nd query for primaryObjRef in TaskMapper
private String porSystem; // auxiliary field needed to avoid 2nd query for primaryObjRef in TaskMapper
private String porSystemInstance; // auxiliary field needed to avoid 2nd query for primaryObjRef in TaskMapper
private String porType; // auxiliary field needed to avoid 2nd query for primaryObjRef in TaskMapper
private String porValue; // auxiliary field needed to avoid 2nd query for primaryObjRef in TaskMapper
private List<Attachment> attachments;
private String custom1;
private String custom2;
@ -392,46 +387,6 @@ public class TaskImpl implements Task {
this.classification = classification;
}
public String getPorCompany() {
return porCompany;
}
public void setPorCompany(String porCompany) {
this.porCompany = porCompany;
}
public String getPorSystem() {
return porSystem;
}
public void setPorSystem(String porSystem) {
this.porSystem = porSystem;
}
public String getPorSystemInstance() {
return porSystemInstance;
}
public void setPorSystemInstance(String porSystemInstance) {
this.porSystemInstance = porSystemInstance;
}
public String getPorType() {
return porType;
}
public void setPorType(String porType) {
this.porType = porType;
}
public String getPorValue() {
return porValue;
}
public void setPorValue(String porValue) {
this.porValue = porValue;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -481,16 +436,6 @@ public class TaskImpl implements Task {
builder.append(isTransferred);
builder.append(", customAttributes=");
builder.append(customAttributes);
builder.append(", porCompany=");
builder.append(porCompany);
builder.append(", porSystem=");
builder.append(porSystem);
builder.append(", porSystemInstance=");
builder.append(porSystemInstance);
builder.append(", porType=");
builder.append(porType);
builder.append(", porValue=");
builder.append(porValue);
builder.append(", attachments=");
builder.append(attachments);
builder.append(", custom1=");

View File

@ -203,7 +203,6 @@ public class TaskQueryImpl implements TaskQuery {
checkAuthorization();
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
for (TaskImpl taskImpl : tasks) {
TaskServiceImpl.setPrimaryObjRef(taskImpl);
try {
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
taskImpl.setClassification(classification);
@ -234,7 +233,6 @@ public class TaskQueryImpl implements TaskQuery {
RowBounds rowBounds = new RowBounds(offset, limit);
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
for (TaskImpl taskImpl : tasks) {
TaskServiceImpl.setPrimaryObjRef(taskImpl);
try {
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
taskImpl.setClassification(classification);
@ -263,7 +261,6 @@ public class TaskQueryImpl implements TaskQuery {
taskanaEngineImpl.openConnection();
checkAuthorization();
taskImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
TaskServiceImpl.setPrimaryObjRef(taskImpl);
try {
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
taskImpl.setClassification(classification);

View File

@ -202,10 +202,7 @@ public class TaskServiceImpl implements TaskService {
taskanaEngineImpl.openConnection();
result = taskMapper.findById(id);
if (result != null) {
setPrimaryObjRef(result);
List<Attachment> attachments = setAttachmentObjRef(
attachmentMapper.findAttachmentsByTaskId(result.getId()));
result.setAttachments(attachments);
setAttachments(result);
Classification classification;
try {
classification = this.classificationService.getClassificationByTask(result);
@ -305,7 +302,6 @@ public class TaskServiceImpl implements TaskService {
workbasketService.checkAuthorization(workbasketKey, WorkbasketAuthorization.READ);
List<TaskImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketKey, taskState);
tasks.stream().forEach(t -> {
TaskServiceImpl.setPrimaryObjRef(t);
results.add(t);
});
} finally {
@ -444,31 +440,15 @@ public class TaskServiceImpl implements TaskService {
return new AttachmentImpl();
}
static void setPrimaryObjRef(TaskImpl task) {
ObjectReference objRef = new ObjectReference();
objRef.setCompany(task.getPorCompany());
objRef.setSystem(task.getPorSystem());
objRef.setSystemInstance(task.getPorSystemInstance());
objRef.setType(task.getPorType());
objRef.setValue(task.getPorValue());
task.setPrimaryObjRef(objRef);
}
private List<Attachment> setAttachmentObjRef(List<AttachmentImpl> attachments) {
List<Attachment> results = new ArrayList<>();
if (attachments != null && !attachments.isEmpty()) {
for (AttachmentImpl attachment : attachments) {
ObjectReference objRef = new ObjectReference();
objRef.setCompany(attachment.getPorCompany());
objRef.setSystem(attachment.getPorSystem());
objRef.setSystemInstance(attachment.getPorSystemInstance());
objRef.setType(attachment.getPorType());
objRef.setValue(attachment.getPorValue());
attachment.setObjectReference(objRef);
results.add(attachment);
private void setAttachments(TaskImpl result) {
List<AttachmentImpl> attachmentImpls = attachmentMapper.findAttachmentsByTaskId(result.getId());
List<Attachment> attachments = new ArrayList<>();
if (attachmentImpls != null && !attachmentImpls.isEmpty()) {
for (AttachmentImpl attImpl : attachmentImpls) {
attachments.add(attImpl);
}
}
return results;
result.setAttachments(attachments);
}
private void validateObjectReference(ObjectReference objRef, String objRefType, String objName)

View File

@ -37,11 +37,11 @@ public interface AttachmentMapper {
@Result(property = "modified", column = "MODIFIED"),
@Result(property = "classification", column = "CLASSIFICATION_KEY", javaType = Classification.class,
one = @One(select = CLASSIFICATION_FINDBYID)),
@Result(property = "porCompany", column = "REF_COMPANY"),
@Result(property = "porSystem", column = "REF_SYSTEM"),
@Result(property = "porSystemInstance", column = "REF_INSTANCE"),
@Result(property = "porType", column = "REF_TYPE"),
@Result(property = "porValue", column = "REF_VALUE"),
@Result(property = "objectReference.company", column = "REF_COMPANY"),
@Result(property = "objectReference.system", column = "REF_SYSTEM"),
@Result(property = "objectReference.systemInstance", column = "REF_INSTANCE"),
@Result(property = "objectReference.type", column = "REF_TYPE"),
@Result(property = "objectReference.value", column = "REF_VALUE"),
@Result(property = "channel", column = "CHANNEL"),
@Result(property = "received", column = "RECEIVED"),
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,

View File

@ -51,7 +51,7 @@ public interface QueryMapper {
+ "<if test='customFields != null'>AND (t.CUSTOM_1 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_2 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_3 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_4 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_5 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_6 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_7 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_8 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_9 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>) OR t.CUSTOM_10 IN(<foreach item='item' collection='customFields' separator=',' >#{item}</foreach>))</if> "
+ "</where>"
+ "</script>")
@Results(value = { @Result(property = "id", column = "ID"),
@Results(value = {@Result(property = "id", column = "ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "claimed", column = "CLAIMED"),
@Result(property = "completed", column = "COMPLETED"),
@ -69,11 +69,11 @@ public interface QueryMapper {
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
@Result(property = "owner", column = "OWNER"),
@Result(property = "porCompany", column = "POR_COMPANY"),
@Result(property = "porSystem", column = "POR_SYSTEM"),
@Result(property = "porSystemInstance", column = "POR_INSTANCE"),
@Result(property = "porType", column = "POR_TYPE"),
@Result(property = "porValue", column = "POR_VALUE"),
@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"),
@ -85,7 +85,7 @@ 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")})
List<TaskImpl> queryTasks(TaskQueryImpl taskQuery);
@Select("<script>SELECT ID, KEY, PARENT_CLASSIFICATION_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
@ -108,13 +108,13 @@ public interface QueryMapper {
+ "<if test='validUntil != null'>AND VALID_UNTIL IN(<foreach item='item' collection='validUntil' separator=',' >#{item}</foreach>)</if> "
+ "</where>"
+ "</script>")
@Results({ @Result(property = "id", column = "ID"),
@Results({@Result(property = "id", column = "ID"),
@Result(property = "key", column = "KEY"),
@Result(property = "category", column = "CATEGORY"),
@Result(property = "type", column = "TYPE"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "name", column = "NAME"),
@Result(property = "validUntil", column = "VALID_UNTIL") })
@Result(property = "validUntil", column = "VALID_UNTIL")})
List<ClassificationSummaryImpl> queryClassification(ClassificationQueryImpl classificationQuery);
@Select("<script>SELECT ID, COMPANY, SYSTEM, SYSTEM_INSTANCE, TYPE, VALUE "
@ -133,7 +133,7 @@ public interface QueryMapper {
@Result(property = "system", column = "SYSTEM"),
@Result(property = "systemInstance", column = "SYSTEM_INSTANCE"),
@Result(property = "type", column = "TYPE"),
@Result(property = "value", column = "VALUE") })
@Result(property = "value", column = "VALUE")})
List<ObjectReference> queryObjectReference(ObjectReferenceQueryImpl objectReference);
@Select("<script>SELECT w.ID, w.KEY, w.NAME, w.DOMAIN, W.TYPE, w.DESCRIPTION, w.OWNER, w.ORG_LEVEL_1, w.ORG_LEVEL_2, w.ORG_LEVEL_3, w.ORG_LEVEL_4 from WORKBASKET w "
@ -178,6 +178,6 @@ public interface QueryMapper {
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
List<WorkbasketSummary> queryWorkbasket(WorkbasketQueryImpl workbasketQuery);
}

View File

@ -53,11 +53,11 @@ public interface TaskMapper {
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
@Result(property = "owner", column = "OWNER"),
@Result(property = "porCompany", column = "POR_COMPANY"),
@Result(property = "porSystem", column = "POR_SYSTEM"),
@Result(property = "porSystemInstance", column = "POR_INSTANCE"),
@Result(property = "porType", column = "POR_TYPE"),
@Result(property = "porValue", column = "POR_VALUE"),
@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 = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
@ -75,9 +75,9 @@ public interface TaskMapper {
})
TaskImpl findById(@Param("id") String id);
@Results({ @Result(column = "DUE_DATE", property = "due"),
@Results({@Result(column = "DUE_DATE", property = "due"),
@Result(column = "WORKBASKET_KEY", property = "workbasketKey"),
@Result(column = "counter", property = "taskCounter") })
@Result(column = "counter", property = "taskCounter")})
List<DueWorkbasketCounter> getTaskCountByWorkbasketIdAndDaysInPastAndState(@Param("fromDate") Date fromDate,
@Param("status") List<TaskState> states);
@ -115,11 +115,11 @@ public interface TaskMapper {
one = @One(select = CLASSIFICATION_FINDBYKEYANDDOMAIN)),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "owner", column = "OWNER"),
@Result(property = "porCompany", column = "POR_COMPANY"),
@Result(property = "porSystem", column = "POR_SYSTEM"),
@Result(property = "porSystemInstance", column = "POR_INSTANCE"),
@Result(property = "porType", column = "POR_TYPE"),
@Result(property = "porValue", column = "POR_VALUE"),
@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 = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
@ -133,7 +133,7 @@ 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")})
List<TaskImpl> findTasksByWorkbasketIdAndState(@Param("workbasketKey") String workbasketKey,
@Param("taskState") TaskState taskState);