TSK-149 Use embedded primary ObjectReference without helper fields
This commit is contained in:
parent
edddcce2a0
commit
9a9c8aa5e8
|
|
@ -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=");
|
||||
|
|
|
|||
|
|
@ -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=");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue