TSK-1009: automatic formatting number 2

This commit is contained in:
Mustapha Zorgati 2020-01-07 20:54:03 +01:00
parent 78cfd64902
commit c1d74b2126
61 changed files with 1670 additions and 1631 deletions

View File

@ -29,7 +29,6 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
protected SqlSessionManager sessionManager; protected SqlSessionManager sessionManager;
protected TransactionFactory transactionFactory; protected TransactionFactory transactionFactory;
protected TaskanaHistory taskanaHistoryService; protected TaskanaHistory taskanaHistoryService;
TaskanaEngineConfiguration taskanaEngineConfiguration; TaskanaEngineConfiguration taskanaEngineConfiguration;
protected TaskanaHistoryEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) protected TaskanaHistoryEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration)
@ -58,51 +57,6 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
return this.taskanaHistoryService; return this.taskanaHistoryService;
} }
/**
* Open the connection to the database. to be called at the begin of each Api call that accesses
* the database
*
* @throws SQLException thrown if the connection could not be opened.
*/
void openConnection() throws SQLException {
initSqlSession();
this.sessionManager.getConnection().setSchema(taskanaEngineConfiguration.getSchemaName());
}
/**
* Returns the database connection into the pool. In the case of nested calls, simply pops the
* latest session from the session stack. Closes the connection if the session stack is empty. In
* mode AUTOCOMMIT commits before the connection is closed. To be called at the end of each Api
* call that accesses the database
*/
void returnConnection() {
popSessionFromStack();
if (getSessionStack().isEmpty()
&& this.sessionManager != null
&& this.sessionManager.isManagedSessionStarted()) {
try {
this.sessionManager.commit();
} catch (Exception e) {
//ignore
}
this.sessionManager.close();
}
}
/** Initializes the SqlSessionManager. */
void initSqlSession() {
this.sessionManager.startManagedSession();
}
/**
* retrieve the SqlSession used by taskana.
*
* @return the myBatis SqlSession object used by taskana
*/
SqlSession getSqlSession() {
return this.sessionManager;
}
protected SqlSessionManager createSqlSessionManager() { protected SqlSessionManager createSqlSessionManager() {
Environment environment = Environment environment =
new Environment( new Environment(
@ -158,6 +112,51 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
return stack.peek(); return stack.peek();
} }
/**
* Open the connection to the database. to be called at the begin of each Api call that accesses
* the database
*
* @throws SQLException thrown if the connection could not be opened.
*/
void openConnection() throws SQLException {
initSqlSession();
this.sessionManager.getConnection().setSchema(taskanaEngineConfiguration.getSchemaName());
}
/**
* Returns the database connection into the pool. In the case of nested calls, simply pops the
* latest session from the session stack. Closes the connection if the session stack is empty. In
* mode AUTOCOMMIT commits before the connection is closed. To be called at the end of each Api
* call that accesses the database
*/
void returnConnection() {
popSessionFromStack();
if (getSessionStack().isEmpty()
&& this.sessionManager != null
&& this.sessionManager.isManagedSessionStarted()) {
try {
this.sessionManager.commit();
} catch (Exception e) {
// ignore
}
this.sessionManager.close();
}
}
/** Initializes the SqlSessionManager. */
void initSqlSession() {
this.sessionManager.startManagedSession();
}
/**
* retrieve the SqlSession used by taskana.
*
* @return the myBatis SqlSession object used by taskana
*/
SqlSession getSqlSession() {
return this.sessionManager;
}
/** /**
* creates the MyBatis transaction factory. * creates the MyBatis transaction factory.
* *

View File

@ -3,8 +3,8 @@ package pro.taskana.simplehistory.query;
import pro.taskana.QueryColumnName; import pro.taskana.QueryColumnName;
/** /**
* Enum containing the column names for * Enum containing the column names for {@link
* {@link pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper#queryHistoryColumnValues}. * pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper#queryHistoryColumnValues}.
* *
* @author bv * @author bv
*/ */

View File

@ -21,13 +21,18 @@ import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
/** Set up database for tests. */ /** Set up database for tests. */
public class AbstractAccTest { public class AbstractAccTest {
public static SimpleHistoryServiceImpl historyService;
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
private static DataSource dataSource = null;
private static String schemaName = null;
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class); private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class);
private static final int POOL_TIME_TO_WAIT = 50; private static final int POOL_TIME_TO_WAIT = 50;
@SuppressWarnings("checkstyle:DeclarationOrder")
public static SimpleHistoryServiceImpl historyService;
@SuppressWarnings("checkstyle:DeclarationOrder")
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
private static DataSource dataSource = null;
private static String schemaName = null;
protected AbstractAccTest() { protected AbstractAccTest() {
// not called // not called
} }

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation=" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

View File

@ -3,8 +3,6 @@ package pro.taskana;
import javax.ws.rs.ApplicationPath; import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application; import javax.ws.rs.core.Application;
/** /** TODO Why does this test exist?. */
* TODO Why does this test exist?.
*/
@ApplicationPath("/rest") @ApplicationPath("/rest")
public class RestApplication extends Application {} public class RestApplication extends Application {}

View File

@ -1,8 +1,8 @@
package pro.taskana; package pro.taskana;
/** /**
* Enum containing the column names for * Enum containing the column names for {@link
* {@link pro.taskana.mappings.QueryMapper#queryWorkbasketAccessItemColumnValues}. * pro.taskana.mappings.QueryMapper#queryWorkbasketAccessItemColumnValues}.
* *
* @author jsa * @author jsa
*/ */

View File

@ -1,8 +1,8 @@
package pro.taskana; package pro.taskana;
/** /**
* Enum containing the column names for * Enum containing the column names for {@link
* {@link pro.taskana.mappings.QueryMapper#queryClassificationColumnValues}. * pro.taskana.mappings.QueryMapper#queryClassificationColumnValues}.
* *
* @author jsa * @author jsa
*/ */

View File

@ -33,6 +33,11 @@ public class KeyDomain {
this.domain = domain; this.domain = domain;
} }
@Override
public int hashCode() {
return Objects.hash(key, domain);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -45,11 +50,6 @@ public class KeyDomain {
return Objects.equals(key, other.key) && Objects.equals(domain, other.domain); return Objects.equals(key, other.key) && Objects.equals(domain, other.domain);
} }
@Override
public int hashCode() {
return Objects.hash(key, domain);
}
@Override @Override
public String toString() { public String toString() {
return "KeyDomain [key=" + key + ", domain=" + domain + "]"; return "KeyDomain [key=" + key + ", domain=" + domain + "]";

View File

@ -60,6 +60,11 @@ public class ObjectReference {
this.value = value; this.value = value;
} }
@Override
public int hashCode() {
return Objects.hash(id, company, system, systemInstance, type, value);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -77,11 +82,6 @@ public class ObjectReference {
&& Objects.equals(value, other.value); && Objects.equals(value, other.value);
} }
@Override
public int hashCode() {
return Objects.hash(id, company, system, systemInstance, type, value);
}
@Override @Override
public String toString() { public String toString() {
return "ObjectReference [" return "ObjectReference ["

View File

@ -1,8 +1,8 @@
package pro.taskana; package pro.taskana;
/** /**
* Enum containing the column names for * Enum containing the column names for {@link
* {@link pro.taskana.mappings.QueryMapper#queryTaskColumnValues(pro.taskana.impl.TaskQueryImpl)}. * pro.taskana.mappings.QueryMapper#queryTaskColumnValues(pro.taskana.impl.TaskQueryImpl)}.
* *
* @author jsa * @author jsa
*/ */

View File

@ -52,6 +52,11 @@ public class TimeInterval {
this.end = end; this.end = end;
} }
@Override
public int hashCode() {
return Objects.hash(begin, end);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -64,11 +69,6 @@ public class TimeInterval {
return Objects.equals(begin, other.begin) && Objects.equals(end, other.end); return Objects.equals(begin, other.begin) && Objects.equals(end, other.end);
} }
@Override
public int hashCode() {
return Objects.hash(begin, end);
}
@Override @Override
public String toString() { public String toString() {
return "TimeInterval [" + "begin=" + this.begin + ", end=" + this.end + "]"; return "TimeInterval [" + "begin=" + this.begin + ", end=" + this.end + "]";

View File

@ -57,14 +57,6 @@ public class TaskEvent extends TaskanaHistoryEvent {
} }
} }
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getBusinessProcessId() { public String getBusinessProcessId() {
return businessProcessId; return businessProcessId;
} }
@ -81,6 +73,14 @@ public class TaskEvent extends TaskanaHistoryEvent {
this.parentBusinessProcessId = parentBusinessProcessId; this.parentBusinessProcessId = parentBusinessProcessId;
} }
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getDomain() { public String getDomain() {
return domain; return domain;
} }
@ -97,30 +97,6 @@ public class TaskEvent extends TaskanaHistoryEvent {
this.workbasketKey = workbasketKey; this.workbasketKey = workbasketKey;
} }
public String getTaskClassificationCategory() {
return taskClassificationCategory;
}
public void setTaskClassificationCategory(String taskClassificationCategory) {
this.taskClassificationCategory = taskClassificationCategory;
}
public String getTaskClassificationKey() {
return taskClassificationKey;
}
public void setTaskClassificationKey(String taskClassificationKey) {
this.taskClassificationKey = taskClassificationKey;
}
public String getAttachmentClassificationKey() {
return attachmentClassificationKey;
}
public void setAttachmentClassificationKey(String attachmentClassificationKey) {
this.attachmentClassificationKey = attachmentClassificationKey;
}
public String getPorCompany() { public String getPorCompany() {
return porCompany; return porCompany;
} }
@ -161,6 +137,30 @@ public class TaskEvent extends TaskanaHistoryEvent {
this.porValue = porValue; this.porValue = porValue;
} }
public String getTaskClassificationKey() {
return taskClassificationKey;
}
public void setTaskClassificationKey(String taskClassificationKey) {
this.taskClassificationKey = taskClassificationKey;
}
public String getTaskClassificationCategory() {
return taskClassificationCategory;
}
public void setTaskClassificationCategory(String taskClassificationCategory) {
this.taskClassificationCategory = taskClassificationCategory;
}
public String getAttachmentClassificationKey() {
return attachmentClassificationKey;
}
public void setAttachmentClassificationKey(String attachmentClassificationKey) {
this.attachmentClassificationKey = attachmentClassificationKey;
}
@Override @Override
public String toString() { public String toString() {
return "TaskEvent [taskId= " return "TaskEvent [taskId= "

View File

@ -63,11 +63,6 @@ abstract class AbstractWorkbasketAccessItemQueryImpl<
return _this(); return _this();
} }
@Override
public Q orderById(SortDirection sortDirection) {
return addOrderCriteria("ID", sortDirection);
}
@Override @Override
public Q orderByWorkbasketId(SortDirection sortDirection) { public Q orderByWorkbasketId(SortDirection sortDirection) {
return addOrderCriteria("WORKBASKET_ID", sortDirection); return addOrderCriteria("WORKBASKET_ID", sortDirection);
@ -78,6 +73,11 @@ abstract class AbstractWorkbasketAccessItemQueryImpl<
return addOrderCriteria("ACCESS_ID", sortDirection); return addOrderCriteria("ACCESS_ID", sortDirection);
} }
@Override
public Q orderById(SortDirection sortDirection) {
return addOrderCriteria("ID", sortDirection);
}
@Override @Override
public List<T> list() { public List<T> list() {
LOGGER.debug("entry to list(), this = {}", _this()); LOGGER.debug("entry to list(), this = {}", _this());

View File

@ -75,16 +75,6 @@ public class AttachmentImpl implements Attachment {
this.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 @Override
public ObjectReference getObjectReference() { public ObjectReference getObjectReference() {
return objectReference; return objectReference;
@ -142,6 +132,16 @@ public class AttachmentImpl implements Attachment {
return summary; return summary;
} }
// 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(

View File

@ -73,19 +73,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.modified = 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;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see pro.taskana.AttachmentSummary#getObjectReference() * @see pro.taskana.AttachmentSummary#getObjectReference()
@ -108,6 +95,32 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
return channel; return channel;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getClassification()
*/
@Override
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
}
public void setClassificationSummary(ClassificationSummary classificationSummary) {
this.classificationSummary = classificationSummary;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getReceived()
*/
@Override
public Instant getReceived() {
return received;
}
public void setReceived(Instant received) {
this.received = received;
}
public void setChannel(String channel) { public void setChannel(String channel) {
this.channel = channel; this.channel = channel;
} }
@ -122,6 +135,12 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.classificationSummary = classificationSummary; this.classificationSummary = classificationSummary;
} }
@Override
public int hashCode() {
return Objects.hash(
id, taskId, created, modified, classificationSummary, objectReference, channel, received);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -141,25 +160,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
&& Objects.equals(received, other.received); && Objects.equals(received, other.received);
} }
@Override
public int hashCode() {
return Objects.hash(
id, taskId, created, modified, classificationSummary, objectReference, channel, received);
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getReceived()
*/
@Override
public Instant getReceived() {
return received;
}
public void setReceived(Instant received) {
this.received = received;
}
@Override @Override
public String toString() { public String toString() {
return "AttachmentSummaryImpl [id=" return "AttachmentSummaryImpl [id="

View File

@ -115,10 +115,6 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
return summary; return summary;
} }
protected boolean canEqual(Object other) {
return (other instanceof ClassificationImpl);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -144,6 +140,10 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
super.hashCode(), isValidInDomain, created, modified, description, applicationEntryPoint); super.hashCode(), isValidInDomain, created, modified, description, applicationEntryPoint);
} }
protected boolean canEqual(Object other) {
return (other instanceof ClassificationImpl);
}
@Override @Override
public String toString() { public String toString() {
return "ClassificationImpl [id=" return "ClassificationImpl [id="

View File

@ -324,11 +324,6 @@ public class ClassificationQueryImpl implements ClassificationQuery {
return addOrderCriteria("DOMAIN", sortDirection); return addOrderCriteria("DOMAIN", sortDirection);
} }
@Override
public ClassificationQuery orderByPriority(SortDirection sortDirection) {
return addOrderCriteria("PRIORITY", sortDirection);
}
@Override @Override
public ClassificationQuery orderByName(SortDirection sortDirection) { public ClassificationQuery orderByName(SortDirection sortDirection) {
return addOrderCriteria("NAME", sortDirection); return addOrderCriteria("NAME", sortDirection);
@ -339,6 +334,11 @@ public class ClassificationQueryImpl implements ClassificationQuery {
return addOrderCriteria("SERVICE_LEVEL", sortDirection); return addOrderCriteria("SERVICE_LEVEL", sortDirection);
} }
@Override
public ClassificationQuery orderByPriority(SortDirection sortDirection) {
return addOrderCriteria("PRIORITY", sortDirection);
}
@Override @Override
public ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection) { public ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection) {
return addOrderCriteria("APPLICATION_ENTRY_POINT", sortDirection); return addOrderCriteria("APPLICATION_ENTRY_POINT", sortDirection);

View File

@ -50,6 +50,128 @@ public class ClassificationServiceImpl implements ClassificationService {
this.taskMapper = taskMapper; this.taskMapper = taskMapper;
} }
@Override
public Classification getClassification(String key, String domain)
throws ClassificationNotFoundException {
LOGGER.debug("entry to getClassification(key = {}, domain = {})", key, domain);
if (key == null) {
throw new ClassificationNotFoundException(
null, domain, "Classification for null key and domain " + domain + " was not found.");
}
Classification result = null;
try {
taskanaEngine.openConnection();
result = classificationMapper.findByKeyAndDomain(key, domain);
if (result == null) {
result = classificationMapper.findByKeyAndDomain(key, "");
if (result == null) {
throw new ClassificationNotFoundException(
key, domain, "Classification for key = " + key + " and master domain was not found");
}
}
return result;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
}
}
@Override
public Classification getClassification(String id) throws ClassificationNotFoundException {
if (id == null) {
throw new ClassificationNotFoundException(null, "Classification for null id is invalid.");
}
LOGGER.debug("entry to getClassification(id = {})", id);
Classification result = null;
try {
taskanaEngine.openConnection();
result = classificationMapper.findById(id);
if (result == null) {
throw new ClassificationNotFoundException(
id, "Classification for id " + id + " was not found");
}
return result;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
}
}
@Override
public void deleteClassification(String classificationId)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException {
LOGGER.debug("entry to deleteClassification(id = {})", classificationId);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try {
taskanaEngine.openConnection();
Classification classification = this.classificationMapper.findById(classificationId);
if (classification == null) {
throw new ClassificationNotFoundException(
classificationId, "The classification \"" + classificationId + "\" wasn't found");
}
if (classification.getDomain().equals("")) {
// master mode - delete all associated classifications in every domain.
List<ClassificationSummary> classificationsInDomain =
createClassificationQuery().keyIn(classification.getKey()).list();
for (ClassificationSummary classificationInDomain : classificationsInDomain) {
if (!"".equals(classificationInDomain.getDomain())) {
deleteClassification(classificationInDomain.getId());
}
}
}
List<ClassificationSummary> childClassifications =
createClassificationQuery().parentIdIn(classificationId).list();
for (ClassificationSummary child : childClassifications) {
this.deleteClassification(child.getId());
}
try {
this.classificationMapper.deleteClassification(classificationId);
} catch (PersistenceException e) {
if (isReferentialIntegrityConstraintViolation(e)) {
throw new ClassificationInUseException(
String.format(
"The classification id = \"%s\" and key = \"%s\" in domain = \"%s\" "
+ "is in use and cannot be deleted. There are either tasks or "
+ "attachments associated with the classification.",
classificationId, classification.getKey(), classification.getDomain()),
e.getCause());
}
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteClassification()");
}
}
@Override
public void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException {
LOGGER.debug("entry to deleteClassification(key = {}, domain = {})", classificationKey, domain);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try {
taskanaEngine.openConnection();
Classification classification =
this.classificationMapper.findByKeyAndDomain(classificationKey, domain);
if (classification == null) {
throw new ClassificationNotFoundException(
classificationKey,
domain,
"The classification \""
+ classificationKey
+ "\" wasn't found in the domain "
+ domain);
}
deleteClassification(classification.getId());
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteClassification(key,domain)");
}
}
@Override @Override
public Classification createClassification(Classification classification) public Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException, throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
@ -129,54 +251,6 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
} }
@Override
public Classification getClassification(String id) throws ClassificationNotFoundException {
if (id == null) {
throw new ClassificationNotFoundException(null, "Classification for null id is invalid.");
}
LOGGER.debug("entry to getClassification(id = {})", id);
Classification result = null;
try {
taskanaEngine.openConnection();
result = classificationMapper.findById(id);
if (result == null) {
throw new ClassificationNotFoundException(
id, "Classification for id " + id + " was not found");
}
return result;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
}
}
@Override
public Classification getClassification(String key, String domain)
throws ClassificationNotFoundException {
LOGGER.debug("entry to getClassification(key = {}, domain = {})", key, domain);
if (key == null) {
throw new ClassificationNotFoundException(
null, domain, "Classification for null key and domain " + domain + " was not found.");
}
Classification result = null;
try {
taskanaEngine.openConnection();
result = classificationMapper.findByKeyAndDomain(key, domain);
if (result == null) {
result = classificationMapper.findByKeyAndDomain(key, "");
if (result == null) {
throw new ClassificationNotFoundException(
key, domain, "Classification for key = " + key + " and master domain was not found");
}
}
return result;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
}
}
@Override @Override
public ClassificationQuery createClassificationQuery() { public ClassificationQuery createClassificationQuery() {
return new ClassificationQueryImpl(taskanaEngine); return new ClassificationQueryImpl(taskanaEngine);
@ -191,80 +265,6 @@ public class ClassificationServiceImpl implements ClassificationService {
return classification; return classification;
} }
@Override
public void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException {
LOGGER.debug("entry to deleteClassification(key = {}, domain = {})", classificationKey, domain);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try {
taskanaEngine.openConnection();
Classification classification =
this.classificationMapper.findByKeyAndDomain(classificationKey, domain);
if (classification == null) {
throw new ClassificationNotFoundException(
classificationKey,
domain,
"The classification \""
+ classificationKey
+ "\" wasn't found in the domain "
+ domain);
}
deleteClassification(classification.getId());
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteClassification(key,domain)");
}
}
@Override
public void deleteClassification(String classificationId)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException {
LOGGER.debug("entry to deleteClassification(id = {})", classificationId);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try {
taskanaEngine.openConnection();
Classification classification = this.classificationMapper.findById(classificationId);
if (classification == null) {
throw new ClassificationNotFoundException(
classificationId, "The classification \"" + classificationId + "\" wasn't found");
}
if (classification.getDomain().equals("")) {
// master mode - delete all associated classifications in every domain.
List<ClassificationSummary> classificationsInDomain =
createClassificationQuery().keyIn(classification.getKey()).list();
for (ClassificationSummary classificationInDomain : classificationsInDomain) {
if (!"".equals(classificationInDomain.getDomain())) {
deleteClassification(classificationInDomain.getId());
}
}
}
List<ClassificationSummary> childClassifications =
createClassificationQuery().parentIdIn(classificationId).list();
for (ClassificationSummary child : childClassifications) {
this.deleteClassification(child.getId());
}
try {
this.classificationMapper.deleteClassification(classificationId);
} catch (PersistenceException e) {
if (isReferentialIntegrityConstraintViolation(e)) {
throw new ClassificationInUseException(
String.format(
"The classification id = \"%s\" and key = \"%s\" in domain = \"%s\" "
+ "is in use and cannot be deleted. There are either tasks or "
+ "attachments associated with the classification.",
classificationId, classification.getKey(), classification.getDomain()),
e.getCause());
}
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteClassification()");
}
}
private static void validateServiceLevel(String serviceLevel) throws InvalidArgumentException { private static void validateServiceLevel(String serviceLevel) throws InvalidArgumentException {
try { try {
Duration.parse(serviceLevel); Duration.parse(serviceLevel);

View File

@ -28,24 +28,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
ClassificationSummaryImpl() {} ClassificationSummaryImpl() {}
@Override
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
@Override
public String getServiceLevel() {
return serviceLevel;
}
public void setServiceLevel(String serviceLevel) {
this.serviceLevel = serviceLevel;
}
@Override @Override
public String getId() { public String getId() {
return id; return id;
@ -114,8 +96,18 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
return parentKey; return parentKey;
} }
public void setParentKey(String parentKey) { @Override
this.parentKey = parentKey; public String getServiceLevel() {
return serviceLevel;
}
@Override
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
} }
@Override @Override
@ -190,6 +182,41 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom8 = custom8; this.custom8 = custom8;
} }
public void setServiceLevel(String serviceLevel) {
this.serviceLevel = serviceLevel;
}
public void setParentKey(String parentKey) {
this.parentKey = parentKey;
}
protected boolean canEqual(Object other) {
return (other instanceof ClassificationSummaryImpl);
}
@Override
public int hashCode() {
return Objects.hash(
id,
key,
category,
type,
domain,
name,
parentId,
parentKey,
priority,
serviceLevel,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@ -224,33 +251,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
&& Objects.equals(custom8, other.custom8); && Objects.equals(custom8, other.custom8);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
category,
type,
domain,
name,
parentId,
parentKey,
priority,
serviceLevel,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8);
}
protected boolean canEqual(Object other) {
return (other instanceof ClassificationSummaryImpl);
}
@Override @Override
public String toString() { public String toString() {
return "ClassificationSummaryImpl [id=" return "ClassificationSummaryImpl [id="

View File

@ -159,6 +159,20 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
} }
} }
@Override
public long count() {
LOGGER.debug("entry to count(), this = {}", this);
Long rowCount = null;
try {
taskanaEngine.openConnection();
rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
return (rowCount == null) ? 0L : rowCount;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from count(). Returning result {} ", rowCount);
}
}
public String[] getCompany() { public String[] getCompany() {
return company; return company;
} }
@ -203,20 +217,6 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
return columnName; return columnName;
} }
@Override
public long count() {
LOGGER.debug("entry to count(), this = {}", this);
Long rowCount = null;
try {
taskanaEngine.openConnection();
rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
return (rowCount == null) ? 0L : rowCount;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from count(). Returning result {} ", rowCount);
}
}
private ObjectReferenceQuery addOrderCriteria(String colName, SortDirection sortDirection) { private ObjectReferenceQuery addOrderCriteria(String colName, SortDirection sortDirection) {
String orderByDirection = String orderByDirection =
" " + (sortDirection == null ? SortDirection.ASCENDING : sortDirection); " " + (sortDirection == null ? SortDirection.ASCENDING : sortDirection);

View File

@ -93,6 +93,11 @@ public class TaskImpl implements Task {
this.externalId = externalId; this.externalId = externalId;
} }
@Override
public String getCreator() {
return creator;
}
@Override @Override
public Instant getCreated() { public Instant getCreated() {
return created; return created;
@ -159,15 +164,6 @@ public class TaskImpl implements Task {
this.name = name; this.name = name;
} }
@Override
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
@Override @Override
public String getDescription() { public String getDescription() {
return description; return description;
@ -178,16 +174,6 @@ public class TaskImpl implements Task {
this.description = description; this.description = description;
} }
@Override
public String getNote() {
return note;
}
@Override
public void setNote(String note) {
this.note = note;
}
@Override @Override
public int getPriority() { public int getPriority() {
return priority; return priority;
@ -215,16 +201,29 @@ public class TaskImpl implements Task {
this.classificationSummary = classificationSummary; this.classificationSummary = classificationSummary;
} }
@Override public void setCreator(String creator) {
public String getClassificationCategory() { this.creator = creator;
return this.classificationSummary == null ? null : this.classificationSummary.getCategory();
} }
public void setClassificationCategory(String classificationCategory) { public CallbackState getCallbackState() {
return callbackState;
}
public void setCallbackState(CallbackState callbackState) {
this.callbackState = callbackState;
}
public String getClassificationKey() {
return classificationSummary == null ? null : classificationSummary.getKey();
}
@Override
public void setClassificationKey(String classificationKey) {
if (this.classificationSummary == null) { if (this.classificationSummary == null) {
this.classificationSummary = new ClassificationSummaryImpl(); this.classificationSummary = new ClassificationSummaryImpl();
} }
((ClassificationSummaryImpl) this.classificationSummary).setCategory(classificationCategory);
((ClassificationSummaryImpl) this.classificationSummary).setKey(classificationKey);
} }
@Override @Override
@ -344,14 +343,6 @@ public class TaskImpl implements Task {
this.callbackInfo = callbackInfo; this.callbackInfo = callbackInfo;
} }
public CallbackState getCallbackState() {
return callbackState;
}
public void setCallbackState(CallbackState callbackState) {
this.callbackState = callbackState;
}
@Override @Override
public String getCustomAttribute(String number) throws InvalidArgumentException { public String getCustomAttribute(String number) throws InvalidArgumentException {
int num = 0; int num = 0;
@ -491,12 +482,14 @@ public class TaskImpl implements Task {
return attachments; return attachments;
} }
public void setAttachments(List<Attachment> attachments) { @Override
if (attachments != null) { public String getNote() {
this.attachments = attachments; return note;
} else if (this.attachments == null) {
this.attachments = new ArrayList<>();
} }
@Override
public void setNote(String note) {
this.note = note;
} }
@Override @Override
@ -549,17 +542,38 @@ public class TaskImpl implements Task {
return taskSummary; return taskSummary;
} }
public String getClassificationKey() { @Override
return classificationSummary == null ? null : classificationSummary.getKey(); public Attachment removeAttachment(String attachmentId) {
Attachment result = null;
Iterator<Attachment> i = attachments.iterator();
while (i.hasNext()) {
Attachment attachment = i.next();
if (attachment.getId().equals(attachmentId) && attachments.remove(attachment)) {
result = attachment;
break;
}
}
return result;
} }
@Override @Override
public void setClassificationKey(String classificationKey) { public String getClassificationCategory() {
return this.classificationSummary == null ? null : this.classificationSummary.getCategory();
}
public void setClassificationCategory(String classificationCategory) {
if (this.classificationSummary == null) { if (this.classificationSummary == null) {
this.classificationSummary = new ClassificationSummaryImpl(); this.classificationSummary = new ClassificationSummaryImpl();
} }
((ClassificationSummaryImpl) this.classificationSummary).setCategory(classificationCategory);
}
((ClassificationSummaryImpl) this.classificationSummary).setKey(classificationKey); public void setAttachments(List<Attachment> attachments) {
if (attachments != null) {
this.attachments = attachments;
} else if (this.attachments == null) {
this.attachments = new ArrayList<>();
}
} }
public ClassificationSummaryImpl getClassificationSummaryImpl() { public ClassificationSummaryImpl getClassificationSummaryImpl() {
@ -707,17 +721,50 @@ public class TaskImpl implements Task {
} }
@Override @Override
public Attachment removeAttachment(String attachmentId) { public int hashCode() {
Attachment result = null; return Objects.hash(
Iterator<Attachment> i = attachments.iterator(); id,
while (i.hasNext()) { externalId,
Attachment attachment = i.next(); created,
if (attachment.getId().equals(attachmentId) && attachments.remove(attachment)) { claimed,
result = attachment; completed,
break; modified,
} planned,
} due,
return result; name,
creator,
description,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
customAttributes,
callbackInfo,
callbackState,
attachments,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
} }
@Override @Override
@ -773,53 +820,6 @@ public class TaskImpl implements Task {
&& Objects.equals(custom16, other.custom16); && Objects.equals(custom16, other.custom16);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
description,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
customAttributes,
callbackInfo,
callbackState,
attachments,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
}
@Override @Override
public String toString() { public String toString() {
return "TaskImpl [id=" return "TaskImpl [id="

View File

@ -161,14 +161,14 @@ public class TaskQueryImpl implements TaskQuery {
} }
@Override @Override
public TaskQuery idIn(String... taskIds) { public TaskQuery nameIn(String... names) {
this.taskIds = taskIds; this.nameIn = names;
return this; return this;
} }
@Override @Override
public TaskQuery nameIn(String... names) { public TaskQuery nameLike(String... names) {
this.nameIn = names; this.nameLike = toUpperCopy(names);
return this; return this;
} }
@ -184,12 +184,6 @@ public class TaskQueryImpl implements TaskQuery {
return this; return this;
} }
@Override
public TaskQuery nameLike(String... names) {
this.nameLike = toUpperCopy(names);
return this;
}
@Override @Override
public TaskQuery creatorIn(String... creators) { public TaskQuery creatorIn(String... creators) {
this.creatorIn = creators; this.creatorIn = creators;
@ -202,6 +196,175 @@ public class TaskQueryImpl implements TaskQuery {
return this; return this;
} }
@Override
public TaskQuery descriptionLike(String... description) {
this.description = toUpperCopy(description);
return this;
}
@Override
public TaskQuery noteLike(String... note) {
this.noteLike = toUpperCopy(note);
return this;
}
@Override
public TaskQuery priorityIn(int... priorities) {
this.priority = priorities;
return this;
}
@Override
public TaskQuery stateIn(TaskState... states) {
this.stateIn = states;
return this;
}
@Override
public TaskQuery stateNotIn(TaskState... states) {
// No benefit in introducing a new variable
List<TaskState> stateIn = new LinkedList<>(Arrays.asList(TaskState.values()));
for (TaskState state : states) {
stateIn.remove(state);
}
this.stateIn = stateIn.toArray(new TaskState[0]);
return this;
}
@Override
public TaskQuery classificationKeyIn(String... classificationKey) {
this.classificationKeyIn = classificationKey;
return this;
}
@Override
public TaskQuery classificationKeyNotIn(String... classificationKeys) {
this.classificationKeyNotIn = classificationKeys;
return this;
}
@Override
public TaskQuery classificationKeyLike(String... classificationKeys) {
this.classificationKeyLike = toUpperCopy(classificationKeys);
return this;
}
@Override
public TaskQuery classificationIdIn(String... classificationId) {
this.classificationIdIn = classificationId;
return this;
}
@Override
public TaskQuery classificationCategoryIn(String... classificationCategories) {
this.classificationCategoryIn = classificationCategories;
return this;
}
@Override
public TaskQuery classificationCategoryLike(String... classificationCategories) {
this.classificationCategoryLike = toUpperCopy(classificationCategories);
return this;
}
@Override
public TaskQuery classificationNameIn(String... classificationNames) {
joinWithClassifications = true;
this.classificationNameIn = classificationNames;
return this;
}
@Override
public TaskQuery classificationNameLike(String... classificationNames) {
joinWithClassifications = true;
this.classificationNameLike = toUpperCopy(classificationNames);
return this;
}
@Override
public TaskQuery workbasketKeyDomainIn(KeyDomain... workbasketIdentifiers) {
this.workbasketKeyDomainIn = workbasketIdentifiers;
return this;
}
@Override
public TaskQuery workbasketIdIn(String... workbasketIds) {
this.workbasketIdIn = workbasketIds;
return this;
}
@Override
public TaskQuery ownerIn(String... owners) {
this.ownerIn = owners;
return this;
}
@Override
public TaskQuery ownerLike(String... owners) {
this.ownerLike = toUpperCopy(owners);
return this;
}
@Override
public TaskQuery primaryObjectReferenceCompanyIn(String... companies) {
this.porCompanyIn = companies;
return this;
}
@Override
public TaskQuery primaryObjectReferenceCompanyLike(String... company) {
this.porCompanyLike = toUpperCopy(company);
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemIn(String... systems) {
this.porSystemIn = systems;
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemLike(String... system) {
this.porSystemLike = toUpperCopy(system);
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemInstanceIn(String... systemInstances) {
this.porSystemInstanceIn = systemInstances;
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemInstanceLike(String... systemInstance) {
this.porSystemInstanceLike = toUpperCopy(systemInstance);
return this;
}
@Override
public TaskQuery primaryObjectReferenceTypeIn(String... types) {
this.porTypeIn = types;
return this;
}
@Override
public TaskQuery primaryObjectReferenceTypeLike(String... type) {
this.porTypeLike = toUpperCopy(type);
return this;
}
@Override
public TaskQuery primaryObjectReferenceValueLike(String... value) {
this.porValueLike = toUpperCopy(value);
return this;
}
@Override
public TaskQuery primaryObjectReferenceValueIn(String... values) {
this.porValueIn = values;
return this;
}
@Override @Override
public TaskQuery createdWithin(TimeInterval... intervals) { public TaskQuery createdWithin(TimeInterval... intervals) {
this.createdIn = intervals; this.createdIn = intervals;
@ -268,144 +431,6 @@ public class TaskQueryImpl implements TaskQuery {
return this; return this;
} }
@Override
public TaskQuery descriptionLike(String... description) {
this.description = toUpperCopy(description);
return this;
}
@Override
public TaskQuery noteLike(String... note) {
this.noteLike = toUpperCopy(note);
return this;
}
@Override
public TaskQuery priorityIn(int... priorities) {
this.priority = priorities;
return this;
}
@Override
public TaskQuery workbasketKeyDomainIn(KeyDomain... workbasketIdentifiers) {
this.workbasketKeyDomainIn = workbasketIdentifiers;
return this;
}
@Override
public TaskQuery workbasketIdIn(String... workbasketIds) {
this.workbasketIdIn = workbasketIds;
return this;
}
@Override
public TaskQuery classificationKeyIn(String... classificationKey) {
this.classificationKeyIn = classificationKey;
return this;
}
@Override
public TaskQuery classificationKeyNotIn(String... classificationKeys) {
this.classificationKeyNotIn = classificationKeys;
return this;
}
@Override
public TaskQuery classificationKeyLike(String... classificationKeys) {
this.classificationKeyLike = toUpperCopy(classificationKeys);
return this;
}
@Override
public TaskQuery classificationIdIn(String... classificationId) {
this.classificationIdIn = classificationId;
return this;
}
@Override
public TaskQuery classificationCategoryIn(String... classificationCategories) {
this.classificationCategoryIn = classificationCategories;
return this;
}
@Override
public TaskQuery classificationCategoryLike(String... classificationCategories) {
this.classificationCategoryLike = toUpperCopy(classificationCategories);
return this;
}
@Override
public TaskQuery ownerIn(String... owners) {
this.ownerIn = owners;
return this;
}
@Override
public TaskQuery ownerLike(String... owners) {
this.ownerLike = toUpperCopy(owners);
return this;
}
@Override
public TaskQuery primaryObjectReferenceCompanyIn(String... companies) {
this.porCompanyIn = companies;
return this;
}
@Override
public TaskQuery primaryObjectReferenceCompanyLike(String... company) {
this.porCompanyLike = toUpperCopy(company);
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemIn(String... systems) {
this.porSystemIn = systems;
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemLike(String... system) {
this.porSystemLike = toUpperCopy(system);
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemInstanceIn(String... systemInstances) {
this.porSystemInstanceIn = systemInstances;
return this;
}
@Override
public TaskQuery primaryObjectReferenceSystemInstanceLike(String... systemInstance) {
this.porSystemInstanceLike = toUpperCopy(systemInstance);
return this;
}
@Override
public TaskQuery primaryObjectReferenceTypeIn(String... types) {
this.porTypeIn = types;
return this;
}
@Override
public TaskQuery primaryObjectReferenceTypeLike(String... type) {
this.porTypeLike = toUpperCopy(type);
return this;
}
@Override
public TaskQuery primaryObjectReferenceValueIn(String... values) {
this.porValueIn = values;
return this;
}
@Override
public TaskQuery primaryObjectReferenceValueLike(String... value) {
this.porValueLike = toUpperCopy(value);
return this;
}
@Override @Override
public TaskQuery readEquals(Boolean isRead) { public TaskQuery readEquals(Boolean isRead) {
this.isRead = isRead; this.isRead = isRead;
@ -442,29 +467,6 @@ public class TaskQueryImpl implements TaskQuery {
return this; return this;
} }
@Override
public TaskQuery stateIn(TaskState... states) {
this.stateIn = states;
return this;
}
@Override
public TaskQuery stateNotIn(TaskState... states) {
// No benefit in introducing a new variable
List<TaskState> stateIn = new LinkedList<>(Arrays.asList(TaskState.values()));
for (TaskState state : states) {
stateIn.remove(state);
}
this.stateIn = stateIn.toArray(new TaskState[0]);
return this;
}
@Override
public TaskQuery callbackStateIn(CallbackState... states) {
this.callbackStateIn = states;
return this;
}
@Override @Override
public TaskQuery customAttributeIn(String number, String... strings) public TaskQuery customAttributeIn(String number, String... strings)
throws InvalidArgumentException { throws InvalidArgumentException {
@ -640,6 +642,20 @@ public class TaskQueryImpl implements TaskQuery {
return this; return this;
} }
@Override
public TaskQuery attachmentClassificationNameIn(String... attachmentClassificationName) {
joinWithAttachmentClassifications = true;
this.attachmentClassificationNameIn = attachmentClassificationName;
return this;
}
@Override
public TaskQuery attachmentClassificationNameLike(String... attachmentClassificationName) {
joinWithAttachmentClassifications = true;
this.attachmentClassificationNameLike = toUpperCopy(attachmentClassificationName);
return this;
}
@Override @Override
public TaskQuery attachmentChannelIn(String... attachmentChannel) { public TaskQuery attachmentChannelIn(String... attachmentChannel) {
joinWithAttachments = true; joinWithAttachments = true;
@ -681,31 +697,31 @@ public class TaskQueryImpl implements TaskQuery {
} }
@Override @Override
public TaskQuery classificationNameIn(String... classificationNames) { public TaskQuery callbackStateIn(CallbackState... states) {
joinWithClassifications = true; this.callbackStateIn = states;
this.classificationNameIn = classificationNames;
return this; return this;
} }
@Override @Override
public TaskQuery classificationNameLike(String... classificationNames) { public ObjectReferenceQuery createObjectReferenceQuery() {
joinWithClassifications = true; return new ObjectReferenceQueryImpl(taskanaEngine);
this.classificationNameLike = toUpperCopy(classificationNames);
return this;
} }
@Override @Override
public TaskQuery attachmentClassificationNameIn(String... attachmentClassificationName) { public TaskQuery orderByBusinessProcessId(SortDirection sortDirection) {
joinWithAttachmentClassifications = true; return addOrderCriteria("BUSINESS_PROCESS_ID", sortDirection);
this.attachmentClassificationNameIn = attachmentClassificationName;
return this;
} }
@Override @Override
public TaskQuery attachmentClassificationNameLike(String... attachmentClassificationName) { public TaskQuery orderByClaimed(SortDirection sortDirection) {
joinWithAttachmentClassifications = true; return addOrderCriteria("CLAIMED", sortDirection);
this.attachmentClassificationNameLike = toUpperCopy(attachmentClassificationName); }
return this;
@Override
public TaskQuery orderByClassificationKey(SortDirection sortDirection) {
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("TCLASSIFICATION_KEY", sortDirection)
: addOrderCriteria("t.CLASSIFICATION_KEY", sortDirection);
} }
@Override @Override
@ -718,19 +734,13 @@ public class TaskQueryImpl implements TaskQuery {
} }
@Override @Override
public TaskQuery orderByAttachmentClassificationName(SortDirection sortDirection) { public TaskQuery orderByCompleted(SortDirection sortDirection) {
joinWithAttachments = true; return addOrderCriteria("COMPLETED", sortDirection);
addAttachmentClassificationNameToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACNAME", sortDirection)
: addOrderCriteria("ac.NAME", sortDirection);
} }
@Override @Override
public TaskQuery orderByClassificationKey(SortDirection sortDirection) { public TaskQuery orderByCreated(SortDirection sortDirection) {
return DB.DB2.dbProductId.equals(getDatabaseId()) return addOrderCriteria("CREATED", sortDirection);
? addOrderCriteria("TCLASSIFICATION_KEY", sortDirection)
: addOrderCriteria("t.CLASSIFICATION_KEY", sortDirection);
} }
@Override @Override
@ -738,11 +748,6 @@ public class TaskQueryImpl implements TaskQuery {
return addOrderCriteria("DOMAIN", sortDirection); return addOrderCriteria("DOMAIN", sortDirection);
} }
@Override
public TaskQuery orderByPlanned(SortDirection sortDirection) {
return addOrderCriteria("PLANNED", sortDirection);
}
@Override @Override
public TaskQuery orderByDue(SortDirection sortDirection) { public TaskQuery orderByDue(SortDirection sortDirection) {
return addOrderCriteria("DUE", sortDirection); return addOrderCriteria("DUE", sortDirection);
@ -763,11 +768,26 @@ public class TaskQueryImpl implements TaskQuery {
return addOrderCriteria("CREATOR", sortDirection); return addOrderCriteria("CREATOR", sortDirection);
} }
@Override
public TaskQuery orderByNote(SortDirection sortDirection) {
return addOrderCriteria("NOTE", sortDirection);
}
@Override @Override
public TaskQuery orderByOwner(SortDirection sortDirection) { public TaskQuery orderByOwner(SortDirection sortDirection) {
return addOrderCriteria("OWNER", sortDirection); return addOrderCriteria("OWNER", sortDirection);
} }
@Override
public TaskQuery orderByParentBusinessProcessId(SortDirection sortDirection) {
return addOrderCriteria("PARENT_BUSINESS_PROCESS_ID", sortDirection);
}
@Override
public TaskQuery orderByPlanned(SortDirection sortDirection) {
return addOrderCriteria("PLANNED", sortDirection);
}
@Override @Override
public TaskQuery orderByPrimaryObjectReferenceCompany(SortDirection sortDirection) { public TaskQuery orderByPrimaryObjectReferenceCompany(SortDirection sortDirection) {
return addOrderCriteria("POR_COMPANY", sortDirection); return addOrderCriteria("POR_COMPANY", sortDirection);
@ -808,55 +828,6 @@ public class TaskQueryImpl implements TaskQuery {
return addOrderCriteria("WORKBASKET_KEY", sortDirection); return addOrderCriteria("WORKBASKET_KEY", sortDirection);
} }
@Override
public TaskQuery orderByWorkbasketId(SortDirection sortDirection) {
return addOrderCriteria("WORKBASKET_ID", sortDirection);
}
@Override
public TaskQuery orderByAttachmentClassificationKey(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACLASSIFICATION_KEY", sortDirection)
: addOrderCriteria("a.CLASSIFICATION_KEY", sortDirection);
}
@Override
public TaskQuery orderByAttachmentClassificationId(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACLASSIFICATION_ID", sortDirection)
: addOrderCriteria("a.CLASSIFICATION_ID", sortDirection);
}
@Override
public TaskQuery orderByAttachmentChannel(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return addOrderCriteria("CHANNEL", sortDirection);
}
@Override
public TaskQuery orderByAttachmentReference(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return addOrderCriteria("REF_VALUE", sortDirection);
}
@Override
public TaskQuery orderByAttachmentReceived(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return addOrderCriteria("RECEIVED", sortDirection);
}
@Override
public TaskQuery orderByNote(SortDirection sortDirection) {
return addOrderCriteria("NOTE", sortDirection);
}
@Override @Override
public TaskQuery orderByCustomAttribute(String number, SortDirection sortDirection) public TaskQuery orderByCustomAttribute(String number, SortDirection sortDirection)
throws InvalidArgumentException { throws InvalidArgumentException {
@ -911,33 +882,62 @@ public class TaskQueryImpl implements TaskQuery {
} }
@Override @Override
public TaskQuery orderByBusinessProcessId(SortDirection sortDirection) { public TaskQuery idIn(String... taskIds) {
return addOrderCriteria("BUSINESS_PROCESS_ID", sortDirection); this.taskIds = taskIds;
return this;
} }
@Override @Override
public TaskQuery orderByClaimed(SortDirection sortDirection) { public TaskQuery orderByWorkbasketId(SortDirection sortDirection) {
return addOrderCriteria("CLAIMED", sortDirection); return addOrderCriteria("WORKBASKET_ID", sortDirection);
} }
@Override @Override
public TaskQuery orderByCompleted(SortDirection sortDirection) { public TaskQuery orderByAttachmentClassificationKey(SortDirection sortDirection) {
return addOrderCriteria("COMPLETED", sortDirection); joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACLASSIFICATION_KEY", sortDirection)
: addOrderCriteria("a.CLASSIFICATION_KEY", sortDirection);
} }
@Override @Override
public TaskQuery orderByCreated(SortDirection sortDirection) { public TaskQuery orderByAttachmentClassificationName(SortDirection sortDirection) {
return addOrderCriteria("CREATED", sortDirection); joinWithAttachments = true;
addAttachmentClassificationNameToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACNAME", sortDirection)
: addOrderCriteria("ac.NAME", sortDirection);
} }
@Override @Override
public TaskQuery orderByParentBusinessProcessId(SortDirection sortDirection) { public TaskQuery orderByAttachmentClassificationId(SortDirection sortDirection) {
return addOrderCriteria("PARENT_BUSINESS_PROCESS_ID", sortDirection); joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACLASSIFICATION_ID", sortDirection)
: addOrderCriteria("a.CLASSIFICATION_ID", sortDirection);
} }
@Override @Override
public ObjectReferenceQuery createObjectReferenceQuery() { public TaskQuery orderByAttachmentChannel(SortDirection sortDirection) {
return new ObjectReferenceQueryImpl(taskanaEngine); joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return addOrderCriteria("CHANNEL", sortDirection);
}
@Override
public TaskQuery orderByAttachmentReference(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return addOrderCriteria("REF_VALUE", sortDirection);
}
@Override
public TaskQuery orderByAttachmentReceived(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentColumnsToSelectClauseForOrdering = true;
return addOrderCriteria("RECEIVED", sortDirection);
} }
@Override @Override
@ -1004,14 +1004,6 @@ public class TaskQueryImpl implements TaskQuery {
} }
} }
public String getLinkToMapperScript() {
return DB.DB2.dbProductId.equals(getDatabaseId()) ? LINK_TO_MAPPER_DB2 : LINK_TO_MAPPER;
}
public String getLinkToCounterTaskScript() {
return DB.DB2.dbProductId.equals(getDatabaseId()) ? LINK_TO_COUNTER_DB2 : LINK_TO_COUNTER;
}
@Override @Override
public List<String> listValues(TaskQueryColumnName columnName, SortDirection sortDirection) { public List<String> listValues(TaskQueryColumnName columnName, SortDirection sortDirection) {
LOGGER.debug("Entry to listValues(dbColumnName={}) this = {}", columnName, this); LOGGER.debug("Entry to listValues(dbColumnName={}) this = {}", columnName, this);
@ -1093,6 +1085,14 @@ public class TaskQueryImpl implements TaskQuery {
} }
} }
public String getLinkToMapperScript() {
return DB.DB2.dbProductId.equals(getDatabaseId()) ? LINK_TO_MAPPER_DB2 : LINK_TO_MAPPER;
}
public String getLinkToCounterTaskScript() {
return DB.DB2.dbProductId.equals(getDatabaseId()) ? LINK_TO_COUNTER_DB2 : LINK_TO_COUNTER;
}
public boolean isUseDistinctKeyword() { public boolean isUseDistinctKeyword() {
return useDistinctKeyword; return useDistinctKeyword;
} }

View File

@ -59,6 +59,7 @@ import pro.taskana.mappings.TaskMapper;
import pro.taskana.security.CurrentUserContext; import pro.taskana.security.CurrentUserContext;
/** This is the implementation of TaskService. */ /** This is the implementation of TaskService. */
@SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
public class TaskServiceImpl implements TaskService { public class TaskServiceImpl implements TaskService {
private static final String IS_ALREADY_CLAIMED_BY = " is already claimed by "; private static final String IS_ALREADY_CLAIMED_BY = " is already claimed by ";
@ -115,42 +116,6 @@ public class TaskServiceImpl implements TaskService {
return claim(taskId, false); return claim(taskId, false);
} }
private Task claim(String taskId, boolean forceClaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug(
"entry to claim(id = {}, userId = {}, forceClaim = {})", taskId, userId, forceClaim);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
throw new InvalidStateException(TASK_WITH_ID + taskId + IS_ALREADY_COMPLETED);
}
if (state == TaskState.CLAIMED && !forceClaim && !task.getOwner().equals(userId)) {
throw new InvalidOwnerException(
TASK_WITH_ID + taskId + IS_ALREADY_CLAIMED_BY + task.getOwner() + ".");
}
Instant now = Instant.now();
task.setOwner(userId);
task.setModified(now);
task.setClaimed(now);
task.setRead(true);
task.setState(TaskState.CLAIMED);
taskMapper.update(task);
LOGGER.debug("Task '{}' claimed by user '{}'.", taskId, userId);
if (HistoryEventProducer.isHistoryEnabled()) {
historyEventProducer.createEvent(new ClaimedEvent(task));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from claim()");
}
return task;
}
@Override @Override
public Task forceClaim(String taskId) public Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
@ -165,45 +130,6 @@ public class TaskServiceImpl implements TaskService {
return this.cancelClaim(taskId, false); return this.cancelClaim(taskId, false);
} }
private Task cancelClaim(String taskId, boolean forceUnclaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug(
"entry to cancelClaim(taskId = {}), userId = {}, forceUnclaim = {})",
taskId,
userId,
forceUnclaim);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
throw new InvalidStateException(TASK_WITH_ID + taskId + IS_ALREADY_COMPLETED);
}
if (state == TaskState.CLAIMED && !forceUnclaim && !userId.equals(task.getOwner())) {
throw new InvalidOwnerException(
TASK_WITH_ID + taskId + IS_ALREADY_CLAIMED_BY + task.getOwner() + ".");
}
Instant now = Instant.now();
task.setOwner(null);
task.setModified(now);
task.setClaimed(null);
task.setRead(true);
task.setState(TaskState.READY);
taskMapper.update(task);
LOGGER.debug("Task '{}' unclaimed by user '{}'.", taskId, userId);
if (HistoryEventProducer.isHistoryEnabled()) {
historyEventProducer.createEvent(new ClaimCancelledEvent(task));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from cancelClaim()");
}
return task;
}
@Override @Override
public Task forceCancelClaim(String taskId) public Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
@ -218,57 +144,6 @@ public class TaskServiceImpl implements TaskService {
return completeTask(taskId, false); return completeTask(taskId, false);
} }
private Task completeTask(String taskId, boolean isForced)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug(
"entry to completeTask(id = {}, userId = {}, isForced = {})", taskId, userId, isForced);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) this.getTask(taskId);
if (task.getState() == TaskState.COMPLETED) {
return task;
}
// check pre-conditions for non-forced invocation
if (!isForced) {
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
throw new InvalidStateException(TASK_WITH_ID + taskId + " has to be claimed before.");
} else if (!CurrentUserContext.getAccessIds().contains(task.getOwner())) {
throw new InvalidOwnerException(
"Owner of task "
+ taskId
+ " is "
+ task.getOwner()
+ ", but current User is "
+ userId);
}
} else {
// CLAIM-forced, if task was not already claimed before.
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
task = (TaskImpl) this.forceClaim(taskId);
}
}
Instant now = Instant.now();
task.setCompleted(now);
task.setModified(now);
task.setState(TaskState.COMPLETED);
task.setOwner(userId);
taskMapper.update(task);
LOGGER.debug("Task '{}' completed by user '{}'.", taskId, userId);
if (HistoryEventProducer.isHistoryEnabled()) {
historyEventProducer.createEvent(new CompletedEvent(task));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from completeTask()");
}
return task;
}
@Override @Override
public Task forceCompleteTask(String taskId) public Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
@ -276,35 +151,6 @@ public class TaskServiceImpl implements TaskService {
return completeTask(taskId, true); return completeTask(taskId, true);
} }
@Override
public BulkOperationResults<String, TaskanaException> completeTasks(
List<String> taskIdsToBeCompleted) throws InvalidArgumentException {
try {
LOGGER.debug("entry to completeTasks(taskIds = {})", taskIdsToBeCompleted);
taskanaEngine.openConnection();
if (taskIdsToBeCompleted == null || taskIdsToBeCompleted.isEmpty()) {
throw new InvalidArgumentException("TaskIds can´t be used as NULL-Parameter.");
}
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
List<String> taskIds = new ArrayList<>(taskIdsToBeCompleted);
removeNonExistingTasksFromTaskIdList(taskIds, bulkLog);
List<TaskSummary> taskSummaries =
this.createTaskQuery().idIn(taskIds.toArray(new String[0])).list();
checkIfTasksMatchCompleteCriteria(taskIds, taskSummaries, bulkLog);
updateTasksToBeCompleted(taskIds, taskSummaries);
return bulkLog;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from to completeTasks(taskIds = {})", taskIdsToBeCompleted);
}
}
@Override @Override
public Task createTask(Task taskToCreate) public Task createTask(Task taskToCreate)
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
@ -465,6 +311,20 @@ public class TaskServiceImpl implements TaskService {
} }
} }
@Override
public Task transfer(String taskId, String destinationWorkbasketId)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidStateException {
return taskTransferrer.transfer(taskId, destinationWorkbasketId);
}
@Override
public Task transfer(String taskId, String workbasketKey, String domain)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidStateException {
return taskTransferrer.transfer(taskId, workbasketKey, domain);
}
@Override @Override
public Task setTaskRead(String taskId, boolean isRead) public Task setTaskRead(String taskId, boolean isRead)
throws TaskNotFoundException, NotAuthorizedException { throws TaskNotFoundException, NotAuthorizedException {
@ -484,35 +344,6 @@ public class TaskServiceImpl implements TaskService {
} }
} }
@Override
public Task transfer(String taskId, String destinationWorkbasketId)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidStateException {
return taskTransferrer.transfer(taskId, destinationWorkbasketId);
}
@Override
public Task transfer(String taskId, String workbasketKey, String domain)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidStateException {
return taskTransferrer.transfer(taskId, workbasketKey, domain);
}
@Override
public BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketId, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
return taskTransferrer.transferTasks(destinationWorkbasketId, taskIds);
}
@Override
public BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketKey, String destinationWorkbasketDomain, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
return taskTransferrer.transferTasks(
destinationWorkbasketKey, destinationWorkbasketDomain, taskIds);
}
@Override @Override
public TaskQuery createTaskQuery() { public TaskQuery createTaskQuery() {
return new TaskQueryImpl(taskanaEngine); return new TaskQueryImpl(taskanaEngine);
@ -550,38 +381,52 @@ public class TaskServiceImpl implements TaskService {
return new AttachmentImpl(); return new AttachmentImpl();
} }
@Override
public Task updateTask(Task task)
throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException,
ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug("entry to updateTask(task = {}, userId = {})", task, userId);
TaskImpl newTaskImpl = (TaskImpl) task;
TaskImpl oldTaskImpl = null;
try {
taskanaEngine.openConnection();
oldTaskImpl = (TaskImpl) getTask(newTaskImpl.getId());
PrioDurationHolder prioDurationFromAttachments =
handleAttachmentsOnTaskUpdate(oldTaskImpl, newTaskImpl);
standardUpdateActions(oldTaskImpl, newTaskImpl, prioDurationFromAttachments);
taskMapper.update(newTaskImpl);
LOGGER.debug("Method updateTask() updated task '{}' for user '{}'.", task.getId(), userId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from claim()");
}
return task;
}
@Override
public BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketId, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
return taskTransferrer.transferTasks(destinationWorkbasketId, taskIds);
}
@Override
public BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketKey, String destinationWorkbasketDomain, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
return taskTransferrer.transferTasks(
destinationWorkbasketKey, destinationWorkbasketDomain, taskIds);
}
@Override @Override
public void deleteTask(String taskId) public void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
deleteTask(taskId, false); deleteTask(taskId, false);
} }
private void deleteTask(String taskId, boolean forceDelete)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("entry to deleteTask(taskId = {} , forceDelete = {})", taskId, forceDelete);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
if (!TaskState.COMPLETED.equals(task.getState()) && !forceDelete) {
throw new InvalidStateException(
"Cannot delete Task " + taskId + " because it is not completed.");
}
if (CallbackState.CALLBACK_PROCESSING_REQUIRED.equals(task.getCallbackState())) {
throw new InvalidStateException(
"Task " + taskId + " cannot be deleted because its callback is not yet processed");
}
taskMapper.delete(taskId);
LOGGER.debug("Task {} deleted.", taskId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteTask().");
}
}
@Override @Override
public void forceDeleteTask(String taskId) public void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
@ -623,35 +468,31 @@ public class TaskServiceImpl implements TaskService {
} }
@Override @Override
public BulkOperationResults<String, TaskanaException> setCallbackStateForTasks( public BulkOperationResults<String, TaskanaException> completeTasks(
List<String> externalIds, CallbackState state) { List<String> taskIdsToBeCompleted) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"entry to setCallbackStateForTasks(externalIds = {})",
LoggerUtils.listToString(externalIds));
}
try { try {
LOGGER.debug("entry to completeTasks(taskIds = {})", taskIdsToBeCompleted);
taskanaEngine.openConnection(); taskanaEngine.openConnection();
if (taskIdsToBeCompleted == null || taskIdsToBeCompleted.isEmpty()) {
throw new InvalidArgumentException("TaskIds can´t be used as NULL-Parameter.");
}
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>(); BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
List<String> taskIds = new ArrayList<>(taskIdsToBeCompleted);
removeNonExistingTasksFromTaskIdList(taskIds, bulkLog);
if (externalIds == null || externalIds.isEmpty()) { List<TaskSummary> taskSummaries =
return bulkLog; this.createTaskQuery().idIn(taskIds.toArray(new String[0])).list();
}
List<MinimalTaskSummary> taskSummaries = taskMapper.findExistingTasks(null, externalIds); checkIfTasksMatchCompleteCriteria(taskIds, taskSummaries, bulkLog);
updateTasksToBeCompleted(taskIds, taskSummaries);
Iterator<String> taskIdIterator = externalIds.iterator();
while (taskIdIterator.hasNext()) {
removeSingleTaskForCallbackStateByExternalId(bulkLog, taskSummaries, taskIdIterator, state);
}
if (!externalIds.isEmpty()) {
taskMapper.setCallbackStateMultiple(externalIds, state);
}
return bulkLog; return bulkLog;
} finally { } finally {
LOGGER.debug("exit from setCallbckStateForTasks()");
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from to completeTasks(taskIds = {})", taskIdsToBeCompleted);
} }
} }
@ -739,28 +580,36 @@ public class TaskServiceImpl implements TaskService {
} }
@Override @Override
public Task updateTask(Task task) public BulkOperationResults<String, TaskanaException> setCallbackStateForTasks(
throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException, List<String> externalIds, CallbackState state) {
ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException { if (LOGGER.isDebugEnabled()) {
String userId = CurrentUserContext.getUserid(); LOGGER.debug(
LOGGER.debug("entry to updateTask(task = {}, userId = {})", task, userId); "entry to setCallbackStateForTasks(externalIds = {})",
TaskImpl newTaskImpl = (TaskImpl) task; LoggerUtils.listToString(externalIds));
TaskImpl oldTaskImpl = null; }
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
oldTaskImpl = (TaskImpl) getTask(newTaskImpl.getId());
PrioDurationHolder prioDurationFromAttachments =
handleAttachmentsOnTaskUpdate(oldTaskImpl, newTaskImpl);
standardUpdateActions(oldTaskImpl, newTaskImpl, prioDurationFromAttachments);
taskMapper.update(newTaskImpl); BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
LOGGER.debug("Method updateTask() updated task '{}' for user '{}'.", task.getId(), userId);
} finally { if (externalIds == null || externalIds.isEmpty()) {
taskanaEngine.returnConnection(); return bulkLog;
LOGGER.debug("exit from claim()"); }
List<MinimalTaskSummary> taskSummaries = taskMapper.findExistingTasks(null, externalIds);
Iterator<String> taskIdIterator = externalIds.iterator();
while (taskIdIterator.hasNext()) {
removeSingleTaskForCallbackStateByExternalId(bulkLog, taskSummaries, taskIdIterator, state);
}
if (!externalIds.isEmpty()) {
taskMapper.setCallbackStateMultiple(externalIds, state);
}
return bulkLog;
} finally {
LOGGER.debug("exit from setCallbckStateForTasks()");
taskanaEngine.returnConnection();
} }
return task;
} }
public Set<String> findTasksIdsAffectedByClassificationChange(String classificationId) { public Set<String> findTasksIdsAffectedByClassificationChange(String classificationId) {
@ -904,6 +753,158 @@ public class TaskServiceImpl implements TaskService {
return result; return result;
} }
private Task claim(String taskId, boolean forceClaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug(
"entry to claim(id = {}, userId = {}, forceClaim = {})", taskId, userId, forceClaim);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
throw new InvalidStateException(TASK_WITH_ID + taskId + IS_ALREADY_COMPLETED);
}
if (state == TaskState.CLAIMED && !forceClaim && !task.getOwner().equals(userId)) {
throw new InvalidOwnerException(
TASK_WITH_ID + taskId + IS_ALREADY_CLAIMED_BY + task.getOwner() + ".");
}
Instant now = Instant.now();
task.setOwner(userId);
task.setModified(now);
task.setClaimed(now);
task.setRead(true);
task.setState(TaskState.CLAIMED);
taskMapper.update(task);
LOGGER.debug("Task '{}' claimed by user '{}'.", taskId, userId);
if (HistoryEventProducer.isHistoryEnabled()) {
historyEventProducer.createEvent(new ClaimedEvent(task));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from claim()");
}
return task;
}
private Task cancelClaim(String taskId, boolean forceUnclaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug(
"entry to cancelClaim(taskId = {}), userId = {}, forceUnclaim = {})",
taskId,
userId,
forceUnclaim);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
throw new InvalidStateException(TASK_WITH_ID + taskId + IS_ALREADY_COMPLETED);
}
if (state == TaskState.CLAIMED && !forceUnclaim && !userId.equals(task.getOwner())) {
throw new InvalidOwnerException(
TASK_WITH_ID + taskId + IS_ALREADY_CLAIMED_BY + task.getOwner() + ".");
}
Instant now = Instant.now();
task.setOwner(null);
task.setModified(now);
task.setClaimed(null);
task.setRead(true);
task.setState(TaskState.READY);
taskMapper.update(task);
LOGGER.debug("Task '{}' unclaimed by user '{}'.", taskId, userId);
if (HistoryEventProducer.isHistoryEnabled()) {
historyEventProducer.createEvent(new ClaimCancelledEvent(task));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from cancelClaim()");
}
return task;
}
private Task completeTask(String taskId, boolean isForced)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug(
"entry to completeTask(id = {}, userId = {}, isForced = {})", taskId, userId, isForced);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) this.getTask(taskId);
if (task.getState() == TaskState.COMPLETED) {
return task;
}
// check pre-conditions for non-forced invocation
if (!isForced) {
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
throw new InvalidStateException(TASK_WITH_ID + taskId + " has to be claimed before.");
} else if (!CurrentUserContext.getAccessIds().contains(task.getOwner())) {
throw new InvalidOwnerException(
"Owner of task "
+ taskId
+ " is "
+ task.getOwner()
+ ", but current User is "
+ userId);
}
} else {
// CLAIM-forced, if task was not already claimed before.
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
task = (TaskImpl) this.forceClaim(taskId);
}
}
Instant now = Instant.now();
task.setCompleted(now);
task.setModified(now);
task.setState(TaskState.COMPLETED);
task.setOwner(userId);
taskMapper.update(task);
LOGGER.debug("Task '{}' completed by user '{}'.", taskId, userId);
if (HistoryEventProducer.isHistoryEnabled()) {
historyEventProducer.createEvent(new CompletedEvent(task));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from completeTask()");
}
return task;
}
private void deleteTask(String taskId, boolean forceDelete)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("entry to deleteTask(taskId = {} , forceDelete = {})", taskId, forceDelete);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
if (!TaskState.COMPLETED.equals(task.getState()) && !forceDelete) {
throw new InvalidStateException(
"Cannot delete Task " + taskId + " because it is not completed.");
}
if (CallbackState.CALLBACK_PROCESSING_REQUIRED.equals(task.getCallbackState())) {
throw new InvalidStateException(
"Task " + taskId + " cannot be deleted because its callback is not yet processed");
}
taskMapper.delete(taskId);
LOGGER.debug("Task {} deleted.", taskId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteTask().");
}
}
private void removeSingleTaskForTaskDeletionById( private void removeSingleTaskForTaskDeletionById(
BulkOperationResults<String, TaskanaException> bulkLog, BulkOperationResults<String, TaskanaException> bulkLog,
List<MinimalTaskSummary> taskSummaries, List<MinimalTaskSummary> taskSummaries,

View File

@ -26,18 +26,6 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
this.taskMonitorMapper = taskMonitorMapper; this.taskMonitorMapper = taskMonitorMapper;
} }
@Override
public TaskStatusReportBuilderImpl stateIn(List<TaskState> states) {
this.states = states;
return this;
}
@Override
public TaskStatusReportBuilderImpl domainIn(List<String> domains) {
this.domains = domains;
return this;
}
@Override @Override
public TaskStatusReport buildReport() throws NotAuthorizedException { public TaskStatusReport buildReport() throws NotAuthorizedException {
LOGGER.debug("entry to buildReport(), this = {}", this); LOGGER.debug("entry to buildReport(), this = {}", this);
@ -54,4 +42,16 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
LOGGER.debug("exit from buildReport()."); LOGGER.debug("exit from buildReport().");
} }
} }
@Override
public TaskStatusReportBuilderImpl stateIn(List<TaskState> states) {
this.states = states;
return this;
}
@Override
public TaskStatusReportBuilderImpl domainIn(List<String> domains) {
this.domains = domains;
return this;
}
} }

View File

@ -84,6 +84,15 @@ public class TaskSummaryImpl implements TaskSummary {
this.externalId = externalId; this.externalId = externalId;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreator()
*/
@Override
public String getCreator() {
return creator;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreated() * @see pro.taskana.TaskSummary#getCreated()
@ -175,19 +184,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.name = name; this.name = name;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreator()
*/
@Override
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see pro.taskana.TaskSummary#getNote() * @see pro.taskana.TaskSummary#getNote()
@ -253,14 +249,12 @@ public class TaskSummaryImpl implements TaskSummary {
this.workbasketSummary = workbasketSummary; this.workbasketSummary = workbasketSummary;
} }
// utility method to allow mybatis access to workbasketSummary @Override
public WorkbasketSummaryImpl getWorkbasketSummaryImpl() { public List<AttachmentSummary> getAttachmentSummaries() {
return (WorkbasketSummaryImpl) workbasketSummary; if (attachmentSummaries == null) {
attachmentSummaries = new ArrayList<>();
} }
return attachmentSummaries;
// utility method to allow mybatis access to workbasketSummary
public void setWorkbasketSummaryImpl(WorkbasketSummaryImpl workbasketSummary) {
setWorkbasketSummary(workbasketSummary);
} }
/* /*
@ -357,25 +351,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.isTransferred = isTransferred; this.isTransferred = isTransferred;
} }
@Override
public List<AttachmentSummary> getAttachmentSummaries() {
if (attachmentSummaries == null) {
attachmentSummaries = new ArrayList<>();
}
return attachmentSummaries;
}
public void setAttachmentSummaries(List<AttachmentSummary> attachmentSummaries) {
this.attachmentSummaries = attachmentSummaries;
}
public void addAttachmentSummary(AttachmentSummary attachmentSummary) {
if (this.attachmentSummaries == null) {
this.attachmentSummaries = new ArrayList<>();
}
this.attachmentSummaries.add(attachmentSummary);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see pro.taskana.TaskSummary#getCustomAttribute(String number) * @see pro.taskana.TaskSummary#getCustomAttribute(String number)
@ -434,6 +409,31 @@ public class TaskSummaryImpl implements TaskSummary {
} }
} }
public void setAttachmentSummaries(List<AttachmentSummary> attachmentSummaries) {
this.attachmentSummaries = attachmentSummaries;
}
public void setCreator(String creator) {
this.creator = creator;
}
// 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) {
setWorkbasketSummary(workbasketSummary);
}
public void addAttachmentSummary(AttachmentSummary attachmentSummary) {
if (this.attachmentSummaries == null) {
this.attachmentSummaries = new ArrayList<>();
}
this.attachmentSummaries.add(attachmentSummary);
}
// auxiliary Method to enable Mybatis to access classificationSummary // auxiliary Method to enable Mybatis to access classificationSummary
public ClassificationSummaryImpl getClassificationSummaryImpl() { public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary; return (ClassificationSummaryImpl) classificationSummary;
@ -588,6 +588,49 @@ public class TaskSummaryImpl implements TaskSummary {
this.custom16 = custom16; this.custom16 = custom16;
} }
@Override
public int hashCode() {
return Objects.hash(
taskId,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
attachmentSummaries,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -637,49 +680,6 @@ public class TaskSummaryImpl implements TaskSummary {
&& Objects.equals(custom16, other.custom16); && Objects.equals(custom16, other.custom16);
} }
@Override
public int hashCode() {
return Objects.hash(
taskId,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
attachmentSummaries,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
}
@Override @Override
public String toString() { public String toString() {
return "TaskSummaryImpl [taskId=" return "TaskSummaryImpl [taskId="

View File

@ -169,23 +169,6 @@ public class TaskanaEngineImpl implements TaskanaEngine {
} }
} }
@Override
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException {
if (!isUserInRole(roles)) {
if (LOGGER.isDebugEnabled()) {
String accessIds = LoggerUtils.listToString(CurrentUserContext.getAccessIds());
String rolesAsString = Arrays.toString(roles);
LOGGER.debug(
"Throwing NotAuthorizedException because accessIds {} are not member of roles {}",
accessIds,
rolesAsString);
}
throw new NotAuthorizedException(
"current user is not member of role(s) " + Arrays.toString(roles),
CurrentUserContext.getUserid());
}
}
@Override @Override
public boolean isUserInRole(TaskanaRole... roles) { public boolean isUserInRole(TaskanaRole... roles) {
if (!getConfiguration().isSecurityEnabled()) { if (!getConfiguration().isSecurityEnabled()) {
@ -206,6 +189,23 @@ public class TaskanaEngineImpl implements TaskanaEngine {
return false; return false;
} }
@Override
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException {
if (!isUserInRole(roles)) {
if (LOGGER.isDebugEnabled()) {
String accessIds = LoggerUtils.listToString(CurrentUserContext.getAccessIds());
String rolesAsString = Arrays.toString(roles);
LOGGER.debug(
"Throwing NotAuthorizedException because accessIds {} are not member of roles {}",
accessIds,
rolesAsString);
}
throw new NotAuthorizedException(
"current user is not member of role(s) " + Arrays.toString(roles),
CurrentUserContext.getUserid());
}
}
/** /**
* This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and * This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and
* sets the databaseId attribute. * sets the databaseId attribute.
@ -330,16 +330,6 @@ public class TaskanaEngineImpl implements TaskanaEngine {
} }
} }
@Override
public void initSqlSession() {
if (mode == ConnectionManagementMode.EXPLICIT && connection == null) {
throw new ConnectionNotSetException();
} else if (mode != ConnectionManagementMode.EXPLICIT
&& !sessionManager.isManagedSessionStarted()) {
sessionManager.startManagedSession();
}
}
@Override @Override
public void returnConnection() { public void returnConnection() {
if (mode != ConnectionManagementMode.EXPLICIT) { if (mode != ConnectionManagementMode.EXPLICIT) {
@ -370,6 +360,16 @@ public class TaskanaEngineImpl implements TaskanaEngine {
} }
} }
@Override
public void initSqlSession() {
if (mode == ConnectionManagementMode.EXPLICIT && connection == null) {
throw new ConnectionNotSetException();
} else if (mode != ConnectionManagementMode.EXPLICIT
&& !sessionManager.isManagedSessionStarted()) {
sessionManager.startManagedSession();
}
}
@Override @Override
public boolean domainExists(String domain) { public boolean domainExists(String domain) {
return getConfiguration().getDomains().contains(domain); return getConfiguration().getDomains().contains(domain);

View File

@ -109,31 +109,6 @@ abstract class TimeIntervalReportBuilderImpl<
return _this(); return _this();
} }
@Override
public List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
throws NotAuthorizedException {
LOGGER.debug(
"entry to listCustomAttributeValuesForCustomAttributeName(customField = {}), this = {}",
customField,
this);
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
return taskMonitorMapper.getCustomAttributeValuesForReport(
this.workbasketIds,
this.states,
this.categories,
this.domains,
this.classificationIds,
this.excludedClassificationIds,
this.customAttributeFilter,
customField);
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from listCustomAttributeValuesForCustomAttributeName().");
}
}
@Override @Override
public List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems) public List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
@ -177,6 +152,31 @@ abstract class TimeIntervalReportBuilderImpl<
} }
} }
@Override
public List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
throws NotAuthorizedException {
LOGGER.debug(
"entry to listCustomAttributeValuesForCustomAttributeName(customField = {}), this = {}",
customField,
this);
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
return taskMonitorMapper.getCustomAttributeValuesForReport(
this.workbasketIds,
this.states,
this.categories,
this.domains,
this.classificationIds,
this.excludedClassificationIds,
this.customAttributeFilter,
customField);
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from listCustomAttributeValuesForCustomAttributeName().");
}
}
@SuppressWarnings("checkstyle:MethodName") @SuppressWarnings("checkstyle:MethodName")
protected abstract B _this(); protected abstract B _this();

View File

@ -44,6 +44,16 @@ public class TimestampReportBuilderImpl
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
protected TimestampReport.Builder _this() {
return this;
}
@Override
protected String determineGroupedBy() {
throw new UnsupportedOperationException();
}
@Override @Override
public TimestampReport.Builder withTimestamps(List<Timestamp> statuses) { public TimestampReport.Builder withTimestamps(List<Timestamp> statuses) {
this.status = new ArrayList<>(statuses); this.status = new ArrayList<>(statuses);
@ -77,16 +87,6 @@ public class TimestampReportBuilderImpl
} }
} }
@Override
protected TimestampReport.Builder _this() {
return this;
}
@Override
protected String determineGroupedBy() {
throw new UnsupportedOperationException();
}
private List<TimestampQueryItem> getTasksCountForStatusGroupedByOrgLevel(Timestamp s) { private List<TimestampQueryItem> getTasksCountForStatusGroupedByOrgLevel(Timestamp s) {
return taskMonitorMapper.getTasksCountForStatusGroupedByOrgLevel( return taskMonitorMapper.getTasksCountForStatusGroupedByOrgLevel(
s, s,

View File

@ -83,14 +83,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.accessId = accessId; this.accessId = accessId;
} }
public void setAccessIdWithSanitizing(String accessId) {
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
setAccessId(accessId != null ? accessId.toLowerCase() : null);
} else {
setAccessId(accessId);
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getAccessName() * @see pro.taskana.impl.WorkbasketAccessItem#getAccessName()
@ -415,6 +407,41 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.permCustom12 = permCustom12; this.permCustom12 = permCustom12;
} }
public void setAccessIdWithSanitizing(String accessId) {
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
setAccessId(accessId != null ? accessId.toLowerCase() : null);
} else {
setAccessId(accessId);
}
}
@Override
public int hashCode() {
return Objects.hash(
id,
workbasketId,
workbasketKey,
accessId,
accessName,
permRead,
permOpen,
permAppend,
permTransfer,
permDistribute,
permCustom1,
permCustom2,
permCustom3,
permCustom4,
permCustom5,
permCustom6,
permCustom7,
permCustom8,
permCustom9,
permCustom10,
permCustom11,
permCustom12);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -448,33 +475,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
&& Objects.equals(accessName, other.accessName); && Objects.equals(accessName, other.accessName);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
workbasketId,
workbasketKey,
accessId,
accessName,
permRead,
permOpen,
permAppend,
permTransfer,
permDistribute,
permCustom1,
permCustom2,
permCustom3,
permCustom4,
permCustom5,
permCustom6,
permCustom7,
permCustom8,
permCustom9,
permCustom10,
permCustom11,
permCustom12);
}
@Override @Override
public String toString() { public String toString() {
return "WorkbasketAccessItem [id=" return "WorkbasketAccessItem [id="

View File

@ -79,11 +79,6 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
return this; return this;
} }
@Override
public WorkbasketAccessItemQuery orderById(SortDirection sortDirection) {
return addOrderCriteria("ID", sortDirection);
}
@Override @Override
public WorkbasketAccessItemQuery orderByWorkbasketId(SortDirection sortDirection) { public WorkbasketAccessItemQuery orderByWorkbasketId(SortDirection sortDirection) {
return addOrderCriteria("WORKBASKET_ID", sortDirection); return addOrderCriteria("WORKBASKET_ID", sortDirection);
@ -99,6 +94,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
return addOrderCriteria("ACCESS_ID", sortDirection); return addOrderCriteria("ACCESS_ID", sortDirection);
} }
@Override
public WorkbasketAccessItemQuery orderById(SortDirection sortDirection) {
return addOrderCriteria("ID", sortDirection);
}
@Override @Override
public List<WorkbasketAccessItem> list() { public List<WorkbasketAccessItem> list() {
LOGGER.debug("entry to list(), this = {}", this); LOGGER.debug("entry to list(), this = {}", this);

View File

@ -40,6 +40,11 @@ public class WorkbasketImpl implements Workbasket {
this.id = id; this.id = id;
} }
@Override
public Instant getCreated() {
return created;
}
@Override @Override
public String getKey() { public String getKey() {
return key; return key;
@ -50,12 +55,22 @@ public class WorkbasketImpl implements Workbasket {
} }
@Override @Override
public Instant getCreated() { public String getDomain() {
return created; return domain;
} }
public void setCreated(Instant created) { public void setDomain(String domain) {
this.created = created; this.domain = domain;
}
@Override
public WorkbasketType getType() {
return type;
}
@Override
public void setType(WorkbasketType type) {
this.type = type;
} }
@Override @Override
@ -97,25 +112,6 @@ public class WorkbasketImpl implements Workbasket {
this.owner = owner; this.owner = owner;
} }
@Override
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
@Override
public WorkbasketType getType() {
return type;
}
@Override
public void setType(WorkbasketType type) {
this.type = type;
}
@Override @Override
public String getCustom1() { public String getCustom1() {
return custom1; return custom1;
@ -228,6 +224,33 @@ public class WorkbasketImpl implements Workbasket {
return result; return result;
} }
public void setCreated(Instant created) {
this.created = created;
}
@Override
public int hashCode() {
return Objects.hash(
id,
key,
created,
modified,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -257,29 +280,6 @@ public class WorkbasketImpl implements Workbasket {
&& Objects.equals(orgLevel4, other.orgLevel4); && Objects.equals(orgLevel4, other.orgLevel4);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
created,
modified,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public String toString() { public String toString() {
return "WorkbasketImpl [id=" return "WorkbasketImpl [id="

View File

@ -128,12 +128,6 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
return this; return this;
} }
@Override
public WorkbasketQuery domainLike(String... domain) {
this.domainLike = domain;
return this;
}
@Override @Override
public WorkbasketQuery typeIn(WorkbasketType... type) { public WorkbasketQuery typeIn(WorkbasketType... type) {
this.type = type; this.type = type;
@ -180,6 +174,109 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
return this; return this;
} }
@Override
public WorkbasketQuery accessIdsHavePermission(
WorkbasketPermission permission, String... accessIds)
throws InvalidArgumentException, NotAuthorizedException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
// Checking pre-conditions
if (permission == null) {
throw new InvalidArgumentException("Permission can´t be null.");
}
if (accessIds == null || accessIds.length == 0) {
throw new InvalidArgumentException("accessIds can´t be NULL or empty.");
}
// set up permissions and ids
this.permission = permission;
this.accessId = accessIds;
lowercaseAccessIds(this.accessId);
return this;
}
@Override
public WorkbasketQuery callerHasPermission(WorkbasketPermission permission) {
this.permission = permission;
return this;
}
@Override
public WorkbasketQuery orderByName(SortDirection sortDirection) {
return addOrderCriteria("NAME", sortDirection);
}
@Override
public WorkbasketQuery orderByKey(SortDirection sortDirection) {
return addOrderCriteria("KEY", sortDirection);
}
@Override
public WorkbasketQuery orderByDescription(SortDirection sortDirection) {
return addOrderCriteria("DESCRIPTION", sortDirection);
}
@Override
public WorkbasketQuery orderByOwner(SortDirection sortDirection) {
return addOrderCriteria("OWNER", sortDirection);
}
@Override
public WorkbasketQuery orderByType(SortDirection sortDirection) {
return addOrderCriteria("TYPE", sortDirection);
}
@Override
public WorkbasketQuery orderByDomain(SortDirection sortDirection) {
return addOrderCriteria("DOMAIN", sortDirection);
}
@Override
public WorkbasketQuery domainLike(String... domain) {
this.domainLike = domain;
return this;
}
@Override
public WorkbasketQuery orderByCustom1(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_1", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom2(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_2", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom3(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_3", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom4(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_4", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel1(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_1", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel2(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_2", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel3(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_3", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel4(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_4", sortDirection);
}
@Override @Override
public WorkbasketQuery custom1In(String... custom1) { public WorkbasketQuery custom1In(String... custom1) {
this.custom1In = custom1; this.custom1In = custom1;
@ -282,103 +379,6 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
return this; return this;
} }
@Override
public WorkbasketQuery orderByName(SortDirection sortDirection) {
return addOrderCriteria("NAME", sortDirection);
}
@Override
public WorkbasketQuery orderByKey(SortDirection sortDirection) {
return addOrderCriteria("KEY", sortDirection);
}
@Override
public WorkbasketQuery orderByDomain(SortDirection sortDirection) {
return addOrderCriteria("DOMAIN", sortDirection);
}
@Override
public WorkbasketQuery orderByDescription(SortDirection sortDirection) {
return addOrderCriteria("DESCRIPTION", sortDirection);
}
@Override
public WorkbasketQuery orderByOwner(SortDirection sortDirection) {
return addOrderCriteria("OWNER", sortDirection);
}
@Override
public WorkbasketQuery orderByType(SortDirection sortDirection) {
return addOrderCriteria("TYPE", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom1(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_1", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom2(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_2", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom3(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_3", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom4(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_4", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel1(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_1", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel2(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_2", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel3(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_3", sortDirection);
}
@Override
public WorkbasketQuery orderByOrgLevel4(SortDirection sortDirection) {
return addOrderCriteria("ORG_LEVEL_4", sortDirection);
}
@Override
public WorkbasketQuery accessIdsHavePermission(
WorkbasketPermission permission, String... accessIds)
throws InvalidArgumentException, NotAuthorizedException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
// Checking pre-conditions
if (permission == null) {
throw new InvalidArgumentException("Permission can´t be null.");
}
if (accessIds == null || accessIds.length == 0) {
throw new InvalidArgumentException("accessIds can´t be NULL or empty.");
}
// set up permissions and ids
this.permission = permission;
this.accessId = accessIds;
lowercaseAccessIds(this.accessId);
return this;
}
@Override
public WorkbasketQuery callerHasPermission(WorkbasketPermission permission) {
this.permission = permission;
return this;
}
@Override @Override
public List<WorkbasketSummary> list() { public List<WorkbasketSummary> list() {
LOGGER.debug("entry to list(), this = {}", this); LOGGER.debug("entry to list(), this = {}", this);

View File

@ -204,53 +204,32 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public void setWorkbasketAccessItems( public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug( LOGGER.debug(
"entry to setWorkbasketAccessItems(workbasketAccessItems = {})", wbAccessItems.toString()); "entry to updateWorkbasketAccessItem(workbasketAccessItem = {}", workbasketAccessItem);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
List<WorkbasketAccessItemImpl> newItems = new ArrayList<>(); WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
// Check pre-conditions and set ID WorkbasketAccessItem originalItem = workbasketAccessMapper.findById(accessItem.getId());
if (!wbAccessItems.isEmpty()) {
for (WorkbasketAccessItem workbasketAccessItem : wbAccessItems) { if ((originalItem.getAccessId() != null
WorkbasketAccessItemImpl wbAccessItemImpl = && !originalItem.getAccessId().equals(accessItem.getAccessId()))
(WorkbasketAccessItemImpl) workbasketAccessItem; || (originalItem.getWorkbasketId() != null
if (wbAccessItemImpl.getWorkbasketId() == null) { && !originalItem.getWorkbasketId().equals(accessItem.getWorkbasketId()))) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
String.format( "AccessId and WorkbasketId must not be changed in updateWorkbasketAccessItem calls");
"Checking the preconditions of the current WorkbasketAccessItem failed "
+ "- WBID is NULL. WorkbasketAccessItem=%s",
workbasketAccessItem));
} else if (!wbAccessItemImpl.getWorkbasketId().equals(workbasketId)) {
throw new InvalidArgumentException(
String.format(
"Checking the preconditions of the current WorkbasketAccessItem failed "
+ "- the WBID does not match. Target-WBID=''%s'' WorkbasketAccessItem=%s",
workbasketId, workbasketAccessItem));
}
if (wbAccessItemImpl.getId() == null || wbAccessItemImpl.getId().isEmpty()) {
wbAccessItemImpl.setId(
IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
}
newItems.add(wbAccessItemImpl);
}
} }
// delete all current ones workbasketAccessMapper.update(accessItem);
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId); LOGGER.debug(
"Method updateWorkbasketAccessItem() updated workbasketAccessItem {}", accessItem);
// add all return accessItem;
if (!newItems.isEmpty()) {
newItems.forEach(item -> workbasketAccessMapper.insert(item));
}
} finally { } finally {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug( LOGGER.debug(
"exit from setWorkbasketAccessItems(workbasketAccessItems = {})", "exit from updateWorkbasketAccessItem(workbasketAccessItem). Returning {}", accessItem);
wbAccessItems.toString());
} }
} }
@ -270,20 +249,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
} }
@Override
public void deleteWorkbasketAccessItemsForAccessId(String accessId)
throws NotAuthorizedException {
LOGGER.debug("entry to deleteWorkbasketAccessItemsForAccessId(accessId = {})", accessId);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try {
taskanaEngine.openConnection();
workbasketAccessMapper.deleteAccessItemsForAccessId(accessId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteWorkbasketAccessItemsForAccessId(accessId={}).", accessId);
}
}
@Override @Override
public void checkAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions) public void checkAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
@ -389,36 +354,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
} }
@Override
public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug(
"entry to updateWorkbasketAccessItem(workbasketAccessItem = {}", workbasketAccessItem);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
try {
taskanaEngine.openConnection();
WorkbasketAccessItem originalItem = workbasketAccessMapper.findById(accessItem.getId());
if ((originalItem.getAccessId() != null
&& !originalItem.getAccessId().equals(accessItem.getAccessId()))
|| (originalItem.getWorkbasketId() != null
&& !originalItem.getWorkbasketId().equals(accessItem.getWorkbasketId()))) {
throw new InvalidArgumentException(
"AccessId and WorkbasketId must not be changed in updateWorkbasketAccessItem calls");
}
workbasketAccessMapper.update(accessItem);
LOGGER.debug(
"Method updateWorkbasketAccessItem() updated workbasketAccessItem {}", accessItem);
return accessItem;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug(
"exit from updateWorkbasketAccessItem(workbasketAccessItem). Returning {}", accessItem);
}
}
@Override @Override
public List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId) public List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId)
throws NotAuthorizedException { throws NotAuthorizedException {
@ -443,11 +378,54 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId) { public void setWorkbasketAccessItems(
WorkbasketAccessItem wbAcc = String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
workbasketAccessMapper.findByWorkbasketAndAccessId( throws InvalidArgumentException, NotAuthorizedException {
workbasketId, CurrentUserContext.getAccessIds()); LOGGER.debug(
return this.getPermissionsFromWorkbasketAccessItem(wbAcc); "entry to setWorkbasketAccessItems(workbasketAccessItems = {})", wbAccessItems.toString());
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
List<WorkbasketAccessItemImpl> newItems = new ArrayList<>();
try {
taskanaEngine.openConnection();
// Check pre-conditions and set ID
if (!wbAccessItems.isEmpty()) {
for (WorkbasketAccessItem workbasketAccessItem : wbAccessItems) {
WorkbasketAccessItemImpl wbAccessItemImpl =
(WorkbasketAccessItemImpl) workbasketAccessItem;
if (wbAccessItemImpl.getWorkbasketId() == null) {
throw new InvalidArgumentException(
String.format(
"Checking the preconditions of the current WorkbasketAccessItem failed "
+ "- WBID is NULL. WorkbasketAccessItem=%s",
workbasketAccessItem));
} else if (!wbAccessItemImpl.getWorkbasketId().equals(workbasketId)) {
throw new InvalidArgumentException(
String.format(
"Checking the preconditions of the current WorkbasketAccessItem failed "
+ "- the WBID does not match. Target-WBID=''%s'' WorkbasketAccessItem=%s",
workbasketId, workbasketAccessItem));
}
if (wbAccessItemImpl.getId() == null || wbAccessItemImpl.getId().isEmpty()) {
wbAccessItemImpl.setId(
IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
}
newItems.add(wbAccessItemImpl);
}
}
// delete all current ones
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId);
// add all
if (!newItems.isEmpty()) {
newItems.forEach(item -> workbasketAccessMapper.insert(item));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug(
"exit from setWorkbasketAccessItems(workbasketAccessItems = {})",
wbAccessItems.toString());
}
} }
@Override @Override
@ -455,6 +433,12 @@ public class WorkbasketServiceImpl implements WorkbasketService {
return new WorkbasketQueryImpl(taskanaEngine); return new WorkbasketQueryImpl(taskanaEngine);
} }
@Override
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine);
}
@Override @Override
public Workbasket newWorkbasket(String key, String domain) { public Workbasket newWorkbasket(String key, String domain) {
WorkbasketImpl wb = new WorkbasketImpl(); WorkbasketImpl wb = new WorkbasketImpl();
@ -463,6 +447,14 @@ public class WorkbasketServiceImpl implements WorkbasketService {
return wb; return wb;
} }
@Override
public List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId) {
WorkbasketAccessItem wbAcc =
workbasketAccessMapper.findByWorkbasketAndAccessId(
workbasketId, CurrentUserContext.getAccessIds());
return this.getPermissionsFromWorkbasketAccessItem(wbAcc);
}
@Override @Override
public List<WorkbasketSummary> getDistributionTargets(String workbasketId) public List<WorkbasketSummary> getDistributionTargets(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
@ -520,63 +512,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
} }
@Override
public List<WorkbasketSummary> getDistributionSources(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("entry to getDistributionSources(workbasketId = {})", workbasketId);
List<WorkbasketSummary> result = new ArrayList<>();
try {
taskanaEngine.openConnection();
// check that source workbasket exists
getWorkbasket(workbasketId);
if (!taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN)) {
checkAuthorization(workbasketId, WorkbasketPermission.READ);
}
List<WorkbasketSummaryImpl> distributionSources =
workbasketMapper.findDistributionSources(workbasketId);
result.addAll(distributionSources);
return result;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result.size();
LOGGER.debug(
"exit from getDistributionSources(workbasketId). Returning {} resulting Objects: {} ",
numberOfResultObjects,
LoggerUtils.listToString(result));
}
}
}
@Override
public List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug(
"entry to getDistributionSources(workbasketKey = {}, domain = {})", workbasketKey, domain);
List<WorkbasketSummary> result = new ArrayList<>();
try {
taskanaEngine.openConnection();
// check that source workbasket exists
Workbasket workbasket = getWorkbasket(workbasketKey, domain);
if (!taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN)) {
checkAuthorization(workbasket.getId(), WorkbasketPermission.READ);
}
List<WorkbasketSummaryImpl> distributionSources =
workbasketMapper.findDistributionSources(workbasket.getId());
result.addAll(distributionSources);
return result;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result.size();
LOGGER.debug(
"exit from getDistributionSources(workbasketId). Returning {} resulting Objects: {} ",
numberOfResultObjects,
LoggerUtils.listToString(result));
}
}
}
@Override @Override
public void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds) public void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
@ -811,9 +746,74 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException { public List<WorkbasketSummary> getDistributionSources(String workbasketId)
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN); throws NotAuthorizedException, WorkbasketNotFoundException {
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine); LOGGER.debug("entry to getDistributionSources(workbasketId = {})", workbasketId);
List<WorkbasketSummary> result = new ArrayList<>();
try {
taskanaEngine.openConnection();
// check that source workbasket exists
getWorkbasket(workbasketId);
if (!taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN)) {
checkAuthorization(workbasketId, WorkbasketPermission.READ);
}
List<WorkbasketSummaryImpl> distributionSources =
workbasketMapper.findDistributionSources(workbasketId);
result.addAll(distributionSources);
return result;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result.size();
LOGGER.debug(
"exit from getDistributionSources(workbasketId). Returning {} resulting Objects: {} ",
numberOfResultObjects,
LoggerUtils.listToString(result));
}
}
}
@Override
public List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug(
"entry to getDistributionSources(workbasketKey = {}, domain = {})", workbasketKey, domain);
List<WorkbasketSummary> result = new ArrayList<>();
try {
taskanaEngine.openConnection();
// check that source workbasket exists
Workbasket workbasket = getWorkbasket(workbasketKey, domain);
if (!taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN)) {
checkAuthorization(workbasket.getId(), WorkbasketPermission.READ);
}
List<WorkbasketSummaryImpl> distributionSources =
workbasketMapper.findDistributionSources(workbasket.getId());
result.addAll(distributionSources);
return result;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result.size();
LOGGER.debug(
"exit from getDistributionSources(workbasketId). Returning {} resulting Objects: {} ",
numberOfResultObjects,
LoggerUtils.listToString(result));
}
}
}
@Override
public void deleteWorkbasketAccessItemsForAccessId(String accessId)
throws NotAuthorizedException {
LOGGER.debug("entry to deleteWorkbasketAccessItemsForAccessId(accessId = {})", accessId);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try {
taskanaEngine.openConnection();
workbasketAccessMapper.deleteAccessItemsForAccessId(accessId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteWorkbasketAccessItemsForAccessId(accessId={}).", accessId);
}
} }
private boolean skipAuthorizationCheck() { private boolean skipAuthorizationCheck() {

View File

@ -231,6 +231,27 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.markedForDeletion = markedForDeletion; this.markedForDeletion = markedForDeletion;
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@ -258,27 +279,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
&& Objects.equals(orgLevel4, other.orgLevel4); && Objects.equals(orgLevel4, other.orgLevel4);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public String toString() { public String toString() {
return "WorkbasketSummaryImpl [id=" return "WorkbasketSummaryImpl [id="

View File

@ -19,6 +19,11 @@ public class MonitorQueryItem implements AgeQueryItem {
this.key = key; this.key = key;
} }
@Override
public int getValue() {
return numberOfTasks;
}
@Override @Override
public int getAgeInDays() { public int getAgeInDays() {
return ageInDays; return ageInDays;
@ -29,11 +34,6 @@ public class MonitorQueryItem implements AgeQueryItem {
this.ageInDays = ageInDays; this.ageInDays = ageInDays;
} }
@Override
public int getValue() {
return numberOfTasks;
}
public void setNumberOfTasks(int numberOfTasks) { public void setNumberOfTasks(int numberOfTasks) {
this.numberOfTasks = numberOfTasks; this.numberOfTasks = numberOfTasks;
} }

View File

@ -37,14 +37,6 @@ public abstract class FoldableRow<I extends QueryItem> extends SingleRow<I> {
return foldableRows.keySet(); return foldableRows.keySet();
} }
@Override
public void updateTotalValue(I item) {
super.updateTotalValue(item);
foldableRows
.computeIfAbsent(calcFoldableRowKey.apply(item), (s) -> buildRow(columnSize))
.updateTotalValue(item);
}
@Override @Override
public void addItem(I item, int index) throws IndexOutOfBoundsException { public void addItem(I item, int index) throws IndexOutOfBoundsException {
super.addItem(item, index); super.addItem(item, index);
@ -53,6 +45,14 @@ public abstract class FoldableRow<I extends QueryItem> extends SingleRow<I> {
.addItem(item, index); .addItem(item, index);
} }
@Override
public void updateTotalValue(I item) {
super.updateTotalValue(item);
foldableRows
.computeIfAbsent(calcFoldableRowKey.apply(item), (s) -> buildRow(columnSize))
.updateTotalValue(item);
}
public Row<I> getFoldableRow(String key) { public Row<I> getFoldableRow(String key) {
return foldableRows.get(key); return foldableRows.get(key);
} }

View File

@ -22,9 +22,7 @@ public class CategoryReport extends Report<MonitorQueryItem, TimeIntervalColumnH
super(timeIntervalColumnHeaders, new String[] {"CLASSIFICATION CATEGORIES"}); super(timeIntervalColumnHeaders, new String[] {"CLASSIFICATION CATEGORIES"});
} }
/** /** Builder for {@link CategoryReport}. */
* Builder for {@link CategoryReport}.
*/
public interface Builder public interface Builder
extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> { extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> {

View File

@ -95,7 +95,8 @@ public final class CurrentUserContext {
LOGGER.debug("Public credentials of caller: {}", publicCredentials); LOGGER.debug("Public credentials of caller: {}", publicCredentials);
for (Object credential : publicCredentials) { for (Object credential : publicCredentials) {
Object o = Object o =
credential.getClass() credential
.getClass()
.getMethod(GET_UNIQUE_SECURITY_NAME_METHOD, (Class<?>[]) null) .getMethod(GET_UNIQUE_SECURITY_NAME_METHOD, (Class<?>[]) null)
.invoke(credential, (Object[]) null); .invoke(credential, (Object[]) null);
LOGGER.debug("Returning the unique security name of first public credential: {}", o); LOGGER.debug("Returning the unique security name of first public credential: {}", o);

View File

@ -67,6 +67,11 @@ public class TestClassificationQuery implements ClassificationQuery {
return this; return this;
} }
@Override
public ClassificationQuery modifiedWithin(TimeInterval... modifiedIn) {
return this;
}
@Override @Override
public ClassificationQuery nameIn(String... name) { public ClassificationQuery nameIn(String... name) {
return this; return this;
@ -117,28 +122,6 @@ public class TestClassificationQuery implements ClassificationQuery {
return this; return this;
} }
@Override
public List<ClassificationSummary> list() {
List<ClassificationSummary> returnedClassifications = new ArrayList<>();
returnedClassifications.addAll(classifications);
return returnedClassifications;
}
@Override
public List<ClassificationSummary> list(int offset, int limit) {
return new ArrayList<>();
}
@Override
public ClassificationSummary single() {
return null;
}
@Override
public long count() {
return 0;
}
@Override @Override
public ClassificationQuery orderByKey(SortDirection sortDirection) { public ClassificationQuery orderByKey(SortDirection sortDirection) {
return this; return this;
@ -190,8 +173,15 @@ public class TestClassificationQuery implements ClassificationQuery {
} }
@Override @Override
public ClassificationQuery modifiedWithin(TimeInterval... modifiedIn) { public List<ClassificationSummary> list() {
return this; List<ClassificationSummary> returnedClassifications = new ArrayList<>();
returnedClassifications.addAll(classifications);
return returnedClassifications;
}
@Override
public List<ClassificationSummary> list(int offset, int limit) {
return new ArrayList<>();
} }
@Override @Override
@ -199,4 +189,14 @@ public class TestClassificationQuery implements ClassificationQuery {
ClassificationQueryColumnName dbColumnName, SortDirection sortDirection) { ClassificationQueryColumnName dbColumnName, SortDirection sortDirection) {
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public ClassificationSummary single() {
return null;
}
@Override
public long count() {
return 0;
}
} }

View File

@ -46,8 +46,9 @@ import pro.taskana.sampledata.SampleDataGenerator;
*/ */
public class ClassificationServiceImplIntExplicitTest { public class ClassificationServiceImplIntExplicitTest {
static int counter = 0;
private static final String ID_PREFIX_CLASSIFICATION = "CLI"; private static final String ID_PREFIX_CLASSIFICATION = "CLI";
@SuppressWarnings("checkstyle:DeclarationOrder")
static int counter = 0;
private DataSource dataSource; private DataSource dataSource;
private ClassificationService classificationService; private ClassificationService classificationService;
private TaskanaEngineConfiguration taskanaEngineConfiguration; private TaskanaEngineConfiguration taskanaEngineConfiguration;

View File

@ -224,8 +224,8 @@ class TaskServiceImplIntAutocommitTest {
final Workbasket destinationWB = workbasketService.createWorkbasket(wb); final Workbasket destinationWB = workbasketService.createWorkbasket(wb);
// Classification required for Task // Classification required for Task
ClassificationImpl classification = (ClassificationImpl) classificationService ClassificationImpl classification =
.newClassification("KEY", "DOMAIN_A", "TASK"); (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL"); classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification"); classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification); classificationService.createClassification(classification);

View File

@ -328,8 +328,8 @@ class TaskServiceImplIntExplicitTest {
createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true); createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true);
// Classification required for Task // Classification required for Task
ClassificationImpl classification = (ClassificationImpl) classificationService ClassificationImpl classification =
.newClassification("KEY", "DOMAIN_A", "TASK"); (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL"); classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification"); classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification); classificationService.createClassification(classification);

View File

@ -45,9 +45,9 @@ import pro.taskana.security.WithAccessId;
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class WorkbasketServiceImplIntExplicitTest { class WorkbasketServiceImplIntExplicitTest {
static int counter = 0;
private static final int SLEEP_TIME = 100; private static final int SLEEP_TIME = 100;
@SuppressWarnings("checkstyle:DeclarationOrder")
static int counter = 0;
private DataSource dataSource; private DataSource dataSource;
private TaskanaEngineConfiguration taskanaEngineConfiguration; private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine; private TaskanaEngine taskanaEngine;

View File

@ -37,9 +37,12 @@ public class JaasExtension implements InvocationInterceptor {
} }
} }
subject.getPrincipals().addAll(principalList); subject.getPrincipals().addAll(principalList);
Subject.doAs( Subject.doAs(subject, getObjectPrivilegedExceptionAction(invocation, invocationContext));
subject, }
(PrivilegedExceptionAction<Object>) () -> {
private PrivilegedExceptionAction<Object> getObjectPrivilegedExceptionAction(
Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext) {
return () -> {
try { try {
invocation.proceed(); invocation.proceed();
} catch (Exception | Error e) { } catch (Exception | Error e) {
@ -49,6 +52,6 @@ public class JaasExtension implements InvocationInterceptor {
"Execution of test failed: " + invocationContext.getExecutable().getName(), e); "Execution of test failed: " + invocationContext.getExecutable().getName(), e);
} }
return null; return null;
}); };
} }
} }

View File

@ -18,8 +18,7 @@ final class SqlReplacer {
static final DateTimeFormatter DATE_TIME_FORMATTER = static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
private SqlReplacer() { private SqlReplacer() {}
}
static String getScriptAsSql(String dbProductName, LocalDateTime now, String scriptPath) { static String getScriptAsSql(String dbProductName, LocalDateTime now, String scriptPath) {
return parseAndReplace(getScriptBufferedStream(scriptPath), now, dbProductName); return parseAndReplace(getScriptBufferedStream(scriptPath), now, dbProductName);

View File

@ -38,9 +38,7 @@ import pro.taskana.jobs.TaskCleanupJob;
import pro.taskana.jobs.WorkbasketCleanupJob; import pro.taskana.jobs.WorkbasketCleanupJob;
import pro.taskana.transaction.TaskanaTransactionProvider; import pro.taskana.transaction.TaskanaTransactionProvider;
/** /** Test for internal transaction management. */
* Test for internal transaction management.
*/
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest( @SpringBootTest(
classes = TaskanaConfigTestApplication.class, classes = TaskanaConfigTestApplication.class,

View File

@ -146,8 +146,45 @@
<option name="INDENT_SIZE" value="2" /> <option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" /> <option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" /> <option name="TAB_SIZE" value="2" />
<option name="USE_RELATIVE_INDENTS" value="true" />
</indentOptions> </indentOptions>
<arrangement> <arrangement>
<tokens>
<token id="visibility" name="visibility">
<rules>
<rule>
<match>
<PUBLIC>true</PUBLIC>
</match>
</rule>
<rule>
<match>
<PROTECTED>true</PROTECTED>
</match>
</rule>
<rule>
<match>
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
</match>
</rule>
<rule>
<match>
<PRIVATE>true</PRIVATE>
</match>
</rule>
</rules>
</token>
</tokens>
<groups>
<group>
<type>GETTERS_AND_SETTERS</type>
<order>KEEP</order>
</group>
<group>
<type>OVERRIDDEN_METHODS</type>
<order>KEEP</order>
</group>
</groups>
<rules> <rules>
<section> <section>
<rule> <rule>

View File

@ -24,18 +24,6 @@ public class SampleLoginModule extends UsernamePasswordAuthenticationFilter impl
private Subject subject; private Subject subject;
@Override
public boolean abort() {
return true;
}
@Override
public boolean commit() {
addUserPrincipalToSubject();
addGroupSubjectsDerivedFromUsername();
return true;
}
@Override @Override
public void initialize( public void initialize(
Subject subject, Subject subject,
@ -60,6 +48,18 @@ public class SampleLoginModule extends UsernamePasswordAuthenticationFilter impl
return nameCallback.getName().equals(new String(passwordCallback.getPassword())); return nameCallback.getName().equals(new String(passwordCallback.getPassword()));
} }
@Override
public boolean commit() {
addUserPrincipalToSubject();
addGroupSubjectsDerivedFromUsername();
return true;
}
@Override
public boolean abort() {
return true;
}
@Override @Override
public boolean logout() { public boolean logout() {
return true; return true;

View File

@ -41,8 +41,9 @@ import pro.taskana.rest.resource.TaskResourceAssembler;
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class AsyncUpdateJobIntTest { class AsyncUpdateJobIntTest {
static RestTemplate template;
private static final String CLASSIFICATION_ID = "CLI:100000000000000000000000000000000003"; private static final String CLASSIFICATION_ID = "CLI:100000000000000000000000000000000003";
@SuppressWarnings("checkstyle:DeclarationOrder")
static RestTemplate template;
@Autowired ClassificationResourceAssembler classificationResourceAssembler; @Autowired ClassificationResourceAssembler classificationResourceAssembler;
@Autowired TaskResourceAssembler taskResourceAssembler; @Autowired TaskResourceAssembler taskResourceAssembler;
@Autowired JobScheduler jobScheduler; @Autowired JobScheduler jobScheduler;

View File

@ -81,12 +81,28 @@ public class WildflyWebSecurityConfig extends WebSecurityConfig {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public boolean isEnabled() { public Collection<? extends GrantedAuthority> getAuthorities() {
return true; List<GrantedAuthority> authorities = new ArrayList<>();
SecurityIdentity securityIdentity = getSecurityIdentity();
if (securityIdentity != null) {
Roles roles = securityIdentity.getRoles();
roles.forEach(role -> authorities.add(new SimpleGrantedAuthority(role)));
}
return authorities;
} }
@Override @Override
public boolean isCredentialsNonExpired() { public String getPassword() {
return (String) token.getCredentials();
}
@Override
public String getUsername() {
return token.getName();
}
@Override
public boolean isAccountNonExpired() {
return true; return true;
} }
@ -96,29 +112,13 @@ public class WildflyWebSecurityConfig extends WebSecurityConfig {
} }
@Override @Override
public boolean isAccountNonExpired() { public boolean isCredentialsNonExpired() {
return true; return true;
} }
@Override @Override
public String getUsername() { public boolean isEnabled() {
return token.getName(); return true;
}
@Override
public String getPassword() {
return (String) token.getCredentials();
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> authorities = new ArrayList<>();
SecurityIdentity securityIdentity = getSecurityIdentity();
if (securityIdentity != null) {
Roles roles = securityIdentity.getRoles();
roles.forEach(role -> authorities.add(new SimpleGrantedAuthority(role)));
}
return authorities;
} }
private SecurityIdentity getSecurityIdentity() { private SecurityIdentity getSecurityIdentity() {

View File

@ -3,7 +3,7 @@ package pro.taskana.rest;
/** Collection of Url to Controller mappings. */ /** Collection of Url to Controller mappings. */
public final class Mapping { public final class Mapping {
private static final String PRE = "/api/v1/"; public static final String PRE = "/api/v1/";
public static final String URL_ACCESSID = PRE + "access-ids"; public static final String URL_ACCESSID = PRE + "access-ids";
public static final String URL_ACCESSID_GROUPS = URL_ACCESSID + "/groups"; public static final String URL_ACCESSID_GROUPS = URL_ACCESSID + "/groups";
public static final String URL_CLASSIFICATIONS = PRE + "classifications"; public static final String URL_CLASSIFICATIONS = PRE + "classifications";

View File

@ -17,15 +17,15 @@ public class DistributionTargetListResource extends PagedResources<DistributionT
super(content, null, links); super(content, null, links);
} }
@Override
@JsonProperty("distributionTargets")
public Collection<DistributionTargetResource> getContent() {
return super.getContent();
}
@Override @Override
@JsonIgnore @JsonIgnore
public PageMetadata getMetadata() { public PageMetadata getMetadata() {
return super.getMetadata(); return super.getMetadata();
} }
@Override
@JsonProperty("distributionTargets")
public Collection<DistributionTargetResource> getContent() {
return super.getContent();
}
} }

View File

@ -14,10 +14,7 @@ import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.PagedResources.PageMetadata; import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.rest.resource.links.PageLinks; import pro.taskana.rest.resource.links.PageLinks;
/** Resource assembler for {@link WorkbasketSummaryResource}. */
/**
* Resource assembler for {@link WorkbasketSummaryResource}.
*/
@Component @Component
public class WorkbasketSummaryResourceAssembler public class WorkbasketSummaryResourceAssembler
extends ResourceAssemblerSupport<WorkbasketSummary, WorkbasketSummaryResource> { extends ResourceAssemblerSupport<WorkbasketSummary, WorkbasketSummaryResource> {

View File

@ -281,8 +281,8 @@ class TaskControllerIntTest {
@Test @Test
void testGetTaskWithAttachments() throws IOException { void testGetTaskWithAttachments() throws IOException {
final URL url = new URL(restHelper.toUrl("/api/v1/tasks/" final URL url =
+ "TKI:000000000000000000000000000000000002")); new URL(restHelper.toUrl("/api/v1/tasks/" + "TKI:000000000000000000000000000000000002"));
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");

View File

@ -26,18 +26,6 @@ public class SampleLoginModule extends UsernamePasswordAuthenticationFilter impl
private Subject subject; private Subject subject;
@Override
public boolean abort() {
return true;
}
@Override
public boolean commit() {
addUserPrincipalToSubject();
addGroupSubjectsDerivedFromUsername();
return true;
}
@Override @Override
public void initialize( public void initialize(
Subject subject, Subject subject,
@ -62,6 +50,18 @@ public class SampleLoginModule extends UsernamePasswordAuthenticationFilter impl
return nameCallback.getName().equals(new String(passwordCallback.getPassword())); return nameCallback.getName().equals(new String(passwordCallback.getPassword()));
} }
@Override
public boolean commit() {
addUserPrincipalToSubject();
addGroupSubjectsDerivedFromUsername();
return true;
}
@Override
public boolean abort() {
return true;
}
@Override @Override
public boolean logout() { public boolean logout() {
return true; return true;