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 TransactionFactory transactionFactory;
protected TaskanaHistory taskanaHistoryService;
TaskanaEngineConfiguration taskanaEngineConfiguration;
protected TaskanaHistoryEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration)
@ -58,51 +57,6 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
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() {
Environment environment =
new Environment(
@ -158,6 +112,51 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
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.
*

View File

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

View File

@ -21,13 +21,18 @@ import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
/** Set up database for tests. */
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 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() {
// not called
}

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" />
</Root>
</Loggers>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>

View File

@ -1,6 +1,7 @@
<?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"
xsi:schemaLocation="
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,6 +52,11 @@ public class TimeInterval {
this.end = end;
}
@Override
public int hashCode() {
return Objects.hash(begin, end);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
@ -64,11 +69,6 @@ public class TimeInterval {
return Objects.equals(begin, other.begin) && Objects.equals(end, other.end);
}
@Override
public int hashCode() {
return Objects.hash(begin, end);
}
@Override
public String toString() {
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() {
return businessProcessId;
}
@ -81,6 +73,14 @@ public class TaskEvent extends TaskanaHistoryEvent {
this.parentBusinessProcessId = parentBusinessProcessId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getDomain() {
return domain;
}
@ -97,30 +97,6 @@ public class TaskEvent extends TaskanaHistoryEvent {
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() {
return porCompany;
}
@ -161,6 +137,30 @@ public class TaskEvent extends TaskanaHistoryEvent {
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
public String toString() {
return "TaskEvent [taskId= "

View File

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

View File

@ -75,16 +75,6 @@ public class AttachmentImpl implements Attachment {
this.classificationSummary = classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) {
this.classificationSummary = classificationSummary;
}
@Override
public ObjectReference getObjectReference() {
return objectReference;
@ -142,6 +132,16 @@ public class AttachmentImpl implements Attachment {
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
public int hashCode() {
return Objects.hash(

View File

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

View File

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

View File

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

View File

@ -50,6 +50,128 @@ public class ClassificationServiceImpl implements ClassificationService {
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
public Classification createClassification(Classification classification)
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
public ClassificationQuery createClassificationQuery() {
return new ClassificationQueryImpl(taskanaEngine);
@ -191,80 +265,6 @@ public class ClassificationServiceImpl implements ClassificationService {
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 {
try {
Duration.parse(serviceLevel);

View File

@ -28,24 +28,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
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
public String getId() {
return id;
@ -114,8 +96,18 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
return parentKey;
}
public void setParentKey(String parentKey) {
this.parentKey = parentKey;
@Override
public String getServiceLevel() {
return serviceLevel;
}
@Override
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
@Override
@ -190,6 +182,41 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
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
public boolean equals(Object obj) {
@ -224,33 +251,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
&& 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
public String toString() {
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() {
return company;
}
@ -203,20 +217,6 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
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) {
String orderByDirection =
" " + (sortDirection == null ? SortDirection.ASCENDING : sortDirection);

View File

@ -93,6 +93,11 @@ public class TaskImpl implements Task {
this.externalId = externalId;
}
@Override
public String getCreator() {
return creator;
}
@Override
public Instant getCreated() {
return created;
@ -159,15 +164,6 @@ public class TaskImpl implements Task {
this.name = name;
}
@Override
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
@Override
public String getDescription() {
return description;
@ -178,16 +174,6 @@ public class TaskImpl implements Task {
this.description = description;
}
@Override
public String getNote() {
return note;
}
@Override
public void setNote(String note) {
this.note = note;
}
@Override
public int getPriority() {
return priority;
@ -215,16 +201,29 @@ public class TaskImpl implements Task {
this.classificationSummary = classificationSummary;
}
@Override
public String getClassificationCategory() {
return this.classificationSummary == null ? null : this.classificationSummary.getCategory();
public void setCreator(String creator) {
this.creator = creator;
}
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) {
this.classificationSummary = new ClassificationSummaryImpl();
}
((ClassificationSummaryImpl) this.classificationSummary).setCategory(classificationCategory);
((ClassificationSummaryImpl) this.classificationSummary).setKey(classificationKey);
}
@Override
@ -344,14 +343,6 @@ public class TaskImpl implements Task {
this.callbackInfo = callbackInfo;
}
public CallbackState getCallbackState() {
return callbackState;
}
public void setCallbackState(CallbackState callbackState) {
this.callbackState = callbackState;
}
@Override
public String getCustomAttribute(String number) throws InvalidArgumentException {
int num = 0;
@ -491,12 +482,14 @@ public class TaskImpl implements Task {
return attachments;
}
public void setAttachments(List<Attachment> attachments) {
if (attachments != null) {
this.attachments = attachments;
} else if (this.attachments == null) {
this.attachments = new ArrayList<>();
}
@Override
public String getNote() {
return note;
}
@Override
public void setNote(String note) {
this.note = note;
}
@Override
@ -549,17 +542,38 @@ public class TaskImpl implements Task {
return taskSummary;
}
public String getClassificationKey() {
return classificationSummary == null ? null : classificationSummary.getKey();
@Override
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
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) {
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() {
@ -707,17 +721,50 @@ public class TaskImpl implements Task {
}
@Override
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;
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
@ -773,53 +820,6 @@ public class TaskImpl implements Task {
&& 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
public String toString() {
return "TaskImpl [id="

View File

@ -161,14 +161,14 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery idIn(String... taskIds) {
this.taskIds = taskIds;
public TaskQuery nameIn(String... names) {
this.nameIn = names;
return this;
}
@Override
public TaskQuery nameIn(String... names) {
this.nameIn = names;
public TaskQuery nameLike(String... names) {
this.nameLike = toUpperCopy(names);
return this;
}
@ -184,12 +184,6 @@ public class TaskQueryImpl implements TaskQuery {
return this;
}
@Override
public TaskQuery nameLike(String... names) {
this.nameLike = toUpperCopy(names);
return this;
}
@Override
public TaskQuery creatorIn(String... creators) {
this.creatorIn = creators;
@ -202,6 +196,175 @@ public class TaskQueryImpl implements TaskQuery {
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
public TaskQuery createdWithin(TimeInterval... intervals) {
this.createdIn = intervals;
@ -268,144 +431,6 @@ public class TaskQueryImpl implements TaskQuery {
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
public TaskQuery readEquals(Boolean isRead) {
this.isRead = isRead;
@ -442,29 +467,6 @@ public class TaskQueryImpl implements TaskQuery {
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
public TaskQuery customAttributeIn(String number, String... strings)
throws InvalidArgumentException {
@ -640,6 +642,20 @@ public class TaskQueryImpl implements TaskQuery {
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
public TaskQuery attachmentChannelIn(String... attachmentChannel) {
joinWithAttachments = true;
@ -681,31 +697,31 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery classificationNameIn(String... classificationNames) {
joinWithClassifications = true;
this.classificationNameIn = classificationNames;
public TaskQuery callbackStateIn(CallbackState... states) {
this.callbackStateIn = states;
return this;
}
@Override
public TaskQuery classificationNameLike(String... classificationNames) {
joinWithClassifications = true;
this.classificationNameLike = toUpperCopy(classificationNames);
return this;
public ObjectReferenceQuery createObjectReferenceQuery() {
return new ObjectReferenceQueryImpl(taskanaEngine);
}
@Override
public TaskQuery attachmentClassificationNameIn(String... attachmentClassificationName) {
joinWithAttachmentClassifications = true;
this.attachmentClassificationNameIn = attachmentClassificationName;
return this;
public TaskQuery orderByBusinessProcessId(SortDirection sortDirection) {
return addOrderCriteria("BUSINESS_PROCESS_ID", sortDirection);
}
@Override
public TaskQuery attachmentClassificationNameLike(String... attachmentClassificationName) {
joinWithAttachmentClassifications = true;
this.attachmentClassificationNameLike = toUpperCopy(attachmentClassificationName);
return this;
public TaskQuery orderByClaimed(SortDirection sortDirection) {
return addOrderCriteria("CLAIMED", sortDirection);
}
@Override
public TaskQuery orderByClassificationKey(SortDirection sortDirection) {
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("TCLASSIFICATION_KEY", sortDirection)
: addOrderCriteria("t.CLASSIFICATION_KEY", sortDirection);
}
@Override
@ -718,19 +734,13 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery orderByAttachmentClassificationName(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentClassificationNameToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACNAME", sortDirection)
: addOrderCriteria("ac.NAME", sortDirection);
public TaskQuery orderByCompleted(SortDirection sortDirection) {
return addOrderCriteria("COMPLETED", sortDirection);
}
@Override
public TaskQuery orderByClassificationKey(SortDirection sortDirection) {
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("TCLASSIFICATION_KEY", sortDirection)
: addOrderCriteria("t.CLASSIFICATION_KEY", sortDirection);
public TaskQuery orderByCreated(SortDirection sortDirection) {
return addOrderCriteria("CREATED", sortDirection);
}
@Override
@ -738,11 +748,6 @@ public class TaskQueryImpl implements TaskQuery {
return addOrderCriteria("DOMAIN", sortDirection);
}
@Override
public TaskQuery orderByPlanned(SortDirection sortDirection) {
return addOrderCriteria("PLANNED", sortDirection);
}
@Override
public TaskQuery orderByDue(SortDirection sortDirection) {
return addOrderCriteria("DUE", sortDirection);
@ -763,11 +768,26 @@ public class TaskQueryImpl implements TaskQuery {
return addOrderCriteria("CREATOR", sortDirection);
}
@Override
public TaskQuery orderByNote(SortDirection sortDirection) {
return addOrderCriteria("NOTE", sortDirection);
}
@Override
public TaskQuery orderByOwner(SortDirection 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
public TaskQuery orderByPrimaryObjectReferenceCompany(SortDirection sortDirection) {
return addOrderCriteria("POR_COMPANY", sortDirection);
@ -808,55 +828,6 @@ public class TaskQueryImpl implements TaskQuery {
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
public TaskQuery orderByCustomAttribute(String number, SortDirection sortDirection)
throws InvalidArgumentException {
@ -911,33 +882,62 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery orderByBusinessProcessId(SortDirection sortDirection) {
return addOrderCriteria("BUSINESS_PROCESS_ID", sortDirection);
public TaskQuery idIn(String... taskIds) {
this.taskIds = taskIds;
return this;
}
@Override
public TaskQuery orderByClaimed(SortDirection sortDirection) {
return addOrderCriteria("CLAIMED", sortDirection);
public TaskQuery orderByWorkbasketId(SortDirection sortDirection) {
return addOrderCriteria("WORKBASKET_ID", sortDirection);
}
@Override
public TaskQuery orderByCompleted(SortDirection sortDirection) {
return addOrderCriteria("COMPLETED", sortDirection);
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 orderByCreated(SortDirection sortDirection) {
return addOrderCriteria("CREATED", sortDirection);
public TaskQuery orderByAttachmentClassificationName(SortDirection sortDirection) {
joinWithAttachments = true;
addAttachmentClassificationNameToSelectClauseForOrdering = true;
return DB.DB2.dbProductId.equals(getDatabaseId())
? addOrderCriteria("ACNAME", sortDirection)
: addOrderCriteria("ac.NAME", sortDirection);
}
@Override
public TaskQuery orderByParentBusinessProcessId(SortDirection sortDirection) {
return addOrderCriteria("PARENT_BUSINESS_PROCESS_ID", sortDirection);
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 ObjectReferenceQuery createObjectReferenceQuery() {
return new ObjectReferenceQueryImpl(taskanaEngine);
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
@ -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
public List<String> listValues(TaskQueryColumnName columnName, SortDirection sortDirection) {
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() {
return useDistinctKeyword;
}

View File

@ -59,6 +59,7 @@ import pro.taskana.mappings.TaskMapper;
import pro.taskana.security.CurrentUserContext;
/** This is the implementation of TaskService. */
@SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
public class TaskServiceImpl implements TaskService {
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);
}
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
public Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
@ -165,45 +130,6 @@ public class TaskServiceImpl implements TaskService {
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
public Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
@ -218,57 +144,6 @@ public class TaskServiceImpl implements TaskService {
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
public Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
@ -276,35 +151,6 @@ public class TaskServiceImpl implements TaskService {
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
public Task createTask(Task taskToCreate)
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
public Task setTaskRead(String taskId, boolean isRead)
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
public TaskQuery createTaskQuery() {
return new TaskQueryImpl(taskanaEngine);
@ -550,38 +381,52 @@ public class TaskServiceImpl implements TaskService {
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
public void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
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
public void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
@ -623,35 +468,31 @@ public class TaskServiceImpl implements TaskService {
}
@Override
public BulkOperationResults<String, TaskanaException> setCallbackStateForTasks(
List<String> externalIds, CallbackState state) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"entry to setCallbackStateForTasks(externalIds = {})",
LoggerUtils.listToString(externalIds));
}
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);
if (externalIds == null || externalIds.isEmpty()) {
return bulkLog;
}
List<TaskSummary> taskSummaries =
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;
} finally {
LOGGER.debug("exit from setCallbckStateForTasks()");
taskanaEngine.returnConnection();
LOGGER.debug("exit from to completeTasks(taskIds = {})", taskIdsToBeCompleted);
}
}
@ -739,28 +580,36 @@ public class TaskServiceImpl implements TaskService {
}
@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;
public BulkOperationResults<String, TaskanaException> setCallbackStateForTasks(
List<String> externalIds, CallbackState state) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"entry to setCallbackStateForTasks(externalIds = {})",
LoggerUtils.listToString(externalIds));
}
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);
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
if (externalIds == null || externalIds.isEmpty()) {
return bulkLog;
}
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();
LOGGER.debug("exit from claim()");
}
return task;
}
public Set<String> findTasksIdsAffectedByClassificationChange(String classificationId) {
@ -904,6 +753,158 @@ public class TaskServiceImpl implements TaskService {
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(
BulkOperationResults<String, TaskanaException> bulkLog,
List<MinimalTaskSummary> taskSummaries,

View File

@ -26,18 +26,6 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
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
public TaskStatusReport buildReport() throws NotAuthorizedException {
LOGGER.debug("entry to buildReport(), this = {}", this);
@ -54,4 +42,16 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
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;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreator()
*/
@Override
public String getCreator() {
return creator;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreated()
@ -175,19 +184,6 @@ public class TaskSummaryImpl implements TaskSummary {
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)
* @see pro.taskana.TaskSummary#getNote()
@ -253,14 +249,12 @@ public class TaskSummaryImpl implements TaskSummary {
this.workbasketSummary = workbasketSummary;
}
// utility method to allow mybatis access to workbasketSummary
public WorkbasketSummaryImpl getWorkbasketSummaryImpl() {
return (WorkbasketSummaryImpl) workbasketSummary;
}
// utility method to allow mybatis access to workbasketSummary
public void setWorkbasketSummaryImpl(WorkbasketSummaryImpl workbasketSummary) {
setWorkbasketSummary(workbasketSummary);
@Override
public List<AttachmentSummary> getAttachmentSummaries() {
if (attachmentSummaries == null) {
attachmentSummaries = new ArrayList<>();
}
return attachmentSummaries;
}
/*
@ -357,25 +351,6 @@ public class TaskSummaryImpl implements TaskSummary {
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)
* @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
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
@ -588,6 +588,49 @@ public class TaskSummaryImpl implements TaskSummary {
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
public boolean equals(Object obj) {
if (this == obj) {
@ -637,49 +680,6 @@ public class TaskSummaryImpl implements TaskSummary {
&& 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
public String toString() {
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
public boolean isUserInRole(TaskanaRole... roles) {
if (!getConfiguration().isSecurityEnabled()) {
@ -206,6 +189,23 @@ public class TaskanaEngineImpl implements TaskanaEngine {
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
* 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
public void returnConnection() {
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
public boolean domainExists(String domain) {
return getConfiguration().getDomains().contains(domain);

View File

@ -109,31 +109,6 @@ abstract class TimeIntervalReportBuilderImpl<
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
public List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems)
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")
protected abstract B _this();

View File

@ -44,6 +44,16 @@ public class TimestampReportBuilderImpl
throw new UnsupportedOperationException();
}
@Override
protected TimestampReport.Builder _this() {
return this;
}
@Override
protected String determineGroupedBy() {
throw new UnsupportedOperationException();
}
@Override
public TimestampReport.Builder withTimestamps(List<Timestamp> 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) {
return taskMonitorMapper.getTasksCountForStatusGroupedByOrgLevel(
s,

View File

@ -83,14 +83,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.accessId = accessId;
}
public void setAccessIdWithSanitizing(String accessId) {
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
setAccessId(accessId != null ? accessId.toLowerCase() : null);
} else {
setAccessId(accessId);
}
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getAccessName()
@ -415,6 +407,41 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
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
public boolean equals(Object obj) {
if (this == obj) {
@ -448,33 +475,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
&& 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
public String toString() {
return "WorkbasketAccessItem [id="

View File

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

View File

@ -40,6 +40,11 @@ public class WorkbasketImpl implements Workbasket {
this.id = id;
}
@Override
public Instant getCreated() {
return created;
}
@Override
public String getKey() {
return key;
@ -50,12 +55,22 @@ public class WorkbasketImpl implements Workbasket {
}
@Override
public Instant getCreated() {
return created;
public String getDomain() {
return domain;
}
public void setCreated(Instant created) {
this.created = created;
public void setDomain(String domain) {
this.domain = domain;
}
@Override
public WorkbasketType getType() {
return type;
}
@Override
public void setType(WorkbasketType type) {
this.type = type;
}
@Override
@ -97,25 +112,6 @@ public class WorkbasketImpl implements Workbasket {
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
public String getCustom1() {
return custom1;
@ -228,6 +224,33 @@ public class WorkbasketImpl implements Workbasket {
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
public boolean equals(Object obj) {
if (this == obj) {
@ -257,29 +280,6 @@ public class WorkbasketImpl implements Workbasket {
&& 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
public String toString() {
return "WorkbasketImpl [id="

View File

@ -128,12 +128,6 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
return this;
}
@Override
public WorkbasketQuery domainLike(String... domain) {
this.domainLike = domain;
return this;
}
@Override
public WorkbasketQuery typeIn(WorkbasketType... type) {
this.type = type;
@ -180,6 +174,109 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
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
public WorkbasketQuery custom1In(String... custom1) {
this.custom1In = custom1;
@ -282,103 +379,6 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
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
public List<WorkbasketSummary> list() {
LOGGER.debug("entry to list(), this = {}", this);

View File

@ -204,53 +204,32 @@ public class WorkbasketServiceImpl implements WorkbasketService {
}
@Override
public void setWorkbasketAccessItems(
String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug(
"entry to setWorkbasketAccessItems(workbasketAccessItems = {})", wbAccessItems.toString());
"entry to updateWorkbasketAccessItem(workbasketAccessItem = {}", workbasketAccessItem);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
List<WorkbasketAccessItemImpl> newItems = new ArrayList<>();
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
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);
}
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");
}
// delete all current ones
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId);
// add all
if (!newItems.isEmpty()) {
newItems.forEach(item -> workbasketAccessMapper.insert(item));
}
workbasketAccessMapper.update(accessItem);
LOGGER.debug(
"Method updateWorkbasketAccessItem() updated workbasketAccessItem {}", accessItem);
return accessItem;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug(
"exit from setWorkbasketAccessItems(workbasketAccessItems = {})",
wbAccessItems.toString());
"exit from updateWorkbasketAccessItem(workbasketAccessItem). Returning {}", accessItem);
}
}
@ -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
public void checkAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions)
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
public List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId)
throws NotAuthorizedException {
@ -443,11 +378,54 @@ public class WorkbasketServiceImpl implements WorkbasketService {
}
@Override
public List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId) {
WorkbasketAccessItem wbAcc =
workbasketAccessMapper.findByWorkbasketAndAccessId(
workbasketId, CurrentUserContext.getAccessIds());
return this.getPermissionsFromWorkbasketAccessItem(wbAcc);
public void setWorkbasketAccessItems(
String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug(
"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
@ -455,6 +433,12 @@ public class WorkbasketServiceImpl implements WorkbasketService {
return new WorkbasketQueryImpl(taskanaEngine);
}
@Override
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine);
}
@Override
public Workbasket newWorkbasket(String key, String domain) {
WorkbasketImpl wb = new WorkbasketImpl();
@ -463,6 +447,14 @@ public class WorkbasketServiceImpl implements WorkbasketService {
return wb;
}
@Override
public List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId) {
WorkbasketAccessItem wbAcc =
workbasketAccessMapper.findByWorkbasketAndAccessId(
workbasketId, CurrentUserContext.getAccessIds());
return this.getPermissionsFromWorkbasketAccessItem(wbAcc);
}
@Override
public List<WorkbasketSummary> getDistributionTargets(String workbasketId)
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
public void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds)
throws WorkbasketNotFoundException, NotAuthorizedException {
@ -811,9 +746,74 @@ public class WorkbasketServiceImpl implements WorkbasketService {
}
@Override
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine);
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
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() {

View File

@ -231,6 +231,27 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
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
public boolean equals(Object obj) {
if (this == obj) {
@ -258,27 +279,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
&& 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
public String toString() {
return "WorkbasketSummaryImpl [id="

View File

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

View File

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

View File

@ -70,7 +70,7 @@ public class JobRunner {
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
//ignore
// ignore
}
job.setLockedBy(hostAddress + " - " + Thread.currentThread().getName());
String owner = hostAddress + " - " + Thread.currentThread().getName();

View File

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

View File

@ -95,7 +95,8 @@ public final class CurrentUserContext {
LOGGER.debug("Public credentials of caller: {}", publicCredentials);
for (Object credential : publicCredentials) {
Object o =
credential.getClass()
credential
.getClass()
.getMethod(GET_UNIQUE_SECURITY_NAME_METHOD, (Class<?>[]) null)
.invoke(credential, (Object[]) null);
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;
}
@Override
public ClassificationQuery modifiedWithin(TimeInterval... modifiedIn) {
return this;
}
@Override
public ClassificationQuery nameIn(String... name) {
return this;
@ -117,28 +122,6 @@ public class TestClassificationQuery implements ClassificationQuery {
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
public ClassificationQuery orderByKey(SortDirection sortDirection) {
return this;
@ -190,8 +173,15 @@ public class TestClassificationQuery implements ClassificationQuery {
}
@Override
public ClassificationQuery modifiedWithin(TimeInterval... modifiedIn) {
return this;
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
@ -199,4 +189,14 @@ public class TestClassificationQuery implements ClassificationQuery {
ClassificationQueryColumnName dbColumnName, SortDirection sortDirection) {
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 {
static int counter = 0;
private static final String ID_PREFIX_CLASSIFICATION = "CLI";
@SuppressWarnings("checkstyle:DeclarationOrder")
static int counter = 0;
private DataSource dataSource;
private ClassificationService classificationService;
private TaskanaEngineConfiguration taskanaEngineConfiguration;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>

View File

@ -18,8 +18,7 @@ final class SqlReplacer {
static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
private SqlReplacer() {
}
private SqlReplacer() {}
static String getScriptAsSql(String dbProductName, LocalDateTime now, String scriptPath) {
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.transaction.TaskanaTransactionProvider;
/**
* Test for internal transaction management.
*/
/** Test for internal transaction management. */
@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = TaskanaConfigTestApplication.class,

View File

@ -146,8 +146,45 @@
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
<option name="USE_RELATIVE_INDENTS" value="true" />
</indentOptions>
<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>
<section>
<rule>

View File

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

View File

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

View File

@ -81,12 +81,28 @@ public class WildflyWebSecurityConfig extends WebSecurityConfig {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return true;
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;
}
@Override
public boolean isCredentialsNonExpired() {
public String getPassword() {
return (String) token.getCredentials();
}
@Override
public String getUsername() {
return token.getName();
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@ -96,29 +112,13 @@ public class WildflyWebSecurityConfig extends WebSecurityConfig {
}
@Override
public boolean isAccountNonExpired() {
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public String getUsername() {
return token.getName();
}
@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;
public boolean isEnabled() {
return true;
}
private SecurityIdentity getSecurityIdentity() {

View File

@ -3,7 +3,7 @@ package pro.taskana.rest;
/** Collection of Url to Controller mappings. */
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_GROUPS = URL_ACCESSID + "/groups";
public static final String URL_CLASSIFICATIONS = PRE + "classifications";

View File

@ -108,9 +108,9 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
} else {
throw new InvalidArgumentException(
String.format(
"%s corresponding to a group, not a user. "
+ "You just can remove access items for a user",
accessId));
"%s corresponding to a group, not a user. "
+ "You just can remove access items for a user",
accessId));
}
ResponseEntity<Void> response = ResponseEntity.noContent().build();

View File

@ -17,15 +17,15 @@ public class DistributionTargetListResource extends PagedResources<DistributionT
super(content, null, links);
}
@Override
@JsonProperty("distributionTargets")
public Collection<DistributionTargetResource> getContent() {
return super.getContent();
}
@Override
@JsonIgnore
public PageMetadata 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.links.PageLinks;
/**
* Resource assembler for {@link WorkbasketSummaryResource}.
*/
/** Resource assembler for {@link WorkbasketSummaryResource}. */
@Component
public class WorkbasketSummaryResourceAssembler
extends ResourceAssemblerSupport<WorkbasketSummary, WorkbasketSummaryResource> {

View File

@ -165,8 +165,8 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
.description("The domain for which this classification is specified"),
fieldWithPath("key")
.description(
"The key of the classification. This is typically an externally "
+ "known code or abbreviation of the classification"),
"The key of the classification. This is typically an externally "
+ "known code or abbreviation of the classification"),
fieldWithPath("name")
.type("String")
.description("The name of the classification")

View File

@ -35,8 +35,8 @@ class MonitorControllerRestDocumentation extends BaseRestDocumentation {
fieldWithPath("rows[].total").description("Sum of all values of the given row"),
fieldWithPath("rows[].depth")
.description(
"Depth of the row. If the depth is > 0, "
+ "then this row is a sub-row of a prior row"),
"Depth of the row. If the depth is > 0, "
+ "then this row is a sub-row of a prior row"),
fieldWithPath("rows[].desc").description("Array containing description of the row."),
fieldWithPath("rows[].display")
.description(

View File

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

View File

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