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 Timestamp modified;
|
||||||
private Classification classification;
|
private Classification classification;
|
||||||
private ObjectReference objectReference;
|
private ObjectReference objectReference;
|
||||||
private String porCompany;
|
|
||||||
private String porSystem;
|
|
||||||
private String porSystemInstance;
|
|
||||||
private String porType;
|
|
||||||
private String porValue;
|
|
||||||
private String channel;
|
private String channel;
|
||||||
private Timestamp received;
|
private Timestamp received;
|
||||||
private Map<String, Object> customAttributes = Collections.emptyMap();;
|
private Map<String, Object> customAttributes = Collections.emptyMap();;
|
||||||
|
|
@ -119,46 +114,6 @@ public class AttachmentImpl implements Attachment {
|
||||||
this.customAttributes = customAttributes;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
@ -172,16 +127,6 @@ public class AttachmentImpl implements Attachment {
|
||||||
builder.append(modified);
|
builder.append(modified);
|
||||||
builder.append(", classification=");
|
builder.append(", classification=");
|
||||||
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(objectReference);
|
builder.append(objectReference);
|
||||||
builder.append(", channel=");
|
builder.append(", channel=");
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,6 @@ public class TaskImpl implements Task {
|
||||||
private boolean isTransferred;
|
private boolean isTransferred;
|
||||||
// All objects have to be serializable
|
// All objects have to be serializable
|
||||||
private Map<String, Object> customAttributes = Collections.emptyMap();
|
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 List<Attachment> attachments;
|
||||||
private String custom1;
|
private String custom1;
|
||||||
private String custom2;
|
private String custom2;
|
||||||
|
|
@ -392,46 +387,6 @@ public class TaskImpl implements Task {
|
||||||
this.classification = classification;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
@ -481,16 +436,6 @@ public class TaskImpl implements Task {
|
||||||
builder.append(isTransferred);
|
builder.append(isTransferred);
|
||||||
builder.append(", customAttributes=");
|
builder.append(", customAttributes=");
|
||||||
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(attachments);
|
builder.append(attachments);
|
||||||
builder.append(", custom1=");
|
builder.append(", custom1=");
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,6 @@ public class TaskQueryImpl implements TaskQuery {
|
||||||
checkAuthorization();
|
checkAuthorization();
|
||||||
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||||
for (TaskImpl taskImpl : tasks) {
|
for (TaskImpl taskImpl : tasks) {
|
||||||
TaskServiceImpl.setPrimaryObjRef(taskImpl);
|
|
||||||
try {
|
try {
|
||||||
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
|
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
|
||||||
taskImpl.setClassification(classification);
|
taskImpl.setClassification(classification);
|
||||||
|
|
@ -234,7 +233,6 @@ public class TaskQueryImpl implements TaskQuery {
|
||||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||||
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||||
for (TaskImpl taskImpl : tasks) {
|
for (TaskImpl taskImpl : tasks) {
|
||||||
TaskServiceImpl.setPrimaryObjRef(taskImpl);
|
|
||||||
try {
|
try {
|
||||||
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
|
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
|
||||||
taskImpl.setClassification(classification);
|
taskImpl.setClassification(classification);
|
||||||
|
|
@ -263,7 +261,6 @@ public class TaskQueryImpl implements TaskQuery {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
checkAuthorization();
|
checkAuthorization();
|
||||||
taskImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
taskImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||||
TaskServiceImpl.setPrimaryObjRef(taskImpl);
|
|
||||||
try {
|
try {
|
||||||
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
|
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
|
||||||
taskImpl.setClassification(classification);
|
taskImpl.setClassification(classification);
|
||||||
|
|
|
||||||
|
|
@ -202,10 +202,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
result = taskMapper.findById(id);
|
result = taskMapper.findById(id);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
setPrimaryObjRef(result);
|
setAttachments(result);
|
||||||
List<Attachment> attachments = setAttachmentObjRef(
|
|
||||||
attachmentMapper.findAttachmentsByTaskId(result.getId()));
|
|
||||||
result.setAttachments(attachments);
|
|
||||||
Classification classification;
|
Classification classification;
|
||||||
try {
|
try {
|
||||||
classification = this.classificationService.getClassificationByTask(result);
|
classification = this.classificationService.getClassificationByTask(result);
|
||||||
|
|
@ -305,7 +302,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
workbasketService.checkAuthorization(workbasketKey, WorkbasketAuthorization.READ);
|
workbasketService.checkAuthorization(workbasketKey, WorkbasketAuthorization.READ);
|
||||||
List<TaskImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketKey, taskState);
|
List<TaskImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketKey, taskState);
|
||||||
tasks.stream().forEach(t -> {
|
tasks.stream().forEach(t -> {
|
||||||
TaskServiceImpl.setPrimaryObjRef(t);
|
|
||||||
results.add(t);
|
results.add(t);
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -444,31 +440,15 @@ public class TaskServiceImpl implements TaskService {
|
||||||
return new AttachmentImpl();
|
return new AttachmentImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPrimaryObjRef(TaskImpl task) {
|
private void setAttachments(TaskImpl result) {
|
||||||
ObjectReference objRef = new ObjectReference();
|
List<AttachmentImpl> attachmentImpls = attachmentMapper.findAttachmentsByTaskId(result.getId());
|
||||||
objRef.setCompany(task.getPorCompany());
|
List<Attachment> attachments = new ArrayList<>();
|
||||||
objRef.setSystem(task.getPorSystem());
|
if (attachmentImpls != null && !attachmentImpls.isEmpty()) {
|
||||||
objRef.setSystemInstance(task.getPorSystemInstance());
|
for (AttachmentImpl attImpl : attachmentImpls) {
|
||||||
objRef.setType(task.getPorType());
|
attachments.add(attImpl);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
result.setAttachments(attachments);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateObjectReference(ObjectReference objRef, String objRefType, String objName)
|
private void validateObjectReference(ObjectReference objRef, String objRefType, String objName)
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,11 @@ public interface AttachmentMapper {
|
||||||
@Result(property = "modified", column = "MODIFIED"),
|
@Result(property = "modified", column = "MODIFIED"),
|
||||||
@Result(property = "classification", column = "CLASSIFICATION_KEY", javaType = Classification.class,
|
@Result(property = "classification", column = "CLASSIFICATION_KEY", javaType = Classification.class,
|
||||||
one = @One(select = CLASSIFICATION_FINDBYID)),
|
one = @One(select = CLASSIFICATION_FINDBYID)),
|
||||||
@Result(property = "porCompany", column = "REF_COMPANY"),
|
@Result(property = "objectReference.company", column = "REF_COMPANY"),
|
||||||
@Result(property = "porSystem", column = "REF_SYSTEM"),
|
@Result(property = "objectReference.system", column = "REF_SYSTEM"),
|
||||||
@Result(property = "porSystemInstance", column = "REF_INSTANCE"),
|
@Result(property = "objectReference.systemInstance", column = "REF_INSTANCE"),
|
||||||
@Result(property = "porType", column = "REF_TYPE"),
|
@Result(property = "objectReference.type", column = "REF_TYPE"),
|
||||||
@Result(property = "porValue", column = "REF_VALUE"),
|
@Result(property = "objectReference.value", column = "REF_VALUE"),
|
||||||
@Result(property = "channel", column = "CHANNEL"),
|
@Result(property = "channel", column = "CHANNEL"),
|
||||||
@Result(property = "received", column = "RECEIVED"),
|
@Result(property = "received", column = "RECEIVED"),
|
||||||
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
|
@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 = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
|
||||||
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
|
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
|
||||||
@Result(property = "owner", column = "OWNER"),
|
@Result(property = "owner", column = "OWNER"),
|
||||||
@Result(property = "porCompany", column = "POR_COMPANY"),
|
@Result(property = "primaryObjRef.company", column = "POR_COMPANY"),
|
||||||
@Result(property = "porSystem", column = "POR_SYSTEM"),
|
@Result(property = "primaryObjRef.system", column = "POR_SYSTEM"),
|
||||||
@Result(property = "porSystemInstance", column = "POR_INSTANCE"),
|
@Result(property = "primaryObjRef.systemInstance", column = "POR_INSTANCE"),
|
||||||
@Result(property = "porType", column = "POR_TYPE"),
|
@Result(property = "primaryObjRef.type", column = "POR_TYPE"),
|
||||||
@Result(property = "porValue", column = "POR_VALUE"),
|
@Result(property = "primaryObjRef.value", column = "POR_VALUE"),
|
||||||
@Result(property = "isRead", column = "IS_READ"),
|
@Result(property = "isRead", column = "IS_READ"),
|
||||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,11 @@ public interface TaskMapper {
|
||||||
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
|
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
|
||||||
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
|
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
|
||||||
@Result(property = "owner", column = "OWNER"),
|
@Result(property = "owner", column = "OWNER"),
|
||||||
@Result(property = "porCompany", column = "POR_COMPANY"),
|
@Result(property = "primaryObjRef.company", column = "POR_COMPANY"),
|
||||||
@Result(property = "porSystem", column = "POR_SYSTEM"),
|
@Result(property = "primaryObjRef.system", column = "POR_SYSTEM"),
|
||||||
@Result(property = "porSystemInstance", column = "POR_INSTANCE"),
|
@Result(property = "primaryObjRef.systemInstance", column = "POR_INSTANCE"),
|
||||||
@Result(property = "porType", column = "POR_TYPE"),
|
@Result(property = "primaryObjRef.type", column = "POR_TYPE"),
|
||||||
@Result(property = "porValue", column = "POR_VALUE"),
|
@Result(property = "primaryObjRef.value", column = "POR_VALUE"),
|
||||||
@Result(property = "isRead", column = "IS_READ"),
|
@Result(property = "isRead", column = "IS_READ"),
|
||||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||||
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
|
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
|
||||||
|
|
@ -115,11 +115,11 @@ public interface TaskMapper {
|
||||||
one = @One(select = CLASSIFICATION_FINDBYKEYANDDOMAIN)),
|
one = @One(select = CLASSIFICATION_FINDBYKEYANDDOMAIN)),
|
||||||
@Result(property = "domain", column = "DOMAIN"),
|
@Result(property = "domain", column = "DOMAIN"),
|
||||||
@Result(property = "owner", column = "OWNER"),
|
@Result(property = "owner", column = "OWNER"),
|
||||||
@Result(property = "porCompany", column = "POR_COMPANY"),
|
@Result(property = "primaryObjRef.company", column = "POR_COMPANY"),
|
||||||
@Result(property = "porSystem", column = "POR_SYSTEM"),
|
@Result(property = "primaryObjRef.system", column = "POR_SYSTEM"),
|
||||||
@Result(property = "porSystemInstance", column = "POR_INSTANCE"),
|
@Result(property = "primaryObjRef.systemInstance", column = "POR_INSTANCE"),
|
||||||
@Result(property = "porType", column = "POR_TYPE"),
|
@Result(property = "primaryObjRef.type", column = "POR_TYPE"),
|
||||||
@Result(property = "porValue", column = "POR_VALUE"),
|
@Result(property = "primaryObjRef.value", column = "POR_VALUE"),
|
||||||
@Result(property = "isRead", column = "IS_READ"),
|
@Result(property = "isRead", column = "IS_READ"),
|
||||||
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
@Result(property = "isTransferred", column = "IS_TRANSFERRED"),
|
||||||
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
|
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue