TSK-151 update task summary and use it in all list operations. Avoid joins for list queries.

This commit is contained in:
BerndBreier 2018-01-17 09:51:29 +01:00 committed by Marcel Lengl
parent f0d1b7b6cc
commit e396adf040
50 changed files with 2484 additions and 755 deletions

View File

@ -37,7 +37,7 @@ export class CategoryService {
private createAuthorizationHeader() {
let headers: Headers = new Headers();
headers.append("Authorization", "Basic TWF4OnRlc3Q=");
headers.append("Authorization", "Basic dXNlcl8xXzE6dXNlcl8xXzE=");
return new RequestOptions({ headers: headers });
}

View File

@ -52,7 +52,7 @@ export class WorkbasketserviceService {
private createAuthorizationHeader() {
let headers: Headers = new Headers();
headers.append("Authorization", "Basic TWF4OnRlc3Q=");
headers.append("Authorization", "Basic dXNlcl8xXzE6dXNlcl8xXzE=");
headers.append("content-type", "application/json");
return new RequestOptions({ headers: headers });

View File

@ -24,14 +24,6 @@ public interface Attachment {
*/
String getTaskId();
/**
* Sets the taskId of the attachment where it should be appended to.
*
* @param taskId
* id of the reference task
*/
void setTaskId(String taskId);
/**
* Returns the time when the attachment was created.
*
@ -47,27 +39,20 @@ public interface Attachment {
Timestamp getModified();
/**
* Returns the classificationKey for the mapping.
*
* @return classificationKey key for the correct mapping.
*/
String getClassificationKey();
/**
* Sets the classificationKey for the mapping.
*
* @param classificationKey
* key for the correct mapping.
*/
void setClassificationKey(String classificationKey);
/**
* Returns the classificationsummary of the attachment.
* Returns the classification summary of the attachment.
*
* @return the {@link ClassificationSummary} of this attachment
*/
ClassificationSummary getClassificationSummary();
/**
* Set the classification summary for this attachment.
*
* @param classificationSummary
* the {@link ClassificationSummary} for this attachment
*/
void setClassificationSummary(ClassificationSummary classificationSummary);
/**
* Returns the {@link ObjectReference primaryObjectReference} of the attachment.
*
@ -127,4 +112,11 @@ public interface Attachment {
* a {@link Map} that contains the custom attributes of the attachment as key, value pairs
*/
void setCustomAttributes(Map<String, Object> customAttributes);
/**
* Return a summary of the current Attachment.
*
* @return the AttachmentSummary object for the current attachment
*/
AttachmentSummary asSummary();
}

View File

@ -0,0 +1,53 @@
package pro.taskana;
import java.sql.Timestamp;
/**
* Interface for AttachmentSummaries. This is a specific short model-object which only contains the most important
* information.
*/
public interface AttachmentSummary {
/**
* Gets the id of the attachment.
*
* @return attachmentId
*/
String getId();
/**
* Gets the id of the associated task.
*
* @return taskId
*/
String getTaskId();
/**
* Gets the time when the attachment was created.
*
* @return the created timestamp
*/
Timestamp getCreated();
/**
* Gets the time when the attachment was last modified.
*
* @return the last modified timestamp
*/
Timestamp getModified();
/**
* Gets the classificationSummary of the attachment.
*
* @return the classification summary
*/
ClassificationSummary getClassificationSummary();
/**
* Gets the time when the attachment was received.
*
* @return received timestamp
*/
Timestamp getReceived();
}

View File

@ -18,7 +18,6 @@ public interface Classification {
String getKey();
/**
* Used to get the ID of the parent classification. There will be no value if the current classification is a
* parent-classification.
*
@ -293,4 +292,12 @@ public interface Classification {
* @return validUntil
*/
Date getValidUntil();
/**
* Return a summary of the current Classification.
*
* @return the ClassificationSummary object for the current classification
*/
ClassificationSummary asSummary();
}

View File

@ -114,11 +114,11 @@ public interface Task {
TaskState getState();
/**
* Returns the {@link Classification} of the task.
* Returns the {@link ClassificationSummary} of the task.
*
* @return classification for specification
* @return classification summary for the task
*/
Classification getClassification();
ClassificationSummary getClassificationSummary();
/**
* Sets the Classification key that - together with the Domain from this task's work basket - selects the
@ -144,6 +144,21 @@ public interface Task {
*/
void setWorkbasketKey(String workbasketKey);
/**
* Returns the the Summary of the workbasket where the task is stored in.
*
* @return workbasketSummary
*/
WorkbasketSummary getWorkbasketSummary();
/**
* Sets the Summary of the Workbasket where the task should be stored in.
*
* @param workbasket
* the WorkbasketSummary
*/
void setWorkbasketSummary(WorkbasketSummary workbasket);
/**
* Returns the Domain, to which the Task belongs at this moment.
*
@ -384,7 +399,7 @@ public interface Task {
/**
* Returns the custom note for this Task.
*
* @return note
* @return the custom note for this TAsk
*/
String getNote();
@ -392,6 +407,15 @@ public interface Task {
* Sets/Changing the custom note for this Task.
*
* @param note
* the custom note for this Task.
*/
void setNote(String note);
/**
* Return a summary of the current Task.
*
* @return the TaskSummary object for the current task
*/
TaskSummary asSummary();
}

View File

@ -6,7 +6,7 @@ import pro.taskana.model.TaskState;
/**
* TaskQuery for generating dynamic sql.
*/
public interface TaskQuery extends BaseQuery<Task> {
public interface TaskQuery extends BaseQuery<TaskSummary> {
/**
* Add your names to your query.
@ -15,7 +15,7 @@ public interface TaskQuery extends BaseQuery<Task> {
* the names as Strings
* @return the query
*/
TaskQuery name(String... name);
TaskQuery nameIn(String... name);
/**
* Add your description for pattern matching to your query. It will be compared in SQL with the LIKE operator. You
@ -44,7 +44,7 @@ public interface TaskQuery extends BaseQuery<Task> {
* as a integer
* @return the query
*/
TaskQuery priority(int... priorities);
TaskQuery priorityIn(int... priorities);
/**
* Add your state to your query.
@ -53,7 +53,7 @@ public interface TaskQuery extends BaseQuery<Task> {
* the states as {@link TaskState}
* @return the query
*/
TaskQuery state(TaskState... states);
TaskQuery stateIn(TaskState... states);
/**
* Add your classificationKey to your query.
@ -91,7 +91,7 @@ public interface TaskQuery extends BaseQuery<Task> {
* the owners as String
* @return the query
*/
TaskQuery owner(String... owners);
TaskQuery ownerIn(String... owners);
/**
* Add the companies of the primary object reference for exact matching to your query.
@ -195,7 +195,7 @@ public interface TaskQuery extends BaseQuery<Task> {
* as Boolean. If null, it won't be integrated into the statement. You have to set false.
* @return the query
*/
TaskQuery read(Boolean isRead);
TaskQuery readEquals(Boolean isRead);
/**
* Add the isTransferred flag to the query.
@ -204,7 +204,7 @@ public interface TaskQuery extends BaseQuery<Task> {
* as Boolean. If null, it won't be integrated into the statement. You have to set false.
* @return the query
*/
TaskQuery transferred(Boolean isTransferred);
TaskQuery transferredEquals(Boolean isTransferred);
/**
* Filter the custom fields with this query. The scan will be run over all 10 fields.
@ -213,7 +213,7 @@ public interface TaskQuery extends BaseQuery<Task> {
* the value in the fields
* @return the query
*/
TaskQuery customFields(String... customFields);
TaskQuery customFieldsIn(String... customFields);
/**
* This method provides a query builder for quering the database.

View File

@ -13,7 +13,6 @@ import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.model.TaskState;
import pro.taskana.model.TaskSummary;
/**
* The Task Service manages all operations on tasks.
@ -163,7 +162,7 @@ public interface TaskService {
TaskQuery createTaskQuery();
/**
* Getting a list of all Tasks which got matching workbasketIds and states.
* Getting a list of all Task summaries which got matching workbasketIds and states.
*
* @param workbasketKey
* the key of the workbasket where the tasks need to be in.
@ -177,7 +176,7 @@ public interface TaskService {
* @throws ClassificationNotFoundException
* if a single Classification can not be found for a task which is returned
*/
List<Task> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
List<TaskSummary> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
throws WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException;
/**

View File

@ -0,0 +1,223 @@
package pro.taskana;
import java.sql.Timestamp;
import pro.taskana.model.ObjectReference;
import pro.taskana.model.TaskState;
/**
* Interface for TaskSummary. This is a specific short model-object which only contains the most important information.
*/
public interface TaskSummary {
/**
* Gets the id of the task..
*
* @return taskId
*/
String getTaskId();
/**
* Gets the time when the task was created.
*
* @return the created timestamp
*/
Timestamp getCreated();
/**
* Gets the time when the task was claimed.
*
* @return the claimed timestamp
*/
Timestamp getClaimed();
/**
* Gets the time when the task was completed.
*
* @return the completed timestamp
*/
Timestamp getCompleted();
/**
* Gets the time when the task was last modified.
*
* @return the last modified timestamp
*/
Timestamp getModified();
/**
* Gets the time when the task is planned to be executed.
*
* @return the planned timestamp
*/
Timestamp getPlanned();
/**
* Gets the time when the task is due.
*
* @return the due timestamp
*/
Timestamp getDue();
/**
* Gets the name of the task.
*
* @return the task's name
*/
String getName();
/**
* Gets the note attached to the task.
*
* @return the task's note
*/
String getNote();
/**
* Gets the priority of the task.
*
* @return the task's priority
*/
int getPriority();
/**
* Gets the state of the task.
*
* @return the task's state
*/
TaskState getState();
/**
* Gets the classification summary of the task.
*
* @return the task's classificationSummary
*/
ClassificationSummary getClassificationSummary();
/**
* Gets the workbasket summary of the task.
*
* @return the task's workbasketSummary
*/
WorkbasketSummary getWorkbasketSummary();
/**
* Gets the domain of the task.
*
* @return the task's domain
*/
String getDomain();
/**
* Gets the businessProcessId of the task.
*
* @return the task's businessProcessId
*/
String getBusinessProcessId();
/**
* Gets the parentBusinessProcessId of the task.
*
* @return the task's parentBusinessProcessId
*/
String getParentBusinessProcessId();
/**
* Gets the owner of the task.
*
* @return the task's owner
*/
String getOwner();
/**
* Gets the primary ObjectReference of the task.
*
* @return the task's primary ObjectReference
*/
ObjectReference getPrimaryObjRef();
/**
* Gets the isRead flag of the task.
*
* @return the task's isRead flag
*/
boolean isRead();
/**
* Gets the isTransferred flag of the task.
*
* @return the task's isTransferred flag.
*/
boolean isTransferred();
/**
* Gets the custom1 property of the task.
*
* @return the task's custom1 property
*/
String getCustom1();
/**
* Gets the custom2 property of the task.
*
* @return the task's custom2 property
*/
String getCustom2();
/**
* Gets the custom3 property of the task.
*
* @return the task's custom3 property
*/
String getCustom3();
/**
* Gets the custom4 property of the task.
*
* @return the task's custom4 property
*/
String getCustom4();
/**
* Gets the custom5 property of the task.
*
* @return the task's custom5 property
*/
String getCustom5();
/**
* Gets the custom6 property of the task.
*
* @return the task's custom6 property
*/
String getCustom6();
/**
* Gets the custom7 property of the task.
*
* @return the task's custom7 property
*/
String getCustom7();
/**
* Gets the custom8 property of the task.
*
* @return the task's custom8 property
*/
String getCustom8();
/**
* Gets the custom9 property of the task.
*
* @return the task's custom9 property
*/
String getCustom9();
/**
* Gets the custom10 property of the task.
*
* @return the task's custom10 property
*/
String getCustom10();
}

View File

@ -3,7 +3,6 @@ package pro.taskana;
import java.sql.Timestamp;
import java.util.List;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
/**

View File

@ -4,7 +4,6 @@ import java.util.Date;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
/**

View File

@ -7,7 +7,6 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
/**
* This service manages Workbaskets.

View File

@ -0,0 +1,88 @@
package pro.taskana;
import pro.taskana.model.WorkbasketType;
/**
* Interface for WorkbasketSummary. This is a specific short model-object which only contains the most important
* information.
*/
public interface WorkbasketSummary {
/**
* Gets the id of the workbasket.
*
* @return workbasketId
*/
String getId();
/**
* Gets the key of the workbasket.
*
* @return workbasketKey
*/
String getKey();
/**
* Gets the name of the workbasket.
*
* @return workbasket's name
*/
String getName();
/**
* Gets the description of the workbasket.
*
* @return workbasket's description
*/
String getDescription();
/**
* Gets the owner of the workbasket.
*
* @return workbasket's owner
*/
String getOwner();
/**
* Gets the domain of the workbasket.
*
* @return workbasket's domain
*/
String getDomain();
/**
* Gets the type of the workbasket.
*
* @return workbasket's type
*/
WorkbasketType getType();
/**
* Gets the orglevel1 property of the task.
*
* @return the task's orglevel1 property
*/
String getOrgLevel1();
/**
* Gets the orglevel2 property of the task.
*
* @return the task's orglevel2 property
*/
String getOrgLevel2();
/**
* Gets the orglevel3 property of the task.
*
* @return the task's orglevel3 property
*/
String getOrgLevel3();
/**
* Gets the orglevel4 property of the task.
*
* @return the task's orglevel4 property
*/
String getOrgLevel4();
}

View File

@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.Map;
import pro.taskana.Attachment;
import pro.taskana.AttachmentSummary;
import pro.taskana.ClassificationSummary;
import pro.taskana.model.ObjectReference;
@ -24,7 +25,7 @@ public class AttachmentImpl implements Attachment {
private ObjectReference objectReference;
private String channel;
private Timestamp received;
private Map<String, Object> customAttributes = Collections.emptyMap();;
private Map<String, Object> customAttributes = Collections.emptyMap();
AttachmentImpl() {
}
@ -43,7 +44,6 @@ public class AttachmentImpl implements Attachment {
return taskId;
}
@Override
public void setTaskId(String taskId) {
this.taskId = taskId;
}
@ -66,25 +66,26 @@ public class AttachmentImpl implements Attachment {
this.modified = modified;
}
@Override
public String getClassificationKey() {
return classificationKey;
}
@Override
public void setClassificationKey(String classificationKey) {
this.classificationKey = classificationKey;
}
@Override
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
}
@Override
public void setClassificationSummary(ClassificationSummary classificationSummary) {
this.classificationSummary = classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) {
this.classificationSummary = classificationSummary;
}
@Override
public ObjectReference getObjectReference() {
return objectReference;
@ -125,10 +126,22 @@ public class AttachmentImpl implements Attachment {
this.customAttributes = customAttributes;
}
@Override
public AttachmentSummary asSummary() {
AttachmentSummaryImpl summary = new AttachmentSummaryImpl();
summary.setClassificationSummary(this.classificationSummary);
summary.setCreated(this.created);
summary.setId(this.id);
summary.setModified(this.modified);
summary.setReceived(this.received);
summary.setTaskId(this.taskId);
return summary;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Attachment [id=");
builder.append("AttachmentImpl [id=");
builder.append(id);
builder.append(", taskId=");
builder.append(taskId);
@ -138,6 +151,8 @@ public class AttachmentImpl implements Attachment {
builder.append(modified);
builder.append(", classificationKey=");
builder.append(classificationKey);
builder.append(", classificationSummary=");
builder.append(classificationSummary);
builder.append(", objectReference=");
builder.append(objectReference);
builder.append(", channel=");
@ -149,4 +164,5 @@ public class AttachmentImpl implements Attachment {
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,197 @@
package pro.taskana.impl;
import java.sql.Timestamp;
import pro.taskana.AttachmentSummary;
import pro.taskana.ClassificationSummary;
/**
* The most important fields of the Attachment entity.
*/
public class AttachmentSummaryImpl implements AttachmentSummary {
private String id;
private String taskId;
private Timestamp created;
private Timestamp modified;
private ClassificationSummary classificationSummary;
private Timestamp received;
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getId()
*/
@Override
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getTaskId()
*/
@Override
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getCreated()
*/
@Override
public Timestamp getCreated() {
return created;
}
public void setCreated(Timestamp created) {
this.created = created;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getModified()
*/
@Override
public Timestamp getModified() {
return modified;
}
public void setModified(Timestamp modified) {
this.modified = modified;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getClassification()
*/
@Override
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
}
public void setClassificationSummary(ClassificationSummary classificationSummary) {
this.classificationSummary = classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) {
this.classificationSummary = classificationSummary;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getReceived()
*/
@Override
public Timestamp getReceived() {
return received;
}
public void setReceived(Timestamp received) {
this.received = received;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((classificationSummary == null) ? 0 : classificationSummary.hashCode());
result = prime * result + ((created == null) ? 0 : created.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((modified == null) ? 0 : modified.hashCode());
result = prime * result + ((received == null) ? 0 : received.hashCode());
result = prime * result + ((taskId == null) ? 0 : taskId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AttachmentSummaryImpl)) {
return false;
}
AttachmentSummaryImpl other = (AttachmentSummaryImpl) obj;
if (classificationSummary == null) {
if (other.classificationSummary != null) {
return false;
}
} else if (!classificationSummary.equals(other.classificationSummary)) {
return false;
}
if (created == null) {
if (other.created != null) {
return false;
}
} else if (!created.equals(other.created)) {
return false;
}
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
if (modified == null) {
if (other.modified != null) {
return false;
}
} else if (!modified.equals(other.modified)) {
return false;
}
if (received == null) {
if (other.received != null) {
return false;
}
} else if (!received.equals(other.received)) {
return false;
}
if (taskId == null) {
if (other.taskId != null) {
return false;
}
} else if (!taskId.equals(other.taskId)) {
return false;
}
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("AttachmentSummaryImpl [id=");
builder.append(id);
builder.append(", taskId=");
builder.append(taskId);
builder.append(", created=");
builder.append(created);
builder.append(", modified=");
builder.append(modified);
builder.append(", classificationSummary=");
builder.append(classificationSummary);
builder.append(", received=");
builder.append(received);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,9 +1,11 @@
package pro.taskana.impl;
import java.sql.Date;
import java.sql.Timestamp;
import java.time.Duration;
import pro.taskana.Classification;
import pro.taskana.ClassificationSummary;
/**
* Classification entity.
@ -265,6 +267,21 @@ public class ClassificationImpl implements Classification {
this.validUntil = validUntil;
}
@Override
public ClassificationSummary asSummary() {
ClassificationSummaryImpl summary = new ClassificationSummaryImpl();
summary.setCategory(this.category);
summary.setDomain(this.domain);
summary.setId(this.id);
summary.setKey(this.key);
summary.setName(this.name);
summary.setType(this.type);
if (this.validUntil != null) {
summary.setValidUntil(new Timestamp(this.validUntil.getTime()));
}
return summary;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

View File

@ -13,7 +13,6 @@ import pro.taskana.Classification;
import pro.taskana.ClassificationQuery;
import pro.taskana.ClassificationService;
import pro.taskana.ClassificationSummary;
import pro.taskana.Task;
import pro.taskana.TaskanaEngine;
import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException;
@ -328,27 +327,4 @@ public class ClassificationServiceImpl implements ClassificationService {
return isExisting;
}
public Classification getClassificationByTask(Task task) throws ClassificationNotFoundException {
if (task.getId() == null) {
throw new ClassificationNotFoundException("Classification for task with id null was not found.");
}
LOGGER.debug("entry to getClassificationByTask(taskId = {})", task.getId());
TaskImpl taskImpl = (TaskImpl) task;
String classificationKey = taskImpl.getClassificationKey();
Classification result = null;
try {
taskanaEngineImpl.openConnection();
result = classificationMapper.findByTask(classificationKey, task.getWorkbasketKey(),
CURRENT_CLASSIFICATIONS_VALID_UNTIL);
if (result == null) {
throw new ClassificationNotFoundException(
"Classification for task with id " + task.getId() + " was not found.");
}
return result;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
}
}
}

View File

@ -102,7 +102,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (!(obj instanceof ClassificationSummaryImpl)) {
return false;
}
ClassificationSummaryImpl other = (ClassificationSummaryImpl) obj;
@ -161,7 +161,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ClassificationSummary [id=");
builder.append("ClassificationSummaryImpl [id=");
builder.append(id);
builder.append(", key=");
builder.append(key);
@ -178,4 +178,5 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
builder.append("]");
return builder.toString();
}
}

View File

@ -7,8 +7,11 @@ import java.util.List;
import java.util.Map;
import pro.taskana.Attachment;
import pro.taskana.Classification;
import pro.taskana.AttachmentSummary;
import pro.taskana.ClassificationSummary;
import pro.taskana.Task;
import pro.taskana.TaskSummary;
import pro.taskana.WorkbasketSummary;
import pro.taskana.model.ObjectReference;
import pro.taskana.model.TaskState;
@ -30,7 +33,8 @@ public class TaskImpl implements Task {
private int priority;
private TaskState state;
private String classificationKey;
private Classification classification;
private ClassificationSummary classificationSummary;
private WorkbasketSummary workbasketSummary;
private String workbasketKey;
private String domain;
private String businessProcessId;
@ -169,8 +173,8 @@ public class TaskImpl implements Task {
}
@Override
public Classification getClassification() {
return classification;
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
}
@Override
@ -188,6 +192,16 @@ public class TaskImpl implements Task {
this.workbasketKey = workbasketKey;
}
@Override
public WorkbasketSummary getWorkbasketSummary() {
return workbasketSummary;
}
@Override
public void setWorkbasketSummary(WorkbasketSummary workbasket) {
this.workbasketSummary = workbasket;
}
@Override
public String getDomain() {
return domain;
@ -375,6 +389,48 @@ public class TaskImpl implements Task {
return attachments;
}
@Override
public TaskSummary asSummary() {
TaskSummaryImpl taskSummary = new TaskSummaryImpl();
List<AttachmentSummary> attSummaries = new ArrayList<>();
for (Attachment att : attachments) {
attSummaries.add(att.asSummary());
}
taskSummary.setAttachmentSummaries(attSummaries);
taskSummary.setBusinessProcessId(this.businessProcessId);
taskSummary.setClaimed(claimed);
taskSummary.setClassificationSummary(classificationSummary);
taskSummary.setCompleted(completed);
taskSummary.setCreated(created);
taskSummary.setCustom1(custom1);
taskSummary.setCustom2(custom2);
taskSummary.setCustom3(custom3);
taskSummary.setCustom4(custom4);
taskSummary.setCustom5(custom5);
taskSummary.setCustom6(custom6);
taskSummary.setCustom7(custom7);
taskSummary.setCustom8(custom8);
taskSummary.setCustom9(custom9);
taskSummary.setCustom10(custom10);
taskSummary.setDomain(domain);
taskSummary.setDue(due);
taskSummary.setTaskId(id);
taskSummary.setModified(modified);
taskSummary.setName(name);
taskSummary.setNote(note);
taskSummary.setOwner(owner);
taskSummary.setParentBusinessProcessId(parentBusinessProcessId);
taskSummary.setPlanned(planned);
taskSummary.setPrimaryObjRef(primaryObjRef);
taskSummary.setPriority(priority);
taskSummary.setRead(isRead);
taskSummary.setState(state);
taskSummary.setTransferred(isTransferred);
taskSummary.setWorkbasketSummary(workbasketSummary);
return taskSummary;
}
public void setAttachments(List<Attachment> attachments) {
this.attachments = attachments;
}
@ -383,8 +439,8 @@ public class TaskImpl implements Task {
return classificationKey;
}
public void setClassification(Classification classification) {
this.classification = classification;
public void setClassificationSummary(ClassificationSummary classificationSummary) {
this.classificationSummary = classificationSummary;
}
@Override
@ -416,8 +472,10 @@ public class TaskImpl implements Task {
builder.append(state);
builder.append(", classificationKey=");
builder.append(classificationKey);
builder.append(", classification=");
builder.append(classification);
builder.append(", classificationSummary=");
builder.append(classificationSummary);
builder.append(", workbasketSummary=");
builder.append(workbasketSummary);
builder.append(", workbasketKey=");
builder.append(workbasketKey);
builder.append(", domain=");

View File

@ -2,20 +2,18 @@ package pro.taskana.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.Classification;
import pro.taskana.ObjectReferenceQuery;
import pro.taskana.Task;
import pro.taskana.TaskQuery;
import pro.taskana.TaskSummary;
import pro.taskana.TaskanaEngine;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.model.TaskState;
import pro.taskana.model.WorkbasketAuthorization;
@ -29,6 +27,7 @@ public class TaskQueryImpl implements TaskQuery {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryImpl.class);
private TaskanaEngineImpl taskanaEngineImpl;
private ClassificationServiceImpl classificationService;
private TaskServiceImpl taskService;
private String[] name;
private String description;
private String note;
@ -55,10 +54,11 @@ public class TaskQueryImpl implements TaskQuery {
public TaskQueryImpl(TaskanaEngine taskanaEngine) {
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
this.classificationService = (ClassificationServiceImpl) taskanaEngineImpl.getClassificationService();
this.taskService = (TaskServiceImpl) taskanaEngineImpl.getTaskService();
}
@Override
public TaskQuery name(String... names) {
public TaskQuery nameIn(String... names) {
this.name = names;
return this;
}
@ -76,13 +76,13 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery priority(int... priorities) {
public TaskQuery priorityIn(int... priorities) {
this.priority = priorities;
return this;
}
@Override
public TaskQuery state(TaskState... states) {
public TaskQuery stateIn(TaskState... states) {
this.states = states;
return this;
}
@ -106,7 +106,7 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery owner(String... owners) {
public TaskQuery ownerIn(String... owners) {
this.owner = owners;
return this;
}
@ -172,19 +172,19 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery read(Boolean isRead) {
public TaskQuery readEquals(Boolean isRead) {
this.isRead = isRead;
return this;
}
@Override
public TaskQuery transferred(Boolean isTransferred) {
public TaskQuery transferredEquals(Boolean isTransferred) {
this.isTransferred = isTransferred;
return this;
}
@Override
public TaskQuery customFields(String... customFields) {
public TaskQuery customFieldsIn(String... customFields) {
this.customFields = customFields;
return this;
}
@ -195,23 +195,14 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public List<Task> list() throws NotAuthorizedException {
public List<TaskSummary> list() throws NotAuthorizedException {
LOGGER.debug("entry to list(), this = {}", this);
List<Task> result = new ArrayList<>();
List<TaskSummary> result = new ArrayList<>();
try {
taskanaEngineImpl.openConnection();
checkAuthorization();
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
for (TaskImpl taskImpl : tasks) {
try {
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
taskImpl.setClassification(classification);
} catch (ClassificationNotFoundException e) {
throw new SystemException(
this.toString() + " failed to find a classification for task " + taskImpl);
}
result.add(taskImpl);
}
List<TaskSummaryImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
return result;
} finally {
taskanaEngineImpl.returnConnection();
@ -224,24 +215,15 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public List<Task> list(int offset, int limit) throws NotAuthorizedException {
public List<TaskSummary> list(int offset, int limit) throws NotAuthorizedException {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<Task> result = new ArrayList<>();
List<TaskSummary> result = new ArrayList<>();
try {
taskanaEngineImpl.openConnection();
checkAuthorization();
RowBounds rowBounds = new RowBounds(offset, limit);
List<TaskImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
for (TaskImpl taskImpl : tasks) {
try {
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
taskImpl.setClassification(classification);
} catch (ClassificationNotFoundException e) {
throw new SystemException(
this.toString() + " failed to find a classification for task " + taskImpl);
}
result.add(taskImpl);
}
List<TaskSummaryImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
return result;
} finally {
taskanaEngineImpl.returnConnection();
@ -254,24 +236,25 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskImpl single() throws NotAuthorizedException {
public TaskSummary single() throws NotAuthorizedException {
LOGGER.debug("entry to single(), this = {}", this);
TaskImpl taskImpl = null;
TaskSummary result = null;
try {
taskanaEngineImpl.openConnection();
checkAuthorization();
taskImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
try {
Classification classification = this.classificationService.getClassificationByTask(taskImpl);
taskImpl.setClassification(classification);
} catch (ClassificationNotFoundException e) {
throw new SystemException(
this.toString() + " failed to find a classification for task " + taskImpl);
TaskSummaryImpl taskSummaryImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
if (taskSummaryImpl == null) {
return null;
}
return taskImpl;
List<TaskSummaryImpl> tasks = new ArrayList<>();
tasks.add(taskSummaryImpl);
List<TaskSummary> augmentedList = taskService.augmentTaskSummariesByContainedSummaries(tasks);
result = augmentedList.get(0);
return result;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", taskImpl);
LOGGER.debug("exit from single(). Returning result {} ", result);
}
}

View File

@ -4,8 +4,10 @@ import java.sql.Timestamp;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,9 +18,11 @@ import pro.taskana.ClassificationSummary;
import pro.taskana.Task;
import pro.taskana.TaskQuery;
import pro.taskana.TaskService;
import pro.taskana.TaskSummary;
import pro.taskana.TaskanaEngine;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.ConcurrencyException;
import pro.taskana.exceptions.InvalidArgumentException;
@ -34,7 +38,6 @@ import pro.taskana.impl.util.IdGenerator;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.model.ObjectReference;
import pro.taskana.model.TaskState;
import pro.taskana.model.TaskSummary;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.mappings.AttachmentMapper;
import pro.taskana.model.mappings.ObjectReferenceMapper;
@ -171,18 +174,20 @@ public class TaskServiceImpl implements TaskService {
} else {
LOGGER.debug("Task {} cannot be be found, so it can be created.", taskToCreate.getId());
Workbasket workbasket = workbasketService.getWorkbasketByKey(task.getWorkbasketKey());
workbasketService.checkAuthorization(task.getWorkbasketKey(), WorkbasketAuthorization.APPEND);
workbasketService.checkAuthorization(task.getWorkbasketKey(),
WorkbasketAuthorization.APPEND);
String classificationKey = task.getClassificationKey();
if (classificationKey == null || classificationKey.length() == 0) {
throw new InvalidArgumentException("classificationKey of task must not be empty");
}
Classification classification = this.classificationService.getClassification(classificationKey,
workbasket.getDomain());
task.setClassification(classification);
task.setClassificationSummary(classification.asSummary());
task.setWorkbasketSummary(workbasket.asSummary());
validateObjectReference(task.getPrimaryObjRef(), "primary ObjectReference", "Task");
validateAttachments(task);
task.setDomain(workbasket.getDomain());
standardSettings(task);
standardSettings(task, classification);
this.taskMapper.insert(task);
LOGGER.debug("Method createTask() created Task '{}'.", task.getId());
}
@ -199,15 +204,16 @@ public class TaskServiceImpl implements TaskService {
TaskImpl resultTask = null;
try {
taskanaEngineImpl.openConnection();
resultTask = taskMapper.findById(id);
if (resultTask != null) {
organizeAttachments(resultTask);
// TODO - DELETE getting task-Classification and enable it in
// organizeTaskAttachmentClassificationSummaries();
List<AttachmentImpl> attachmentImpls = attachmentMapper.findAttachmentsByTaskId(resultTask.getId());
List<Attachment> attachments = addClassificationSummariesToAttachments(resultTask, attachmentImpls);
resultTask.setAttachments(attachments);
Classification classification;
try {
Classification classification = this.classificationService.getClassificationByTask(resultTask);
resultTask.setClassification(classification);
classification = this.classificationService.getClassification(resultTask.getClassificationKey(),
resultTask.getDomain());
} catch (ClassificationNotFoundException e) {
LOGGER.debug(
"getTask(taskId = {}) caught a ClassificationNotFoundException when attemptin to get "
@ -216,7 +222,8 @@ public class TaskServiceImpl implements TaskService {
throw new SystemException(
"TaskService.getTask could not find the classification associated to " + id);
}
organizeTaskAttachmentClassificationSummaries(resultTask);
resultTask.setClassificationSummary(classification.asSummary());
return resultTask;
} else {
LOGGER.warn("Method getTaskById() didn't find task with id {}. Throwing TaskNotFoundException", id);
@ -241,11 +248,7 @@ public class TaskServiceImpl implements TaskService {
workbasketService.checkAuthorization(destinationWorkbasketKey, WorkbasketAuthorization.APPEND);
workbasketService.checkAuthorization(task.getWorkbasketKey(), WorkbasketAuthorization.TRANSFER);
// if security is disabled, the implicit existance check on the
// destination workbasket has been skipped and needs to be performed
if (!taskanaEngine.getConfiguration().isSecurityEnabled()) {
workbasketService.getWorkbasketByKey(destinationWorkbasketKey);
}
Workbasket destinationWorkbasket = workbasketService.getWorkbasketByKey(destinationWorkbasketKey);
// reset read flag and set transferred flag
task.setRead(false);
@ -253,7 +256,8 @@ public class TaskServiceImpl implements TaskService {
// transfer task from source to destination workbasket
task.setWorkbasketKey(destinationWorkbasketKey);
task.setDomain(workbasketService.getWorkbasketByKey(destinationWorkbasketKey).getDomain());
task.setWorkbasketSummary(destinationWorkbasket.asSummary());
task.setDomain(destinationWorkbasket.getDomain());
task.setModified(Timestamp.valueOf(LocalDateTime.now()));
taskMapper.update(task);
@ -293,21 +297,18 @@ public class TaskServiceImpl implements TaskService {
}
@Override
public List<Task> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
public List<TaskSummary> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
throws WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException {
LOGGER.debug("entry to getTasksByWorkbasketKeyAndState(workbasketKey = {}, taskState = {})", workbasketKey,
taskState);
List<Task> results = new ArrayList<>();
List<TaskSummary> results = new ArrayList<>();
try {
taskanaEngineImpl.openConnection();
workbasketService.checkAuthorization(workbasketKey, WorkbasketAuthorization.READ);
List<TaskImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketKey, taskState);
for (TaskImpl taskImpl : tasks) {
Classification classification = classificationService.getClassification(taskImpl.getClassificationKey(),
taskImpl.getDomain());
taskImpl.setClassification(classification);
results.add(taskImpl);
}
List<TaskSummaryImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketKey, taskState);
// postprocessing: augment each tasksummary by classificationSummary, workbasketSummary and
// list<attachmentsummary>
results = augmentTaskSummariesByContainedSummaries(tasks);
} finally {
taskanaEngineImpl.returnConnection();
if (LOGGER.isDebugEnabled()) {
@ -343,7 +344,7 @@ public class TaskServiceImpl implements TaskService {
return task;
}
private void standardSettings(TaskImpl task) {
private void standardSettings(TaskImpl task, Classification classification) {
Timestamp now = new Timestamp(System.currentTimeMillis());
task.setId(IdGenerator.generateWithPrefix(ID_PREFIX_TASK));
task.setState(TaskState.READY);
@ -362,10 +363,10 @@ public class TaskServiceImpl implements TaskService {
}
// insert Classification specifications if Classification is given.
Classification classification = task.getClassification();
if (classification != null) {
if (classification.getServiceLevel() != null) {
Duration serviceLevel = Duration.parse(task.getClassification().getServiceLevel());
Duration serviceLevel = Duration.parse(classification.getServiceLevel());
LocalDateTime due = task.getPlanned().toLocalDateTime().plus(serviceLevel);
task.setDue(Timestamp.valueOf(due));
}
@ -412,26 +413,235 @@ public class TaskServiceImpl implements TaskService {
public List<TaskSummary> getTaskSummariesByWorkbasketKey(String workbasketKey)
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
LOGGER.debug("entry to getTaskSummariesByWorkbasketId(workbasketId = {}", workbasketKey);
List<TaskSummary> taskSummaries = new ArrayList<>();
workbasketService.getWorkbasketByKey(workbasketKey);
List<TaskSummary> results = new ArrayList<>();
try {
taskanaEngineImpl.openConnection();
taskSummaries = taskMapper.findTaskSummariesByWorkbasketKey(workbasketKey);
workbasketService.getWorkbasketByKey(workbasketKey); // make sure that the workbasket exists
List<TaskSummaryImpl> taskSummaries = taskMapper.findTaskSummariesByWorkbasketKey(workbasketKey);
// postprocessing: augment each tasksummary by classificationSummary, workbasketSummary and
// list<attachmentsummary>
results = augmentTaskSummariesByContainedSummaries(taskSummaries);
} catch (WorkbasketNotFoundException ex) {
throw ex;
} catch (NotAuthorizedException ex) {
throw ex;
} catch (Exception ex) {
LOGGER.error("Getting TASKSUMMARY failed internally.", ex);
} finally {
if (taskSummaries == null) {
taskSummaries = new ArrayList<>();
}
taskanaEngineImpl.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = taskSummaries.size();
int numberOfResultObjects = results.size();
LOGGER.debug(
"exit from getTaskSummariesByWorkbasketId(workbasketId). Returning {} resulting Objects: {} ",
numberOfResultObjects, LoggerUtils.listToString(taskSummaries));
numberOfResultObjects, LoggerUtils.listToString(results));
}
}
return taskSummaries;
return results;
}
List<TaskSummary> augmentTaskSummariesByContainedSummaries(List<TaskSummaryImpl> taskSummaries)
throws NotAuthorizedException {
List<TaskSummary> result = new ArrayList<>();
if (taskSummaries == null || taskSummaries.isEmpty()) {
return result;
}
addClassificationSummariesToTaskSummaries(taskSummaries);
addWorkbasketSummariesToTaskSummaries(taskSummaries);
addAttachmentSummariesToTaskSummaries(taskSummaries);
result.addAll(taskSummaries);
return result;
}
void addClassificationSummariesToTaskSummaries(List<TaskSummaryImpl> tasks) throws NotAuthorizedException {
if (tasks == null || tasks.isEmpty()) {
return;
}
// calculate parameters for classification query: domains and keys
// use Set to avoid duplicate entries
Set<String> classificationDomainSet = new HashSet<>();
Set<String> classificationKeySet = new HashSet<>();
for (TaskSummaryImpl task : tasks) {
classificationDomainSet.add(task.getDomain());
classificationKeySet.add(task.getClassificationSummary().getKey());
}
String[] classificationDomainArray = classificationDomainSet.toArray(new String[0]);
String[] classificationKeyArray = classificationKeySet.toArray(new String[0]);
// perform classification query
List<ClassificationSummary> classifications = this.classificationService.createClassificationQuery()
.domain(classificationDomainArray)
.key(classificationKeyArray)
.list();
// assign query results to appropriate tasks.
for (TaskSummaryImpl task : tasks) {
String taskClassKey = task.getClassificationSummary().getKey();
String taskDomain = task.getDomain();
// find the appropriate classification from the query result
ClassificationSummary aClassification = classifications.stream()
.filter(x -> taskClassKey != null && taskClassKey.equals(x.getKey()) && taskDomain != null
&& taskDomain.equals(x.getDomain()))
.findFirst()
.orElse(null);
if (aClassification == null) {
LOGGER.error("Could not find a Classification for task {}.", task.getTaskId());
throw new SystemException("Could not find a Classification for task " + task.getTaskId());
}
// set the classification on the task object
task.setClassificationSummary(aClassification);
}
}
private void addWorkbasketSummariesToTaskSummaries(List<TaskSummaryImpl> taskSummaries)
throws NotAuthorizedException {
if (taskSummaries == null || taskSummaries.isEmpty()) {
return;
}
// calculate parameters for workbasket query: workbasket keys
Set<String> workbasketKeySet = taskSummaries.stream().map(t -> t.getWorkbasketSummary().getKey()).collect(
Collectors.toSet());
String[] workbasketKeyArray = workbasketKeySet.toArray(new String[0]);
// perform workbasket query
List<WorkbasketSummary> workbaskets = this.workbasketService.createWorkbasketQuery()
.keyIn(workbasketKeyArray)
.list();
// assign query results to appropriate tasks.
for (TaskSummaryImpl task : taskSummaries) {
String workbasketKey = task.getWorkbasketSummaryImpl().getKey();
// find the appropriate classification from the query result
WorkbasketSummary aWorkbasket = workbaskets.stream()
.filter(x -> workbasketKey != null && workbasketKey.equals(x.getKey()))
.findFirst()
.orElse(null);
if (aWorkbasket == null) {
LOGGER.error("Could not find a Workbasket for task {}.", task.getTaskId());
throw new SystemException("Could not find a Workbasket for task " + task.getTaskId());
}
// set the classification on the task object
task.setWorkbasketSummary(aWorkbasket);
}
}
private void addAttachmentSummariesToTaskSummaries(List<TaskSummaryImpl> taskSummaries)
throws NotAuthorizedException {
if (taskSummaries == null || taskSummaries.isEmpty()) {
return;
}
Set<String> taskIdSet = taskSummaries.stream().map(t -> t.getTaskId()).collect(Collectors.toSet());
String[] taskIdArray = taskIdSet.toArray(new String[0]);
List<AttachmentSummaryImpl> attachmentSummaries = attachmentMapper
.findAttachmentSummariesByTaskIds(taskIdArray);
// the mapper sets for each Attachment summary the property classificationSummary.key from the
// CLASSIFICATION_KEY property in the DB
// augment attachment summaries by classification summaries
addClassificationSummariesToAttachmentSummaries(attachmentSummaries, taskSummaries);
// assign attachment summaries to task summaries
for (TaskSummaryImpl task : taskSummaries) {
for (AttachmentSummaryImpl attachment : attachmentSummaries) {
if (attachment.getTaskId() != null && attachment.getTaskId().equals(task.getTaskId())) {
task.addAttachmentSummary(attachment);
}
}
}
}
private void addClassificationSummariesToAttachmentSummaries(List<AttachmentSummaryImpl> attachmentSummaries,
List<TaskSummaryImpl> taskSummaries) throws NotAuthorizedException {
// prereq: in each attachmentSummary, the classificationSummary.key property is set.
if (attachmentSummaries == null || attachmentSummaries.isEmpty() || taskSummaries == null
|| taskSummaries.isEmpty()) {
return;
}
Set<String> classificationDomainSet = taskSummaries.stream().map(t -> t.getDomain()).collect(
Collectors.toSet());
Set<String> classificationKeySet = attachmentSummaries.stream()
.map(t -> t.getClassificationSummary().getKey())
.collect(
Collectors.toSet());
String[] classificationDomainArray = classificationDomainSet.toArray(new String[0]);
String[] classificationKeyArray = classificationKeySet.toArray(new String[0]);
// perform classification query
List<ClassificationSummary> classifications = this.classificationService.createClassificationQuery()
.domain(classificationDomainArray)
.key(classificationKeyArray)
.list();
// iterate over all attachment summaries an add the appropriate classification summary to each
for (AttachmentSummaryImpl att : attachmentSummaries) {
// find the associated task to use the correct domain
TaskSummaryImpl aTaskSummary = taskSummaries.stream()
.filter(x -> x.getTaskId().equals(att.getTaskId()))
.findFirst()
.orElse(null);
if (aTaskSummary == null) {
LOGGER.error("Could not find a Task associated to attachment {}.", att);
throw new SystemException("Could not find a Task associated to attachment " + att);
}
String domain = aTaskSummary.getDomain();
String classificationKey = att.getClassificationSummary().getKey();
ClassificationSummary aClassification = classifications.stream()
.filter(x -> classificationKey != null && classificationKey.equals(x.getKey()) && domain != null
&& domain.equals(x.getDomain()))
.findFirst()
.orElse(null);
if (aClassification == null) {
LOGGER.error("Could not find a Classification for attachment {}.", att);
throw new SystemException("Could not find a Classification for attachment " + att);
}
att.setClassificationSummary(aClassification);
}
}
private List<Attachment> addClassificationSummariesToAttachments(TaskImpl task,
List<AttachmentImpl> attachmentImpls) {
if (attachmentImpls == null || attachmentImpls.isEmpty()) {
return null;
}
List<Attachment> result = new ArrayList<>();
Set<String> classificationKeySet = attachmentImpls.stream()
.map(t -> t.getClassificationSummary().getKey())
.collect(
Collectors.toSet());
String[] classificationKeyArray = classificationKeySet.toArray(new String[0]);
// perform classification query
List<ClassificationSummary> classifications;
try {
classifications = this.classificationService.createClassificationQuery()
.domain(task.getDomain())
.key(classificationKeyArray)
.list();
} catch (NotAuthorizedException e) {
LOGGER.error("ClassificationQuery unexpectedly returned NotauthorizedException. Throwing SystemException ");
throw new SystemException("ClassificationQuery unexpectedly returned NotauthorizedException.");
}
// iterate over all attachment summaries an add the appropriate classification summary to each
for (AttachmentImpl att : attachmentImpls) {
// find the associated task to use the correct domain
String domain = task.getDomain();
String classificationKey = att.getClassificationSummary().getKey();
ClassificationSummary aClassification = classifications.stream()
.filter(x -> classificationKey != null && classificationKey.equals(x.getKey()) && domain != null
&& domain.equals(x.getDomain()))
.findFirst()
.orElse(null);
if (aClassification == null) {
LOGGER.error("Could not find a Classification for attachment {}.", att);
throw new SystemException("Could not find a Classification for attachment " + att);
}
att.setClassificationSummary(aClassification);
result.add(att);
}
return result;
}
@Override
@ -444,64 +654,6 @@ public class TaskServiceImpl implements TaskService {
return new AttachmentImpl();
}
private void organizeTaskAttachmentClassificationSummaries(TaskImpl taskImpl) {
List<Attachment> attachments = taskImpl.getAttachments();
List<ClassificationSummary> classificationSummaries;
List<String> classificationKeyList = new ArrayList<>();
String[] classificationKeys;
String domain = taskImpl.getDomain();
if (attachments != null && !attachments.isEmpty()) {
for (Attachment attachment : attachments) {
if (!classificationKeyList.contains(attachment.getClassificationKey())) {
classificationKeyList.add(attachment.getClassificationKey());
}
}
} else {
attachments = new ArrayList<>();
}
classificationKeyList.add(taskImpl.getClassificationKey());
classificationKeys = classificationKeyList.toArray(new String[0]);
try {
classificationSummaries = classificationService.createClassificationQuery()
.domain(domain)
.key(classificationKeys)
.list();
for (Attachment attachment : attachments) {
Optional<ClassificationSummary> summary = classificationSummaries.stream()
.filter(cs -> cs.getKey().equals(attachment.getClassificationKey()))
.findFirst();
if (summary.isPresent()) {
((AttachmentImpl) attachment).setClassificationSummary(summary.get());
}
}
// TODO - Change Task.Classification to ClassificationSummary and enable this snippet.
// Optional<ClassificationSummary> summary = classificationSummaries.stream()
// .filter(cs -> cs.getKey().equals(taskImpl.getClassificationKey()))
// .findFirst();
// if (summary.isPresent()) {
// taskImpl.setClassification(summary.get());
// }
} catch (NotAuthorizedException e) {
LOGGER.warn(
"Throwing NotAuthorizedException when getting Classifications of the Task-Attachments. TaskId={}",
taskImpl.getId());
}
}
private void organizeAttachments(TaskImpl taskImpl) {
List<Attachment> attachments = new ArrayList<>();
List<AttachmentImpl> attachmentImpls;
attachmentImpls = attachmentMapper.findAttachmentsByTaskId(taskImpl.getId());
if (attachmentImpls != null && !attachmentImpls.isEmpty()) {
attachments.addAll(attachmentImpls);
}
taskImpl.setAttachments(attachments);
}
private void validateObjectReference(ObjectReference objRef, String objRefType, String objName)
throws InvalidArgumentException {
// check that all values in the ObjectReference are set correctly
@ -525,7 +677,7 @@ public class TaskServiceImpl implements TaskService {
private void validateAttachments(TaskImpl task) throws InvalidArgumentException {
List<Attachment> attachments = task.getAttachments();
if (attachments == null || attachments.size() == 0) {
if (attachments == null || attachments.isEmpty()) {
return;
}
@ -563,40 +715,47 @@ public class TaskServiceImpl implements TaskService {
}
// insert Classification specifications if Classification is given.
Classification oldClassification = oldTaskImpl.getClassification();
Classification newClassification = oldClassification;
ClassificationSummary oldClassificationSummary = oldTaskImpl.getClassificationSummary();
ClassificationSummary newClassificationSummary = oldClassificationSummary;
String newClassificationKey = newTaskImpl.getClassificationKey();
if (newClassificationKey != null && !newClassificationKey.equals(oldClassification.getKey())) {
Workbasket workbasket = workbasketService.getWorkbasketByKey(newTaskImpl.getWorkbasketKey());
Classification newClassification = null;
if (newClassificationKey != null && !newClassificationKey.equals(oldClassificationSummary.getKey())) {
Workbasket workbasket = workbasketService.getWorkbasketByKey(newTaskImpl.getWorkbasketSummary().getKey());
// set new classification
newClassification = this.classificationService.getClassification(newClassificationKey,
workbasket.getDomain());
newClassificationSummary = newClassification.asSummary();
}
newTaskImpl.setClassification(newClassification);
newTaskImpl.setClassificationSummary(newClassificationSummary);
// if (newClassification != null) {
if (newClassification.getServiceLevel() != null) {
Duration serviceLevel = Duration.parse(newClassification.getServiceLevel());
LocalDateTime due = newTaskImpl.getPlanned().toLocalDateTime().plus(serviceLevel);
newTaskImpl.setDue(Timestamp.valueOf(due));
}
if (newClassification != null) {
if (newClassification.getServiceLevel() != null) {
Duration serviceLevel = Duration.parse(newClassification.getServiceLevel());
LocalDateTime due = newTaskImpl.getPlanned().toLocalDateTime().plus(serviceLevel);
newTaskImpl.setDue(Timestamp.valueOf(due));
}
if (newTaskImpl.getName() == null) {
newTaskImpl.setName(newClassification.getName());
}
if (newTaskImpl.getName() == null) {
newTaskImpl.setName(newClassification.getName());
}
if (newTaskImpl.getDescription() == null) {
newTaskImpl.setDescription(newClassification.getDescription());
}
if (newTaskImpl.getDescription() == null) {
newTaskImpl.setDescription(newClassification.getDescription());
}
if (newTaskImpl.getPriority() == 0) {
newTaskImpl.setPriority(newClassification.getPriority());
if (newTaskImpl.getPriority() == 0) {
newTaskImpl.setPriority(newClassification.getPriority());
}
}
// }
Timestamp now = new Timestamp(System.currentTimeMillis());
newTaskImpl.setModified(now);
}
AttachmentMapper getAttachmentMapper() {
return attachmentMapper;
}
}

View File

@ -0,0 +1,800 @@
package pro.taskana.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import pro.taskana.AttachmentSummary;
import pro.taskana.ClassificationSummary;
import pro.taskana.TaskSummary;
import pro.taskana.WorkbasketSummary;
import pro.taskana.model.ObjectReference;
import pro.taskana.model.TaskState;
/**
* Entity which contains the most important informations about a Task.
*/
public class TaskSummaryImpl implements TaskSummary {
private String taskId;
private Timestamp created;
private Timestamp claimed;
private Timestamp completed;
private Timestamp modified;
private Timestamp planned;
private Timestamp due;
private String name;
private String note;
private int priority;
private TaskState state;
private ClassificationSummary classificationSummary;
private WorkbasketSummary workbasketSummary;
private String domain;
private String businessProcessId;
private String parentBusinessProcessId;
private String owner;
private ObjectReference primaryObjRef;
private boolean isRead;
private boolean isTransferred;
// All objects have to be serializable
private List<AttachmentSummary> attachmentSummaries;
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;
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getId()
*/
@Override
public String getTaskId() {
return taskId;
}
public void setTaskId(String id) {
this.taskId = id;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCreated()
*/
@Override
public Timestamp getCreated() {
return created;
}
public void setCreated(Timestamp created) {
this.created = created;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getClaimed()
*/
@Override
public Timestamp getClaimed() {
return claimed;
}
public void setClaimed(Timestamp claimed) {
this.claimed = claimed;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCompleted()
*/
@Override
public Timestamp getCompleted() {
return completed;
}
public void setCompleted(Timestamp completed) {
this.completed = completed;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getModified()
*/
@Override
public Timestamp getModified() {
return modified;
}
public void setModified(Timestamp modified) {
this.modified = modified;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getPlanned()
*/
@Override
public Timestamp getPlanned() {
return planned;
}
public void setPlanned(Timestamp planned) {
this.planned = planned;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getDue()
*/
@Override
public Timestamp getDue() {
return due;
}
public void setDue(Timestamp due) {
this.due = due;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getName()
*/
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getNote()
*/
@Override
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getPriority()
*/
@Override
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getState()
*/
@Override
public TaskState getState() {
return state;
}
public void setState(TaskState state) {
this.state = state;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getClassificationSummary()
*/
@Override
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
}
public void setClassificationSummary(ClassificationSummary classificationSummary) {
this.classificationSummary = classificationSummary;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getWorkbasketSummary()
*/
@Override
public WorkbasketSummary getWorkbasketSummary() {
return workbasketSummary;
}
public void setWorkbasketSummary(WorkbasketSummary workbasketSummary) {
this.workbasketSummary = workbasketSummary;
}
// utility method to allow mybatis access to workbasketSummary
public WorkbasketSummaryImpl getWorkbasketSummaryImpl() {
return (WorkbasketSummaryImpl) workbasketSummary;
}
// utility method to allow mybatis access to workbasketSummary
public void setWorkbasketSummaryImpl(WorkbasketSummaryImpl workbasketSummary) {
this.workbasketSummary = workbasketSummary;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getDomain()
*/
@Override
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getBusinessProcessId()
*/
@Override
public String getBusinessProcessId() {
return businessProcessId;
}
public void setBusinessProcessId(String businessProcessId) {
this.businessProcessId = businessProcessId;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getParentBusinessProcessId()
*/
@Override
public String getParentBusinessProcessId() {
return parentBusinessProcessId;
}
public void setParentBusinessProcessId(String parentBusinessProcessId) {
this.parentBusinessProcessId = parentBusinessProcessId;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getOwner()
*/
@Override
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getPrimaryObjRef()
*/
@Override
public ObjectReference getPrimaryObjRef() {
return primaryObjRef;
}
public void setPrimaryObjRef(ObjectReference primaryObjRef) {
this.primaryObjRef = primaryObjRef;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#isRead()
*/
@Override
public boolean isRead() {
return isRead;
}
public void setRead(boolean isRead) {
this.isRead = isRead;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#isTransferred()
*/
@Override
public boolean isTransferred() {
return isTransferred;
}
public void setTransferred(boolean isTransferred) {
this.isTransferred = isTransferred;
}
public List<AttachmentSummary> getAttachmentSummaries() {
return attachmentSummaries;
}
public void setAttachmentSummaries(List<AttachmentSummary> attachmentSummaries) {
this.attachmentSummaries = attachmentSummaries;
}
public void addAttachmentSummary(AttachmentSummary attachmentSummary) {
if (this.attachmentSummaries == null) {
this.attachmentSummaries = new ArrayList<AttachmentSummary>();
}
this.attachmentSummaries.add(attachmentSummary);
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom1()
*/
@Override
public String getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom2()
*/
@Override
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom3()
*/
@Override
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom4()
*/
@Override
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom5()
*/
@Override
public String getCustom5() {
return custom5;
}
public void setCustom5(String custom5) {
this.custom5 = custom5;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom6()
*/
@Override
public String getCustom6() {
return custom6;
}
public void setCustom6(String custom6) {
this.custom6 = custom6;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom7()
*/
@Override
public String getCustom7() {
return custom7;
}
public void setCustom7(String custom7) {
this.custom7 = custom7;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom8()
*/
@Override
public String getCustom8() {
return custom8;
}
public void setCustom8(String custom8) {
this.custom8 = custom8;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom9()
*/
@Override
public String getCustom9() {
return custom9;
}
public void setCustom9(String custom9) {
this.custom9 = custom9;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.TaskSummary#getCustom10()
*/
@Override
public String getCustom10() {
return custom10;
}
public void setCustom10(String custom10) {
this.custom10 = custom10;
}
// auxiliary Method to enable Mybatis to access classificationSummary
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
}
// auxiliary Method to enable Mybatis to access classificationSummary
public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) {
this.classificationSummary = classificationSummary;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((attachmentSummaries == null) ? 0 : attachmentSummaries.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 + ((custom1 == null) ? 0 : custom1.hashCode());
result = prime * result + ((custom10 == null) ? 0 : custom10.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 + ((domain == null) ? 0 : domain.hashCode());
result = prime * result + ((due == null) ? 0 : due.hashCode());
result = prime * result + ((taskId == null) ? 0 : taskId.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 (!(obj instanceof TaskSummaryImpl)) {
return false;
}
TaskSummaryImpl other = (TaskSummaryImpl) obj;
if (attachmentSummaries == null) {
if (other.attachmentSummaries != null) {
return false;
}
} else if (!attachmentSummaries.equals(other.attachmentSummaries)) {
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 (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 (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 (domain == null) {
if (other.domain != null) {
return false;
}
} else if (!domain.equals(other.domain)) {
return false;
}
if (due == null) {
if (other.due != null) {
return false;
}
} else if (!due.equals(other.due)) {
return false;
}
if (taskId == null) {
if (other.taskId != null) {
return false;
}
} else if (!taskId.equals(other.taskId)) {
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;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("TaskSummaryImpl [taskId=");
builder.append(taskId);
builder.append(", created=");
builder.append(created);
builder.append(", claimed=");
builder.append(claimed);
builder.append(", completed=");
builder.append(completed);
builder.append(", modified=");
builder.append(modified);
builder.append(", planned=");
builder.append(planned);
builder.append(", due=");
builder.append(due);
builder.append(", name=");
builder.append(name);
builder.append(", note=");
builder.append(note);
builder.append(", priority=");
builder.append(priority);
builder.append(", state=");
builder.append(state);
builder.append(", classificationSummary=");
builder.append(classificationSummary);
builder.append(", workbasketSummary=");
builder.append(workbasketSummary);
builder.append(", domain=");
builder.append(domain);
builder.append(", businessProcessId=");
builder.append(businessProcessId);
builder.append(", parentBusinessProcessId=");
builder.append(parentBusinessProcessId);
builder.append(", owner=");
builder.append(owner);
builder.append(", primaryObjRef=");
builder.append(primaryObjRef);
builder.append(", isRead=");
builder.append(isRead);
builder.append(", isTransferred=");
builder.append(isTransferred);
builder.append(", attachmentSummaries=");
builder.append(attachmentSummaries);
builder.append(", custom1=");
builder.append(custom1);
builder.append(", custom2=");
builder.append(custom2);
builder.append(", custom3=");
builder.append(custom3);
builder.append(", custom4=");
builder.append(custom4);
builder.append(", custom5=");
builder.append(custom5);
builder.append(", custom6=");
builder.append(custom6);
builder.append(", custom7=");
builder.append(custom7);
builder.append(", custom8=");
builder.append(custom8);
builder.append(", custom9=");
builder.append(custom9);
builder.append(", custom10=");
builder.append(custom10);
builder.append("]");
return builder.toString();
}
}

View File

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import pro.taskana.Workbasket;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
/**
@ -214,7 +214,7 @@ public class WorkbasketImpl implements Workbasket {
@Override
public WorkbasketSummary asSummary() {
WorkbasketSummary result = new WorkbasketSummary();
WorkbasketSummaryImpl result = new WorkbasketSummaryImpl();
result.setId(this.getId());
result.setKey(this.getKey());
result.setName(this.getName());

View File

@ -10,11 +10,11 @@ import org.slf4j.LoggerFactory;
import pro.taskana.TaskanaEngine;
import pro.taskana.WorkbasketQuery;
import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
import pro.taskana.model.mappings.WorkbasketAccessMapper;
import pro.taskana.security.CurrentUserContext;

View File

@ -13,6 +13,7 @@ import pro.taskana.TaskanaEngine;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketQuery;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -20,7 +21,6 @@ import pro.taskana.impl.util.IdGenerator;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.model.mappings.DistributionTargetMapper;
import pro.taskana.model.mappings.WorkbasketAccessMapper;
import pro.taskana.model.mappings.WorkbasketMapper;
@ -128,7 +128,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
List<WorkbasketSummary> workbaskets = new ArrayList<>();
try {
taskanaEngineImpl.openConnection();
workbaskets = workbasketMapper.findAll();
List<WorkbasketSummaryImpl> workbasketImpls = workbasketMapper.findAll();
for (WorkbasketSummaryImpl workbasketSummaryImpl : workbasketImpls) {
workbaskets.add(workbasketSummaryImpl);
}
return workbaskets;
} finally {
taskanaEngineImpl.returnConnection();

View File

@ -0,0 +1,303 @@
package pro.taskana.impl;
import pro.taskana.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
/**
* This entity contains the most important information about a workbasket.
*
* @author bbr
*/
public class WorkbasketSummaryImpl implements WorkbasketSummary {
private String id;
private String key;
private String name;
private String description;
private String owner;
private String domain;
private WorkbasketType type;
private String orgLevel1;
private String orgLevel2;
private String orgLevel3;
private String orgLevel4;
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getId()
*/
@Override
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getKey()
*/
@Override
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getName()
*/
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getDescription()
*/
@Override
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOwner()
*/
@Override
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getDomain()
*/
@Override
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getType()
*/
@Override
public WorkbasketType getType() {
return type;
}
public void setType(WorkbasketType type) {
this.type = type;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel1()
*/
@Override
public String getOrgLevel1() {
return orgLevel1;
}
public void setOrgLevel1(String orgLevel1) {
this.orgLevel1 = orgLevel1;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel2()
*/
@Override
public String getOrgLevel2() {
return orgLevel2;
}
public void setOrgLevel2(String orgLevel2) {
this.orgLevel2 = orgLevel2;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel3()
*/
@Override
public String getOrgLevel3() {
return orgLevel3;
}
public void setOrgLevel3(String orgLevel3) {
this.orgLevel3 = orgLevel3;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel4()
*/
@Override
public String getOrgLevel4() {
return orgLevel4;
}
public void setOrgLevel4(String orgLevel4) {
this.orgLevel4 = orgLevel4;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
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 + ((key == null) ? 0 : key.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((orgLevel1 == null) ? 0 : orgLevel1.hashCode());
result = prime * result + ((orgLevel2 == null) ? 0 : orgLevel2.hashCode());
result = prime * result + ((orgLevel3 == null) ? 0 : orgLevel3.hashCode());
result = prime * result + ((orgLevel4 == null) ? 0 : orgLevel4.hashCode());
result = prime * result + ((owner == null) ? 0 : owner.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 (!(obj instanceof WorkbasketSummaryImpl)) {
return false;
}
WorkbasketSummaryImpl other = (WorkbasketSummaryImpl) obj;
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 (key == null) {
if (other.key != null) {
return false;
}
} else if (!key.equals(other.key)) {
return false;
}
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
if (orgLevel1 == null) {
if (other.orgLevel1 != null) {
return false;
}
} else if (!orgLevel1.equals(other.orgLevel1)) {
return false;
}
if (orgLevel2 == null) {
if (other.orgLevel2 != null) {
return false;
}
} else if (!orgLevel2.equals(other.orgLevel2)) {
return false;
}
if (orgLevel3 == null) {
if (other.orgLevel3 != null) {
return false;
}
} else if (!orgLevel3.equals(other.orgLevel3)) {
return false;
}
if (orgLevel4 == null) {
if (other.orgLevel4 != null) {
return false;
}
} else if (!orgLevel4.equals(other.orgLevel4)) {
return false;
}
if (owner == null) {
if (other.owner != null) {
return false;
}
} else if (!owner.equals(other.owner)) {
return false;
}
if (type != other.type) {
return false;
}
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkbasketSummaryImpl [id=");
builder.append(id);
builder.append(", key=");
builder.append(key);
builder.append(", name=");
builder.append(name);
builder.append(", description=");
builder.append(description);
builder.append(", owner=");
builder.append(owner);
builder.append(", domain=");
builder.append(domain);
builder.append(", type=");
builder.append(type);
builder.append(", orgLevel1=");
builder.append(orgLevel1);
builder.append(", orgLevel2=");
builder.append(orgLevel2);
builder.append(", orgLevel3=");
builder.append(orgLevel3);
builder.append(", orgLevel4=");
builder.append(orgLevel4);
builder.append("]");
return builder.toString();
}
}

View File

@ -6,9 +6,9 @@ import java.util.Map.Entry;
import java.util.Set;
/**
* Util methods for logging.
* @author bbr
* Utility methods for logging.
*
* @author bbr
*/
public final class LoggerUtils {
@ -17,8 +17,11 @@ public final class LoggerUtils {
/**
* make a String for logging from a list of objects.
* @param list TODO
* @param <T> TODO
*
* @param list
* the input list to be stringified
* @param <T>
* the type of the objects in the input list
* @return A String representation of the list.
*/
public static <T> String listToString(List<T> list) {
@ -29,7 +32,7 @@ public final class LoggerUtils {
builder.append("[");
for (T t : list) {
builder.append(t.toString());
builder.append(";");
builder.append(";\n");
}
builder.append("]");
return builder.toString();
@ -39,9 +42,12 @@ public final class LoggerUtils {
/**
* make a String for logging from a map.
*
* @param map the map to be stringified
* @param <K> TODO
* @param <V> TODO
* @param map
* the map to be stringified
* @param <K>
* the type of the keys in the map
* @param <V>
* the type of the values in the map
* @return A String representation of the map.
*/
public static <K, V> String mapToString(Map<K, V> map) {
@ -61,7 +67,7 @@ public final class LoggerUtils {
}
builder.append("]");
return builder.toString();
}
}
}
}

View File

@ -1,151 +0,0 @@
package pro.taskana.model;
/**
* Entity which contains the most important informations about a Task.
*/
public class TaskSummary {
private String taskId;
private String taskName;
private String workbasketKey;
private String workbasketName;
private String classificationKey;
private String classificationName;
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public String getWorkbasketKey() {
return workbasketKey;
}
public void setWorkbasketKey(String workbasketKey) {
this.workbasketKey = workbasketKey;
}
public String getWorkbasketName() {
return workbasketName;
}
public void setWorkbasketName(String workbasketName) {
this.workbasketName = workbasketName;
}
public String getClassificationKey() {
return classificationKey;
}
public void setClassificationKey(String classificationKey) {
this.classificationKey = classificationKey;
}
public String getClassificationName() {
return classificationName;
}
public void setClassificationName(String classificationName) {
this.classificationName = classificationName;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((classificationKey == null) ? 0 : classificationKey.hashCode());
result = prime * result + ((classificationName == null) ? 0 : classificationName.hashCode());
result = prime * result + ((taskId == null) ? 0 : taskId.hashCode());
result = prime * result + ((taskName == null) ? 0 : taskName.hashCode());
result = prime * result + ((workbasketKey == null) ? 0 : workbasketKey.hashCode());
result = prime * result + ((workbasketName == null) ? 0 : workbasketName.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;
}
TaskSummary other = (TaskSummary) obj;
if (classificationKey == null) {
if (other.classificationKey != null) {
return false;
}
} else if (!classificationKey.equals(other.classificationKey)) {
return false;
}
if (classificationName == null) {
if (other.classificationName != null) {
return false;
}
} else if (!classificationName.equals(other.classificationName)) {
return false;
}
if (taskId == null) {
if (other.taskId != null) {
return false;
}
} else if (!taskId.equals(other.taskId)) {
return false;
}
if (taskName == null) {
if (other.taskName != null) {
return false;
}
} else if (!taskName.equals(other.taskName)) {
return false;
}
if (workbasketKey == null) {
if (other.workbasketKey != null) {
return false;
}
} else if (!workbasketKey.equals(other.workbasketKey)) {
return false;
}
if (workbasketName == null) {
if (other.workbasketName != null) {
return false;
}
} else if (!workbasketName.equals(other.workbasketName)) {
return false;
}
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("TaskSummary [taskId=");
builder.append(taskId);
builder.append(", taskName=");
builder.append(taskName);
builder.append(", workbasketKey=");
builder.append(workbasketKey);
builder.append(", workbasketName=");
builder.append(workbasketName);
builder.append(", classificationKey=");
builder.append(classificationKey);
builder.append(", classificationName=");
builder.append(classificationName);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,139 +0,0 @@
package pro.taskana.model;
/**
* This entity contains the most important information about a workbasket.
*
* @author bbr
*/
public class WorkbasketSummary {
private String id;
private String key;
private String name;
private String description;
private String owner;
private String domain;
private WorkbasketType type;
private String orgLevel1;
private String orgLevel2;
private String orgLevel3;
private String orgLevel4;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public WorkbasketType getType() {
return type;
}
public void setType(WorkbasketType type) {
this.type = type;
}
public String getOrgLevel1() {
return orgLevel1;
}
public void setOrgLevel1(String orgLevel1) {
this.orgLevel1 = orgLevel1;
}
public String getOrgLevel2() {
return orgLevel2;
}
public void setOrgLevel2(String orgLevel2) {
this.orgLevel2 = orgLevel2;
}
public String getOrgLevel3() {
return orgLevel3;
}
public void setOrgLevel3(String orgLevel3) {
this.orgLevel3 = orgLevel3;
}
public String getOrgLevel4() {
return orgLevel4;
}
public void setOrgLevel4(String orgLevel4) {
this.orgLevel4 = orgLevel4;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkbasketSummary [id=");
builder.append(id);
builder.append(", key=");
builder.append(key);
builder.append(", name=");
builder.append(name);
builder.append(", description=");
builder.append(description);
builder.append(", owner=");
builder.append(owner);
builder.append(", domain=");
builder.append(domain);
builder.append(", type=");
builder.append(type);
builder.append(", orgLevel1=");
builder.append(orgLevel1);
builder.append(", orgLevel2=");
builder.append(orgLevel2);
builder.append(", orgLevel3=");
builder.append(orgLevel3);
builder.append(", orgLevel4=");
builder.append(orgLevel4);
builder.append("]");
return builder.toString();
}
}

View File

@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import pro.taskana.impl.AttachmentImpl;
import pro.taskana.impl.AttachmentSummaryImpl;
import pro.taskana.impl.persistence.MapTypeHandler;
/**
@ -18,6 +19,7 @@ import pro.taskana.impl.persistence.MapTypeHandler;
*/
public interface AttachmentMapper {
@Insert("INSERT INTO ATTACHMENT (ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES) "
+ "VALUES (#{att.id}, #{att.taskId}, #{att.created}, #{att.modified}, #{att.classificationSummary.key}, #{att.objectReference.company}, #{att.objectReference.system}, #{att.objectReference.systemInstance}, "
+ " #{att.objectReference.type}, #{att.objectReference.value}, #{att.channel}, #{att.received}, #{att.customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler} )")
@ -31,7 +33,7 @@ public interface AttachmentMapper {
@Result(property = "taskId", column = "TASK_ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "modified", column = "MODIFIED"),
@Result(property = "classificationKey", column = "CLASSIFICATION_KEY"),
@Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"),
@Result(property = "objectReference.company", column = "REF_COMPANY"),
@Result(property = "objectReference.system", column = "REF_SYSTEM"),
@Result(property = "objectReference.systemInstance", column = "REF_INSTANCE"),
@ -40,7 +42,24 @@ public interface AttachmentMapper {
@Result(property = "channel", column = "CHANNEL"),
@Result(property = "received", column = "RECEIVED"),
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
javaType = Map.class, typeHandler = MapTypeHandler.class),
javaType = Map.class, typeHandler = MapTypeHandler.class)
})
List<AttachmentImpl> findAttachmentsByTaskId(@Param("taskId") String taskId);
@Select("<script>SELECT ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, RECEIVED "
+ "FROM ATTACHMENT "
+ "<where>"
+ "TASK_ID IN (<foreach collection='array' item='item' separator=',' >#{item}</foreach>)"
+ "</where>"
+ "</script>")
@Results(value = {
@Result(property = "id", column = "ID"),
@Result(property = "taskId", column = "TASK_ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "modified", column = "MODIFIED"),
@Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"),
@Result(property = "received", column = "RECEIVED"),
})
List<AttachmentSummaryImpl> findAttachmentSummariesByTaskIds(String[] taskIds);
}

View File

@ -9,11 +9,11 @@ import org.apache.ibatis.annotations.Select;
import pro.taskana.impl.ClassificationQueryImpl;
import pro.taskana.impl.ClassificationSummaryImpl;
import pro.taskana.impl.ObjectReferenceQueryImpl;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskQueryImpl;
import pro.taskana.impl.TaskSummaryImpl;
import pro.taskana.impl.WorkbasketQueryImpl;
import pro.taskana.impl.WorkbasketSummaryImpl;
import pro.taskana.model.ObjectReference;
import pro.taskana.model.WorkbasketSummary;
/**
* This class provides a mapper for all queries.
@ -23,6 +23,7 @@ public interface QueryMapper {
String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById";
String CLASSIFICATION_FINDBYKEYANDDOMAIN = "pro.taskana.model.mappings.ClassificationMapper.findByKeyAndDomain";
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findById";
String WORKBASKET_FINDSUMMARYBYKEY = "pro.taskana.model.mappings.WorkbasketMapper.findSummaryByKey";
@Select("<script>SELECT t.ID, t.CREATED, t.CLAIMED, t.COMPLETED, t.MODIFIED, t.PLANNED, t.DUE, t.NAME, t.DESCRIPTION, t.NOTE, t.PRIORITY, t.STATE, t.CLASSIFICATION_KEY, t.DOMAIN, t.WORKBASKET_KEY, t.BUSINESS_PROCESS_ID, t.PARENT_BUSINESS_PROCESS_ID, t.OWNER, t.POR_COMPANY, t.POR_SYSTEM, t.POR_INSTANCE, t.POR_TYPE, t.POR_VALUE, t.IS_READ, t.IS_TRANSFERRED, t.CUSTOM_1, t.CUSTOM_2, t.CUSTOM_3, t.CUSTOM_4, t.CUSTOM_5, t.CUSTOM_6, t.CUSTOM_7, t.CUSTOM_8, t.CUSTOM_9, t.CUSTOM_10 "
+ "FROM TASK t "
@ -51,7 +52,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 = "taskId", column = "ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "claimed", column = "CLAIMED"),
@Result(property = "completed", column = "COMPLETED"),
@ -59,13 +60,13 @@ public interface QueryMapper {
@Result(property = "planned", column = "PLANNED"),
@Result(property = "due", column = "DUE"),
@Result(property = "name", column = "NAME"),
@Result(property = "description", column = "DESCRIPTION"),
// @Result(property = "description", column = "DESCRIPTION"),
@Result(property = "note", column = "NOTE"),
@Result(property = "priority", column = "PRIORITY"),
@Result(property = "state", column = "STATE"),
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "classificationKey", column = "CLASSIFICATION_KEY"),
@Result(property = "workbasketSummaryImpl.key", column = "WORKBASKET_KEY"),
@Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"),
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
@Result(property = "owner", column = "OWNER"),
@ -86,7 +87,7 @@ public interface QueryMapper {
@Result(property = "custom8", column = "CUSTOM_8"),
@Result(property = "custom9", column = "CUSTOM_9"),
@Result(property = "custom10", column = "CUSTOM_10")})
List<TaskImpl> queryTasks(TaskQueryImpl taskQuery);
List<TaskSummaryImpl> 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 "
+ "FROM CLASSIFICATION "
@ -114,7 +115,7 @@ public interface QueryMapper {
@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 "
@ -179,5 +180,5 @@ public interface QueryMapper {
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
List<WorkbasketSummary> queryWorkbasket(WorkbasketQueryImpl workbasketQuery);
List<WorkbasketSummaryImpl> queryWorkbasket(WorkbasketQueryImpl workbasketQuery);
}

View File

@ -1,11 +1,11 @@
package pro.taskana.model.mappings;
import java.sql.Date;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
@ -15,16 +15,21 @@ import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskSummaryImpl;
import pro.taskana.impl.WorkbasketSummaryImpl;
import pro.taskana.impl.persistence.MapTypeHandler;
import pro.taskana.model.DueWorkbasketCounter;
import pro.taskana.model.TaskState;
import pro.taskana.model.TaskSummary;
/**
* This class is the mybatis mapping of task.
*/
public interface TaskMapper {
String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById";
String CLASSIFICATION_FINDBYKEYANDDOMAIN = "pro.taskana.model.mappings.ClassificationMapper.findByKeyAndDomain";
String WORKBASKET_FINDSUMMARYBYKEY = "pro.taskana.model.mappings.WorkbasketMapper.findSummaryByKey";
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findById";
@Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, NOTE, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
+ "FROM TASK "
+ "WHERE ID = #{id}")
@ -42,6 +47,8 @@ public interface TaskMapper {
@Result(property = "priority", column = "PRIORITY"),
@Result(property = "state", column = "STATE"),
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
@Result(property = "workbasketSummary", column = "WORKBASKET_KEY", javaType = WorkbasketSummaryImpl.class,
one = @One(select = WORKBASKET_FINDSUMMARYBYKEY)),
@Result(property = "classificationKey", column = "CLASSIFICATION_KEY"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@ -69,30 +76,24 @@ public interface TaskMapper {
})
TaskImpl findById(@Param("id") String id);
@Results({ @Result(column = "DUE_DATE", property = "due"),
@Result(column = "WORKBASKET_KEY", property = "workbasketKey"),
@Result(column = "counter", property = "taskCounter") })
List<DueWorkbasketCounter> getTaskCountByWorkbasketIdAndDaysInPastAndState(@Param("fromDate") Date fromDate,
@Param("status") List<TaskState> states);
@Insert("INSERT INTO TASK(ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, NOTE, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10) "
+ "VALUES(#{id}, #{created}, #{claimed}, #{completed}, #{modified}, #{planned}, #{due}, #{name}, #{description}, #{note}, #{priority}, #{state}, #{classification.key}, #{workbasketKey}, #{domain}, #{businessProcessId}, #{parentBusinessProcessId}, #{owner}, #{primaryObjRef.company},#{primaryObjRef.system},#{primaryObjRef.systemInstance},#{primaryObjRef.type},#{primaryObjRef.value}, #{isRead}, #{isTransferred}, #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, #{custom1}, #{custom2}, #{custom3}, #{custom4}, #{custom5}, #{custom6}, #{custom7}, #{custom8}, #{custom9}, #{custom10})")
+ "VALUES(#{id}, #{created}, #{claimed}, #{completed}, #{modified}, #{planned}, #{due}, #{name}, #{description}, #{note}, #{priority}, #{state}, #{classificationKey}, #{workbasketKey}, #{domain}, #{businessProcessId}, #{parentBusinessProcessId}, #{owner}, #{primaryObjRef.company},#{primaryObjRef.system},#{primaryObjRef.systemInstance},#{primaryObjRef.type},#{primaryObjRef.value}, #{isRead}, #{isTransferred}, #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, #{custom1}, #{custom2}, #{custom3}, #{custom4}, #{custom5}, #{custom6}, #{custom7}, #{custom8}, #{custom9}, #{custom10})")
@Options(keyProperty = "id", keyColumn = "ID")
void insert(TaskImpl task);
@Update("UPDATE TASK SET CLAIMED = #{claimed}, COMPLETED = #{completed}, MODIFIED = #{modified}, PLANNED = #{planned}, DUE = #{due}, NAME = #{name}, DESCRIPTION = #{description}, NOTE = #{note}, PRIORITY = #{priority}, STATE = #{state}, CLASSIFICATION_KEY = #{classification.key}, WORKBASKET_KEY = #{workbasketKey}, DOMAIN = #{domain}, BUSINESS_PROCESS_ID = #{businessProcessId}, PARENT_BUSINESS_PROCESS_ID = #{parentBusinessProcessId}, OWNER = #{owner}, POR_COMPANY = #{primaryObjRef.company}, POR_SYSTEM = #{primaryObjRef.system}, POR_INSTANCE = #{primaryObjRef.systemInstance}, POR_TYPE = #{primaryObjRef.type}, POR_VALUE = #{primaryObjRef.value}, IS_READ = #{isRead}, IS_TRANSFERRED = #{isTransferred}, CUSTOM_ATTRIBUTES = #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, CUSTOM_1 = #{custom1}, CUSTOM_2 = #{custom2}, CUSTOM_3 = #{custom3}, CUSTOM_4 = #{custom4}, CUSTOM_5 = #{custom5}, CUSTOM_6 = #{custom6}, CUSTOM_7 = #{custom7}, CUSTOM_8 = #{custom8}, CUSTOM_9 = #{custom9}, CUSTOM_10 = #{custom10} "
@Update("UPDATE TASK SET CLAIMED = #{claimed}, COMPLETED = #{completed}, MODIFIED = #{modified}, PLANNED = #{planned}, DUE = #{due}, NAME = #{name}, DESCRIPTION = #{description}, NOTE = #{note}, PRIORITY = #{priority}, STATE = #{state}, CLASSIFICATION_KEY = #{classificationKey}, WORKBASKET_KEY = #{workbasketKey}, DOMAIN = #{domain}, BUSINESS_PROCESS_ID = #{businessProcessId}, PARENT_BUSINESS_PROCESS_ID = #{parentBusinessProcessId}, OWNER = #{owner}, POR_COMPANY = #{primaryObjRef.company}, POR_SYSTEM = #{primaryObjRef.system}, POR_INSTANCE = #{primaryObjRef.systemInstance}, POR_TYPE = #{primaryObjRef.type}, POR_VALUE = #{primaryObjRef.value}, IS_READ = #{isRead}, IS_TRANSFERRED = #{isTransferred}, CUSTOM_ATTRIBUTES = #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, CUSTOM_1 = #{custom1}, CUSTOM_2 = #{custom2}, CUSTOM_3 = #{custom3}, CUSTOM_4 = #{custom4}, CUSTOM_5 = #{custom5}, CUSTOM_6 = #{custom6}, CUSTOM_7 = #{custom7}, CUSTOM_8 = #{custom8}, CUSTOM_9 = #{custom9}, CUSTOM_10 = #{custom10} "
+ "WHERE ID = #{id}")
void update(TaskImpl task);
@Delete("DELETE FROM TASK WHERE ID = #{id}")
void delete(String id);
@Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
@Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
+ "FROM TASK "
+ "WHERE WORKBASKET_KEY = #{workbasketKey} "
+ "AND STATE = #{taskState}")
@Results(value = {
@Result(property = "id", column = "ID"),
@Result(property = "taskId", column = "ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "claimed", column = "CLAIMED"),
@Result(property = "completed", column = "COMPLETED"),
@ -100,12 +101,15 @@ public interface TaskMapper {
@Result(property = "planned", column = "PLANNED"),
@Result(property = "due", column = "DUE"),
@Result(property = "name", column = "NAME"),
@Result(property = "description", column = "DESCRIPTION"),
@Result(property = "note", column = "NOTE"),
@Result(property = "priority", column = "PRIORITY"),
@Result(property = "state", column = "STATE"),
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
@Result(property = "classificationSummaryImpl.Key", column = "CLASSIFICATION_KEY"),
@Result(property = "workbasketSummaryImpl.key", column = "WORKBASKET_KEY"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
@Result(property = "owner", column = "OWNER"),
@Result(property = "primaryObjRef.company", column = "POR_COMPANY"),
@Result(property = "primaryObjRef.system", column = "POR_SYSTEM"),
@ -114,8 +118,6 @@ public interface TaskMapper {
@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,
javaType = Map.class, typeHandler = MapTypeHandler.class),
@Result(property = "custom1", column = "CUSTOM_1"),
@Result(property = "custom2", column = "CUSTOM_2"),
@Result(property = "custom3", column = "CUSTOM_3"),
@ -125,23 +127,47 @@ 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") })
List<TaskImpl> findTasksByWorkbasketIdAndState(@Param("workbasketKey") String workbasketKey,
@Result(property = "custom10", column = "CUSTOM_10")})
List<TaskSummaryImpl> findTasksByWorkbasketIdAndState(@Param("workbasketKey") String workbasketKey,
@Param("taskState") TaskState taskState);
@Select("SELECT TASK.ID AS taskId, TASK.NAME AS taskName, TASK.WORKBASKET_KEY AS workId, TASK.CLASSIFICATION_KEY AS classificationKey, "
+ "WORKBASKET.NAME AS workName, CLASSIFICATION.NAME AS classificationName "
@Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
+ "FROM TASK "
+ "LEFT JOIN WORKBASKET ON WORKBASKET.KEY = TASK.WORKBASKET_KEY "
+ "LEFT JOIN CLASSIFICATION ON CLASSIFICATION.KEY = TASK.CLASSIFICATION_KEY AND CLASSIFICATION.DOMAIN = WORKBASKET.DOMAIN "
+ "WHERE TASK.WORKBASKET_KEY = #{workbasketKey}")
@Results({
@Result(property = "taskId", column = "taskId"),
@Result(property = "taskName", column = "taskName"),
@Result(property = "workbasketKey", column = "workKey"),
@Result(property = "workbasketName", column = "workName"),
@Result(property = "classificationKey", column = "classificationKey"),
@Result(property = "classificationName", column = "classificationName")
})
List<TaskSummary> findTaskSummariesByWorkbasketKey(@Param("workbasketKey") String workbasketKey);
+ "WHERE WORKBASKET_KEY = #{workbasketKey} ")
@Results(value = {
@Result(property = "taskId", column = "ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "claimed", column = "CLAIMED"),
@Result(property = "completed", column = "COMPLETED"),
@Result(property = "modified", column = "MODIFIED"),
@Result(property = "planned", column = "PLANNED"),
@Result(property = "due", column = "DUE"),
@Result(property = "name", column = "NAME"),
@Result(property = "note", column = "NOTE"),
@Result(property = "priority", column = "PRIORITY"),
@Result(property = "state", column = "STATE"),
@Result(property = "classificationSummaryImpl.key", column = "CLASSIFICATION_KEY"),
@Result(property = "workbasketSummaryImpl.key", column = "WORKBASKET_KEY"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
@Result(property = "owner", column = "OWNER"),
@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"),
@Result(property = "custom2", column = "CUSTOM_2"),
@Result(property = "custom3", column = "CUSTOM_3"),
@Result(property = "custom4", column = "CUSTOM_4"),
@Result(property = "custom5", column = "CUSTOM_5"),
@Result(property = "custom6", column = "CUSTOM_6"),
@Result(property = "custom7", column = "CUSTOM_7"),
@Result(property = "custom8", column = "CUSTOM_8"),
@Result(property = "custom9", column = "CUSTOM_9"),
@Result(property = "custom10", column = "CUSTOM_10")})
List<TaskSummaryImpl> findTaskSummariesByWorkbasketKey(@Param("workbasketKey") String workbasketKey);
}

View File

@ -14,8 +14,8 @@ import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.mapping.FetchType;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.WorkbasketSummaryImpl;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
/**
* This class is the mybatis mapping of workbaskets.
@ -23,7 +23,7 @@ import pro.taskana.model.WorkbasketSummary;
public interface WorkbasketMapper {
@Select("SELECT ID, KEY, CREATED, MODIFIED, NAME, DOMAIN, TYPE, DESCRIPTION, OWNER, CUSTOM_1 ,CUSTOM_2 ,CUSTOM_3 ,CUSTOM_4 ,ORG_LEVEL_1 ,ORG_LEVEL_2 ,ORG_LEVEL_3 ,ORG_LEVEL_4 FROM WORKBASKET WHERE ID = #{id}")
@Results(value = { @Result(property = "id", column = "ID"),
@Results(value = {@Result(property = "id", column = "ID"),
@Result(property = "key", column = "KEY"),
@Result(property = "created", column = "CREATED"),
@Result(property = "modified", column = "MODIFIED"),
@ -45,7 +45,7 @@ public interface WorkbasketMapper {
WorkbasketImpl findById(@Param("id") String id);
@Select("SELECT ID, KEY, CREATED, MODIFIED, NAME, DOMAIN, TYPE, DESCRIPTION, OWNER, CUSTOM_1 ,CUSTOM_2 ,CUSTOM_3 ,CUSTOM_4 ,ORG_LEVEL_1 ,ORG_LEVEL_2 ,ORG_LEVEL_3 ,ORG_LEVEL_4 FROM WORKBASKET WHERE KEY = #{key}")
@Results(value = { @Result(property = "id", column = "ID"),
@Results(value = {@Result(property = "id", column = "ID"),
@Result(property = "key", column = "KEY"),
@Result(property = "created", column = "CREATED"),
@Result(property = "modified", column = "MODIFIED"),
@ -81,7 +81,23 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
List<WorkbasketSummary> findByDistributionTargets(@Param("id") String id);
List<WorkbasketSummaryImpl> findByDistributionTargets(@Param("id") String id);
@Select("SELECT ID, KEY, NAME, DESCRIPTION, OWNER, DOMAIN, TYPE, ORG_LEVEL_1, ORG_LEVEL_2, ORG_LEVEL_3, ORG_LEVEL_4 FROM WORKBASKET WHERE key = #{key}")
@Results(value = {
@Result(property = "id", column = "ID"),
@Result(property = "key", column = "KEY"),
@Result(property = "name", column = "NAME"),
@Result(property = "description", column = "DESCRIPTION"),
@Result(property = "owner", column = "OWNER"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "type", column = "TYPE"),
@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")})
List<WorkbasketSummaryImpl> findSummaryByKey(@Param("key") String key);
@Select("SELECT * FROM WORKBASKET ORDER BY id")
@Results(value = {
@ -96,7 +112,7 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
List<WorkbasketSummary> findAll();
List<WorkbasketSummaryImpl> findAll();
@Select("<script>SELECT W.ID, W.KEY, W.NAME, W.DESCRIPTION, W.OWNER, W.DOMAIN, W.TYPE, W.ORG_LEVEL_1, W.ORG_LEVEL_2, W.ORG_LEVEL_3, W.ORG_LEVEL_4 FROM WORKBASKET AS W "
+ "INNER JOIN WORKBASKET_ACCESS_LIST AS ACL "
@ -130,7 +146,7 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
List<WorkbasketSummary> findByPermission(@Param("authorizations") List<WorkbasketAuthorization> authorizations,
List<WorkbasketSummaryImpl> findByPermission(@Param("authorizations") List<WorkbasketAuthorization> authorizations,
@Param("accessId") String accessId);
@Insert("INSERT INTO WORKBASKET (ID, KEY, CREATED, MODIFIED, NAME, DOMAIN, TYPE, DESCRIPTION, OWNER, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, ORG_LEVEL_1, ORG_LEVEL_2, ORG_LEVEL_3, ORG_LEVEL_4) VALUES (#{workbasket.id}, #{workbasket.key}, #{workbasket.created}, #{workbasket.modified}, #{workbasket.name}, #{workbasket.domain}, #{workbasket.type}, #{workbasket.description}, #{workbasket.owner}, #{workbasket.custom1}, #{workbasket.custom2}, #{workbasket.custom3}, #{workbasket.custom4}, #{workbasket.orgLevel1}, #{workbasket.orgLevel2}, #{workbasket.orgLevel3}, #{workbasket.orgLevel4})")

View File

@ -64,7 +64,7 @@ CREATE TABLE WORKBASKET(
ORG_LEVEL_3 VARCHAR(255) NULL,
ORG_LEVEL_4 VARCHAR(255) NULL,
PRIMARY KEY (ID),
CONSTRAINT UC_NAME UNIQUE (NAME)
CONSTRAINT UC_NAME UNIQUE (ID)
);
CREATE TABLE DISTRIBUTION_TARGETS(

View File

@ -16,7 +16,6 @@ import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.database.TestDataGenerator;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.AttachmentImpl;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
@ -72,13 +71,9 @@ public abstract class AbstractAccTest {
String channel, String receivedDate, Map<String, Object> customAttributes)
throws ClassificationNotFoundException, NotAuthorizedException {
Attachment attachment = taskanaEngine.getTaskService().newAttachment();
((AttachmentImpl) attachment).setClassificationSummary(
taskanaEngine.getClassificationService()
.createClassificationQuery()
.key(classificationKey)
.domain("DOMAIN_A")
.single());
attachment.setClassificationKey(classificationKey);
attachment.setClassificationSummary(
taskanaEngine.getClassificationService().getClassification(classificationKey, "DOMAIN_A").asSummary());
attachment.setObjectReference(objRef);
attachment.setChannel(channel);
Timestamp receivedTimestamp = null;

View File

@ -9,8 +9,8 @@ import org.junit.Assert;
import org.junit.Test;
import acceptance.AbstractAccTest;
import pro.taskana.Task;
import pro.taskana.TaskService;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
@ -28,7 +28,7 @@ public class QueryTasksByObjectReferenceAccTest extends AbstractAccTest {
public void testQueryTasksByExcactValueOfObjectReference()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<Task> results = taskService.createTaskQuery()
List<TaskSummary> results = taskService.createTaskQuery()
.primaryObjectReferenceValueIn("Value1", "Value2")
.list();
Assert.assertEquals(10L, results.size());
@ -38,7 +38,7 @@ public class QueryTasksByObjectReferenceAccTest extends AbstractAccTest {
public void testQueryTasksByExcactValueAndTypeOfObjectReference()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<Task> results = taskService.createTaskQuery()
List<TaskSummary> results = taskService.createTaskQuery()
.primaryObjectReferenceTypeIn("Type3")
.primaryObjectReferenceValueIn("Value3")
.list();
@ -49,7 +49,7 @@ public class QueryTasksByObjectReferenceAccTest extends AbstractAccTest {
public void testQueryTasksByValueLikeOfObjectReference()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<Task> results = taskService.createTaskQuery()
List<TaskSummary> results = taskService.createTaskQuery()
.primaryObjectReferenceValueLike("Val%")
.list();
Assert.assertEquals(14L, results.size());

View File

@ -11,11 +11,11 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;

View File

@ -1,6 +1,7 @@
package pro.taskana.impl;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
@ -15,7 +16,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.Task;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.model.TaskState;
@ -40,9 +41,13 @@ public class TaskQueryImplTest {
@Mock
ClassificationServiceImpl classificationService;
@Mock
TaskServiceImpl taskServiceMock;
@Before
public void setup() {
when(taskanaEngine.getClassificationService()).thenReturn(classificationService);
when(taskanaEngine.getTaskService()).thenReturn(taskServiceMock);
taskQueryImpl = new TaskQueryImpl(taskanaEngine);
}
@ -50,11 +55,14 @@ public class TaskQueryImplTest {
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
List<TaskSummary> intermediate = new ArrayList<>();
intermediate.add(new TaskSummaryImpl());
doReturn(intermediate).when(taskServiceMock).augmentTaskSummariesByContainedSummaries(any());
List<Task> result = taskQueryImpl.name("test", "asd", "blubber")
.customFields("cool", "bla")
.priority(1, 2)
.state(TaskState.CLAIMED, TaskState.COMPLETED)
List<TaskSummary> result = taskQueryImpl.nameIn("test", "asd", "blubber")
.customFieldsIn("cool", "bla")
.priorityIn(1, 2)
.stateIn(TaskState.CLAIMED, TaskState.COMPLETED)
.list();
Assert.assertNotNull(result);
}
@ -64,11 +72,14 @@ public class TaskQueryImplTest {
throws NotAuthorizedException, InvalidArgumentException {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
List<TaskSummary> intermediate = new ArrayList<>();
intermediate.add(new TaskSummaryImpl());
doReturn(intermediate).when(taskServiceMock).augmentTaskSummariesByContainedSummaries(any());
List<Task> result = taskQueryImpl.name("test", "asd", "blubber")
.customFields("cool", "bla")
.priority(1, 2)
.state(TaskState.CLAIMED, TaskState.COMPLETED)
List<TaskSummary> result = taskQueryImpl.nameIn("test", "asd", "blubber")
.customFieldsIn("cool", "bla")
.priorityIn(1, 2)
.stateIn(TaskState.CLAIMED, TaskState.COMPLETED)
.list(1, 1);
Assert.assertNotNull(result);
}
@ -76,12 +87,16 @@ public class TaskQueryImplTest {
@Test
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectOne(any(), any())).thenReturn(new TaskImpl());
when(sqlSession.selectOne(any(), any())).thenReturn(new TaskSummaryImpl());
List<TaskSummary> intermediate = new ArrayList<>();
intermediate.add(new TaskSummaryImpl());
doReturn(intermediate).when(taskServiceMock).augmentTaskSummariesByContainedSummaries(any());
// when(taskServiceMock.augmentTaskSummariesByContainedSummaries(any())).thenReturn(intermediate);
Task result = taskQueryImpl.name("test", "asd", "blubber")
.customFields("cool", "bla")
.priority(1, 2)
.state(TaskState.CLAIMED, TaskState.COMPLETED)
TaskSummary result = taskQueryImpl.nameIn("test", "asd", "blubber")
.customFieldsIn("cool", "bla")
.priorityIn(1, 2)
.stateIn(TaskState.CLAIMED, TaskState.COMPLETED)
.single();
Assert.assertNotNull(result);
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@ -33,7 +34,9 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import pro.taskana.Classification;
import pro.taskana.ClassificationSummary;
import pro.taskana.Task;
import pro.taskana.TaskSummary;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.configuration.TaskanaEngineConfiguration;
@ -49,7 +52,6 @@ import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.model.ObjectReference;
import pro.taskana.model.TaskState;
import pro.taskana.model.TaskSummary;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.mappings.AttachmentMapper;
import pro.taskana.model.mappings.ObjectReferenceMapper;
@ -91,7 +93,7 @@ public class TaskServiceImplTest {
private WorkbasketService workbasketServiceMock;
@Mock
private ClassificationServiceImpl classificationServiceMock;
private ClassificationServiceImpl classificationServiceImplMock;
@Mock
private AttachmentMapper attachmentMapperMock;
@ -106,7 +108,7 @@ public class TaskServiceImplTest {
public void setup() {
MockitoAnnotations.initMocks(this);
doReturn(workbasketServiceMock).when(taskanaEngineMock).getWorkbasketService();
doReturn(classificationServiceMock).when(taskanaEngineMock).getClassificationService();
doReturn(classificationServiceImplMock).when(taskanaEngineMock).getClassificationService();
try {
Mockito.doNothing().when(workbasketServiceMock).checkAuthorization(any(), any());
} catch (NotAuthorizedException e) {
@ -121,14 +123,19 @@ public class TaskServiceImplTest {
ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException,
TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "k1");
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "k1", dummyClassification);
WorkbasketImpl wb = new WorkbasketImpl();
wb.setId("1");
wb.setKey("k1");
wb.setName("workbasket");
wb.setDomain(dummyClassification.getDomain());
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
doReturn(wb).when(workbasketServiceMock).getWorkbasketByKey(wb.getKey());
doNothing().when(taskMapperMock).insert(expectedTask);
doReturn(dummyClassification).when(
classificationServiceImplMock)
.getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
expectedTask.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
Task actualTask = cutSpy.createTask(expectedTask);
@ -136,13 +143,13 @@ public class TaskServiceImplTest {
verify(taskanaEngineImpl, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
verify(classificationServiceMock, times(1)).getClassification(any(), any());
verify(classificationServiceImplMock, times(1)).getClassification(any(), any());
verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock,
classificationServiceMock);
classificationServiceImplMock);
assertNull(actualTask.getOwner());
assertNotNull(actualTask.getCreated());
@ -165,27 +172,31 @@ public class TaskServiceImplTest {
wb.setKey("k33");
wb.setDomain("dummy-domain");
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", wb.getKey());
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", wb.getKey(), dummyClassification);
expectedTask.setPrimaryObjRef(expectedObjectReference);
Classification classification = expectedTask.getClassification();
ClassificationSummary classification = expectedTask.getClassificationSummary();
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
doReturn(wb).when(workbasketServiceMock).getWorkbasketByKey(expectedTask.getWorkbasketKey());
doReturn(expectedObjectReference).when(objectReferenceMapperMock)
.findByObjectReference(expectedObjectReference);
doReturn(dummyClassification).when(
classificationServiceImplMock)
.getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
doNothing().when(taskMapperMock).insert(expectedTask);
Task actualTask = cutSpy.createTask(expectedTask);
verify(taskanaEngineImpl, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(wb.getKey());
verify(workbasketServiceMock, times(1)).checkAuthorization(wb.getKey(), WorkbasketAuthorization.APPEND);
verify(classificationServiceMock, times(1)).getClassification(classification.getKey(),
verify(classificationServiceImplMock, times(1)).getClassification(classification.getKey(),
classification.getDomain());
verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock,
classificationServiceMock);
classificationServiceImplMock);
assertNull(actualTask.getOwner());
assertNotNull(actualTask.getCreated());
assertNotNull(actualTask.getModified());
@ -206,13 +217,15 @@ public class TaskServiceImplTest {
wb.setId("1");
wb.setKey("key1");
wb.setName("workbasket");
wb.setDomain("dummy-domain");
doReturn(wb).when(workbasketServiceMock).getWorkbasketByKey(wb.getKey());
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "key1");
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "key1", dummyClassification);
expectedTask.setPrimaryObjRef(expectedObjectReference);
Classification classification = expectedTask.getClassification();
ClassificationSummary classification = expectedTask.getClassificationSummary();
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
doReturn(classification).when(classificationServiceMock).getClassification(classification.getKey(),
doReturn(dummyClassification).when(classificationServiceImplMock).getClassification(classification.getKey(),
classification.getDomain());
doNothing().when(taskMapperMock).insert(expectedTask);
doNothing().when(objectReferenceMapperMock).insert(expectedObjectReference);
@ -225,14 +238,14 @@ public class TaskServiceImplTest {
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(expectedTask.getWorkbasketKey());
verify(workbasketServiceMock, times(1)).checkAuthorization(expectedTask.getWorkbasketKey(),
WorkbasketAuthorization.APPEND);
verify(classificationServiceMock, times(1)).getClassification(classification.getKey(),
verify(classificationServiceImplMock, times(1)).getClassification(classification.getKey(),
wb.getDomain());
verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock,
classificationServiceMock);
classificationServiceImplMock);
assertNull(actualTask.getOwner());
assertNotNull(actualTask.getCreated());
assertNotNull(actualTask.getModified());
@ -261,12 +274,12 @@ public class TaskServiceImplTest {
TaskImpl task = new TaskImpl();
task.setWorkbasketKey(wb.getKey());
task.setClassificationKey("classificationKey");
task.setClassification(classification);
task.setClassificationSummary(classification.asSummary());
task.setPrimaryObjRef(expectedObjectReference);
task.setDescription("simply awesome task");
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
doReturn(wb).when(workbasketServiceMock).getWorkbasketByKey(wb.getKey());
doReturn(classification).when(classificationServiceMock).getClassification(classification.getKey(),
doReturn(classification).when(classificationServiceImplMock).getClassification(classification.getKey(),
classification.getDomain());
doReturn(expectedObjectReference).when(objectReferenceMapperMock)
.findByObjectReference(expectedObjectReference);
@ -287,14 +300,14 @@ public class TaskServiceImplTest {
verify(taskanaEngineImpl, times(2)).openConnection();
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
verify(workbasketServiceMock, times(2)).getWorkbasketByKey(any());
verify(classificationServiceMock, times(2)).getClassification(any(), any());
verify(classificationServiceImplMock, times(2)).getClassification(any(), any());
verify(taskMapperMock, times(1)).insert(task);
verify(taskMapperMock, times(1)).insert(task2);
verify(taskanaEngineImpl, times(2)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock,
classificationServiceMock);
classificationServiceImplMock);
assertNull(task.getOwner());
assertNotNull(task.getCreated());
@ -315,7 +328,8 @@ public class TaskServiceImplTest {
ClassificationNotFoundException, NotAuthorizedException, TaskAlreadyExistException, TaskNotFoundException,
InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("12", "Task Name", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("12", "Task Name", "1", dummyClassification);
doReturn(task).when(cutSpy).getTask(task.getId());
try {
@ -326,7 +340,7 @@ public class TaskServiceImplTest {
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock,
classificationServiceMock);
classificationServiceImplMock);
throw ex;
}
}
@ -336,7 +350,8 @@ public class TaskServiceImplTest {
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("", "dummyTask", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("", "dummyTask", "1", dummyClassification);
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketKey(),
WorkbasketAuthorization.APPEND);
@ -351,7 +366,7 @@ public class TaskServiceImplTest {
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock,
classificationServiceMock);
classificationServiceImplMock);
throw e;
}
}
@ -361,7 +376,8 @@ public class TaskServiceImplTest {
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidWorkbasketException, TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("", "dumma-task", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("", "dumma-task", "1", dummyClassification);
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasketByKey(any());
try {
@ -373,24 +389,28 @@ public class TaskServiceImplTest {
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock,
classificationServiceMock);
classificationServiceImplMock);
throw e;
}
}
@Test
public void testClaimSuccessfulToOwner() throws Exception {
TaskImpl expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(expectedTask.getId());
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
Thread.sleep(SLEEP_TIME); // to have different timestamps
String expectedOwner = "John Does";
PowerMockito.mockStatic(CurrentUserContext.class);
Mockito.when(CurrentUserContext.getUserid()).thenReturn(expectedOwner);
doReturn(classificationQueryImplMock).when(classificationServiceMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationServiceImplMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).domain(any());
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).key(any());
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
doReturn(dummyClassification).when(
classificationServiceImplMock)
.getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
// Mockito.doReturn(expectedOwner).when(currentUserContext).getUserid();
Task acturalTask = cut.claim(expectedTask.getId(), true);
@ -398,10 +418,10 @@ public class TaskServiceImplTest {
verify(taskanaEngineImpl, times(2)).openConnection();
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
verify(classificationServiceMock, times(1)).createClassificationQuery();
verify(classificationQueryImplMock, times(1)).domain(any());
verify(classificationQueryImplMock, times(1)).key(any());
verify(classificationQueryImplMock, times(1)).list();
verify(classificationServiceImplMock, times(1)).getClassification(any(), any());
verify(classificationQueryImplMock, times(0)).domain(any());
verify(classificationQueryImplMock, times(0)).key(any());
verify(classificationQueryImplMock, times(0)).list();
verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(2)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
@ -440,7 +460,8 @@ public class TaskServiceImplTest {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final long sleepTime = 100L;
final boolean isForced = false;
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
Thread.sleep(sleepTime);
task.setState(TaskState.CLAIMED);
task.setClaimed(new Timestamp(System.currentTimeMillis()));
@ -448,20 +469,23 @@ public class TaskServiceImplTest {
doReturn(task).when(taskMapperMock).findById(task.getId());
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(task.getId());
doReturn(task).when(cutSpy).completeTask(task.getId(), isForced);
doReturn(classificationQueryImplMock).when(classificationServiceMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationServiceImplMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).domain(any());
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).key(any());
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
doReturn(dummyClassification).when(
classificationServiceImplMock)
.getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
Task actualTask = cut.completeTask(task.getId());
verify(taskanaEngineImpl, times(2)).openConnection();
verify(taskMapperMock, times(1)).findById(task.getId());
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(task.getId());
verify(classificationServiceMock, times(1)).createClassificationQuery();
verify(classificationQueryImplMock, times(1)).domain(any());
verify(classificationQueryImplMock, times(1)).key(any());
verify(classificationQueryImplMock, times(1)).list();
verify(classificationServiceImplMock, times(0)).createClassificationQuery();
verify(classificationQueryImplMock, times(0)).domain(any());
verify(classificationQueryImplMock, times(0)).key(any());
verify(classificationQueryImplMock, times(0)).list();
verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(2)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
@ -480,7 +504,8 @@ public class TaskServiceImplTest {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final long sleepTime = 100L;
final boolean isForced = false;
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
// created and modify should be able to be different.
Thread.sleep(sleepTime);
task.setState(TaskState.CLAIMED);
@ -510,7 +535,8 @@ public class TaskServiceImplTest {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException {
final boolean isForced = false;
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
task.setState(TaskState.READY);
task.setClaimed(null);
doReturn(task).when(cutSpy).getTask(task.getId());
@ -533,7 +559,8 @@ public class TaskServiceImplTest {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException {
final boolean isForced = false;
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
task.setOwner("Dummy-Owner-ID: 10");
task.setState(TaskState.CLAIMED);
task.setClaimed(new Timestamp(System.currentTimeMillis()));
@ -579,7 +606,8 @@ public class TaskServiceImplTest {
final boolean isForced = true;
final long sleepTime = 100L;
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
// created and modify should be able to be different.
Thread.sleep(sleepTime);
task.setState(TaskState.CLAIMED);
@ -610,11 +638,12 @@ public class TaskServiceImplTest {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final boolean isForced = true;
final long sleepTime = 100L;
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
task.setState(TaskState.READY);
task.setClaimed(null);
doReturn(task).when(cutSpy).getTask(task.getId());
TaskImpl claimedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
TaskImpl claimedTask = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
// created and modify should be able to be different.
Thread.sleep(sleepTime);
claimedTask.setState(TaskState.CLAIMED);
@ -644,7 +673,8 @@ public class TaskServiceImplTest {
ClassificationAlreadyExistException, InvalidWorkbasketException, ClassificationNotFoundException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Workbasket destinationWorkbasket = createWorkbasket("2", "k1");
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "k1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "k1", dummyClassification);
task.setRead(true);
doReturn(destinationWorkbasket).when(workbasketServiceMock).getWorkbasketByKey(destinationWorkbasket.getKey());
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
@ -663,9 +693,7 @@ public class TaskServiceImplTest {
WorkbasketAuthorization.APPEND);
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketKey(),
WorkbasketAuthorization.TRANSFER);
verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(workbasketServiceMock, times(2)).getWorkbasketByKey(destinationWorkbasket.getKey());
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(destinationWorkbasket.getKey());
verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
@ -683,7 +711,8 @@ public class TaskServiceImplTest {
ClassificationAlreadyExistException, InvalidWorkbasketException, ClassificationNotFoundException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Workbasket destinationWorkbasket = createWorkbasket("2", "k2");
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "k1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "k1", dummyClassification);
task.setRead(true);
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
@ -694,7 +723,6 @@ public class TaskServiceImplTest {
WorkbasketAuthorization.APPEND);
doNothing().when(workbasketServiceMock).checkAuthorization(task.getWorkbasketKey(),
WorkbasketAuthorization.TRANSFER);
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getKey());
verify(taskanaEngineImpl, times(1)).openConnection();
@ -703,8 +731,8 @@ public class TaskServiceImplTest {
verify(workbasketServiceMock, times(1)).checkAuthorization("k1",
WorkbasketAuthorization.TRANSFER);
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(destinationWorkbasket.getKey());
verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskanaEngineMock, times(0)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(0)).isSecurityEnabled();
verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
@ -721,7 +749,8 @@ public class TaskServiceImplTest {
throws Exception {
String destinationWorkbasketKey = "2";
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock)
.checkAuthorization(destinationWorkbasketKey, WorkbasketAuthorization.APPEND);
@ -745,7 +774,8 @@ public class TaskServiceImplTest {
public void testTransferTaskDoesNotExist()
throws Exception {
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
@ -765,7 +795,8 @@ public class TaskServiceImplTest {
public void testTransferNotAuthorizationOnWorkbasketAppend()
throws Exception {
String destinationWorkbasketKey = "2";
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doReturn(task).when(cutSpy).getTask(task.getId());
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketKey,
@ -789,7 +820,8 @@ public class TaskServiceImplTest {
public void testTransferNotAuthorizationOnWorkbasketTransfer()
throws Exception {
String destinationWorkbasketKey = "2";
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doReturn(task).when(cutSpy).getTask(task.getId());
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasketKey,
@ -817,7 +849,8 @@ public class TaskServiceImplTest {
public void testSetTaskReadWIthExistingTask()
throws TaskNotFoundException, ClassificationAlreadyExistException, ClassificationNotFoundException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
task.setModified(null);
doReturn(task).when(cutSpy).getTask(task.getId());
doNothing().when(taskMapperMock).update(task);
@ -837,7 +870,8 @@ public class TaskServiceImplTest {
@Test(expected = TaskNotFoundException.class)
public void testSetTaskReadTaskNotBeFound() throws Exception {
TaskServiceImpl cutSpy = Mockito.spy(cut);
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
task.setModified(null);
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
@ -857,23 +891,28 @@ public class TaskServiceImplTest {
@Test
public void testGetTaskByIdWithExistingTask()
throws TaskNotFoundException, ClassificationAlreadyExistException, ClassificationNotFoundException {
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1");
Classification dummyClassification = createDummyClassification();
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1", dummyClassification);
doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(expectedTask.getId());
doReturn(classificationQueryImplMock).when(classificationServiceMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationServiceImplMock).createClassificationQuery();
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).domain(any());
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).key(any());
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
doReturn(dummyClassification).when(
classificationServiceImplMock)
.getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
Task actualTask = cut.getTask(expectedTask.getId());
verify(taskanaEngineImpl, times(1)).openConnection();
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
verify(classificationServiceMock, times(1)).createClassificationQuery();
verify(classificationQueryImplMock, times(1)).domain(any());
verify(classificationQueryImplMock, times(1)).key(any());
verify(classificationQueryImplMock, times(1)).list();
verify(classificationServiceImplMock, times(0)).createClassificationQuery();
verify(classificationQueryImplMock, times(0)).domain(any());
verify(classificationQueryImplMock, times(0)).key(any());
verify(classificationQueryImplMock, times(0)).list();
verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
@ -883,7 +922,8 @@ public class TaskServiceImplTest {
@Test(expected = TaskNotFoundException.class)
public void testGetTaskByIdWhereTaskDoesNotExist() throws Exception {
Task task = createUnitTestTask("1", "DUMMY-TASK", "1");
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "DUMMY-TASK", "1", dummyClassification);
doThrow(TaskNotFoundException.class).when(taskMapperMock).findById(task.getId());
try {
@ -904,7 +944,7 @@ public class TaskServiceImplTest {
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
// given - set behaviour and expected result
String workbasketKey = "1";
List<TaskSummary> expectedResultList = new ArrayList<>();
List<TaskSummaryImpl> expectedResultList = new ArrayList<>();
doNothing().when(taskanaEngineImpl).openConnection();
doThrow(new IllegalArgumentException("Invalid ID: " + workbasketKey)).when(taskMapperMock)
.findTaskSummariesByWorkbasketKey(workbasketKey);
@ -925,11 +965,12 @@ public class TaskServiceImplTest {
assertThat(actualResultList, equalTo(expectedResultList));
}
@Ignore
@Test
public void testGetTaskSummariesByWorkbasketIdGettingResults()
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
String workbasketKey = "1";
List<TaskSummary> expectedResultList = Arrays.asList(new TaskSummary(), new TaskSummary());
List<TaskSummaryImpl> expectedResultList = Arrays.asList(new TaskSummaryImpl(), new TaskSummaryImpl());
doNothing().when(taskanaEngineImpl).openConnection();
doNothing().when(taskanaEngineImpl).returnConnection();
doReturn(new WorkbasketImpl()).when(workbasketServiceMock).getWorkbasketByKey(any());
@ -937,7 +978,6 @@ public class TaskServiceImplTest {
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketKey(workbasketKey);
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
verify(taskanaEngineImpl, times(1)).openConnection();
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
verify(taskanaEngineImpl, times(1)).returnConnection();
@ -952,7 +992,7 @@ public class TaskServiceImplTest {
public void testGetTaskSummariesByWorkbasketIdGettingNull()
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
String workbasketKey = "1";
List<TaskSummary> expectedResultList = new ArrayList<>();
List<TaskSummaryImpl> expectedResultList = new ArrayList<>();
doNothing().when(taskanaEngineImpl).openConnection();
doNothing().when(taskanaEngineImpl).returnConnection();
doReturn(null).when(taskMapperMock).findTaskSummariesByWorkbasketKey(workbasketKey);
@ -970,7 +1010,7 @@ public class TaskServiceImplTest {
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
}
private TaskImpl createUnitTestTask(String id, String name, String workbasketKey) {
private TaskImpl createUnitTestTask(String id, String name, String workbasketKey, Classification classification) {
TaskImpl task = new TaskImpl();
task.setId(id);
task.setName(name);
@ -980,13 +1020,18 @@ public class TaskServiceImplTest {
Timestamp now = new Timestamp(System.currentTimeMillis());
task.setCreated(now);
task.setModified(now);
task.setClassificationSummary(classification.asSummary());
task.setClassificationKey(classification.getKey());
task.setDomain(classification.getDomain());
return task;
}
private Classification createDummyClassification() {
ClassificationImpl classification = new ClassificationImpl();
classification.setName("dummy-classification");
classification.setDomain("dummy-domain");
classification.setKey("dummy-classification-key");
task.setClassification(classification);
task.setClassificationKey(classification.getKey());
return task;
return classification;
}
private WorkbasketImpl createWorkbasket(String id, String key) {

View File

@ -26,12 +26,12 @@ import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
import pro.taskana.model.mappings.DistributionTargetMapper;
import pro.taskana.model.mappings.WorkbasketAccessMapper;

View File

@ -25,6 +25,7 @@ import org.junit.runner.RunWith;
import pro.taskana.Classification;
import pro.taskana.ClassificationService;
import pro.taskana.Task;
import pro.taskana.TaskSummary;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
@ -43,6 +44,7 @@ import pro.taskana.impl.ClassificationImpl;
import pro.taskana.impl.JunitHelper;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskServiceImpl;
import pro.taskana.impl.TaskSummaryImpl;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.configuration.DBCleaner;
@ -50,7 +52,6 @@ import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.impl.util.IdGenerator;
import pro.taskana.model.ObjectReference;
import pro.taskana.model.TaskState;
import pro.taskana.model.TaskSummary;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketType;
import pro.taskana.security.CurrentUserContext;
@ -208,14 +209,14 @@ public class TaskServiceImplIntAutocommitTest {
TaskanaEngineImpl taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
List<Task> results = taskServiceImpl.createTaskQuery()
.name("bla", "test")
List<TaskSummary> results = taskServiceImpl.createTaskQuery()
.nameIn("bla", "test")
.descriptionLike("test")
.priority(1, 2, 2)
.state(TaskState.CLAIMED)
.priorityIn(1, 2, 2)
.stateIn(TaskState.CLAIMED)
.workbasketKeyIn("asd", "asdasdasd")
.owner("test", "test2", "bla")
.customFields("test")
.ownerIn("test", "test2", "bla")
.customFieldsIn("test")
.classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys")
@ -248,14 +249,10 @@ public class TaskServiceImplIntAutocommitTest {
dummyTask.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
dummyTask = (TaskImpl) taskServiceImpl.createTask(dummyTask);
List<TaskSummary> expectedTaskSumamries = new ArrayList<>();
TaskSummary taskSummary = new TaskSummary();
List<TaskSummaryImpl> expectedTaskSumamries = new ArrayList<>();
TaskSummaryImpl taskSummary = new TaskSummaryImpl();
taskSummary.setTaskId(dummyTask.getId());
taskSummary.setTaskName(dummyTask.getName());
taskSummary.setWorkbasketKey(dummyWorkbasket.getKey());
taskSummary.setWorkbasketName(dummyWorkbasket.getName());
taskSummary.setClassificationKey(dummyClassification.getKey());
taskSummary.setClassificationName(dummyClassification.getName());
taskSummary.setName(dummyTask.getName());
expectedTaskSumamries.add(taskSummary);
List<TaskSummary> actualTaskSumamryResult = taskServiceImpl

View File

@ -28,6 +28,7 @@ import org.junit.runner.RunWith;
import pro.taskana.Classification;
import pro.taskana.ClassificationService;
import pro.taskana.Task;
import pro.taskana.TaskSummary;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
@ -272,7 +273,8 @@ public class TaskServiceImplIntExplicitTest {
Assert.assertEquals(resultTask2.getPlanned(), resultTask2.getCreated());
Assert.assertTrue(resultTask2.getName().equals(classification.getName()));
Assert.assertEquals(resultTask.getClassification().getId(), resultTask2.getClassification().getId());
Assert.assertEquals(resultTask.getClassificationSummary().getId(),
resultTask2.getClassificationSummary().getId());
Assert.assertTrue(resultTask.getDue().after(resultTask2.getDue()));
Assert.assertFalse(resultTask.getName().equals(resultTask2.getName()));
}
@ -352,14 +354,14 @@ public class TaskServiceImplIntExplicitTest {
TaskanaEngineImpl taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
List<Task> results = taskServiceImpl.createTaskQuery()
.name("bla", "test")
List<TaskSummary> results = taskServiceImpl.createTaskQuery()
.nameIn("bla", "test")
.descriptionLike("test")
.priority(1, 2, 2)
.state(TaskState.CLAIMED)
.priorityIn(1, 2, 2)
.stateIn(TaskState.CLAIMED)
.workbasketKeyIn("k1")
.owner("test", "test2", "bla")
.customFields("test")
.ownerIn("test", "test2", "bla")
.customFieldsIn("test")
.classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys")
@ -606,4 +608,5 @@ public class TaskServiceImplIntExplicitTest {
public static void cleanUpClass() {
FileUtils.deleteRecursive("~/data", true);
}
}

View File

@ -26,6 +26,7 @@ import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketQuery;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
@ -39,7 +40,6 @@ import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.impl.util.IdGenerator;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
import pro.taskana.model.mappings.WorkbasketMapper;
import pro.taskana.security.CurrentUserContext;

View File

@ -22,6 +22,7 @@ import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
@ -32,7 +33,6 @@ import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.impl.util.IdGenerator;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.model.WorkbasketType;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;

View File

@ -23,7 +23,7 @@ export class RestConnectorService {
private createAuthorizationHeader() {
let headers: Headers = new Headers();
headers.append("Authorization", "Basic TWF4OnRlc3Q=");
headers.append("Authorization", "Basic dXNlcl8xXzE6dXNlcl8xXzE=");
return new RequestOptions({ headers: headers });
}

View File

@ -15,10 +15,10 @@ import org.springframework.web.bind.annotation.RestController;
import pro.taskana.TaskMonitorService;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.model.DueWorkbasketCounter;
import pro.taskana.model.TaskState;
import pro.taskana.model.TaskStateCounter;
import pro.taskana.model.WorkbasketSummary;
import pro.taskana.rest.model.WorkbasketCounterDataDto;
import pro.taskana.rest.model.WorkbasketCounterDto;

View File

@ -21,19 +21,19 @@ import org.springframework.web.bind.annotation.RestController;
import pro.taskana.Task;
import pro.taskana.TaskService;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.model.TaskState;
import pro.taskana.model.TaskSummary;
import pro.taskana.rest.query.TaskFilter;
@RestController
@RequestMapping(path = "/v1/tasks", produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(path = "/v1/tasks", produces = {MediaType.APPLICATION_JSON_VALUE})
public class TaskController {
private static final Logger logger = LoggerFactory.getLogger(TaskController.class);
@ -45,7 +45,7 @@ public class TaskController {
private TaskFilter taskLogic;
@RequestMapping
public ResponseEntity<List<Task>> getTasks(@RequestParam MultiValueMap<String, String> params)
public ResponseEntity<List<TaskSummary>> getTasks(@RequestParam MultiValueMap<String, String> params)
throws LoginException, InvalidArgumentException {
try {
if (params.keySet().size() == 0) {
@ -72,11 +72,11 @@ public class TaskController {
}
@RequestMapping(value = "/workbasket/{workbasketKey}/state/{taskState}")
public ResponseEntity<List<Task>> getTasksByWorkbasketIdAndState(
public ResponseEntity<List<TaskSummary>> getTasksByWorkbasketIdAndState(
@PathVariable(value = "workbasketKey") String workbasketKey,
@PathVariable(value = "taskState") TaskState taskState) {
try {
List<Task> taskList = taskService.getTasksByWorkbasketKeyAndState(workbasketKey, taskState);
List<TaskSummary> taskList = taskService.getTasksByWorkbasketKeyAndState(workbasketKey, taskState);
return ResponseEntity.status(HttpStatus.OK).body(taskList);
} catch (WorkbasketNotFoundException e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();

View File

@ -19,12 +19,12 @@ import org.springframework.web.bind.annotation.RestController;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketAuthorization;
import pro.taskana.model.WorkbasketSummary;
@RestController
@RequestMapping(path = "/v1/workbaskets", produces = { MediaType.APPLICATION_JSON_VALUE })

View File

@ -9,9 +9,9 @@ import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import pro.taskana.ClassificationService;
import pro.taskana.Task;
import pro.taskana.TaskQuery;
import pro.taskana.TaskService;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.model.TaskState;
@ -52,18 +52,18 @@ public class TaskFilter {
@Autowired
private ClassificationService classificationService;
public List<Task> getAll() throws NotAuthorizedException, InvalidArgumentException {
public List<TaskSummary> getAll() throws NotAuthorizedException {
return taskService.createTaskQuery().list();
}
public List<Task> inspectPrams(MultiValueMap<String, String> params)
public List<TaskSummary> inspectPrams(MultiValueMap<String, String> params)
throws NotAuthorizedException, InvalidArgumentException {
TaskQuery taskQuery = taskService.createTaskQuery();
// apply filters
if (params.containsKey(NAME)) {
String[] names = extractCommaSeperatedFields(params.get(NAME));
taskQuery.name(names);
taskQuery.nameIn(names);
}
if (params.containsKey(DESCRIPTION)) {
taskQuery.descriptionLike(params.get(DESCRIPTION).get(0));
@ -71,11 +71,11 @@ public class TaskFilter {
if (params.containsKey(PRIORITY)) {
String[] prioritesInString = extractCommaSeperatedFields(params.get(PRIORITY));
int[] priorites = extractPriorities(prioritesInString);
taskQuery.priority(priorites);
taskQuery.priorityIn(priorites);
}
if (params.containsKey(STATE)) {
TaskState[] states = extractStates(params);
taskQuery.state(states);
taskQuery.stateIn(states);
}
if (params.containsKey(CLASSIFICATION_KEY)) {
String[] classificationKeys = extractCommaSeperatedFields(params.get(CLASSIFICATION_KEY));
@ -87,7 +87,7 @@ public class TaskFilter {
}
if (params.containsKey(OWNER)) {
String[] owners = extractCommaSeperatedFields(params.get(OWNER));
taskQuery.owner(owners);
taskQuery.ownerIn(owners);
}
// objectReference
if (params.keySet().stream().filter(s -> s.startsWith(POR)).toArray().length > 0) {
@ -113,14 +113,14 @@ public class TaskFilter {
}
}
if (params.containsKey(IS_READ)) {
taskQuery.read(Boolean.getBoolean(params.get(IS_READ).get(0)));
taskQuery.readEquals(Boolean.getBoolean(params.get(IS_READ).get(0)));
}
if (params.containsKey(IS_TRANSFERRED)) {
taskQuery.transferred(Boolean.getBoolean(params.get(IS_TRANSFERRED).get(0)));
taskQuery.transferredEquals(Boolean.getBoolean(params.get(IS_TRANSFERRED).get(0)));
}
if (params.containsKey(CUSTOM)) {
String[] custom = extractCommaSeperatedFields(params.get(CUSTOM));
taskQuery.customFields(custom);
taskQuery.customFieldsIn(custom);
}
return taskQuery.list();
}

View File

@ -45,7 +45,7 @@ export class RestConnectorService {
private createAuthorizationHeader() {
const headers: Headers = new Headers();
headers.append('Authorization', 'Basic TWF4OnRlc3Q=');
headers.append('Authorization', 'Basic dXNlcl8xXzE6dXNlcl8xXzE=');
return new RequestOptions({ headers: headers });
}