TSK-1065 Refactor TaskImpl

This commit is contained in:
Sofie Hofmann 2020-02-06 14:39:31 +01:00 committed by Mustapha Zorgati
parent e308578ced
commit 6eeff1ba22
16 changed files with 151 additions and 849 deletions

View File

@ -511,7 +511,7 @@ public class ClassificationServiceImpl implements ClassificationService {
if (!taskSummaries.isEmpty()) {
List<String> taskIds = new ArrayList<>();
taskSummaries.forEach(ts -> taskIds.add(ts.getTaskId()));
taskSummaries.forEach(ts -> taskIds.add(ts.getId()));
taskMapper.updateClassificationCategoryOnChange(taskIds, classificationImpl.getCategory());
}
}

View File

@ -178,7 +178,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
}
List<String> tasksIdsToBeDeleted =
tasksToBeDeleted.stream().map(task -> task.getTaskId()).collect(Collectors.toList());
tasksToBeDeleted.stream().map(task -> task.getId()).collect(Collectors.toList());
BulkOperationResults<String, TaskanaException> results =
taskanaEngineImpl.getTaskService().deleteTasks(tasksIdsToBeDeleted);
LOGGER.debug("{} tasks deleted.", tasksIdsToBeDeleted.size() - results.getFailedIds().size());

View File

@ -33,7 +33,7 @@ public class TaskEvent extends TaskanaHistoryEvent {
public TaskEvent(TaskSummary task) {
super();
taskId = task.getTaskId();
taskId = task.getId();
businessProcessId = task.getBusinessProcessId();
parentBusinessProcessId = task.getParentBusinessProcessId();
domain = task.getDomain();

View File

@ -5,12 +5,10 @@ import java.util.List;
import java.util.Map;
import pro.taskana.classification.api.Classification;
import pro.taskana.classification.api.ClassificationSummary;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.workbasket.api.WorkbasketSummary;
/** task-Interface to specify attribute interactions. */
public interface Task {
public interface Task extends TaskSummary {
/**
* The key that is used to supply Callback_state within the CallbackInfo map. The Callback_state
@ -19,22 +17,6 @@ public interface Task {
*/
String CALLBACK_STATE = "callbackState";
/**
* Returns the current id of the task.
*
* @return taskId
*/
String getId();
/**
* Returns the external id of the task. This Id can be used to correlate the task to a task in an
* external system and to enforce idempotency of task creation. If not set by the client, it will
* be set by taskana.
*
* @return external Id
*/
String getExternalId();
/**
* Sets the external Id. It can be used to correlate the task to a task in an external system. The
* external Id is enforced to be unique. An attempt to create a task with an existing external Id
@ -46,48 +28,6 @@ public interface Task {
*/
void setExternalId(String externalId);
/**
* Gets the UserId of the task-creator.
*
* @return creator
*/
String getCreator();
/**
* Returns the time when the task was {@link TaskState#READY}.
*
* @return created as exact {@link Instant}
*/
Instant getCreated();
/**
* Returns the time when the task was set to {@link TaskState#CLAIMED} by/to a user.
*
* @return claimed as exact {@link Instant}
*/
Instant getClaimed();
/**
* Returns the time when the task was set into {@link TaskState#COMPLETED}.
*
* @return completed as exact {@link Instant}
*/
Instant getCompleted();
/**
* Returns the time when the task was modified the last time.
*
* @return modified as exact {@link Instant}
*/
Instant getModified();
/**
* Returns the time when the work on this task was planned to be started.
*
* @return planned as exact {@link Instant}
*/
Instant getPlanned();
/**
* Sets the time when the work on this task should be started.
*
@ -95,13 +35,6 @@ public interface Task {
*/
void setPlanned(Instant planned);
/**
* Returns the time when this task should be finished.
*
* @return due as exact {@link Instant}
*/
Instant getDue();
/**
* Sets the time when the work on this task should be finished.
*
@ -109,13 +42,6 @@ public interface Task {
*/
void setDue(Instant due);
/**
* Return the name of the current task.
*
* @return name of the task
*/
String getName();
/**
* Sets the name of the current task.
*
@ -123,13 +49,6 @@ public interface Task {
*/
void setName(String name);
/**
* Return the task-description.
*
* @return description of a task
*/
String getDescription();
/**
* Sets the description of the task.
*
@ -137,27 +56,6 @@ public interface Task {
*/
void setDescription(String description);
/**
* Returns the numeric priority of a task.
*
* @return priority of the task
*/
int getPriority();
/**
* Returns the current {@link TaskState} of the task.
*
* @return taskState
*/
TaskState getState();
/**
* Returns the {@link ClassificationSummary} of the task.
*
* @return classification summary for the task
*/
ClassificationSummary getClassificationSummary();
/**
* Sets the Classification key that - together with the Domain from this task's work basket -
* selects the appropriate {@link Classification} for this task.
@ -173,90 +71,6 @@ public interface Task {
*/
String getWorkbasketKey();
/**
* Returns the the Summary of the workbasket where the task is stored in.
*
* @return workbasketSummary
*/
WorkbasketSummary getWorkbasketSummary();
/**
* Returns the Domain, to which the Task belongs at this moment.
*
* @return domain the current domain of the task
*/
String getDomain();
/**
* Returns the businessProcessId of a task.
*
* @return businessProcessId Gets the business process id the task belongs to.
*/
String getBusinessProcessId();
/**
* Sets the external business process id.
*
* @param businessProcessId Sets the business process id the task belongs to.
*/
void setBusinessProcessId(String businessProcessId);
/**
* Returns the parentBusinessProcessId of a task.
*
* @return parentBusinessProcessId Gets the parent business process id the task belongs to
*/
String getParentBusinessProcessId();
/**
* Sets the parent business process id to group associated processes.
*
* @param parentBusinessProcessId Sets the parent business process id the task belongs to
*/
void setParentBusinessProcessId(String parentBusinessProcessId);
/**
* Return the id of the task-owner.
*
* @return taskOwnerId
*/
String getOwner();
/**
* Sets the ownerId of this task.
*
* @param taskOwnerId the user id of the task's owner
*/
void setOwner(String taskOwnerId);
/**
* Returns the {@link ObjectReference primaryObjectReference} of the task.
*
* @return primaryObjRef to task main-subject
*/
ObjectReference getPrimaryObjRef();
/**
* Sets the {@link ObjectReference primaryObjectReference} of the task.
*
* @param primaryObjRef to task main-subject
*/
void setPrimaryObjRef(ObjectReference primaryObjRef);
/**
* Return the isRead-flag, which flags a task as viewed at least one time.
*
* @return isRead-flag
*/
boolean isRead();
/**
* Return the isTransferred-flag, which flags a task as transfered into an other workbasket.
*
* @return isTransferred-flag
*/
boolean isTransferred();
/**
* Returns a Map of custom Attributes.
*
@ -285,17 +99,6 @@ public interface Task {
*/
void setCallbackInfo(Map<String, String> callbackInfo);
/**
* Return the value for custom Attribute number num.
*
* @param num identifies which custom attribute is requested. Taskana concatenates "custom_" with
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @return the value of custom attribute number num
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16"
*/
String getCustomAttribute(String num) throws InvalidArgumentException;
/**
* Sets the value for custom Attribute number num.
*
@ -325,11 +128,32 @@ public interface Task {
List<Attachment> getAttachments();
/**
* Returns the custom note for this Task.
* Sets the external business process id.
*
* @return the custom note for this TAsk
* @param businessProcessId Sets the business process id the task belongs to.
*/
String getNote();
void setBusinessProcessId(String businessProcessId);
/**
* Sets the parent business process id to group associated processes.
*
* @param parentBusinessProcessId Sets the parent business process id the task belongs to
*/
void setParentBusinessProcessId(String parentBusinessProcessId);
/**
* Sets the ownerId of this task.
*
* @param taskOwnerId the user id of the task's owner
*/
void setOwner(String taskOwnerId);
/**
* Sets the {@link ObjectReference primaryObjectReference} of the task.
*
* @param primaryObjRef to task main-subject
*/
void setPrimaryObjRef(ObjectReference primaryObjRef);
/**
* Sets/Changing the custom note for this Task.

View File

@ -18,7 +18,7 @@ public interface TaskSummary {
*
* @return taskId
*/
String getTaskId();
String getId();
/**
* Gets the external id of the task.

View File

@ -1,6 +1,5 @@
package pro.taskana.task.internal;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -9,204 +8,28 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import pro.taskana.classification.api.ClassificationSummary;
import pro.taskana.classification.internal.ClassificationSummaryImpl;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.task.api.Attachment;
import pro.taskana.task.api.AttachmentSummary;
import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.ObjectReference;
import pro.taskana.task.api.Task;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.TaskSummary;
import pro.taskana.workbasket.api.WorkbasketSummary;
import pro.taskana.workbasket.internal.WorkbasketSummaryImpl;
/** Task entity. */
public class TaskImpl implements Task {
public class TaskImpl extends TaskSummaryImpl implements Task {
private static final String ARGUMENT_STR = "Argument '";
private static final String NOT_A_VALID_NUMBER_GET =
"' of getCustomAttribute() cannot be converted to a number between 1 and 16";
private static final String NOT_A_VALID_NUMBER_SET =
"' of setCustomAttribute() cannot be converted to a number between 1 and 16";
private String id;
private String externalId;
private Instant created;
private Instant claimed;
private Instant completed;
private Instant modified;
private Instant planned;
private Instant due;
private String name;
private String creator;
private String description;
private String note;
private int priority;
private TaskState state;
private ClassificationSummary classificationSummary;
private WorkbasketSummary workbasketSummary;
private String businessProcessId;
private String parentBusinessProcessId;
private String owner;
private ObjectReference primaryObjRef;
private boolean isRead;
private boolean isTransferred;
"Argument '%s' of setCustomAttribute() cannot be converted to a number between 1 and 16";
// All objects have to be serializable
private Map<String, String> customAttributes = Collections.emptyMap();
private Map<String, String> callbackInfo = Collections.emptyMap();
private CallbackState callbackState;
private List<Attachment> attachments = new ArrayList<>();
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String custom5;
private String custom6;
private String custom7;
private String custom8;
private String custom9;
private String custom10;
private String custom11;
private String custom12;
private String custom13;
private String custom14;
private String custom15;
private String custom16;
TaskImpl() {}
@Override
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String getExternalId() {
return externalId;
}
@Override
public void setExternalId(String externalId) {
this.externalId = externalId;
}
@Override
public String getCreator() {
return creator;
}
@Override
public Instant getCreated() {
return created;
}
public void setCreated(Instant created) {
this.created = created;
}
@Override
public Instant getClaimed() {
return claimed;
}
public void setClaimed(Instant claimed) {
this.claimed = claimed;
}
@Override
public Instant getCompleted() {
return completed;
}
public void setCompleted(Instant completed) {
this.completed = completed;
}
@Override
public Instant getModified() {
return modified;
}
public void setModified(Instant modified) {
this.modified = modified;
}
@Override
public Instant getPlanned() {
return planned;
}
@Override
public void setPlanned(Instant planned) {
this.planned = planned;
}
@Override
public Instant getDue() {
return due;
}
@Override
public void setDue(Instant due) {
this.due = due;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getDescription() {
return description;
}
@Override
public void setDescription(String description) {
this.description = description;
}
@Override
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
@Override
public TaskState getState() {
return state;
}
public void setState(TaskState state) {
this.state = state;
}
@Override
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
}
public void setClassificationSummary(ClassificationSummary classificationSummary) {
this.classificationSummary = classificationSummary;
}
public void setCreator(String creator) {
this.creator = creator;
}
public CallbackState getCallbackState() {
return callbackState;
}
@ -240,85 +63,6 @@ public class TaskImpl implements Task {
((WorkbasketSummaryImpl) this.workbasketSummary).setKey(workbasketKey);
}
@Override
public WorkbasketSummary getWorkbasketSummary() {
return workbasketSummary;
}
public void setWorkbasketSummary(WorkbasketSummary workbasket) {
this.workbasketSummary = workbasket;
}
@Override
public String getDomain() {
return workbasketSummary == null ? null : workbasketSummary.getDomain();
}
public void setDomain(String domain) {
if (workbasketSummary == null) {
workbasketSummary = new WorkbasketSummaryImpl();
}
((WorkbasketSummaryImpl) this.workbasketSummary).setDomain(domain);
}
@Override
public String getBusinessProcessId() {
return businessProcessId;
}
@Override
public void setBusinessProcessId(String businessProcessId) {
this.businessProcessId = businessProcessId;
}
@Override
public String getParentBusinessProcessId() {
return parentBusinessProcessId;
}
@Override
public void setParentBusinessProcessId(String parentBusinessProcessId) {
this.parentBusinessProcessId = parentBusinessProcessId;
}
@Override
public String getOwner() {
return owner;
}
@Override
public void setOwner(String owner) {
this.owner = owner;
}
@Override
public ObjectReference getPrimaryObjRef() {
return primaryObjRef;
}
@Override
public void setPrimaryObjRef(ObjectReference primaryObjRef) {
this.primaryObjRef = primaryObjRef;
}
@Override
public boolean isRead() {
return isRead;
}
public void setRead(boolean isRead) {
this.isRead = isRead;
}
@Override
public boolean isTransferred() {
return isTransferred;
}
public void setTransferred(boolean isTransferred) {
this.isTransferred = isTransferred;
}
@Override
public Map<String, String> getCustomAttributes() {
if (customAttributes == null) {
@ -345,54 +89,6 @@ public class TaskImpl implements Task {
this.callbackInfo = callbackInfo;
}
@Override
public String getCustomAttribute(String number) throws InvalidArgumentException {
int num = 0;
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
ARGUMENT_STR + number + NOT_A_VALID_NUMBER_GET, e.getCause());
}
switch (num) {
case 1:
return custom1;
case 2:
return custom2;
case 3:
return custom3;
case 4:
return custom4;
case 5:
return custom5;
case 6:
return custom6;
case 7:
return custom7;
case 8:
return custom8;
case 9:
return custom9;
case 10:
return custom10;
case 11:
return custom11;
case 12:
return custom12;
case 13:
return custom13;
case 14:
return custom14;
case 15:
return custom15;
case 16:
return custom16;
default:
throw new InvalidArgumentException(ARGUMENT_STR + number + NOT_A_VALID_NUMBER_GET);
}
}
@Override
public void setCustomAttribute(String number, String value) throws InvalidArgumentException {
int num = 0;
@ -400,7 +96,7 @@ public class TaskImpl implements Task {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
ARGUMENT_STR + number + NOT_A_VALID_NUMBER_SET, e.getCause());
String.format(NOT_A_VALID_NUMBER_SET, number), e.getCause());
}
switch (num) {
@ -453,7 +149,7 @@ public class TaskImpl implements Task {
custom16 = value;
break;
default:
throw new InvalidArgumentException(ARGUMENT_STR + number + NOT_A_VALID_NUMBER_SET);
throw new InvalidArgumentException(String.format(NOT_A_VALID_NUMBER_SET, number));
}
}
@ -484,16 +180,6 @@ public class TaskImpl implements Task {
return attachments;
}
@Override
public String getNote() {
return note;
}
@Override
public void setNote(String note) {
this.note = note;
}
@Override
public TaskSummary asSummary() {
TaskSummaryImpl taskSummary = new TaskSummaryImpl();
@ -527,7 +213,7 @@ public class TaskImpl implements Task {
taskSummary.setCustom15(custom15);
taskSummary.setCustom16(custom16);
taskSummary.setDue(due);
taskSummary.setTaskId(id);
taskSummary.setId(id);
taskSummary.setModified(modified);
taskSummary.setName(name);
taskSummary.setCreator(creator);
@ -579,195 +265,14 @@ public class TaskImpl implements Task {
}
}
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
}
public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) {
setClassificationSummary(classificationSummary);
}
public WorkbasketSummaryImpl getWorkbasketSummaryImpl() {
return (WorkbasketSummaryImpl) workbasketSummary;
}
public void setWorkbasketSummaryImpl(WorkbasketSummaryImpl workbasketSummary) {
this.workbasketSummary = workbasketSummary;
}
public String getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
public String getCustom5() {
return custom5;
}
public void setCustom5(String custom5) {
this.custom5 = custom5;
}
public String getCustom6() {
return custom6;
}
public void setCustom6(String custom6) {
this.custom6 = custom6;
}
public String getCustom7() {
return custom7;
}
public void setCustom7(String custom7) {
this.custom7 = custom7;
}
public String getCustom8() {
return custom8;
}
public void setCustom8(String custom8) {
this.custom8 = custom8;
}
public String getCustom9() {
return custom9;
}
public void setCustom9(String custom9) {
this.custom9 = custom9;
}
public String getCustom10() {
return custom10;
}
public void setCustom10(String custom10) {
this.custom10 = custom10;
}
public String getCustom11() {
return custom11;
}
public void setCustom11(String custom11) {
this.custom11 = custom11;
}
public String getCustom12() {
return custom12;
}
public void setCustom12(String custom12) {
this.custom12 = custom12;
}
public String getCustom13() {
return custom13;
}
public void setCustom13(String custom13) {
this.custom13 = custom13;
}
public String getCustom14() {
return custom14;
}
public void setCustom14(String custom14) {
this.custom14 = custom14;
}
public String getCustom15() {
return custom15;
}
public void setCustom15(String custom15) {
this.custom15 = custom15;
}
public String getCustom16() {
return custom16;
}
public void setCustom16(String custom16) {
this.custom16 = custom16;
protected boolean canEqual(Object other) {
return (other instanceof TaskImpl);
}
@Override
public int hashCode() {
return Objects.hash(
id,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
description,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
customAttributes,
callbackInfo,
callbackState,
attachments,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
super.hashCode(), id, customAttributes, callbackInfo, callbackState, attachments);
}
@Override
@ -778,49 +283,18 @@ public class TaskImpl implements Task {
if (!(obj instanceof TaskImpl)) {
return false;
}
if (!super.equals(obj)) {
return false;
}
TaskImpl other = (TaskImpl) obj;
return priority == other.priority
&& isRead == other.isRead
&& isTransferred == other.isTransferred
&& Objects.equals(id, other.id)
&& Objects.equals(externalId, other.externalId)
&& Objects.equals(created, other.created)
&& Objects.equals(claimed, other.claimed)
&& Objects.equals(completed, other.completed)
&& Objects.equals(modified, other.modified)
&& Objects.equals(planned, other.planned)
&& Objects.equals(due, other.due)
&& Objects.equals(name, other.name)
&& Objects.equals(creator, other.creator)
&& Objects.equals(description, other.description)
&& Objects.equals(note, other.note)
&& state == other.state
&& Objects.equals(classificationSummary, other.classificationSummary)
&& Objects.equals(workbasketSummary, other.workbasketSummary)
&& Objects.equals(businessProcessId, other.businessProcessId)
&& Objects.equals(parentBusinessProcessId, other.parentBusinessProcessId)
&& Objects.equals(owner, other.owner)
&& Objects.equals(primaryObjRef, other.primaryObjRef)
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(id, other.id)
&& Objects.equals(customAttributes, other.customAttributes)
&& Objects.equals(callbackInfo, other.callbackInfo)
&& callbackState == other.callbackState
&& Objects.equals(attachments, other.attachments)
&& Objects.equals(custom1, other.custom1)
&& Objects.equals(custom2, other.custom2)
&& Objects.equals(custom3, other.custom3)
&& Objects.equals(custom4, other.custom4)
&& Objects.equals(custom5, other.custom5)
&& Objects.equals(custom6, other.custom6)
&& Objects.equals(custom7, other.custom7)
&& Objects.equals(custom8, other.custom8)
&& Objects.equals(custom9, other.custom9)
&& Objects.equals(custom10, other.custom10)
&& Objects.equals(custom11, other.custom11)
&& Objects.equals(custom12, other.custom12)
&& Objects.equals(custom13, other.custom13)
&& Objects.equals(custom14, other.custom14)
&& Objects.equals(custom15, other.custom15)
&& Objects.equals(custom16, other.custom16);
&& Objects.equals(attachments, other.attachments);
}
@Override

View File

@ -137,7 +137,7 @@ public interface TaskQueryMapper {
+ "</script>")
@Results(
value = {
@Result(property = "taskId", column = "ID"),
@Result(property = "id", column = "ID"),
@Result(property = "externalId", column = "EXTERNAL_ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "claimed", column = "CLAIMED"),
@ -377,7 +377,7 @@ public interface TaskQueryMapper {
+ "</script>")
@Results(
value = {
@Result(property = "taskId", column = "ID"),
@Result(property = "id", column = "ID"),
@Result(property = "externalId", column = "EXTERNAL_ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "claimed", column = "CLAIMED"),

View File

@ -521,7 +521,7 @@ public class TaskServiceImpl implements TaskService {
List<String> changedTasks = new ArrayList<>();
if (!taskSummaries.isEmpty()) {
changedTasks =
taskSummaries.stream().map(TaskSummary::getTaskId).collect(Collectors.toList());
taskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList());
taskMapper.updateTasks(changedTasks, updated, fieldSelector);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -562,7 +562,7 @@ public class TaskServiceImpl implements TaskService {
List<String> changedTasks = new ArrayList<>();
if (!taskSummaries.isEmpty()) {
changedTasks =
taskSummaries.stream().map(TaskSummary::getTaskId).collect(Collectors.toList());
taskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList());
taskMapper.updateTasks(changedTasks, updatedTask, fieldSelector);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -635,7 +635,7 @@ public class TaskServiceImpl implements TaskService {
Set<String> affectedTaskIds = new HashSet<>(filteredTaskIdsFromAttachments);
for (TaskSummary task : tasks) {
affectedTaskIds.add(task.getTaskId());
affectedTaskIds.add(task.getId());
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -735,7 +735,7 @@ public class TaskServiceImpl implements TaskService {
}
Set<String> taskIdSet =
taskSummaries.stream().map(TaskSummaryImpl::getTaskId).collect(Collectors.toSet());
taskSummaries.stream().map(TaskSummaryImpl::getId).collect(Collectors.toSet());
String[] taskIdArray = taskIdSet.toArray(new String[0]);
LOGGER.debug(
@ -1133,7 +1133,7 @@ public class TaskServiceImpl implements TaskService {
TaskSummaryImpl taskSummary =
(TaskSummaryImpl)
taskSummaries.stream()
.filter(ts -> currentTaskId.equals(ts.getTaskId()))
.filter(ts -> currentTaskId.equals(ts.getId()))
.findFirst()
.orElse(null);
if (taskSummary == null) {
@ -1204,7 +1204,7 @@ public class TaskServiceImpl implements TaskService {
if (classificationSummary == null) {
throw new SystemException(
"Did not find a Classification for task (Id="
+ task.getTaskId()
+ task.getId()
+ ",classification="
+ task.getClassificationSummary().getId()
+ ")");
@ -1291,7 +1291,7 @@ public class TaskServiceImpl implements TaskService {
.findFirst()
.orElse(null);
if (workbasketSummary == null) {
LOGGER.warn("Could not find a Workbasket for task {}.", task.getTaskId());
LOGGER.warn("Could not find a Workbasket for task {}.", task.getId());
taskIterator.remove();
continue;
}
@ -1327,7 +1327,7 @@ public class TaskServiceImpl implements TaskService {
// assign attachment summaries to task summaries
for (TaskSummaryImpl task : taskSummaries) {
for (AttachmentSummaryImpl attachment : attachmentSummaries) {
if (attachment.getTaskId() != null && attachment.getTaskId().equals(task.getTaskId())) {
if (attachment.getTaskId() != null && attachment.getTaskId().equals(task.getId())) {
task.addAttachmentSummary(attachment);
}
}

View File

@ -18,46 +18,49 @@ import pro.taskana.workbasket.internal.WorkbasketSummaryImpl;
/** Entity which contains the most important informations about a Task. */
public class TaskSummaryImpl implements TaskSummary {
private String taskId;
private String externalId;
private Instant created;
private Instant claimed;
private Instant completed;
private Instant modified;
private Instant planned;
private Instant due;
private String name;
private String creator;
private String note;
private String description;
private int priority;
private TaskState state;
private ClassificationSummary classificationSummary;
private WorkbasketSummary workbasketSummary;
private String businessProcessId;
private String parentBusinessProcessId;
private String owner;
private ObjectReference primaryObjRef;
private boolean isRead;
private boolean isTransferred;
private static final String NOT_A_VALID_NUMBER_GET =
"Argument '%s' of getCustomAttribute() cannot be converted to a number between 1 and 16";
protected String id;
protected String externalId;
protected Instant created;
protected Instant claimed;
protected Instant completed;
protected Instant modified;
protected Instant planned;
protected Instant due;
protected String name;
protected String creator;
protected String note;
protected String description;
protected int priority;
protected TaskState state;
protected ClassificationSummary classificationSummary;
protected WorkbasketSummary workbasketSummary;
protected String businessProcessId;
protected String parentBusinessProcessId;
protected String owner;
protected ObjectReference primaryObjRef;
protected boolean isRead;
protected boolean isTransferred;
// All objects have to be serializable
private List<AttachmentSummary> attachmentSummaries = new ArrayList<>();
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String custom5;
private String custom6;
private String custom7;
private String custom8;
private String custom9;
private String custom10;
private String custom11;
private String custom12;
private String custom13;
private String custom14;
private String custom15;
private String custom16;
protected List<AttachmentSummary> attachmentSummaries = new ArrayList<>();
protected String custom1;
protected String custom2;
protected String custom3;
protected String custom4;
protected String custom5;
protected String custom6;
protected String custom7;
protected String custom8;
protected String custom9;
protected String custom10;
protected String custom11;
protected String custom12;
protected String custom13;
protected String custom14;
protected String custom15;
protected String custom16;
TaskSummaryImpl() {}
@ -66,12 +69,12 @@ public class TaskSummaryImpl implements TaskSummary {
* @see pro.taskana.TaskSummary#getTaskId()
*/
@Override
public String getTaskId() {
return taskId;
public String getId() {
return id;
}
public void setTaskId(String id) {
this.taskId = id;
public void setId(String id) {
this.id = id;
}
/*
@ -378,10 +381,7 @@ public class TaskSummaryImpl implements TaskSummary {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
String.format(NOT_A_VALID_NUMBER_GET, number), e.getCause());
}
switch (num) {
@ -418,10 +418,7 @@ public class TaskSummaryImpl implements TaskSummary {
case 16:
return custom16;
default:
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute does not represent a number between 1 and 16");
throw new InvalidArgumentException(String.format(NOT_A_VALID_NUMBER_GET, number));
}
}
@ -604,10 +601,14 @@ public class TaskSummaryImpl implements TaskSummary {
this.custom16 = custom16;
}
protected boolean canEqual(Object other) {
return (other instanceof TaskSummaryImpl);
}
@Override
public int hashCode() {
return Objects.hash(
taskId,
id,
externalId,
created,
claimed,
@ -657,10 +658,13 @@ public class TaskSummaryImpl implements TaskSummary {
return false;
}
TaskSummaryImpl other = (TaskSummaryImpl) obj;
if (!other.canEqual(this)) {
return false;
}
return priority == other.priority
&& isRead == other.isRead
&& isTransferred == other.isTransferred
&& Objects.equals(taskId, other.taskId)
&& Objects.equals(id, other.id)
&& Objects.equals(externalId, other.externalId)
&& Objects.equals(created, other.created)
&& Objects.equals(claimed, other.claimed)
@ -701,7 +705,7 @@ public class TaskSummaryImpl implements TaskSummary {
@Override
public String toString() {
return "TaskSummaryImpl [taskId="
+ taskId
+ id
+ ", externalId="
+ externalId
+ ", created="

View File

@ -71,7 +71,7 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
tasks.forEach(
item -> {
if (item.getCompleted() == null) {
ids.add(item.getTaskId());
ids.add(item.getId());
}
});
taskService.deleteTasks(ids);

View File

@ -334,9 +334,9 @@ class CallbackStateAccTest extends AbstractAccTest {
List<TaskSummary> claimedTasks =
taskService.createTaskQuery().stateIn(TaskState.CLAIMED).list();
assertTrue(claimedTasks.size() > 10);
taskService.forceCompleteTask(claimedTasks.get(0).getTaskId());
taskService.forceCompleteTask(claimedTasks.get(1).getTaskId());
taskService.forceCompleteTask(claimedTasks.get(2).getTaskId());
taskService.forceCompleteTask(claimedTasks.get(0).getId());
taskService.forceCompleteTask(claimedTasks.get(1).getId());
taskService.forceCompleteTask(claimedTasks.get(2).getId());
// now we should have several completed tasks with callback state NONE.
// let's set it to CALLBACK_PROCESSING_REQUIRED
@ -350,9 +350,9 @@ class CallbackStateAccTest extends AbstractAccTest {
assertFalse(bulkResultCompleted.containsErrors());
// now complete some additional tasks
taskService.forceCompleteTask(claimedTasks.get(3).getTaskId());
taskService.forceCompleteTask(claimedTasks.get(4).getTaskId());
taskService.forceCompleteTask(claimedTasks.get(5).getTaskId());
taskService.forceCompleteTask(claimedTasks.get(3).getId());
taskService.forceCompleteTask(claimedTasks.get(4).getId());
taskService.forceCompleteTask(claimedTasks.get(5).getId());
long numberOfCompletedTasksAtStartOfTest = completedTasks.size();
// now lets retrieve those completed tasks that have callback_processing_required

View File

@ -960,7 +960,7 @@ class QueryTasksAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().attachmentClassificationKeyIn("L110102").list();
assertEquals(1, results.size());
assertEquals("TKI:000000000000000000000000000000000002", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000002", results.get(0).getId());
}
@WithAccessId(userName = "admin")
@ -970,7 +970,7 @@ class QueryTasksAccTest extends AbstractAccTest {
List<TaskSummary> results =
taskService.createTaskQuery().attachmentClassificationKeyLike("%10102").list();
assertEquals(1, results.size());
assertEquals("TKI:000000000000000000000000000000000002", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000002", results.get(0).getId());
}
@WithAccessId(userName = "admin")
@ -983,7 +983,7 @@ class QueryTasksAccTest extends AbstractAccTest {
.attachmentClassificationIdIn("CLI:000000000000000000000000000000000002")
.list();
assertEquals(1, results.size());
assertEquals("TKI:000000000000000000000000000000000001", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000001", results.get(0).getId());
}
@WithAccessId(userName = "admin")
@ -1017,8 +1017,8 @@ class QueryTasksAccTest extends AbstractAccTest {
.orderByWorkbasketId(DESCENDING)
.list();
assertEquals(2, results.size());
assertEquals("TKI:000000000000000000000000000000000001", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000011", results.get(1).getTaskId());
assertEquals("TKI:000000000000000000000000000000000001", results.get(0).getId());
assertEquals("TKI:000000000000000000000000000000000011", results.get(1).getId());
}
@WithAccessId(userName = "admin")
@ -1273,9 +1273,9 @@ class QueryTasksAccTest extends AbstractAccTest {
"TKI:000000000000000000000000000000000012")
.orderByAttachmentClassificationId(ASCENDING)
.list();
assertEquals("TKI:000000000000000000000000000000000011", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000011", results.get(0).getId());
assertEquals(
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getTaskId());
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getId());
}
@WithAccessId(userName = "admin")
@ -1291,9 +1291,9 @@ class QueryTasksAccTest extends AbstractAccTest {
"TKI:000000000000000000000000000000000012")
.orderByAttachmentClassificationId(DESCENDING)
.list();
assertEquals("TKI:000000000000000000000000000000000010", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000010", results.get(0).getId());
assertEquals(
"TKI:000000000000000000000000000000000011", results.get(results.size() - 1).getTaskId());
"TKI:000000000000000000000000000000000011", results.get(results.size() - 1).getId());
}
@WithAccessId(userName = "admin")
@ -1311,9 +1311,9 @@ class QueryTasksAccTest extends AbstractAccTest {
.orderByAttachmentClassificationKey(ASCENDING)
.list();
assertEquals("TKI:000000000000000000000000000000000010", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000010", results.get(0).getId());
assertEquals(
"TKI:000000000000000000000000000000000012", results.get(results.size() - 1).getTaskId());
"TKI:000000000000000000000000000000000012", results.get(results.size() - 1).getId());
}
@WithAccessId(userName = "admin")
@ -1331,9 +1331,9 @@ class QueryTasksAccTest extends AbstractAccTest {
.orderByAttachmentClassificationKey(DESCENDING)
.list();
assertEquals("TKI:000000000000000000000000000000000012", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000012", results.get(0).getId());
assertEquals(
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getTaskId());
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getId());
}
@WithAccessId(userName = "admin")
@ -1351,9 +1351,9 @@ class QueryTasksAccTest extends AbstractAccTest {
.orderByAttachmentReference(DESCENDING)
.list();
assertEquals("TKI:000000000000000000000000000000000012", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000012", results.get(0).getId());
assertEquals(
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getTaskId());
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getId());
}
@WithAccessId(userName = "admin")
@ -1372,9 +1372,9 @@ class QueryTasksAccTest extends AbstractAccTest {
.orderByAttachmentReference(DESCENDING)
.list();
assertEquals("TKI:000000000000000000000000000000000012", results.get(0).getTaskId());
assertEquals("TKI:000000000000000000000000000000000012", results.get(0).getId());
assertEquals(
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getTaskId());
"TKI:000000000000000000000000000000000010", results.get(results.size() - 1).getId());
}
@WithAccessId(userName = "admin")
@ -1427,7 +1427,7 @@ class QueryTasksAccTest extends AbstractAccTest {
.list();
assertThat(results.size(), equalTo(10));
String[] ids = results.stream().map(TaskSummary::getTaskId).toArray(String[]::new);
String[] ids = results.stream().map(TaskSummary::getId).toArray(String[]::new);
List<TaskSummary> result2 = taskService.createTaskQuery().idIn(ids).list();
assertThat(result2.size(), equalTo(10));
@ -1447,7 +1447,7 @@ class QueryTasksAccTest extends AbstractAccTest {
.list();
assertThat(results.size(), equalTo(10));
String[] ids = results.stream().map(TaskSummary::getTaskId).toArray(String[]::new);
String[] ids = results.stream().map(TaskSummary::getId).toArray(String[]::new);
List<TaskSummary> result2 = taskService.createTaskQuery().idIn(ids).list();
assertThat(result2.size(), equalTo(10));

View File

@ -75,12 +75,12 @@ class QueryTasksWithSortingAccTest extends AbstractAccTest {
List<String> idsDesc =
results.stream()
.map(TaskSummary::getTaskId)
.map(TaskSummary::getId)
.sorted(Comparator.reverseOrder())
.collect(Collectors.toList());
for (int i = 0; i < results.size(); i++) {
assertEquals(idsDesc.get(i), results.get(i).getTaskId());
assertEquals(idsDesc.get(i), results.get(i).getId());
}
}
@ -101,10 +101,10 @@ class QueryTasksWithSortingAccTest extends AbstractAccTest {
Assertions.assertTrue(results.size() > 2);
List<String> idsAsc =
results.stream().map(TaskSummary::getTaskId).sorted().collect(Collectors.toList());
results.stream().map(TaskSummary::getId).sorted().collect(Collectors.toList());
for (int i = 0; i < results.size(); i++) {
assertEquals(idsAsc.get(i), results.get(i).getTaskId());
assertEquals(idsAsc.get(i), results.get(i).getId());
}
}

View File

@ -197,15 +197,15 @@ class TaskanaTransactionIntTest {
.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("key1", "DOMAIN_A"))
.list();
taskService.claim(tasks.get(0).getTaskId());
taskService.completeTask(tasks.get(0).getTaskId());
taskService.claim(tasks.get(0).getId());
taskService.completeTask(tasks.get(0).getId());
tasks =
taskService
.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("key2", "DOMAIN_A"))
.list();
taskService.claim(tasks.get(0).getTaskId());
taskService.completeTask(tasks.get(0).getTaskId());
taskService.claim(tasks.get(0).getId());
taskService.completeTask(tasks.get(0).getId());
workbasketService.deleteWorkbasket(
workbasketService.getWorkbasket("key1", "DOMAIN_A").getId());
workbasketService.deleteWorkbasket(
@ -221,8 +221,8 @@ class TaskanaTransactionIntTest {
.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("key3", "DOMAIN_A"))
.list();
taskService.claim(tasks.get(0).getTaskId());
taskService.completeTask(tasks.get(0).getTaskId());
taskService.claim(tasks.get(0).getId());
taskService.completeTask(tasks.get(0).getId());
try {
workbasketService.deleteWorkbasket(

View File

@ -59,7 +59,7 @@ public class TaskSummaryResource extends ResourceSupport {
TaskSummaryResource() {}
public TaskSummaryResource(TaskSummary taskSummary) throws InvalidArgumentException {
this.taskId = taskSummary.getTaskId();
this.taskId = taskSummary.getId();
this.externalId = taskSummary.getExternalId();
created = taskSummary.getCreated() != null ? taskSummary.getCreated().toString() : null;
claimed = taskSummary.getClaimed() != null ? taskSummary.getClaimed().toString() : null;

View File

@ -85,7 +85,7 @@ class TaskSummaryAssemblerTest {
}
void testEquality(TaskSummaryImpl taskSummary, TaskSummaryResource resource) {
Assert.assertEquals(taskSummary.getTaskId(), resource.getTaskId());
Assert.assertEquals(taskSummary.getId(), resource.getTaskId());
Assert.assertEquals(taskSummary.getExternalId(), resource.getExternalId());
Assert.assertEquals(
taskSummary.getCreated() == null ? null : taskSummary.getCreated().toString(),