TSK-1345: replaced every customField API call with CustomField enums

This commit is contained in:
Mustapha Zorgati 2020-07-23 17:12:22 +02:00
parent f5e3d449b6
commit 7cc5b00be6
123 changed files with 2357 additions and 3497 deletions

View File

@ -7,25 +7,26 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper; import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
import pro.taskana.simplehistory.query.HistoryQuery; import pro.taskana.simplehistory.query.HistoryQuery;
import pro.taskana.simplehistory.query.HistoryQueryColumnName; import pro.taskana.simplehistory.query.HistoryQueryColumnName;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
/** Implementation for generating dynamic sql. */ /** Implementation for generating dynamic sql. */
public class HistoryQueryImpl implements HistoryQuery { public class HistoryQueryImpl implements HistoryQuery {
private static final Logger LOGGER = LoggerFactory.getLogger(HistoryQueryImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(HistoryQueryImpl.class);
private TaskanaHistoryEngineImpl taskanaHistoryEngine; private final TaskanaHistoryEngineImpl taskanaHistoryEngine;
private HistoryQueryMapper historyQueryMapper; private final HistoryQueryMapper historyQueryMapper;
private HistoryQueryColumnName columnName; private final List<String> orderBy;
private List<String> orderBy; private final List<String> orderColumns;
private List<String> orderColumns;
private int private int
maxRows; // limit for rows. used to make list(offset, limit) and single() more efficient. maxRows; // limit for rows. used to make list(offset, limit) and single() more efficient.
private HistoryQueryColumnName columnName;
private String[] idIn; private String[] idIn;
private String[] businessProcessIdIn; private String[] businessProcessIdIn;
private String[] parentBusinessProcessIdIn; private String[] parentBusinessProcessIdIn;
@ -195,30 +196,6 @@ public class HistoryQueryImpl implements HistoryQuery {
return this; return this;
} }
@Override
public HistoryQuery custom1In(String... custom1) {
this.custom1In = toUpperCopy(custom1);
return this;
}
@Override
public HistoryQuery custom2In(String... custom2) {
this.custom2In = toUpperCopy(custom2);
return this;
}
@Override
public HistoryQuery custom3In(String... custom3) {
this.custom3In = toUpperCopy(custom3);
return this;
}
@Override
public HistoryQuery custom4In(String... custom4) {
this.custom4In = toUpperCopy(custom4);
return this;
}
@Override @Override
public HistoryQuery businessProcessIdLike(String... businessProcessId) { public HistoryQuery businessProcessIdLike(String... businessProcessId) {
this.businessProcessIdLike = toUpperCopy(businessProcessId); this.businessProcessIdLike = toUpperCopy(businessProcessId);
@ -322,26 +299,46 @@ public class HistoryQueryImpl implements HistoryQuery {
} }
@Override @Override
public HistoryQuery custom1Like(String... custom1) { public HistoryQuery customAttributeIn(
this.custom1Like = toUpperCopy(custom1); TaskHistoryCustomField customField, String... searchArguments) {
switch (customField) {
case CUSTOM_1:
custom1In = toUpperCopy(searchArguments);
break;
case CUSTOM_2:
custom2In = toUpperCopy(searchArguments);
break;
case CUSTOM_3:
custom3In = toUpperCopy(searchArguments);
break;
case CUSTOM_4:
custom4In = toUpperCopy(searchArguments);
break;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
return this; return this;
} }
@Override @Override
public HistoryQuery custom2Like(String... custom2) { public HistoryQuery customAttributeLike(
this.custom2Like = toUpperCopy(custom2); TaskHistoryCustomField customField, String... searchArguments) {
return this; switch (customField) {
case CUSTOM_1:
custom1Like = toUpperCopy(searchArguments);
break;
case CUSTOM_2:
custom2Like = toUpperCopy(searchArguments);
break;
case CUSTOM_3:
custom3Like = toUpperCopy(searchArguments);
break;
case CUSTOM_4:
custom4Like = toUpperCopy(searchArguments);
break;
default:
throw new SystemException("Unknown customField '" + customField + "'");
} }
@Override
public HistoryQuery custom3Like(String... custom3) {
this.custom3Like = toUpperCopy(custom3);
return this;
}
@Override
public HistoryQuery custom4Like(String... custom4) {
this.custom4Like = toUpperCopy(custom4);
return this; return this;
} }
@ -436,22 +433,9 @@ public class HistoryQueryImpl implements HistoryQuery {
} }
@Override @Override
public HistoryQuery orderByCustomAttribute(int num, SortDirection sortDirection) public HistoryQuery orderByCustomAttribute(
throws InvalidArgumentException { TaskHistoryCustomField customField, SortDirection sortDirection) {
return addOrderCriteria(customField.name(), sortDirection);
switch (num) {
case 1:
return addOrderCriteria("CUSTOM_1", sortDirection);
case 2:
return addOrderCriteria("CUSTOM_2", sortDirection);
case 3:
return addOrderCriteria("CUSTOM_3", sortDirection);
case 4:
return addOrderCriteria("CUSTOM_4", sortDirection);
default:
throw new InvalidArgumentException(
"Custom number has to be between 1 and 4, but this is: " + num);
}
} }
@Override @Override
@ -512,7 +496,6 @@ public class HistoryQueryImpl implements HistoryQuery {
this); this);
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
this.columnName = dbColumnName; this.columnName = dbColumnName;
List<String> cacheOrderBy = this.orderBy;
this.orderBy.clear(); this.orderBy.clear();
this.addOrderCriteria(columnName.toString(), sortDirection); this.addOrderCriteria(columnName.toString(), sortDirection);
@ -529,8 +512,6 @@ public class HistoryQueryImpl implements HistoryQuery {
LOGGER.error("No History Event found."); LOGGER.error("No History Event found.");
return result; return result;
} finally { } finally {
this.orderBy = cacheOrderBy;
this.columnName = null;
this.orderColumns.remove(orderColumns.size() - 1); this.orderColumns.remove(orderColumns.size() - 1);
taskanaHistoryEngine.returnConnection(); taskanaHistoryEngine.returnConnection();
} }

View File

@ -2,8 +2,8 @@ package pro.taskana.simplehistory.query;
import pro.taskana.common.api.BaseQuery; import pro.taskana.common.api.BaseQuery;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.simplehistory.impl.HistoryEventImpl; import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
/** HistoryQuery for generating dynamic sql. */ /** HistoryQuery for generating dynamic sql. */
public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryColumnName> { public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryColumnName> {
@ -161,38 +161,6 @@ public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryCo
*/ */
HistoryQuery newValueIn(String... newValue); HistoryQuery newValueIn(String... newValue);
/**
* Add your custom1 to your query.
*
* @param custom1 as String
* @return the query
*/
HistoryQuery custom1In(String... custom1);
/**
* Add your custom2 to your query.
*
* @param custom2 as String
* @return the query
*/
HistoryQuery custom2In(String... custom2);
/**
* Add your custom3 to your query.
*
* @param custom3 as String
* @return the query
*/
HistoryQuery custom3In(String... custom3);
/**
* Add your custom4 to your query.
*
* @param custom4 as String
* @return the query
*/
HistoryQuery custom4In(String... custom4);
/** /**
* Add your businessProcessId to your query. It will be compared in SQL with an LIKE. If you use a * Add your businessProcessId to your query. It will be compared in SQL with an LIKE. If you use a
* wildcard like % then it will be transmitted to the database. * wildcard like % then it will be transmitted to the database.
@ -347,40 +315,24 @@ public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryCo
HistoryQuery newValueLike(String... newValue); HistoryQuery newValueLike(String... newValue);
/** /**
* Add your custom1 to your query. It will be compared in SQL with an LIKE. If you use a wildcard * Add the values of custom attributes for exact matching to your query.
* like % then it will be transmitted to the database.
* *
* @param custom1 as String * @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched for tasks
* @return the query * @return the query
*/ */
HistoryQuery custom1Like(String... custom1); HistoryQuery customAttributeIn(TaskHistoryCustomField customField, String... searchArguments);
/** /**
* Add your custom2 to your query. It will be compared in SQL with an LIKE. If you use a wildcard * Add the values of custom attributes for pattern matching to your query. They will be compared
* like % then it will be transmitted to the database. * in SQL with the LIKE operator. You may use a wildcard like % to specify the pattern. If you
* specify multiple arguments they are combined with the OR keyword.
* *
* @param custom2 as String * @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched-for tasks
* @return the query * @return the query
*/ */
HistoryQuery custom2Like(String... custom2); HistoryQuery customAttributeLike(TaskHistoryCustomField customField, String... searchArguments);
/**
* Add your custom3 to your query. It will be compared in SQL with an LIKE. If you use a wildcard
* like % then it will be transmitted to the database.
*
* @param custom3 as String
* @return the query
*/
HistoryQuery custom3Like(String... custom3);
/**
* Add your custom4 to your query. It will be compared in SQL with an LIKE. If you use a wildcard
* like % then it will be transmitted to the database.
*
* @param custom4 as String
* @return the query
*/
HistoryQuery custom4Like(String... custom4);
/** /**
* Sort the query result by businessProcessId. * Sort the query result by businessProcessId.
@ -545,14 +497,13 @@ public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryCo
HistoryQuery orderByNewValue(SortDirection sortDirection); HistoryQuery orderByNewValue(SortDirection sortDirection);
/** /**
* Sort the query result by a custom attribute. * This method sorts the query result according to the value of a custom field.
* *
* @param num the number of the custom attribute as String (eg "4") * @param customField identifies which custom attribute is affected.
* @param sortDirection Determines whether the result is sorted in ascending or descending order. * @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order * If sortDirection is null, the result is sorted in ascending order
* @return the query * @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect.
*/ */
HistoryQuery orderByCustomAttribute(int num, SortDirection sortDirection) HistoryQuery orderByCustomAttribute(
throws InvalidArgumentException; TaskHistoryCustomField customField, SortDirection sortDirection);
} }

View File

@ -13,15 +13,12 @@ import pro.taskana.common.api.TimeInterval;
import pro.taskana.simplehistory.impl.HistoryEventImpl; import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.query.HistoryQuery; import pro.taskana.simplehistory.query.HistoryQuery;
import pro.taskana.simplehistory.query.HistoryQueryColumnName; import pro.taskana.simplehistory.query.HistoryQueryColumnName;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent; import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Test for History queries. */ /** Test for History queries. */
class QueryHistoryAccTest extends AbstractAccTest { class QueryHistoryAccTest extends AbstractAccTest {
public QueryHistoryAccTest() {
super();
}
@Test @Test
void should_ConfirmEquality_When_UsingListValuesAscendingAndDescending() { void should_ConfirmEquality_When_UsingListValuesAscendingAndDescending() {
List<String> defaultList = List<String> defaultList =
@ -166,16 +163,32 @@ class QueryHistoryAccTest extends AbstractAccTest {
.list(); .list();
assertThat(returnValues).hasSize(6); assertThat(returnValues).hasSize(6);
returnValues = getHistoryService().createHistoryQuery().custom1In("custom1").list(); returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_1, "custom1")
.list();
assertThat(returnValues).hasSize(13); assertThat(returnValues).hasSize(13);
returnValues = getHistoryService().createHistoryQuery().custom2In("custom2").list(); returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_2, "custom2")
.list();
assertThat(returnValues).hasSize(1); assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().custom3In("custom3").list(); returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_3, "custom3")
.list();
assertThat(returnValues).hasSize(7); assertThat(returnValues).hasSize(7);
returnValues = getHistoryService().createHistoryQuery().custom4In("custom4").list(); returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_4, "custom4")
.list();
assertThat(returnValues).hasSize(1); assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().oldValueIn("old_val").list(); returnValues = getHistoryService().createHistoryQuery().oldValueIn("old_val").list();

View File

@ -27,10 +27,11 @@ import pro.taskana.common.rest.QueryHelper;
import pro.taskana.simplehistory.impl.HistoryEventImpl; import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl; import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.query.HistoryQuery; import pro.taskana.simplehistory.query.HistoryQuery;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventListResource; import pro.taskana.simplehistory.rest.assembler.TaskHistoryEventListResourceAssembler;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventListResourceAssembler; import pro.taskana.simplehistory.rest.assembler.TaskHistoryEventRepresentationModelAssembler;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResource; import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResourceAssembler; import pro.taskana.simplehistory.rest.models.TaskHistoryEventRepresentationModel;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent; import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException; import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException;
@ -76,28 +77,26 @@ public class TaskHistoryEventController extends AbstractPagingController {
private static final String ATTACHMENT_CLASSIFICATION_KEY_LIKE = private static final String ATTACHMENT_CLASSIFICATION_KEY_LIKE =
"attachment-classification-key-like"; "attachment-classification-key-like";
private static final String CUSTOM_1 = "custom-1"; private static final String CUSTOM_1 = "custom-1";
private static final String CUSTOM_1_LIKE = "custom-1-like";
private static final String CUSTOM_2 = "custom-2"; private static final String CUSTOM_2 = "custom-2";
private static final String CUSTOM_2_LIKE = "custom-2-like";
private static final String CUSTOM_3 = "custom-3"; private static final String CUSTOM_3 = "custom-3";
private static final String CUSTOM_3_LIKE = "custom-3-like";
private static final String CUSTOM_4 = "custom-4"; private static final String CUSTOM_4 = "custom-4";
private static final String CUSTOM_4_LIKE = "custom-4-like";
private static final String PAGING_PAGE = "page"; private static final String PAGING_PAGE = "page";
private static final String PAGING_PAGE_SIZE = "page-size"; private static final String PAGING_PAGE_SIZE = "page-size";
private final SimpleHistoryServiceImpl simpleHistoryService; private final SimpleHistoryServiceImpl simpleHistoryService;
private final TaskHistoryEventResourceAssembler taskHistoryEventResourceAssembler; private final TaskHistoryEventRepresentationModelAssembler
taskHistoryEventRepresentationModelAssembler;
@Autowired @Autowired
public TaskHistoryEventController( public TaskHistoryEventController(
TaskanaEngineConfiguration taskanaEngineConfiguration, TaskanaEngineConfiguration taskanaEngineConfiguration,
SimpleHistoryServiceImpl simpleHistoryServiceImpl, SimpleHistoryServiceImpl simpleHistoryServiceImpl,
TaskHistoryEventResourceAssembler taskHistoryEventResourceAssembler) { TaskHistoryEventRepresentationModelAssembler taskHistoryEventRepresentationModelAssembler) {
this.simpleHistoryService = simpleHistoryServiceImpl; this.simpleHistoryService = simpleHistoryServiceImpl;
this.simpleHistoryService.initialize(taskanaEngineConfiguration); this.simpleHistoryService.initialize(taskanaEngineConfiguration);
this.taskHistoryEventResourceAssembler = taskHistoryEventResourceAssembler; this.taskHistoryEventRepresentationModelAssembler =
taskHistoryEventRepresentationModelAssembler;
} }
@GetMapping @GetMapping
@ -109,8 +108,8 @@ public class TaskHistoryEventController extends AbstractPagingController {
} }
HistoryQuery query = simpleHistoryService.createHistoryQuery(); HistoryQuery query = simpleHistoryService.createHistoryQuery();
query = applySortingParams(query, params); applySortingParams(query, params);
query = applyFilterParams(query, params); applyFilterParams(query, params);
PageMetadata pageMetadata = null; PageMetadata pageMetadata = null;
List<HistoryEventImpl> historyEvents; List<HistoryEventImpl> historyEvents;
@ -144,7 +143,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
@GetMapping(path = "/{historyEventId}", produces = "application/hal+json") @GetMapping(path = "/{historyEventId}", produces = "application/hal+json")
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskHistoryEventResource> getTaskHistoryEvent( public ResponseEntity<TaskHistoryEventRepresentationModel> getTaskHistoryEvent(
@PathVariable String historyEventId) throws TaskanaHistoryEventNotFoundException { @PathVariable String historyEventId) throws TaskanaHistoryEventNotFoundException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -153,8 +152,8 @@ public class TaskHistoryEventController extends AbstractPagingController {
TaskanaHistoryEvent resultEvent = simpleHistoryService.getHistoryEvent(historyEventId); TaskanaHistoryEvent resultEvent = simpleHistoryService.getHistoryEvent(historyEventId);
TaskHistoryEventResource taskEventResource = TaskHistoryEventRepresentationModel taskEventResource =
taskHistoryEventResourceAssembler.toModel(resultEvent); taskHistoryEventRepresentationModelAssembler.toModel(resultEvent);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
@ -165,7 +164,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
return new ResponseEntity<>(taskEventResource, HttpStatus.OK); return new ResponseEntity<>(taskEventResource, HttpStatus.OK);
} }
private HistoryQuery applySortingParams(HistoryQuery query, MultiValueMap<String, String> params) private void applySortingParams(HistoryQuery query, MultiValueMap<String, String> params)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(params= {})", params); LOGGER.debug("Entry to applySortingParams(params= {})", params);
@ -175,65 +174,65 @@ public class TaskHistoryEventController extends AbstractPagingController {
params, params,
(sortBy, sortDirection) -> { (sortBy, sortDirection) -> {
switch (sortBy) { switch (sortBy) {
case (BUSINESS_PROCESS_ID): case BUSINESS_PROCESS_ID:
query.orderByBusinessProcessId(sortDirection); query.orderByBusinessProcessId(sortDirection);
break; break;
case (PARENT_BUSINESS_PROCESS_ID): case PARENT_BUSINESS_PROCESS_ID:
query.orderByParentBusinessProcessId(sortDirection); query.orderByParentBusinessProcessId(sortDirection);
break; break;
case (TASK_ID): case TASK_ID:
query.orderByTaskId(sortDirection); query.orderByTaskId(sortDirection);
break; break;
case (EVENT_TYPE): case EVENT_TYPE:
query.orderByEventType(sortDirection); query.orderByEventType(sortDirection);
break; break;
case (CREATED): case CREATED:
query.orderByCreated(sortDirection); query.orderByCreated(sortDirection);
break; break;
case (USER_ID): case USER_ID:
query.orderByUserId(sortDirection); query.orderByUserId(sortDirection);
break; break;
case (DOMAIN): case DOMAIN:
query.orderByDomain(sortDirection); query.orderByDomain(sortDirection);
break; break;
case (WORKBASKET_KEY): case WORKBASKET_KEY:
query.orderByWorkbasketKey(sortDirection); query.orderByWorkbasketKey(sortDirection);
break; break;
case (POR_COMPANY): case POR_COMPANY:
query.orderByPorCompany(sortDirection); query.orderByPorCompany(sortDirection);
break; break;
case (POR_SYSTEM): case POR_SYSTEM:
query.orderByPorSystem(sortDirection); query.orderByPorSystem(sortDirection);
break; break;
case (POR_INSTANCE): case POR_INSTANCE:
query.orderByPorInstance(sortDirection); query.orderByPorInstance(sortDirection);
break; break;
case (POR_TYPE): case POR_TYPE:
query.orderByPorType(sortDirection); query.orderByPorType(sortDirection);
break; break;
case (POR_VALUE): case POR_VALUE:
query.orderByPorValue(sortDirection); query.orderByPorValue(sortDirection);
break; break;
case (TASK_CLASSIFICATION_KEY): case TASK_CLASSIFICATION_KEY:
query.orderByTaskClassificationKey(sortDirection); query.orderByTaskClassificationKey(sortDirection);
break; break;
case (TASK_CLASSIFICATION_CATEGORY): case TASK_CLASSIFICATION_CATEGORY:
query.orderByTaskClassificationCategory(sortDirection); query.orderByTaskClassificationCategory(sortDirection);
break; break;
case (ATTACHMENT_CLASSIFICATION_KEY): case ATTACHMENT_CLASSIFICATION_KEY:
query.orderByAttachmentClassificationKey(sortDirection); query.orderByAttachmentClassificationKey(sortDirection);
break; break;
case (CUSTOM_1): case CUSTOM_1:
query.orderByCustomAttribute(1, sortDirection); query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_1, sortDirection);
break; break;
case (CUSTOM_2): case CUSTOM_2:
query.orderByCustomAttribute(2, sortDirection); query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_2, sortDirection);
break; break;
case (CUSTOM_3): case CUSTOM_3:
query.orderByCustomAttribute(3, sortDirection); query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_3, sortDirection);
break; break;
case (CUSTOM_4): case CUSTOM_4:
query.orderByCustomAttribute(4, sortDirection); query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_4, sortDirection);
break; break;
default: default:
throw new IllegalArgumentException("Unknown order '" + sortBy + "'"); throw new IllegalArgumentException("Unknown order '" + sortBy + "'");
@ -243,11 +242,9 @@ public class TaskHistoryEventController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applySortingParams(), returning: {}", query); LOGGER.debug("Exit from applySortingParams(), returning: {}", query);
} }
return query;
} }
private HistoryQuery applyFilterParams(HistoryQuery query, MultiValueMap<String, String> params) { private void applyFilterParams(HistoryQuery query, MultiValueMap<String, String> params) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params); LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
} }
@ -396,47 +393,23 @@ public class TaskHistoryEventController extends AbstractPagingController {
LIKE + params.get(ATTACHMENT_CLASSIFICATION_KEY_LIKE).get(0) + LIKE); LIKE + params.get(ATTACHMENT_CLASSIFICATION_KEY_LIKE).get(0) + LIKE);
params.remove(ATTACHMENT_CLASSIFICATION_KEY_LIKE); params.remove(ATTACHMENT_CLASSIFICATION_KEY_LIKE);
} }
if (params.containsKey(CUSTOM_1)) { for (TaskHistoryCustomField customField : TaskHistoryCustomField.values()) {
String[] custom1 = extractCommaSeparatedFields(params.get(CUSTOM_1)); List<String> list = params.remove(customField.name().replace("_", "-").toLowerCase());
query.custom1In(custom1); if (list != null) {
params.remove(CUSTOM_1); query.customAttributeIn(customField, extractCommaSeparatedFields(list));
} }
if (params.containsKey(CUSTOM_1_LIKE)) { list = params.remove(customField.name().replace("_", "-").toLowerCase() + "-like");
query.custom1Like(LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE); if (list != null) {
params.remove(CUSTOM_1_LIKE); String[] values = extractCommaSeparatedFields(list);
for (int i = 0; i < values.length; i++) {
values[i] = LIKE + values[i] + LIKE;
} }
if (params.containsKey(CUSTOM_2)) { query.customAttributeLike(customField, values);
String[] custom2 = extractCommaSeparatedFields(params.get(CUSTOM_2));
query.custom2In(custom2);
params.remove(CUSTOM_2);
} }
if (params.containsKey(CUSTOM_2_LIKE)) {
query.custom2Like(LIKE + params.get(CUSTOM_2_LIKE).get(0) + LIKE);
params.remove(CUSTOM_2_LIKE);
}
if (params.containsKey(CUSTOM_3)) {
String[] custom3 = extractCommaSeparatedFields(params.get(CUSTOM_3));
query.custom3In(custom3);
params.remove(CUSTOM_3);
}
if (params.containsKey(CUSTOM_3_LIKE)) {
query.custom3Like(LIKE + params.get(CUSTOM_3_LIKE).get(0) + LIKE);
params.remove(CUSTOM_3_LIKE);
}
if (params.containsKey(CUSTOM_4)) {
String[] custom4 = extractCommaSeparatedFields(params.get(CUSTOM_4));
query.custom4In(custom4);
params.remove(CUSTOM_4);
}
if (params.containsKey(CUSTOM_4_LIKE)) {
query.custom4Like(LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE);
params.remove(CUSTOM_4_LIKE);
} }
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
return query;
} }
private TimeInterval getTimeIntervalOf(String[] created) { private TimeInterval getTimeIntervalOf(String[] created) {

View File

@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl; import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResourceAssembler; import pro.taskana.simplehistory.rest.assembler.TaskHistoryEventRepresentationModelAssembler;
/** Configuration for Taskana history REST service. */ /** Configuration for Taskana history REST service. */
@Configuration @Configuration
@ -20,7 +20,7 @@ public class TaskHistoryRestConfiguration {
} }
@Bean @Bean
public TaskHistoryEventResourceAssembler getTaskHistoryEventResourceAssembler() { public TaskHistoryEventRepresentationModelAssembler getTaskHistoryEventResourceAssembler() {
return new TaskHistoryEventResourceAssembler(); return new TaskHistoryEventRepresentationModelAssembler();
} }
} }

View File

@ -1,4 +1,4 @@
package pro.taskana.simplehistory.rest.resource; package pro.taskana.simplehistory.rest.assembler;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
@ -11,6 +11,8 @@ import org.springframework.hateoas.PagedModel.PageMetadata;
import pro.taskana.resource.rest.AbstractRessourcesAssembler; import pro.taskana.resource.rest.AbstractRessourcesAssembler;
import pro.taskana.simplehistory.impl.HistoryEventImpl; import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.rest.TaskHistoryEventController; import pro.taskana.simplehistory.rest.TaskHistoryEventController;
import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
import pro.taskana.simplehistory.rest.models.TaskHistoryEventRepresentationModel;
/** Mapper to convert from a list of HistoryEventImpl to a TaskHistoryEventResource. */ /** Mapper to convert from a list of HistoryEventImpl to a TaskHistoryEventResource. */
public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAssembler { public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAssembler {
@ -18,8 +20,9 @@ public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAss
public TaskHistoryEventListResource toResources( public TaskHistoryEventListResource toResources(
List<HistoryEventImpl> historyEvents, PageMetadata pageMetadata) { List<HistoryEventImpl> historyEvents, PageMetadata pageMetadata) {
TaskHistoryEventResourceAssembler assembler = new TaskHistoryEventResourceAssembler(); TaskHistoryEventRepresentationModelAssembler assembler =
List<TaskHistoryEventResource> resources = new TaskHistoryEventRepresentationModelAssembler();
List<TaskHistoryEventRepresentationModel> resources =
new ArrayList<>(assembler.toCollectionModel(historyEvents).getContent()); new ArrayList<>(assembler.toCollectionModel(historyEvents).getContent());
TaskHistoryEventListResource pagedResources = TaskHistoryEventListResource pagedResources =
new TaskHistoryEventListResource(resources, pageMetadata); new TaskHistoryEventListResource(resources, pageMetadata);

View File

@ -0,0 +1,60 @@
package pro.taskana.simplehistory.rest.assembler;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.rest.TaskHistoryEventController;
import pro.taskana.simplehistory.rest.models.TaskHistoryEventRepresentationModel;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Transforms any {@link HistoryEventImpl} into its {@link TaskHistoryEventRepresentationModel}. */
public class TaskHistoryEventRepresentationModelAssembler
implements RepresentationModelAssembler<
TaskanaHistoryEvent, TaskHistoryEventRepresentationModel> {
@NonNull
@Override
public TaskHistoryEventRepresentationModel toModel(@NonNull TaskanaHistoryEvent historyEvent) {
TaskHistoryEventRepresentationModel repModel = new TaskHistoryEventRepresentationModel();
repModel.setTaskHistoryId(historyEvent.getId());
repModel.setBusinessProcessId(historyEvent.getBusinessProcessId());
repModel.setParentBusinessProcessId(historyEvent.getParentBusinessProcessId());
repModel.setTaskId(historyEvent.getTaskId());
repModel.setEventType(historyEvent.getEventType());
repModel.setCreated(historyEvent.getCreated());
repModel.setUserId(historyEvent.getUserId());
repModel.setDomain(historyEvent.getDomain());
repModel.setWorkbasketKey(historyEvent.getWorkbasketKey());
repModel.setPorCompany(historyEvent.getPorCompany());
repModel.setPorType(historyEvent.getPorType());
repModel.setPorInstance(historyEvent.getPorInstance());
repModel.setPorSystem(historyEvent.getPorSystem());
repModel.setPorValue(historyEvent.getPorValue());
repModel.setTaskClassificationKey(historyEvent.getTaskClassificationKey());
repModel.setTaskClassificationCategory(historyEvent.getTaskClassificationCategory());
repModel.setAttachmentClassificationKey(historyEvent.getAttachmentClassificationKey());
repModel.setOldValue(historyEvent.getOldValue());
repModel.setNewValue(historyEvent.getNewValue());
repModel.setCustom1(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_1));
repModel.setCustom2(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_2));
repModel.setCustom3(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_3));
repModel.setCustom4(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_4));
repModel.setDetails(historyEvent.getDetails());
try {
repModel.add(
linkTo(
methodOn(TaskHistoryEventController.class)
.getTaskHistoryEvent(historyEvent.getId()))
.withSelfRel());
} catch (Exception e) {
throw new SystemException("caught unexpecte Exception", e);
}
return repModel;
}
}

View File

@ -0,0 +1,29 @@
package pro.taskana.simplehistory.rest.models;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel.PageMetadata;
import pro.taskana.common.rest.models.PagedResources;
/** Resource class for {@link TaskHistoryEventRepresentationModel} with Pagination. */
public class TaskHistoryEventListResource
extends PagedResources<TaskHistoryEventRepresentationModel> {
@SuppressWarnings("unused")
private TaskHistoryEventListResource() {}
public TaskHistoryEventListResource(
Collection<TaskHistoryEventRepresentationModel> content,
PageMetadata metadata,
Link... links) {
super(content, metadata, links);
}
@Override
@JsonProperty("taskHistoryEvents")
public Collection<TaskHistoryEventRepresentationModel> getContent() {
return super.getContent();
}
}

View File

@ -1,18 +1,20 @@
package pro.taskana.simplehistory.rest.resource; package pro.taskana.simplehistory.rest.models;
import java.time.Instant;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent; import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Resource class for {@link TaskanaHistoryEvent}. */ /** Resource class for {@link TaskanaHistoryEvent}. */
public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEventResource> { public class TaskHistoryEventRepresentationModel
extends RepresentationModel<TaskHistoryEventRepresentationModel> {
private String taskHistoryEventId; private String taskHistoryId;
private String businessProcessId; private String businessProcessId;
private String parentBusinessProcessId; private String parentBusinessProcessId;
private String taskId; private String taskId;
private String eventType; private String eventType;
private String created; private Instant created;
private String userId; private String userId;
private String domain; private String domain;
private String workbasketKey; private String workbasketKey;
@ -33,11 +35,11 @@ public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEve
private String details; private String details;
public String getTaskHistoryId() { public String getTaskHistoryId() {
return taskHistoryEventId; return taskHistoryId;
} }
public void setTaskHistoryId(String taskHistoryId) { public void setTaskHistoryId(String taskHistoryId) {
this.taskHistoryEventId = taskHistoryId; this.taskHistoryId = taskHistoryId;
} }
public String getBusinessProcessId() { public String getBusinessProcessId() {
@ -72,11 +74,11 @@ public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEve
this.eventType = eventType; this.eventType = eventType;
} }
public String getCreated() { public Instant getCreated() {
return created; return created;
} }
public void setCreated(String created) { public void setCreated(Instant created) {
this.created = created; this.created = created;
} }
@ -226,31 +228,54 @@ public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEve
@Override @Override
public String toString() { public String toString() {
return "TaskHistoryEventResource [" return "TaskHistoryEventRepresentationModel [taskHistoryEventId="
+ "taskHistoryEventId= " + taskHistoryId
+ this.taskHistoryEventId + ", businessProcessId="
+ "businessProcessId= " + businessProcessId
+ this.businessProcessId + ", parentBusinessProcessId="
+ "parentBusinessProcessId= " + parentBusinessProcessId
+ this.parentBusinessProcessId + ", taskId="
+ "taskId= " + taskId
+ this.taskId + ", eventType="
+ "eventType= " + eventType
+ this.eventType + ", created="
+ "created= " + created
+ this.created + ", userId="
+ "userId= " + userId
+ this.userId + ", domain="
+ "domain= " + domain
+ this.domain + ", workbasketKey="
+ "workbasketKey= " + workbasketKey
+ this.workbasketKey + ", porCompany="
+ "oldValue= " + porCompany
+ this.oldValue + ", porType="
+ "newValue= " + porType
+ this.newValue + ", porSystem="
+ "details= " + porSystem
+ this.details + ", porInstance="
+ porInstance
+ ", porValue="
+ porValue
+ ", taskClassificationKey="
+ taskClassificationKey
+ ", taskClassificationCategory="
+ taskClassificationCategory
+ ", attachmentClassificationKey="
+ attachmentClassificationKey
+ ", oldValue="
+ oldValue
+ ", newValue="
+ newValue
+ ", custom1="
+ custom1
+ ", custom2="
+ custom2
+ ", custom3="
+ custom3
+ ", custom4="
+ custom4
+ ", details="
+ details
+ "]"; + "]";
} }
} }

View File

@ -1,32 +0,0 @@
package pro.taskana.simplehistory.rest.resource;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel.PageMetadata;
import pro.taskana.common.rest.models.PagedResources;
/** Resource class for {@link TaskHistoryEventResource} with Pagination. */
public class TaskHistoryEventListResource extends PagedResources<TaskHistoryEventResource> {
public TaskHistoryEventListResource() {
super();
}
public TaskHistoryEventListResource(
Collection<TaskHistoryEventResource> content, PageMetadata metadata, Link... links) {
super(content, metadata, links);
}
public TaskHistoryEventListResource(
Collection<TaskHistoryEventResource> content, PageMetadata metadata, Iterable<Link> links) {
super(content, metadata, links);
}
@Override
@JsonProperty("taskHistoryEvents")
public Collection<TaskHistoryEventResource> getContent() {
return super.getContent();
}
}

View File

@ -1,46 +0,0 @@
package pro.taskana.simplehistory.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import org.springframework.beans.BeanUtils;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.rest.TaskHistoryEventController;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException;
/** Transforms any {@link HistoryEventImpl} into its {@link TaskHistoryEventResource}. */
public class TaskHistoryEventResourceAssembler
extends RepresentationModelAssemblerSupport<TaskanaHistoryEvent, TaskHistoryEventResource> {
public TaskHistoryEventResourceAssembler() {
super(HistoryEventImpl.class, TaskHistoryEventResource.class);
}
@NonNull
@Override
public TaskHistoryEventResource toModel(@NonNull TaskanaHistoryEvent historyEvent) {
TaskHistoryEventResource resource = createModelWithId(historyEvent.getId(), historyEvent);
try {
resource.removeLinks();
resource.add(
linkTo(
methodOn(TaskHistoryEventController.class)
.getTaskHistoryEvent(String.valueOf(historyEvent.getId())))
.withSelfRel());
} catch (TaskanaHistoryEventNotFoundException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
BeanUtils.copyProperties(historyEvent, resource);
if (historyEvent.getCreated() != null) {
resource.setCreated(historyEvent.getCreated().toString());
}
resource.setTaskHistoryId(String.valueOf(historyEvent.getId()));
return resource;
}
}

View File

@ -1,94 +0,0 @@
package pro.taskana;
import static org.assertj.core.api.Assertions.assertThat;
import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.rest.TaskHistoryRestConfiguration;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResource;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResourceAssembler;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Test for {@link TaskHistoryEventResourceAssembler}. */
@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = {TaskHistoryRestConfiguration.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class TaskHistoryEventResourceAssemblerTest {
private final TaskHistoryEventResourceAssembler taskHistoryEventResourceAssembler;
@Autowired
TaskHistoryEventResourceAssemblerTest(
TaskHistoryEventResourceAssembler taskHistoryEventResourceAssembler) {
this.taskHistoryEventResourceAssembler = taskHistoryEventResourceAssembler;
}
@Test
void taskHistoryEventModelToResource() {
HistoryEventImpl historyEvent =
new HistoryEventImpl("HEI:000000000000000000000000000000000000", "user1", "someDetails");
historyEvent.setEventType("TASK_CREATED");
historyEvent.setBusinessProcessId("BPI:01");
historyEvent.setParentBusinessProcessId("BPI:02");
historyEvent.setTaskId("TKI:000000000000000000000000000000000000");
historyEvent.setTaskClassificationCategory("MANUAL");
historyEvent.setDomain("DOMAIN_A");
historyEvent.setWorkbasketKey("WorkbasketKey");
historyEvent.setAttachmentClassificationKey("L1050");
historyEvent.setCreated(Instant.now());
historyEvent.setOldValue("oldValue");
historyEvent.setNewValue("newValue");
historyEvent.setPorCompany("porCompany");
historyEvent.setPorSystem("porSystem");
historyEvent.setPorType("porType");
historyEvent.setPorValue("porValue");
historyEvent.setCustom1("custom1");
historyEvent.setCustom2("custom2");
historyEvent.setCustom3("custom3");
historyEvent.setCustom4("custom4");
TaskHistoryEventResource taskHistoryEventResource =
taskHistoryEventResourceAssembler.toModel(historyEvent);
testEquality(historyEvent, taskHistoryEventResource);
}
private void testEquality(
TaskanaHistoryEvent historyEvent, TaskHistoryEventResource taskHistoryEventResource) {
assertThat(historyEvent.getEventType()).isEqualTo(taskHistoryEventResource.getEventType());
assertThat(historyEvent.getBusinessProcessId())
.isEqualTo(taskHistoryEventResource.getBusinessProcessId());
assertThat(historyEvent.getParentBusinessProcessId())
.isEqualTo(taskHistoryEventResource.getParentBusinessProcessId());
assertThat(historyEvent.getTaskId()).isEqualTo(taskHistoryEventResource.getTaskId());
assertThat(historyEvent.getTaskClassificationCategory())
.isEqualTo(taskHistoryEventResource.getTaskClassificationCategory());
assertThat(historyEvent.getDomain()).isEqualTo(taskHistoryEventResource.getDomain());
assertThat(historyEvent.getWorkbasketKey())
.isEqualTo(taskHistoryEventResource.getWorkbasketKey());
assertThat(historyEvent.getAttachmentClassificationKey())
.isEqualTo(taskHistoryEventResource.getAttachmentClassificationKey());
assertThat(historyEvent.getCreated())
.isEqualTo(Instant.parse(taskHistoryEventResource.getCreated()));
assertThat(historyEvent.getOldValue()).isEqualTo(taskHistoryEventResource.getOldValue());
assertThat(historyEvent.getNewValue()).isEqualTo(taskHistoryEventResource.getNewValue());
assertThat(historyEvent.getPorCompany()).isEqualTo(taskHistoryEventResource.getPorCompany());
assertThat(historyEvent.getPorSystem()).isEqualTo(taskHistoryEventResource.getPorSystem());
assertThat(historyEvent.getPorType()).isEqualTo(taskHistoryEventResource.getPorType());
assertThat(historyEvent.getPorValue()).isEqualTo(taskHistoryEventResource.getPorValue());
assertThat(historyEvent.getCustom1()).isEqualTo(taskHistoryEventResource.getCustom1());
assertThat(historyEvent.getCustom2()).isEqualTo(taskHistoryEventResource.getCustom2());
assertThat(historyEvent.getCustom3()).isEqualTo(taskHistoryEventResource.getCustom3());
assertThat(historyEvent.getCustom4()).isEqualTo(taskHistoryEventResource.getCustom4());
}
}

View File

@ -39,7 +39,7 @@ public class TaskHistoryEventControllerRestDocumentation {
private MockMvc mockMvc; private MockMvc mockMvc;
private HashMap<String, String> taskHistoryEventFieldDescriptionsMap = new HashMap<>(); private final HashMap<String, String> taskHistoryEventFieldDescriptionsMap = new HashMap<>();
private FieldDescriptor[] allTaskHistoryEventFieldDescriptors; private FieldDescriptor[] allTaskHistoryEventFieldDescriptors;

View File

@ -1,4 +1,4 @@
package pro.taskana.rest; package pro.taskana.simplehistory.rest;
import java.sql.SQLException; import java.sql.SQLException;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -15,7 +15,6 @@ import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import pro.taskana.simplehistory.rest.TaskHistoryRestConfiguration;
import pro.taskana.simplehistory.rest.sampledata.SampleDataGenerator; import pro.taskana.simplehistory.rest.sampledata.SampleDataGenerator;
/** Example Application to create the documentation. */ /** Example Application to create the documentation. */

View File

@ -1,10 +1,13 @@
package pro.taskana; package pro.taskana.simplehistory.rest;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collections; import java.util.Collections;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
@ -15,6 +18,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule; import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
@ -26,9 +30,8 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import pro.taskana.simplehistory.rest.TaskHistoryRestConfiguration; import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventListResource; import pro.taskana.simplehistory.rest.models.TaskHistoryEventRepresentationModel;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResource;
/** Controller for integration test. */ /** Controller for integration test. */
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@ -56,6 +59,7 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getContent()).hasSize(45); assertThat(response.getBody().getContent()).hasSize(45);
} }
@ -70,15 +74,14 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getContent()).hasSize(3); assertThat(response.getBody().getContent()).hasSize(3);
assertThat( assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
response .isNotNull()
.getBody() .get()
.getRequiredLink(IanaLinkRelations.SELF) .extracting(Link::getHref)
.getHref() .asString()
.endsWith(parameters)) .endsWith(parameters);
.isTrue();
} }
@Test @Test
@ -92,38 +95,36 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getLinks()).isNotNull();
assertThat(response.getBody().getMetadata()).isNotNull(); assertThat(response.getBody().getMetadata()).isNotNull();
assertThat(response.getBody().getContent()).hasSize(1); assertThat(response.getBody().getContent()).hasSize(1);
assertThat(response.getBody().getContent().stream().findFirst().get().getDetails()).isNull(); assertThat(response.getBody().getContent().iterator().next().getDetails()).isNull();
} }
@Test @Test
void should_ReturnSpecificTaskHistoryEventWithDetails_When_SingleEventIsQueried() { void should_ReturnSpecificTaskHistoryEventWithDetails_When_SingleEventIsQueried() {
ResponseEntity<TaskHistoryEventResource> response = ResponseEntity<TaskHistoryEventRepresentationModel> response =
template.exchange( template.exchange(
server + port + "/api/v1/task-history-event/HEI:000000000000000000000000000000000000", server + port + "/api/v1/task-history-event/HEI:000000000000000000000000000000000000",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventRepresentationModel.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getLinks()).isNotNull();
assertThat(response.getBody().getDetails()).isNotNull(); assertThat(response.getBody().getDetails()).isNotNull();
} }
@Test @Test
void testThrowsExceptionIfInvalidFilterIsUsed() { void testThrowsExceptionIfInvalidFilterIsUsed() {
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () ->
template.exchange( template.exchange(
server + port + "/api/v1/task-history-event?invalid=BPI:01", server + port + "/api/v1/task-history-event?invalid=BPI:01",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("[invalid]") .hasMessageContaining("[invalid]")
@ -136,13 +137,12 @@ class TaskHistoryEventControllerIntTest {
String currentTime = LocalDateTime.now().toString(); String currentTime = LocalDateTime.now().toString();
final String finalCurrentTime = currentTime; final String finalCurrentTime = currentTime;
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () ->
template.exchange( template.exchange(
server + port + "/api/v1/task-history-event?created=" + finalCurrentTime, server + port + "/api/v1/task-history-event?created=" + finalCurrentTime,
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining(currentTime) .hasMessageContaining(currentTime)
@ -157,6 +157,7 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getContent()).hasSize(23); assertThat(response.getBody().getContent()).hasSize(23);
} }
@ -172,25 +173,23 @@ class TaskHistoryEventControllerIntTest {
request, request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)); ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getContent()).hasSize(2); assertThat(response.getBody().getContent()).hasSize(2);
assertThat(response.getBody().getContent().iterator().next().getWorkbasketKey()) assertThat(response.getBody().getContent().iterator().next().getWorkbasketKey())
.isEqualTo("WBI:100000000000000000000000000000000002"); .isEqualTo("WBI:100000000000000000000000000000000002");
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
assertThat( .isNotNull()
response .get()
.getBody() .extracting(Link::getHref)
.getRequiredLink(IanaLinkRelations.SELF) .asString()
.getHref() .endsWith(parameters);
.endsWith(parameters)) assertThat(response.getBody().getLink("allTaskHistoryEvent"))
.isTrue(); .isNotNull()
assertThat(response.getBody().getLink("allTaskHistoryEvent")).isNotNull(); .get()
assertThat( .extracting(Link::getHref)
response .asString()
.getBody() .endsWith("/api/v1/task-history-event");
.getRequiredLink("allTaskHistoryEvent")
.getHref()
.endsWith("/api/v1/task-history-event"))
.isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
} }
@ -204,6 +203,10 @@ class TaskHistoryEventControllerIntTest {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule()); mapper.registerModule(new Jackson2HalModule());
mapper
.registerModule(new ParameterNamesModule())
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));

View File

@ -0,0 +1,108 @@
package pro.taskana.simplehistory.rest.assembler;
import static org.assertj.core.api.Assertions.assertThat;
import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.rest.TaskHistoryRestConfiguration;
import pro.taskana.simplehistory.rest.models.TaskHistoryEventRepresentationModel;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Test for {@link TaskHistoryEventRepresentationModelAssembler}. */
@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = {TaskHistoryRestConfiguration.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class TaskHistoryEventRepresentationModelAssemblerTest {
private final TaskHistoryEventRepresentationModelAssembler
taskHistoryEventRepresentationModelAssembler;
@Autowired
TaskHistoryEventRepresentationModelAssemblerTest(
TaskHistoryEventRepresentationModelAssembler taskHistoryEventRepresentationModelAssembler) {
this.taskHistoryEventRepresentationModelAssembler =
taskHistoryEventRepresentationModelAssembler;
}
@Test
void taskHistoryEventModelToResource() {
HistoryEventImpl historyEvent =
new HistoryEventImpl("HEI:000000000000000000000000000000000000", "user1", "someDetails");
historyEvent.setEventType("TASK_CREATED");
historyEvent.setBusinessProcessId("BPI:01");
historyEvent.setParentBusinessProcessId("BPI:02");
historyEvent.setTaskId("TKI:000000000000000000000000000000000000");
historyEvent.setTaskClassificationCategory("MANUAL");
historyEvent.setDomain("DOMAIN_A");
historyEvent.setWorkbasketKey("WorkbasketKey");
historyEvent.setAttachmentClassificationKey("L1050");
historyEvent.setCreated(Instant.now());
historyEvent.setOldValue("oldValue");
historyEvent.setNewValue("newValue");
historyEvent.setPorCompany("porCompany");
historyEvent.setPorSystem("porSystem");
historyEvent.setPorType("porType");
historyEvent.setPorValue("porValue");
historyEvent.setCustomAttribute(TaskHistoryCustomField.CUSTOM_1, "custom1");
historyEvent.setCustomAttribute(TaskHistoryCustomField.CUSTOM_2, "custom2");
historyEvent.setCustomAttribute(TaskHistoryCustomField.CUSTOM_3, "custom3");
historyEvent.setCustomAttribute(TaskHistoryCustomField.CUSTOM_4, "custom4");
TaskHistoryEventRepresentationModel taskHistoryEventRepresentationModel =
taskHistoryEventRepresentationModelAssembler.toModel(historyEvent);
testEquality(historyEvent, taskHistoryEventRepresentationModel);
}
private void testEquality(
TaskanaHistoryEvent historyEvent,
TaskHistoryEventRepresentationModel taskHistoryEventRepresentationModel) {
assertThat(historyEvent.getEventType())
.isEqualTo(taskHistoryEventRepresentationModel.getEventType());
assertThat(historyEvent.getBusinessProcessId())
.isEqualTo(taskHistoryEventRepresentationModel.getBusinessProcessId());
assertThat(historyEvent.getParentBusinessProcessId())
.isEqualTo(taskHistoryEventRepresentationModel.getParentBusinessProcessId());
assertThat(historyEvent.getTaskId()).isEqualTo(taskHistoryEventRepresentationModel.getTaskId());
assertThat(historyEvent.getTaskClassificationCategory())
.isEqualTo(taskHistoryEventRepresentationModel.getTaskClassificationCategory());
assertThat(historyEvent.getDomain()).isEqualTo(taskHistoryEventRepresentationModel.getDomain());
assertThat(historyEvent.getWorkbasketKey())
.isEqualTo(taskHistoryEventRepresentationModel.getWorkbasketKey());
assertThat(historyEvent.getAttachmentClassificationKey())
.isEqualTo(taskHistoryEventRepresentationModel.getAttachmentClassificationKey());
assertThat(historyEvent.getCreated())
.isEqualTo(taskHistoryEventRepresentationModel.getCreated());
assertThat(historyEvent.getOldValue())
.isEqualTo(taskHistoryEventRepresentationModel.getOldValue());
assertThat(historyEvent.getNewValue())
.isEqualTo(taskHistoryEventRepresentationModel.getNewValue());
assertThat(historyEvent.getPorCompany())
.isEqualTo(taskHistoryEventRepresentationModel.getPorCompany());
assertThat(historyEvent.getPorSystem())
.isEqualTo(taskHistoryEventRepresentationModel.getPorSystem());
assertThat(historyEvent.getPorType())
.isEqualTo(taskHistoryEventRepresentationModel.getPorType());
assertThat(historyEvent.getPorValue())
.isEqualTo(taskHistoryEventRepresentationModel.getPorValue());
assertThat(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_1))
.isEqualTo(taskHistoryEventRepresentationModel.getCustom1());
assertThat(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_2))
.isEqualTo(taskHistoryEventRepresentationModel.getCustom2());
assertThat(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_3))
.isEqualTo(taskHistoryEventRepresentationModel.getCustom3());
assertThat(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_4))
.isEqualTo(taskHistoryEventRepresentationModel.getCustom4());
}
}

View File

@ -0,0 +1,12 @@
package pro.taskana.classification.api;
public enum ClassificationCustomField {
CUSTOM_1,
CUSTOM_2,
CUSTOM_3,
CUSTOM_4,
CUSTOM_5,
CUSTOM_6,
CUSTOM_7,
CUSTOM_8
}

View File

@ -157,25 +157,29 @@ public interface ClassificationQuery
ClassificationQuery applicationEntryPointLike(String... applicationEntryPointLike); ClassificationQuery applicationEntryPointLike(String... applicationEntryPointLike);
/** /**
* Add a custom to your query. * Add the values of custom attributes for exact matching to your query.
* *
* @param num the number of the custom as String (eg "4") * @param customField identifies which custom attribute is affected.
* @param customIn filter for this custom * @param searchArguments the customField values of the searched for tasks
* @return the query * @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect. * @throws InvalidArgumentException when searchArguments is empty or null
*/ */
ClassificationQuery customAttributeIn(String num, String... customIn) ClassificationQuery customAttributeIn(
ClassificationCustomField customField, String... searchArguments)
throws InvalidArgumentException; throws InvalidArgumentException;
/** /**
* Add a custom to your query. * Add the values of custom attributes for pattern matching to your query. They will be compared
* in SQL with the LIKE operator. You may use a wildcard like % to specify the pattern. If you
* specify multiple arguments they are combined with the OR keyword.
* *
* @param num the number of the custom as String (eg "4") * @param customField identifies which custom attribute is affected.
* @param customLike filter for this custom with a LIKE-query * @param searchArguments the customField values of the searched-for tasks
* @return the query * @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect. * @throws InvalidArgumentException when searchArguments is empty or null
*/ */
ClassificationQuery customAttributeLike(String num, String... customLike) ClassificationQuery customAttributeLike(
ClassificationCustomField customField, String... searchArguments)
throws InvalidArgumentException; throws InvalidArgumentException;
/** /**
@ -260,14 +264,13 @@ public interface ClassificationQuery
ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection); ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection);
/** /**
* Sort the query result by a custom. * This method sorts the query result according to the value of a custom field.
* *
* @param num the number of the custom as String (eg "4") * @param customField identifies which custom attribute is affected.
* @param sortDirection Determines whether the result is sorted in ascending or descending order. * @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order * If sortDirection is null, the result is sorted in ascending order
* @return the query * @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect.
*/ */
ClassificationQuery orderByCustomAttribute(String num, SortDirection sortDirection) ClassificationQuery orderByCustomAttribute(
throws InvalidArgumentException; ClassificationCustomField customField, SortDirection sortDirection);
} }

View File

@ -2,6 +2,8 @@ package pro.taskana.classification.api.models;
import java.time.Instant; import java.time.Instant;
import pro.taskana.classification.api.ClassificationCustomField;
/** Interface used to specify the Classification-Model. */ /** Interface used to specify the Classification-Model. */
public interface Classification extends ClassificationSummary { public interface Classification extends ClassificationSummary {
@ -123,60 +125,12 @@ public interface Classification extends ClassificationSummary {
void setServiceLevel(String serviceLevel); void setServiceLevel(String serviceLevel);
/** /**
* Set/Change the 1. custom-attribute. * Sets the value for custom Attribute.
* *
* @param custom1 the first custom attribute * @param customField identifies which custom attribute is to be set.
* @param value the value of the custom attribute to be set
*/ */
void setCustom1(String custom1); void setCustomAttribute(ClassificationCustomField customField, String value);
/**
* Set/Change the 2. custom-attribute.
*
* @param custom2 the second custom attribute
*/
void setCustom2(String custom2);
/**
* Set/Change the 3. custom-attribute.
*
* @param custom3 the third custom attribute
*/
void setCustom3(String custom3);
/**
* Set/Change the 4. custom-attribute.
*
* @param custom4 the fourth custom attribute
*/
void setCustom4(String custom4);
/**
* Set/Change the 5. custom-attribute.
*
* @param custom5 the fifth custom attribute
*/
void setCustom5(String custom5);
/**
* Set/Change the 6. custom-attribute.
*
* @param custom6 the sixth custom attribute
*/
void setCustom6(String custom6);
/**
* Set/Change the 7. custom-attribute.
*
* @param custom7 the seventh custom attribute
*/
void setCustom7(String custom7);
/**
* Set/Change the 8. custom-attribute.
*
* @param custom8 the eight custom attribute
*/
void setCustom8(String custom8);
/** /**
* Return a summary of the current Classification. * Return a summary of the current Classification.

View File

@ -1,5 +1,7 @@
package pro.taskana.classification.api.models; package pro.taskana.classification.api.models;
import pro.taskana.classification.api.ClassificationCustomField;
/** /**
* Interface for ClassificationSummaries. This is a specific short model-object which only requieres * Interface for ClassificationSummaries. This is a specific short model-object which only requieres
* the most important informations. Specific ones can be load afterwards via ID. * the most important informations. Specific ones can be load afterwards via ID.
@ -85,60 +87,12 @@ public interface ClassificationSummary {
int getPriority(); int getPriority();
/** /**
* Get the 1. custom-attribute. * Gets the custom attribute of the classification.
* *
* @return custom1 * @param customField identifies which custom attribute is requested.
* @return the value for the given customField
*/ */
String getCustom1(); String getCustomAttribute(ClassificationCustomField customField);
/**
* Get the 2. custom-attribute.
*
* @return custom2
*/
String getCustom2();
/**
* Get the 3. custom-attribute.
*
* @return custom3
*/
String getCustom3();
/**
* Get the 4. custom-attribute.
*
* @return custom4
*/
String getCustom4();
/**
* Get the 5. custom-attribute.
*
* @return custom5
*/
String getCustom5();
/**
* Get the 6. custom-attribute.
*
* @return custom6
*/
String getCustom6();
/**
* Get the 7. custom-attribute.
*
* @return custom7
*/
String getCustom7();
/**
* Get the 8. custom-attribute.
*
* @return custom8
*/
String getCustom8();
/** /**
* Duplicates this ClassificationSummary without the id. * Duplicates this ClassificationSummary without the id.

View File

@ -8,11 +8,13 @@ import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationQuery; import pro.taskana.classification.api.ClassificationQuery;
import pro.taskana.classification.api.ClassificationQueryColumnName; import pro.taskana.classification.api.ClassificationQueryColumnName;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaRuntimeException; import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
@ -31,7 +33,9 @@ public class ClassificationQueryImpl implements ClassificationQuery {
"pro.taskana.classification.internal.ClassificationQueryMapper." "pro.taskana.classification.internal.ClassificationQueryMapper."
+ "queryClassificationColumnValues"; + "queryClassificationColumnValues";
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationQueryImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationQueryImpl.class);
private InternalTaskanaEngine taskanaEngine; private final InternalTaskanaEngine taskanaEngine;
private final List<String> orderBy;
private final List<String> orderColumns;
private ClassificationQueryColumnName columnName; private ClassificationQueryColumnName columnName;
private String[] key; private String[] key;
private String[] idIn; private String[] idIn;
@ -67,8 +71,6 @@ public class ClassificationQueryImpl implements ClassificationQuery {
private String[] custom7Like; private String[] custom7Like;
private String[] custom8In; private String[] custom8In;
private String[] custom8Like; private String[] custom8Like;
private List<String> orderBy;
private List<String> orderColumns;
ClassificationQueryImpl(InternalTaskanaEngine taskanaEngine) { ClassificationQueryImpl(InternalTaskanaEngine taskanaEngine) {
this.taskanaEngine = taskanaEngine; this.taskanaEngine = taskanaEngine;
@ -195,106 +197,80 @@ public class ClassificationQueryImpl implements ClassificationQuery {
} }
@Override @Override
public ClassificationQuery customAttributeIn(String number, String... customIn) public ClassificationQuery customAttributeIn(
throws InvalidArgumentException { ClassificationCustomField customField, String... customIn) throws InvalidArgumentException {
int num = 0;
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute cannot be converted to a number between 1 and 8",
e.getCause());
}
if (customIn.length == 0) { if (customIn.length == 0) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter"); "At least one string has to be provided as a search parameter");
} }
switch (num) { switch (customField) {
case 1: case CUSTOM_1:
this.custom1In = customIn; this.custom1In = customIn;
break; break;
case 2: case CUSTOM_2:
this.custom2In = customIn; this.custom2In = customIn;
break; break;
case 3: case CUSTOM_3:
this.custom3In = customIn; this.custom3In = customIn;
break; break;
case 4: case CUSTOM_4:
this.custom4In = customIn; this.custom4In = customIn;
break; break;
case 5: case CUSTOM_5:
this.custom5In = customIn; this.custom5In = customIn;
break; break;
case 6: case CUSTOM_6:
this.custom6In = customIn; this.custom6In = customIn;
break; break;
case 7: case CUSTOM_7:
this.custom7In = customIn; this.custom7In = customIn;
break; break;
case 8: case CUSTOM_8:
this.custom8In = customIn; this.custom8In = customIn;
break; break;
default: default:
throw new InvalidArgumentException( throw new SystemException("Unknown customField '" + customField + "'");
"Argument '"
+ number
+ "' to getCustomAttribute does not represent a number between 1 and 8");
} }
return this; return this;
} }
@Override @Override
public ClassificationQuery customAttributeLike(String number, String... customLike) public ClassificationQuery customAttributeLike(
throws InvalidArgumentException { ClassificationCustomField customField, String... customLike) throws InvalidArgumentException {
int num = 0;
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
if (customLike.length == 0) { if (customLike.length == 0) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter"); "At least one string has to be provided as a search parameter");
} }
switch (num) { switch (customField) {
case 1: case CUSTOM_1:
this.custom1Like = toUpperCopy(customLike); this.custom1Like = toUpperCopy(customLike);
break; break;
case 2: case CUSTOM_2:
this.custom2Like = toUpperCopy(customLike); this.custom2Like = toUpperCopy(customLike);
break; break;
case 3: case CUSTOM_3:
this.custom3Like = toUpperCopy(customLike); this.custom3Like = toUpperCopy(customLike);
break; break;
case 4: case CUSTOM_4:
this.custom4Like = toUpperCopy(customLike); this.custom4Like = toUpperCopy(customLike);
break; break;
case 5: case CUSTOM_5:
this.custom5Like = toUpperCopy(customLike); this.custom5Like = toUpperCopy(customLike);
break; break;
case 6: case CUSTOM_6:
this.custom6Like = toUpperCopy(customLike); this.custom6Like = toUpperCopy(customLike);
break; break;
case 7: case CUSTOM_7:
this.custom7Like = toUpperCopy(customLike); this.custom7Like = toUpperCopy(customLike);
break; break;
case 8: case CUSTOM_8:
this.custom8Like = toUpperCopy(customLike); this.custom8Like = toUpperCopy(customLike);
break; break;
default: default:
throw new InvalidArgumentException( throw new SystemException("Unknown customField '" + customField + "'");
"Argument '"
+ number
+ "' to getCustomAttribute does not represent a number between 1 and 16");
} }
return this; return this;
@ -346,42 +322,9 @@ public class ClassificationQueryImpl implements ClassificationQuery {
} }
@Override @Override
public ClassificationQuery orderByCustomAttribute(String number, SortDirection sortDirection) public ClassificationQuery orderByCustomAttribute(
throws InvalidArgumentException { ClassificationCustomField customField, SortDirection sortDirection) {
int num = 0; return addOrderCriteria(customField.name(), sortDirection);
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
switch (num) {
case 1:
return addOrderCriteria("CUSTOM_1", sortDirection);
case 2:
return addOrderCriteria("CUSTOM_2", sortDirection);
case 3:
return addOrderCriteria("CUSTOM_3", sortDirection);
case 4:
return addOrderCriteria("CUSTOM_4", sortDirection);
case 5:
return addOrderCriteria("CUSTOM_5", sortDirection);
case 6:
return addOrderCriteria("CUSTOM_6", sortDirection);
case 7:
return addOrderCriteria("CUSTOM_7", sortDirection);
case 8:
return addOrderCriteria("CUSTOM_8", sortDirection);
default:
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute does not represent a number between 1 and 16");
}
} }
@Override @Override
@ -410,8 +353,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
RowBounds rowBounds = new RowBounds(offset, limit); RowBounds rowBounds = new RowBounds(offset, limit);
result = taskanaEngine.getSqlSession().selectList(LINK_TO_SUMMARYMAPPER, this, rowBounds); result = taskanaEngine.getSqlSession().selectList(LINK_TO_SUMMARYMAPPER, this, rowBounds);
return result; return result;
} catch (Exception e) { } catch (PersistenceException e) {
if (e instanceof PersistenceException) {
if (e.getMessage().contains("ERRORCODE=-4470")) { if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex = TaskanaRuntimeException ex =
new TaskanaRuntimeException( new TaskanaRuntimeException(
@ -419,7 +361,6 @@ public class ClassificationQueryImpl implements ClassificationQuery {
ex.setStackTrace(e.getStackTrace()); ex.setStackTrace(e.getStackTrace());
throw ex; throw ex;
} }
}
throw e; throw e;
} finally { } finally {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();

View File

@ -3,8 +3,10 @@ package pro.taskana.classification.internal.models;
import java.time.Instant; import java.time.Instant;
import java.util.Objects; import java.util.Objects;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.models.Classification; import pro.taskana.classification.api.models.Classification;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.SystemException;
/** Classification entity. */ /** Classification entity. */
public class ClassificationImpl extends ClassificationSummaryImpl implements Classification { public class ClassificationImpl extends ClassificationSummaryImpl implements Classification {
@ -78,6 +80,38 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
this.description = description; this.description = description;
} }
@Override
public void setCustomAttribute(ClassificationCustomField customField, String value) {
switch (customField) {
case CUSTOM_1:
custom1 = value;
break;
case CUSTOM_2:
custom2 = value;
break;
case CUSTOM_3:
custom3 = value;
break;
case CUSTOM_4:
custom4 = value;
break;
case CUSTOM_5:
custom5 = value;
break;
case CUSTOM_6:
custom6 = value;
break;
case CUSTOM_7:
custom7 = value;
break;
case CUSTOM_8:
custom8 = value;
break;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
}
@Override @Override
public ClassificationSummary asSummary() { public ClassificationSummary asSummary() {
ClassificationSummaryImpl summary = new ClassificationSummaryImpl(); ClassificationSummaryImpl summary = new ClassificationSummaryImpl();

View File

@ -2,7 +2,9 @@ package pro.taskana.classification.internal.models;
import java.util.Objects; import java.util.Objects;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.SystemException;
/** Implementation for the short summaries of a classification entity. */ /** Implementation for the short summaries of a classification entity. */
public class ClassificationSummaryImpl implements ClassificationSummary { public class ClassificationSummaryImpl implements ClassificationSummary {
@ -149,6 +151,29 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
} }
@Override @Override
public String getCustomAttribute(ClassificationCustomField customField) {
switch (customField) {
case CUSTOM_1:
return custom1;
case CUSTOM_2:
return custom2;
case CUSTOM_3:
return custom3;
case CUSTOM_4:
return custom4;
case CUSTOM_5:
return custom5;
case CUSTOM_6:
return custom6;
case CUSTOM_7:
return custom7;
case CUSTOM_8:
return custom8;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
}
public String getCustom1() { public String getCustom1() {
return custom1; return custom1;
} }
@ -157,7 +182,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom1 = custom1; this.custom1 = custom1;
} }
@Override
public String getCustom2() { public String getCustom2() {
return custom2; return custom2;
} }
@ -166,7 +190,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom2 = custom2; this.custom2 = custom2;
} }
@Override
public String getCustom3() { public String getCustom3() {
return custom3; return custom3;
} }
@ -175,7 +198,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom3 = custom3; this.custom3 = custom3;
} }
@Override
public String getCustom4() { public String getCustom4() {
return custom4; return custom4;
} }
@ -184,7 +206,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom4 = custom4; this.custom4 = custom4;
} }
@Override
public String getCustom5() { public String getCustom5() {
return custom5; return custom5;
} }
@ -193,7 +214,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom5 = custom5; this.custom5 = custom5;
} }
@Override
public String getCustom6() { public String getCustom6() {
return custom6; return custom6;
} }
@ -202,7 +222,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom6 = custom6; this.custom6 = custom6;
} }
@Override
public String getCustom7() { public String getCustom7() {
return custom7; return custom7;
} }
@ -211,7 +230,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom7 = custom7; this.custom7 = custom7;
} }
@Override
public String getCustom8() { public String getCustom8() {
return custom8; return custom8;
} }

View File

@ -2,11 +2,11 @@ package pro.taskana.monitor.api;
import pro.taskana.monitor.api.reports.ClassificationCategoryReport; import pro.taskana.monitor.api.reports.ClassificationCategoryReport;
import pro.taskana.monitor.api.reports.ClassificationReport; import pro.taskana.monitor.api.reports.ClassificationReport;
import pro.taskana.monitor.api.reports.CustomFieldValueReport; import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
import pro.taskana.monitor.api.reports.TaskStatusReport; import pro.taskana.monitor.api.reports.TaskStatusReport;
import pro.taskana.monitor.api.reports.TimestampReport; import pro.taskana.monitor.api.reports.TimestampReport;
import pro.taskana.monitor.api.reports.WorkbasketReport; import pro.taskana.monitor.api.reports.WorkbasketReport;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
/** The Monitor Service manages operations on tasks regarding the monitoring. */ /** The Monitor Service manages operations on tasks regarding the monitoring. */
public interface MonitorService { public interface MonitorService {
@ -38,13 +38,14 @@ public interface MonitorService {
ClassificationReport.Builder createClassificationReportBuilder(); ClassificationReport.Builder createClassificationReportBuilder();
/** /**
* Provides a {@link CustomFieldValueReport.Builder} for creating a {@link CustomFieldValueReport} * Provides a {@link TaskCustomFieldValueReport.Builder} for creating a {@link
* and list the values of an entered custom attribute. * TaskCustomFieldValueReport} and list the values of an entered custom attribute.
* *
* @param customField the customField whose values should appear in the report * @param taskCustomField the customField whose values should appear in the report
* @return a {@link CustomFieldValueReport.Builder} * @return a {@link TaskCustomFieldValueReport.Builder}
*/ */
CustomFieldValueReport.Builder createCustomFieldValueReportBuilder(CustomField customField); TaskCustomFieldValueReport.Builder createCustomFieldValueReportBuilder(
TaskCustomField taskCustomField);
/** /**
* Provides a {@link TaskStatusReport.Builder} for creating a {@link TaskStatusReport}. * Provides a {@link TaskStatusReport.Builder} for creating a {@link TaskStatusReport}.

View File

@ -16,21 +16,22 @@ import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
* contains also the number of tasks of the respective cluster. The age of the tasks can be counted * contains also the number of tasks of the respective cluster. The age of the tasks can be counted
* in days or in working days. Tasks with Timestamp DUE = null are not considered. * in days or in working days. Tasks with Timestamp DUE = null are not considered.
*/ */
public class CustomFieldValueReport extends Report<MonitorQueryItem, TimeIntervalColumnHeader> { public class TaskCustomFieldValueReport extends Report<MonitorQueryItem, TimeIntervalColumnHeader> {
public CustomFieldValueReport(List<TimeIntervalColumnHeader> timeIntervalColumnHeaders) { public TaskCustomFieldValueReport(List<TimeIntervalColumnHeader> timeIntervalColumnHeaders) {
super(timeIntervalColumnHeaders, new String[] {"CUSTOM FIELDS"}); super(timeIntervalColumnHeaders, new String[] {"TASK CUSTOM FIELDS"});
} }
/** Builder for {@link CustomFieldValueReport}. */ /** Builder for {@link TaskCustomFieldValueReport}. */
public interface Builder public interface Builder
extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> { extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> {
@Override @Override
CustomFieldValueReport buildReport() throws NotAuthorizedException, InvalidArgumentException; TaskCustomFieldValueReport buildReport()
throws NotAuthorizedException, InvalidArgumentException;
@Override @Override
CustomFieldValueReport buildReport(TaskTimestamp timestamp) TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException; throws NotAuthorizedException, InvalidArgumentException;
} }
} }

View File

@ -9,7 +9,7 @@ import pro.taskana.monitor.api.SelectedItem;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.AgeQueryItem; import pro.taskana.monitor.api.reports.item.AgeQueryItem;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** /**
@ -102,7 +102,7 @@ public interface TimeIntervalReportBuilder<
* @param customAttributeFilter a map of custom attributes and custom attribute value * @param customAttributeFilter a map of custom attributes and custom attribute value
* @return the TimeIntervalReportBuilder * @return the TimeIntervalReportBuilder
*/ */
B customAttributeFilterIn(Map<CustomField, String> customAttributeFilter); B customAttributeFilterIn(Map<TaskCustomField, String> customAttributeFilter);
/** /**
* Returns a list of all taskIds of the report that are in the list of selected items. * Returns a list of all taskIds of the report that are in the list of selected items.
@ -118,11 +118,11 @@ public interface TimeIntervalReportBuilder<
/** /**
* Returns a list of all values of an entered custom field that are in the report. * Returns a list of all values of an entered custom field that are in the report.
* *
* @param customField the customField whose values should appear in the list * @param taskCustomField the customField whose values should appear in the list
* @return the list of all custom attribute values * @return the list of all custom attribute values
* @throws NotAuthorizedException if the user has no rights to access the monitor * @throws NotAuthorizedException if the user has no rights to access the monitor
*/ */
List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField) List<String> listCustomAttributeValuesForCustomAttributeName(TaskCustomField taskCustomField)
throws NotAuthorizedException; throws NotAuthorizedException;
Report<I, H> buildReport(TaskTimestamp timestamp) Report<I, H> buildReport(TaskTimestamp timestamp)

View File

@ -14,7 +14,7 @@ import pro.taskana.monitor.api.reports.item.DetailedMonitorQueryItem;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem; import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.monitor.api.reports.item.TaskQueryItem; import pro.taskana.monitor.api.reports.item.TaskQueryItem;
import pro.taskana.monitor.api.reports.item.TimestampQueryItem; import pro.taskana.monitor.api.reports.item.TimestampQueryItem;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** This class is the mybatis mapping of task monitoring. */ /** This class is the mybatis mapping of task monitoring. */
@ -74,7 +74,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp, @Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter, @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter,
@Param("combinedClassificationFilter") @Param("combinedClassificationFilter")
List<CombinedClassificationFilter> combinedClassificationFilter); List<CombinedClassificationFilter> combinedClassificationFilter);
@ -125,7 +125,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp, @Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter); @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select( @Select(
"<script>" "<script>"
@ -174,7 +174,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp, @Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter); @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select( @Select(
"<script>" "<script>"
@ -224,7 +224,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp, @Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter); @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select( @Select(
"<script>" "<script>"
@ -266,7 +266,7 @@ public interface MonitorMapper {
@Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks") @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")
}) })
List<MonitorQueryItem> getTaskCountOfCustomFieldValues( List<MonitorQueryItem> getTaskCountOfCustomFieldValues(
@Param("customField") CustomField customField, @Param("customField") TaskCustomField taskCustomField,
@Param("workbasketIds") List<String> workbasketIds, @Param("workbasketIds") List<String> workbasketIds,
@Param("states") List<TaskState> states, @Param("states") List<TaskState> states,
@Param("classificationCategories") List<String> classificationCategories, @Param("classificationCategories") List<String> classificationCategories,
@ -274,7 +274,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp, @Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter); @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select( @Select(
"<script>" "<script>"
@ -333,7 +333,7 @@ public interface MonitorMapper {
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter, @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter,
@Param("groupedBy") String groupedBy, @Param("groupedBy") String groupedBy,
@Param("selectedItems") List<SelectedItem> selectedItems, @Param("selectedItems") List<SelectedItem> selectedItems,
@Param("joinWithAttachments") boolean joinWithAttachments); @Param("joinWithAttachments") boolean joinWithAttachments);
@ -395,8 +395,8 @@ public interface MonitorMapper {
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter, @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter,
@Param("customField") CustomField customField); @Param("customField") TaskCustomField taskCustomField);
@Select( @Select(
"<script>" "<script>"
@ -452,5 +452,5 @@ public interface MonitorMapper {
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter); @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
} }

View File

@ -4,7 +4,7 @@ import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.reports.ClassificationCategoryReport; import pro.taskana.monitor.api.reports.ClassificationCategoryReport;
import pro.taskana.monitor.api.reports.ClassificationReport; import pro.taskana.monitor.api.reports.ClassificationReport;
import pro.taskana.monitor.api.reports.CustomFieldValueReport; import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
import pro.taskana.monitor.api.reports.TaskStatusReport; import pro.taskana.monitor.api.reports.TaskStatusReport;
import pro.taskana.monitor.api.reports.TimestampReport; import pro.taskana.monitor.api.reports.TimestampReport;
import pro.taskana.monitor.api.reports.WorkbasketReport; import pro.taskana.monitor.api.reports.WorkbasketReport;
@ -14,7 +14,7 @@ import pro.taskana.monitor.internal.reports.CustomFieldValueReportBuilderImpl;
import pro.taskana.monitor.internal.reports.TaskStatusReportBuilderImpl; import pro.taskana.monitor.internal.reports.TaskStatusReportBuilderImpl;
import pro.taskana.monitor.internal.reports.TimestampReportBuilderImpl; import pro.taskana.monitor.internal.reports.TimestampReportBuilderImpl;
import pro.taskana.monitor.internal.reports.WorkbasketReportBuilderImpl; import pro.taskana.monitor.internal.reports.WorkbasketReportBuilderImpl;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
/** This is the implementation of MonitorService. */ /** This is the implementation of MonitorService. */
public class MonitorServiceImpl implements MonitorService { public class MonitorServiceImpl implements MonitorService {
@ -44,9 +44,9 @@ public class MonitorServiceImpl implements MonitorService {
} }
@Override @Override
public CustomFieldValueReport.Builder createCustomFieldValueReportBuilder( public TaskCustomFieldValueReport.Builder createCustomFieldValueReportBuilder(
CustomField customField) { TaskCustomField taskCustomField) {
return new CustomFieldValueReportBuilderImpl(taskanaEngine, monitorMapper, customField); return new CustomFieldValueReportBuilderImpl(taskanaEngine, monitorMapper, taskCustomField);
} }
@Override @Override

View File

@ -9,47 +9,49 @@ import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.CustomFieldValueReport; import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
import pro.taskana.monitor.api.reports.CustomFieldValueReport.Builder; import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport.Builder;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem; import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.monitor.internal.MonitorMapper; import pro.taskana.monitor.internal.MonitorMapper;
import pro.taskana.monitor.internal.preprocessor.DaysToWorkingDaysReportPreProcessor; import pro.taskana.monitor.internal.preprocessor.DaysToWorkingDaysReportPreProcessor;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
/** The implementation of CustomFieldValueReportBuilder. */ /** The implementation of CustomFieldValueReportBuilder. */
public class CustomFieldValueReportBuilderImpl public class CustomFieldValueReportBuilderImpl
extends TimeIntervalReportBuilderImpl<Builder, MonitorQueryItem, TimeIntervalColumnHeader> extends TimeIntervalReportBuilderImpl<Builder, MonitorQueryItem, TimeIntervalColumnHeader>
implements CustomFieldValueReport.Builder { implements TaskCustomFieldValueReport.Builder {
private static final Logger LOGGER = private static final Logger LOGGER =
LoggerFactory.getLogger(CustomFieldValueReportBuilderImpl.class); LoggerFactory.getLogger(CustomFieldValueReportBuilderImpl.class);
private final CustomField customField; private final TaskCustomField taskCustomField;
public CustomFieldValueReportBuilderImpl( public CustomFieldValueReportBuilderImpl(
InternalTaskanaEngine taskanaEngine, MonitorMapper monitorMapper, CustomField customField) { InternalTaskanaEngine taskanaEngine,
MonitorMapper monitorMapper,
TaskCustomField taskCustomField) {
super(taskanaEngine, monitorMapper); super(taskanaEngine, monitorMapper);
this.customField = customField; this.taskCustomField = taskCustomField;
} }
@Override @Override
public CustomFieldValueReport buildReport() public TaskCustomFieldValueReport buildReport()
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
return buildReport(TaskTimestamp.DUE); return buildReport(TaskTimestamp.DUE);
} }
@Override @Override
public CustomFieldValueReport buildReport(TaskTimestamp timestamp) public TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to buildReport(customField = {}), this = {}", this.customField, this); LOGGER.debug("entry to buildReport(taskCustomField = {}), this = {}", taskCustomField, this);
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();
CustomFieldValueReport report = new CustomFieldValueReport(this.columnHeaders); TaskCustomFieldValueReport report = new TaskCustomFieldValueReport(this.columnHeaders);
List<MonitorQueryItem> monitorQueryItems = List<MonitorQueryItem> monitorQueryItems =
this.monitorMapper.getTaskCountOfCustomFieldValues( this.monitorMapper.getTaskCountOfCustomFieldValues(
this.customField, this.taskCustomField,
this.workbasketIds, this.workbasketIds,
this.states, this.states,
this.classificationCategory, this.classificationCategory,
@ -71,12 +73,12 @@ public class CustomFieldValueReportBuilderImpl
} }
@Override @Override
protected CustomFieldValueReport.Builder _this() { protected TaskCustomFieldValueReport.Builder _this() {
return this; return this;
} }
@Override @Override
protected String determineGroupedBy() { protected String determineGroupedBy() {
return customField.name(); return taskCustomField.name();
} }
} }

View File

@ -20,7 +20,7 @@ import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.AgeQueryItem; import pro.taskana.monitor.api.reports.item.AgeQueryItem;
import pro.taskana.monitor.internal.MonitorMapper; import pro.taskana.monitor.internal.MonitorMapper;
import pro.taskana.monitor.internal.preprocessor.WorkingDaysToDaysReportConverter; import pro.taskana.monitor.internal.preprocessor.WorkingDaysToDaysReportConverter;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** /**
@ -48,7 +48,7 @@ abstract class TimeIntervalReportBuilderImpl<
protected List<String> domains; protected List<String> domains;
protected List<String> classificationIds; protected List<String> classificationIds;
protected List<String> excludedClassificationIds; protected List<String> excludedClassificationIds;
protected Map<CustomField, String> customAttributeFilter; protected Map<TaskCustomField, String> customAttributeFilter;
protected WorkingDaysToDaysConverter converter; protected WorkingDaysToDaysConverter converter;
TimeIntervalReportBuilderImpl(InternalTaskanaEngine taskanaEngine, MonitorMapper monitorMapper) { TimeIntervalReportBuilderImpl(InternalTaskanaEngine taskanaEngine, MonitorMapper monitorMapper) {
@ -107,7 +107,7 @@ abstract class TimeIntervalReportBuilderImpl<
} }
@Override @Override
public B customAttributeFilterIn(Map<CustomField, String> customAttributeFilter) { public B customAttributeFilterIn(Map<TaskCustomField, String> customAttributeFilter) {
this.customAttributeFilter = new HashMap<>(customAttributeFilter); this.customAttributeFilter = new HashMap<>(customAttributeFilter);
return _this(); return _this();
} }
@ -156,11 +156,12 @@ abstract class TimeIntervalReportBuilderImpl<
} }
@Override @Override
public List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField) public List<String> listCustomAttributeValuesForCustomAttributeName(
TaskCustomField taskCustomField)
throws NotAuthorizedException { throws NotAuthorizedException {
LOGGER.debug( LOGGER.debug(
"entry to listCustomAttributeValuesForCustomAttributeName(customField = {}), this = {}", "entry to listCustomAttributeValuesForCustomAttributeName(customField = {}), this = {}",
customField, taskCustomField,
this); this);
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR);
try { try {
@ -173,7 +174,7 @@ abstract class TimeIntervalReportBuilderImpl<
this.classificationIds, this.classificationIds,
this.excludedClassificationIds, this.excludedClassificationIds,
this.customAttributeFilter, this.customAttributeFilter,
customField); taskCustomField);
} finally { } finally {
this.taskanaEngine.returnConnection(); this.taskanaEngine.returnConnection();
LOGGER.debug("exit from listCustomAttributeValuesForCustomAttributeName()."); LOGGER.debug("exit from listCustomAttributeValuesForCustomAttributeName().");

View File

@ -0,0 +1,8 @@
package pro.taskana.spi.history.api.events;
public enum TaskHistoryCustomField {
CUSTOM_1,
CUSTOM_2,
CUSTOM_3,
CUSTOM_4
}

View File

@ -2,6 +2,8 @@ package pro.taskana.spi.history.api.events;
import java.time.Instant; import java.time.Instant;
import pro.taskana.common.api.exceptions.SystemException;
/** Super class for all specific events from the TASKANA engine. */ /** Super class for all specific events from the TASKANA engine. */
public class TaskanaHistoryEvent { public class TaskanaHistoryEvent {
@ -38,6 +40,40 @@ public class TaskanaHistoryEvent {
this.details = details; this.details = details;
} }
public void setCustomAttribute(TaskHistoryCustomField customField, String value) {
switch (customField) {
case CUSTOM_1:
custom1 = value;
break;
case CUSTOM_2:
custom2 = value;
break;
case CUSTOM_3:
custom3 = value;
break;
case CUSTOM_4:
custom4 = value;
break;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
}
public String getCustomAttribute(TaskHistoryCustomField customField) {
switch (customField) {
case CUSTOM_1:
return custom1;
case CUSTOM_2:
return custom2;
case CUSTOM_3:
return custom3;
case CUSTOM_4:
return custom4;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
}
public String getId() { public String getId() {
return id; return id;
} }
@ -190,38 +226,6 @@ public class TaskanaHistoryEvent {
this.newValue = newValue; this.newValue = newValue;
} }
public String getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
public String getDetails() { public String getDetails() {
return details; return details;
} }

View File

@ -1,7 +1,6 @@
package pro.taskana.task.api; package pro.taskana.task.api;
/** This enum contains the fields CUSTOM_1 - CUSTOM_10 for the task entity. */ public enum TaskCustomField {
public enum CustomField {
CUSTOM_1, CUSTOM_1,
CUSTOM_2, CUSTOM_2,
CUSTOM_3, CUSTOM_3,

View File

@ -428,31 +428,27 @@ public interface TaskQuery extends BaseQuery<TaskSummary, TaskQueryColumnName> {
TaskQuery businessProcessIdLike(String... businessProcessIds); TaskQuery businessProcessIdLike(String... businessProcessIds);
/** /**
* Add the values of custom attribute number num for exact matching to your query. * Add the values of custom attributes for exact matching to your query.
* *
* @param num identifies which custom attribute is affected. Taskana concatenates "custom_" with * @param customField identifies which custom attribute is affected.
* num and the resulting String must match the name of the database column that contains the * @param searchArguments the customField values of the searched for tasks
* custom attribute. Valid values are "1", "2" .. "16"
* @param searchArguments the custom_num values of the searched for tasks
* @return the query * @return the query
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16" * @throws InvalidArgumentException when searchArguments is not given
*/ */
TaskQuery customAttributeIn(String num, String... searchArguments) TaskQuery customAttributeIn(TaskCustomField customField, String... searchArguments)
throws InvalidArgumentException; throws InvalidArgumentException;
/** /**
* Add the values of custom attribute number num for pattern matching to your query. They will be * Add the values of custom attributes for pattern matching to your query. They will be compared
* compared in SQL with the LIKE operator. You may use a wildcard like % to specify the pattern. * in SQL with the LIKE operator. You may use a wildcard like % to specify the pattern. If you
* If you specify multiple arguments they are combined with the OR keyword. * specify multiple arguments they are combined with the OR keyword.
* *
* @param num identifies which custom attribute is affected. Taskana concatenates "custom_" with * @param customField identifies which custom attribute is affected.
* num and the resulting String must match the name of the database column that contains the * @param searchArguments the customField values of the searched-for tasks
* custom attribute. Valid values are "1", "2" .. "16"
* @param searchArguments the custom_num values of the searched-for tasks
* @return the query * @return the query
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16" * @throws InvalidArgumentException if searchArguments is not given
*/ */
TaskQuery customAttributeLike(String num, String... searchArguments) TaskQuery customAttributeLike(TaskCustomField customField, String... searchArguments)
throws InvalidArgumentException; throws InvalidArgumentException;
/** /**
@ -812,19 +808,14 @@ public interface TaskQuery extends BaseQuery<TaskSummary, TaskQueryColumnName> {
TaskQuery orderByWorkbasketKey(SortDirection sortDirection); TaskQuery orderByWorkbasketKey(SortDirection sortDirection);
/** /**
* This method sorts the query result according to the value of a custom field. The custom field * This method sorts the query result according to the value of a custom field.
* is choosen by parameter num.
* *
* @param num identifies which custom attribute is affected. Taskana concatenates "custom_" with * @param customField identifies which custom attribute is affected.
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @param sortDirection Determines whether the result is sorted in ascending or descending order. * @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order * If sortDirection is null, the result is sorted in ascending order
* @return the query * @return the query
* @throws InvalidArgumentException when number is not a valid number between 1 and 16
*/ */
TaskQuery orderByCustomAttribute(String num, SortDirection sortDirection) TaskQuery orderByCustomAttribute(TaskCustomField customField, SortDirection sortDirection);
throws InvalidArgumentException;
/** /**
* Filter for summaries which are containing one of the given taskIds. * Filter for summaries which are containing one of the given taskIds.

View File

@ -373,15 +373,13 @@ public interface TaskService {
* *
* @param selectionCriteria the {@link ObjectReference} that is used to select the tasks. * @param selectionCriteria the {@link ObjectReference} that is used to select the tasks.
* @param customFieldsToUpdate a {@link Map} that contains as key the identification of the custom * @param customFieldsToUpdate a {@link Map} that contains as key the identification of the custom
* field and as value the corresponding new value of that custom field. The key for * field and as value the corresponding new value of that custom field.
* identification of the custom field must be a String with value "1", "2" ... "16" as in the
* setCustomAttribute or getCustomAttribute method of {@link Task}
* @return a list of the Ids of all modified tasks * @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException If the customFieldsToUpdate map contains an invalid key or if * @throws InvalidArgumentException if the given selectionCriteria is invalid or the given
* the selectionCriteria is invalid * customFieldsToUpdate are null or empty.
*/ */
List<String> updateTasks( List<String> updateTasks(
ObjectReference selectionCriteria, Map<String, String> customFieldsToUpdate) ObjectReference selectionCriteria, Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException; throws InvalidArgumentException;
/** /**
@ -389,14 +387,11 @@ public interface TaskService {
* *
* @param taskIds the taskIds that are used to select the tasks. * @param taskIds the taskIds that are used to select the tasks.
* @param customFieldsToUpdate a {@link Map} that contains as key the identification of the custom * @param customFieldsToUpdate a {@link Map} that contains as key the identification of the custom
* field and as value the corresponding new value of that custom field. The key for * field and as value the corresponding new value of that custom field.
* identification of the custom field must be a String with value "1", "2" ... "16" as in the
* setCustomAttribute or getCustomAttribute method of {@link Task}
* @return a list of the Ids of all modified tasks * @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException If the customFieldsToUpdate map contains an invalid key or if * @throws InvalidArgumentException if the given customFieldsToUpdate are null or empty.
* the selectionCriteria is invalid
*/ */
List<String> updateTasks(List<String> taskIds, Map<String, String> customFieldsToUpdate) List<String> updateTasks(List<String> taskIds, Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException; throws InvalidArgumentException;
/** /**

View File

@ -41,7 +41,7 @@ public interface Attachment extends AttachmentSummary {
* *
* @return customAttributes as {@link Map} * @return customAttributes as {@link Map}
*/ */
Map<String, String> getCustomAttributes(); Map<String, String> getCustomAttributeMap();
/** /**
* Sets the custom attribute Map of the attachment. * Sets the custom attribute Map of the attachment.
@ -49,7 +49,7 @@ public interface Attachment extends AttachmentSummary {
* @param customAttributes a {@link Map} that contains the custom attributes of the attachment as * @param customAttributes a {@link Map} that contains the custom attributes of the attachment as
* key, value pairs * key, value pairs
*/ */
void setCustomAttributes(Map<String, String> customAttributes); void setCustomAttributeMap(Map<String, String> customAttributes);
/** /**
* Return a summary of the current Attachment. * Return a summary of the current Attachment.

View File

@ -5,7 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import pro.taskana.classification.api.models.Classification; import pro.taskana.classification.api.models.Classification;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
/** task-Interface to specify attribute interactions. */ /** task-Interface to specify attribute interactions. */
@ -77,14 +77,14 @@ public interface Task extends TaskSummary {
* *
* @return customAttributes as {@link Map} * @return customAttributes as {@link Map}
*/ */
Map<String, String> getCustomAttributes(); Map<String, String> getCustomAttributeMap();
/** /**
* Sets a Map of custom Attributes. * Sets a Map of custom Attributes.
* *
* @param customAttributes a {@link Map} that contains the custom attributes * @param customAttributes a {@link Map} that contains the custom attributes
*/ */
void setCustomAttributes(Map<String, String> customAttributes); void setCustomAttributeMap(Map<String, String> customAttributes);
/** /**
* Returns a Map of Callback info. * Returns a Map of Callback info.
@ -101,15 +101,12 @@ public interface Task extends TaskSummary {
void setCallbackInfo(Map<String, String> callbackInfo); void setCallbackInfo(Map<String, String> callbackInfo);
/** /**
* Sets the value for custom Attribute number num. * Sets the value for custom Attribute.
* *
* @param num identifies which custom attribute is to be set. Taskana concatenates "custom_" with * @param customField identifies which custom attribute is to be set.
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @param value the value of the custom attribute to be set * @param value the value of the custom attribute to be set
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16"
*/ */
void setCustomAttribute(String num, String value) throws InvalidArgumentException; void setCustomAttribute(TaskCustomField customField, String value);
/** /**
* Add an attachment.<br> * Add an attachment.<br>

View File

@ -4,7 +4,7 @@ import java.time.Instant;
import java.util.List; import java.util.List;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ -183,15 +183,12 @@ public interface TaskSummary {
boolean isTransferred(); boolean isTransferred();
/** /**
* Gets the custom attribute number num of the task. * Gets the custom attribute of the task.
* *
* @param num identifies which custom attribute is requested. Taskana concatenates "custom_" with * @param customField identifies which custom attribute is requested.
* num and the resulting String must match the name of the database column that contains the * @return the value for the given customField
* custom attribute. Valid values are "1", "2" .. "16"
* @return the value of custom attribute number num
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16"
*/ */
String getCustomAttribute(String num) throws InvalidArgumentException; String getCustomAttribute(TaskCustomField customField);
/** /**
* Duplicates this TaskSummary without the internal and external id. * Duplicates this TaskSummary without the internal and external id.

View File

@ -1,13 +1,12 @@
package pro.taskana.common.internal; package pro.taskana.task.internal;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.task.api.TaskCustomField;
/** /**
* Determines which custom properties are to be updated. * Determines which custom properties are to be updated.
*
* @author bbr
*/ */
public class CustomPropertySelector { public class TaskCustomPropertySelector {
boolean custom1 = false; boolean custom1 = false;
boolean custom2 = false; boolean custom2 = false;
@ -26,70 +25,58 @@ public class CustomPropertySelector {
boolean custom15 = false; boolean custom15 = false;
boolean custom16 = false; boolean custom16 = false;
public void setCustomProperty(String propertyNumber, boolean value) public void setCustomProperty(TaskCustomField customField, boolean value) {
throws InvalidArgumentException { switch (customField) {
int num = 0; case CUSTOM_1:
try {
num = Integer.parseInt(propertyNumber);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"propertyNumber '"
+ propertyNumber
+ "' cannot be converted to a number between 1 and 16");
}
switch (num) {
case 1:
this.setCustom1(value); this.setCustom1(value);
break; break;
case 2: case CUSTOM_2:
this.setCustom2(value); this.setCustom2(value);
break; break;
case 3: case CUSTOM_3:
this.setCustom3(value); this.setCustom3(value);
break; break;
case 4: case CUSTOM_4:
this.setCustom4(value); this.setCustom4(value);
break; break;
case 5: case CUSTOM_5:
this.setCustom5(value); this.setCustom5(value);
break; break;
case 6: case CUSTOM_6:
this.setCustom6(value); this.setCustom6(value);
break; break;
case 7: case CUSTOM_7:
this.setCustom7(value); this.setCustom7(value);
break; break;
case 8: case CUSTOM_8:
this.setCustom8(value); this.setCustom8(value);
break; break;
case 9: case CUSTOM_9:
this.setCustom9(value); this.setCustom9(value);
break; break;
case 10: case CUSTOM_10:
this.setCustom10(value); this.setCustom10(value);
break; break;
case 11: case CUSTOM_11:
this.setCustom11(value); this.setCustom11(value);
break; break;
case 12: case CUSTOM_12:
this.setCustom12(value); this.setCustom12(value);
break; break;
case 13: case CUSTOM_13:
this.setCustom13(value); this.setCustom13(value);
break; break;
case 14: case CUSTOM_14:
this.setCustom14(value); this.setCustom14(value);
break; break;
case 15: case CUSTOM_15:
this.setCustom15(value); this.setCustom15(value);
break; break;
case 16: case CUSTOM_16:
this.setCustom16(value); this.setCustom16(value);
break; break;
default: default:
throw new InvalidArgumentException( throw new SystemException("Unknown customField '" + customField + "'");
"propertyNumber '" + propertyNumber + "' does not represent a number between 1 and 16");
} }
} }

View File

@ -12,7 +12,6 @@ import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import pro.taskana.common.internal.CustomPropertySelector;
import pro.taskana.common.internal.persistence.InstantTypeHandler; import pro.taskana.common.internal.persistence.InstantTypeHandler;
import pro.taskana.common.internal.persistence.MapTypeHandler; import pro.taskana.common.internal.persistence.MapTypeHandler;
import pro.taskana.common.internal.util.Pair; import pro.taskana.common.internal.util.Pair;
@ -229,7 +228,7 @@ public interface TaskMapper {
void updateTasks( void updateTasks(
@Param("taskIds") List<String> taskIds, @Param("taskIds") List<String> taskIds,
@Param("task") TaskImpl task, @Param("task") TaskImpl task,
@Param("fields") CustomPropertySelector fields); @Param("fields") TaskCustomPropertySelector fields);
@Update( @Update(
"<script>" "<script>"

View File

@ -2,7 +2,7 @@ package pro.taskana.task.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.EnumSet;
import java.util.List; import java.util.List;
import org.apache.ibatis.exceptions.PersistenceException; import org.apache.ibatis.exceptions.PersistenceException;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
@ -14,12 +14,14 @@ import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaRuntimeException; import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.configuration.DB; import pro.taskana.common.internal.configuration.DB;
import pro.taskana.common.internal.security.CurrentUserContext; import pro.taskana.common.internal.security.CurrentUserContext;
import pro.taskana.task.api.CallbackState; import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.ObjectReferenceQuery; import pro.taskana.task.api.ObjectReferenceQuery;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskQuery; import pro.taskana.task.api.TaskQuery;
import pro.taskana.task.api.TaskQueryColumnName; import pro.taskana.task.api.TaskQueryColumnName;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
@ -34,9 +36,6 @@ import pro.taskana.workbasket.internal.WorkbasketQueryImpl;
/** TaskQuery for generating dynamic sql. */ /** TaskQuery for generating dynamic sql. */
public class TaskQueryImpl implements TaskQuery { public class TaskQueryImpl implements TaskQuery {
private static final String ARGUMENT = "Argument '";
private static final String GET_CUSTOM_ATTRIBUTE_NOT_A_NUMBER_BETWEEN_1_AND_16 =
"' to getCustomAttribute does not represent a number between 1 and 16";
private static final String LINK_TO_MAPPER = private static final String LINK_TO_MAPPER =
"pro.taskana.task.internal.TaskQueryMapper.queryTaskSummaries"; "pro.taskana.task.internal.TaskQueryMapper.queryTaskSummaries";
private static final String LINK_TO_MAPPER_DB2 = private static final String LINK_TO_MAPPER_DB2 =
@ -45,13 +44,15 @@ public class TaskQueryImpl implements TaskQuery {
"pro.taskana.task.internal.TaskQueryMapper.countQueryTasks"; "pro.taskana.task.internal.TaskQueryMapper.countQueryTasks";
private static final String LINK_TO_COUNTER_DB2 = private static final String LINK_TO_COUNTER_DB2 =
"pro.taskana.task.internal.TaskQueryMapper.countQueryTasksDb2"; "pro.taskana.task.internal.TaskQueryMapper.countQueryTasksDb2";
private static final String LINK_TO_VALUEMAPPER = private static final String LINK_TO_VALUE_MAPPER =
"pro.taskana.task.internal.TaskQueryMapper.queryTaskColumnValues"; "pro.taskana.task.internal.TaskQueryMapper.queryTaskColumnValues";
private static final String TIME_INTERVAL = "TimeInterval "; private static final String TIME_INTERVAL = "TimeInterval ";
private static final String IS_INVALID = " is invalid."; private static final String IS_INVALID = " is invalid.";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryImpl.class);
private InternalTaskanaEngine taskanaEngine; private final InternalTaskanaEngine taskanaEngine;
private TaskServiceImpl taskService; private final TaskServiceImpl taskService;
private final List<String> orderBy;
private final List<String> orderColumns;
private TaskQueryColumnName columnName; private TaskQueryColumnName columnName;
private String[] nameIn; private String[] nameIn;
private String[] nameLike; private String[] nameLike;
@ -145,8 +146,6 @@ public class TaskQueryImpl implements TaskQuery {
private TimeInterval[] modifiedIn; private TimeInterval[] modifiedIn;
private TimeInterval[] plannedIn; private TimeInterval[] plannedIn;
private TimeInterval[] dueIn; private TimeInterval[] dueIn;
private List<String> orderBy;
private List<String> orderColumns;
private WildcardSearchField[] wildcardSearchFieldIn; private WildcardSearchField[] wildcardSearchFieldIn;
private String wildcardSearchValueLike; private String wildcardSearchValueLike;
private boolean selectAndClaim; private boolean selectAndClaim;
@ -229,12 +228,8 @@ public class TaskQueryImpl implements TaskQuery {
@Override @Override
public TaskQuery stateNotIn(TaskState... states) { public TaskQuery stateNotIn(TaskState... states) {
// No benefit in introducing a new variable this.stateIn =
List<TaskState> stateIn = new LinkedList<>(Arrays.asList(TaskState.values())); EnumSet.complementOf(EnumSet.copyOf(Arrays.asList(states))).toArray(new TaskState[0]);
for (TaskState state : states) {
stateIn.remove(state);
}
this.stateIn = stateIn.toArray(new TaskState[0]);
return this; return this;
} }
@ -480,147 +475,127 @@ public class TaskQueryImpl implements TaskQuery {
} }
@Override @Override
public TaskQuery customAttributeIn(String number, String... strings) public TaskQuery customAttributeIn(TaskCustomField customField, String... strings)
throws InvalidArgumentException { throws InvalidArgumentException {
int num = 0;
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
ARGUMENT + number + GET_CUSTOM_ATTRIBUTE_NOT_A_NUMBER_BETWEEN_1_AND_16, e.getCause());
}
if (strings.length == 0) { if (strings.length == 0) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter"); "At least one string has to be provided as a search parameter");
} }
switch (customField) {
switch (num) { case CUSTOM_1:
case 1:
this.custom1In = strings; this.custom1In = strings;
break; break;
case 2: case CUSTOM_2:
this.custom2In = strings; this.custom2In = strings;
break; break;
case 3: case CUSTOM_3:
this.custom3In = strings; this.custom3In = strings;
break; break;
case 4: case CUSTOM_4:
this.custom4In = strings; this.custom4In = strings;
break; break;
case 5: case CUSTOM_5:
this.custom5In = strings; this.custom5In = strings;
break; break;
case 6: case CUSTOM_6:
this.custom6In = strings; this.custom6In = strings;
break; break;
case 7: case CUSTOM_7:
this.custom7In = strings; this.custom7In = strings;
break; break;
case 8: case CUSTOM_8:
this.custom8In = strings; this.custom8In = strings;
break; break;
case 9: case CUSTOM_9:
this.custom9In = strings; this.custom9In = strings;
break; break;
case 10: case CUSTOM_10:
this.custom10In = strings; this.custom10In = strings;
break; break;
case 11: case CUSTOM_11:
this.custom11In = strings; this.custom11In = strings;
break; break;
case 12: case CUSTOM_12:
this.custom12In = strings; this.custom12In = strings;
break; break;
case 13: case CUSTOM_13:
this.custom13In = strings; this.custom13In = strings;
break; break;
case 14: case CUSTOM_14:
this.custom14In = strings; this.custom14In = strings;
break; break;
case 15: case CUSTOM_15:
this.custom15In = strings; this.custom15In = strings;
break; break;
case 16: case CUSTOM_16:
this.custom16In = strings; this.custom16In = strings;
break; break;
default: default:
throw new InvalidArgumentException( throw new SystemException("Unknown custom attribute '" + customField + "'");
ARGUMENT + number + GET_CUSTOM_ATTRIBUTE_NOT_A_NUMBER_BETWEEN_1_AND_16);
} }
return this; return this;
} }
@Override @Override
public TaskQuery customAttributeLike(String number, String... strings) public TaskQuery customAttributeLike(TaskCustomField customField, String... strings)
throws InvalidArgumentException { throws InvalidArgumentException {
int num = 0;
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
ARGUMENT
+ number
+ "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
if (strings.length == 0) { if (strings.length == 0) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter"); "At least one string has to be provided as a search parameter");
} }
switch (num) { switch (customField) {
case 1: case CUSTOM_1:
this.custom1Like = toUpperCopy(strings); this.custom1Like = toUpperCopy(strings);
break; break;
case 2: case CUSTOM_2:
this.custom2Like = toUpperCopy(strings); this.custom2Like = toUpperCopy(strings);
break; break;
case 3: case CUSTOM_3:
this.custom3Like = toUpperCopy(strings); this.custom3Like = toUpperCopy(strings);
break; break;
case 4: case CUSTOM_4:
this.custom4Like = toUpperCopy(strings); this.custom4Like = toUpperCopy(strings);
break; break;
case 5: case CUSTOM_5:
this.custom5Like = toUpperCopy(strings); this.custom5Like = toUpperCopy(strings);
break; break;
case 6: case CUSTOM_6:
this.custom6Like = toUpperCopy(strings); this.custom6Like = toUpperCopy(strings);
break; break;
case 7: case CUSTOM_7:
this.custom7Like = toUpperCopy(strings); this.custom7Like = toUpperCopy(strings);
break; break;
case 8: case CUSTOM_8:
this.custom8Like = toUpperCopy(strings); this.custom8Like = toUpperCopy(strings);
break; break;
case 9: case CUSTOM_9:
this.custom9Like = toUpperCopy(strings); this.custom9Like = toUpperCopy(strings);
break; break;
case 10: case CUSTOM_10:
this.custom10Like = toUpperCopy(strings); this.custom10Like = toUpperCopy(strings);
break; break;
case 11: case CUSTOM_11:
this.custom11Like = toUpperCopy(strings); this.custom11Like = toUpperCopy(strings);
break; break;
case 12: case CUSTOM_12:
this.custom12Like = toUpperCopy(strings); this.custom12Like = toUpperCopy(strings);
break; break;
case 13: case CUSTOM_13:
this.custom13Like = toUpperCopy(strings); this.custom13Like = toUpperCopy(strings);
break; break;
case 14: case CUSTOM_14:
this.custom14Like = toUpperCopy(strings); this.custom14Like = toUpperCopy(strings);
break; break;
case 15: case CUSTOM_15:
this.custom15Like = toUpperCopy(strings); this.custom15Like = toUpperCopy(strings);
break; break;
case 16: case CUSTOM_16:
this.custom16Like = toUpperCopy(strings); this.custom16Like = toUpperCopy(strings);
break; break;
default: default:
throw new InvalidArgumentException( throw new SystemException("Unknown custom field '" + customField + "'");
ARGUMENT + number + GET_CUSTOM_ATTRIBUTE_NOT_A_NUMBER_BETWEEN_1_AND_16);
} }
return this; return this;
@ -858,56 +833,9 @@ public class TaskQueryImpl implements TaskQuery {
} }
@Override @Override
public TaskQuery orderByCustomAttribute(String number, SortDirection sortDirection) public TaskQuery orderByCustomAttribute(
throws InvalidArgumentException { TaskCustomField customField, SortDirection sortDirection) {
int num = 0; return addOrderCriteria(customField.name(), sortDirection);
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
ARGUMENT
+ number
+ "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
switch (num) {
case 1:
return addOrderCriteria("CUSTOM_1", sortDirection);
case 2:
return addOrderCriteria("CUSTOM_2", sortDirection);
case 3:
return addOrderCriteria("CUSTOM_3", sortDirection);
case 4:
return addOrderCriteria("CUSTOM_4", sortDirection);
case 5:
return addOrderCriteria("CUSTOM_5", sortDirection);
case 6:
return addOrderCriteria("CUSTOM_6", sortDirection);
case 7:
return addOrderCriteria("CUSTOM_7", sortDirection);
case 8:
return addOrderCriteria("CUSTOM_8", sortDirection);
case 9:
return addOrderCriteria("CUSTOM_9", sortDirection);
case 10:
return addOrderCriteria("CUSTOM_10", sortDirection);
case 11:
return addOrderCriteria("CUSTOM_11", sortDirection);
case 12:
return addOrderCriteria("CUSTOM_12", sortDirection);
case 13:
return addOrderCriteria("CUSTOM_13", sortDirection);
case 14:
return addOrderCriteria("CUSTOM_14", sortDirection);
case 15:
return addOrderCriteria("CUSTOM_15", sortDirection);
case 16:
return addOrderCriteria("CUSTOM_16", sortDirection);
default:
throw new InvalidArgumentException(
ARGUMENT + number + GET_CUSTOM_ATTRIBUTE_NOT_A_NUMBER_BETWEEN_1_AND_16);
}
} }
@Override @Override
@ -1056,7 +984,7 @@ public class TaskQueryImpl implements TaskQuery {
} }
setupJoinAndOrderParameters(); setupJoinAndOrderParameters();
result = taskanaEngine.getSqlSession().selectList(LINK_TO_VALUEMAPPER, this); result = taskanaEngine.getSqlSession().selectList(LINK_TO_VALUE_MAPPER, this);
return result; return result;
} finally { } finally {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
@ -1743,7 +1671,11 @@ public class TaskQueryImpl implements TaskQuery {
@Override @Override
public String toString() { public String toString() {
return "TaskQueryImpl [columnName=" return "TaskQueryImpl [taskanaEngine="
+ taskanaEngine
+ ", taskService="
+ taskService
+ ", columnName="
+ columnName + columnName
+ ", nameIn=" + ", nameIn="
+ Arrays.toString(nameIn) + Arrays.toString(nameIn)
@ -1825,6 +1757,8 @@ public class TaskQueryImpl implements TaskQuery {
+ Arrays.toString(businessProcessIdIn) + Arrays.toString(businessProcessIdIn)
+ ", businessProcessIdLike=" + ", businessProcessIdLike="
+ Arrays.toString(businessProcessIdLike) + Arrays.toString(businessProcessIdLike)
+ ", callbackStateIn="
+ Arrays.toString(callbackStateIn)
+ ", custom1In=" + ", custom1In="
+ Arrays.toString(custom1In) + Arrays.toString(custom1In)
+ ", custom1Like=" + ", custom1Like="
@ -1931,11 +1865,19 @@ public class TaskQueryImpl implements TaskQuery {
+ orderBy + orderBy
+ ", orderColumns=" + ", orderColumns="
+ orderColumns + orderColumns
+ ", wildcardSearchFieldIn="
+ Arrays.toString(wildcardSearchFieldIn)
+ ", wildcardSearchValueLike="
+ wildcardSearchValueLike
+ ", selectAndClaim="
+ selectAndClaim
+ ", useDistinctKeyword="
+ useDistinctKeyword
+ ", joinWithAttachments=" + ", joinWithAttachments="
+ joinWithAttachments + joinWithAttachments
+ ", joinWithClassifications=" + ", joinWithClassifications="
+ joinWithClassifications + joinWithClassifications
+ ", joinWithAttachmentsClassifications=" + ", joinWithAttachmentClassifications="
+ joinWithAttachmentClassifications + joinWithAttachmentClassifications
+ ", addAttachmentColumnsToSelectClauseForOrdering=" + ", addAttachmentColumnsToSelectClauseForOrdering="
+ addAttachmentColumnsToSelectClauseForOrdering + addAttachmentColumnsToSelectClauseForOrdering
@ -1943,12 +1885,6 @@ public class TaskQueryImpl implements TaskQuery {
+ addClassificationNameToSelectClauseForOrdering + addClassificationNameToSelectClauseForOrdering
+ ", addAttachmentClassificationNameToSelectClauseForOrdering=" + ", addAttachmentClassificationNameToSelectClauseForOrdering="
+ addAttachmentClassificationNameToSelectClauseForOrdering + addAttachmentClassificationNameToSelectClauseForOrdering
+ ", wildcardSearchFieldsIn="
+ wildcardSearchFieldIn
+ ", wildcardSearchValueLike="
+ wildcardSearchValueLike
+ ", selectAndClaim="
+ selectAndClaim
+ "]"; + "]";
} }
} }

View File

@ -15,7 +15,6 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.ibatis.exceptions.PersistenceException; import org.apache.ibatis.exceptions.PersistenceException;
import org.json.JSONObject; import org.json.JSONObject;
@ -33,7 +32,6 @@ import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.CustomPropertySelector;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.security.CurrentUserContext; import pro.taskana.common.internal.security.CurrentUserContext;
import pro.taskana.common.internal.util.CheckedConsumer; import pro.taskana.common.internal.util.CheckedConsumer;
@ -48,6 +46,7 @@ import pro.taskana.spi.history.api.events.task.CreatedEvent;
import pro.taskana.spi.history.api.events.task.UpdatedEvent; import pro.taskana.spi.history.api.events.task.UpdatedEvent;
import pro.taskana.spi.history.internal.HistoryEventManager; import pro.taskana.spi.history.internal.HistoryEventManager;
import pro.taskana.task.api.CallbackState; import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskQuery; import pro.taskana.task.api.TaskQuery;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
@ -92,6 +91,8 @@ public class TaskServiceImpl implements TaskService {
"Task wit Id %s cannot be deleted because its callback is not yet processed"; "Task wit Id %s cannot be deleted because its callback is not yet processed";
private static final String TASK_WITH_ID_IS_ALREADY_CLAIMED_BY = private static final String TASK_WITH_ID_IS_ALREADY_CLAIMED_BY =
"Task with id %s is already claimed by %s."; "Task with id %s is already claimed by %s.";
private static final String TASK_WITH_ID_IS_ALREADY_IN_END_STATE =
"Task with Id %s is already in an end state.";
private static final String WAS_MARKED_FOR_DELETION = " was marked for deletion"; private static final String WAS_MARKED_FOR_DELETION = " was marked for deletion";
private static final String THE_WORKBASKET = "The workbasket "; private static final String THE_WORKBASKET = "The workbasket ";
private static final String TASK = "Task"; private static final String TASK = "Task";
@ -99,11 +100,7 @@ public class TaskServiceImpl implements TaskService {
private static final String ID_PREFIX_TASK = "TKI"; private static final String ID_PREFIX_TASK = "TKI";
private static final String ID_PREFIX_EXT_TASK_ID = "ETI"; private static final String ID_PREFIX_EXT_TASK_ID = "ETI";
private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI"; private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI";
private static final Set<String> ALLOWED_CUSTOM_KEYS =
IntStream.rangeClosed(1, 16).mapToObj(String::valueOf).collect(Collectors.toSet());
private static final String ID_PREFIX_HISTORY_EVENT = "HEI"; private static final String ID_PREFIX_HISTORY_EVENT = "HEI";
private static final String TASK_WITH_ID_IS_ALREADY_IN_END_STATE =
"Task with Id %s is already in an end state.";
private final InternalTaskanaEngine taskanaEngine; private final InternalTaskanaEngine taskanaEngine;
private final WorkbasketService workbasketService; private final WorkbasketService workbasketService;
private final ClassificationService classificationService; private final ClassificationService classificationService;
@ -112,8 +109,8 @@ public class TaskServiceImpl implements TaskService {
private final TaskCommentServiceImpl taskCommentService; private final TaskCommentServiceImpl taskCommentService;
private final ServiceLevelHandler serviceLevelHandler; private final ServiceLevelHandler serviceLevelHandler;
private final AttachmentHandler attachmentHandler; private final AttachmentHandler attachmentHandler;
private AttachmentMapper attachmentMapper; private final AttachmentMapper attachmentMapper;
private HistoryEventManager historyEventManager; private final HistoryEventManager historyEventManager;
public TaskServiceImpl( public TaskServiceImpl(
InternalTaskanaEngine taskanaEngine, InternalTaskanaEngine taskanaEngine,
@ -579,7 +576,7 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public List<String> updateTasks( public List<String> updateTasks(
ObjectReference selectionCriteria, Map<String, String> customFieldsToUpdate) ObjectReference selectionCriteria, Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
@ -589,7 +586,7 @@ public class TaskServiceImpl implements TaskService {
} }
ObjectReference.validate(selectionCriteria, "ObjectReference", "updateTasks call"); ObjectReference.validate(selectionCriteria, "ObjectReference", "updateTasks call");
validateCustomFields(customFieldsToUpdate); validateCustomFields(customFieldsToUpdate);
CustomPropertySelector fieldSelector = new CustomPropertySelector(); TaskCustomPropertySelector fieldSelector = new TaskCustomPropertySelector();
TaskImpl updated = initUpdatedTask(customFieldsToUpdate, fieldSelector); TaskImpl updated = initUpdatedTask(customFieldsToUpdate, fieldSelector);
try { try {
@ -617,7 +614,8 @@ public class TaskServiceImpl implements TaskService {
} }
@Override @Override
public List<String> updateTasks(List<String> taskIds, Map<String, String> customFieldsToUpdate) public List<String> updateTasks(
List<String> taskIds, Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
@ -627,7 +625,7 @@ public class TaskServiceImpl implements TaskService {
} }
validateCustomFields(customFieldsToUpdate); validateCustomFields(customFieldsToUpdate);
CustomPropertySelector fieldSelector = new CustomPropertySelector(); TaskCustomPropertySelector fieldSelector = new TaskCustomPropertySelector();
TaskImpl updatedTask = initUpdatedTask(customFieldsToUpdate, fieldSelector); TaskImpl updatedTask = initUpdatedTask(customFieldsToUpdate, fieldSelector);
try { try {
@ -743,9 +741,7 @@ public class TaskServiceImpl implements TaskService {
.map(MinimalTaskSummary::getTaskId) .map(MinimalTaskSummary::getTaskId)
.collect(Collectors.toList()); .collect(Collectors.toList());
bulkLog.addAllErrors(resultsPair.getRight()); bulkLog.addAllErrors(resultsPair.getRight());
if (taskIds.isEmpty()) { if (!taskIds.isEmpty()) {
return bulkLog;
} else {
final int numberOfAffectedTasks = taskMapper.setOwnerOfTasks(owner, taskIds, Instant.now()); final int numberOfAffectedTasks = taskMapper.setOwnerOfTasks(owner, taskIds, Instant.now());
if (numberOfAffectedTasks != taskIds.size()) { // all tasks were updated if (numberOfAffectedTasks != taskIds.size()) { // all tasks were updated
// check the outcome // check the outcome
@ -761,8 +757,8 @@ public class TaskServiceImpl implements TaskService {
bulkLog.getFailedIds().size()); bulkLog.getFailedIds().size());
} }
} }
return bulkLog;
} }
return bulkLog;
} finally { } finally {
LOGGER.debug("exit from setOwnerOfTasks()"); LOGGER.debug("exit from setOwnerOfTasks()");
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
@ -1389,7 +1385,7 @@ public class TaskServiceImpl implements TaskService {
throw new InvalidStateException(String.format(TASK_WITH_ID_CALLBACK_NOT_PROCESSED, taskId)); throw new InvalidStateException(String.format(TASK_WITH_ID_CALLBACK_NOT_PROCESSED, taskId));
} }
attachmentMapper.deleteMultipleByTaskIds(Arrays.asList(taskId)); attachmentMapper.deleteMultipleByTaskIds(Collections.singletonList(taskId));
taskMapper.delete(taskId); taskMapper.delete(taskId);
if (taskanaEngine.getEngine().isHistoryEnabled() if (taskanaEngine.getEngine().isHistoryEnabled()
@ -1825,8 +1821,7 @@ public class TaskServiceImpl implements TaskService {
} }
private TaskImpl initUpdatedTask( private TaskImpl initUpdatedTask(
Map<String, String> customFieldsToUpdate, CustomPropertySelector fieldSelector) Map<TaskCustomField, String> customFieldsToUpdate, TaskCustomPropertySelector fieldSelector) {
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"entry to initUpdatedTask(customFieldsToUpdate = {}, fieldSelector = {})", "entry to initUpdatedTask(customFieldsToUpdate = {}, fieldSelector = {})",
@ -1837,8 +1832,8 @@ public class TaskServiceImpl implements TaskService {
TaskImpl newTask = new TaskImpl(); TaskImpl newTask = new TaskImpl();
newTask.setModified(Instant.now()); newTask.setModified(Instant.now());
for (Map.Entry<String, String> entry : customFieldsToUpdate.entrySet()) { for (Map.Entry<TaskCustomField, String> entry : customFieldsToUpdate.entrySet()) {
String key = entry.getKey(); TaskCustomField key = entry.getKey();
fieldSelector.setCustomProperty(key, true); fieldSelector.setCustomProperty(key, true);
newTask.setCustomAttribute(key, entry.getValue()); newTask.setCustomAttribute(key, entry.getValue());
} }
@ -1849,7 +1844,7 @@ public class TaskServiceImpl implements TaskService {
return newTask; return newTask;
} }
private void validateCustomFields(Map<String, String> customFieldsToUpdate) private void validateCustomFields(Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
@ -1860,14 +1855,6 @@ public class TaskServiceImpl implements TaskService {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"The customFieldsToUpdate argument to updateTasks must not be empty."); "The customFieldsToUpdate argument to updateTasks must not be empty.");
} }
for (Map.Entry<String, String> entry : customFieldsToUpdate.entrySet()) {
String key = entry.getKey();
if (!ALLOWED_CUSTOM_KEYS.contains(key)) {
throw new InvalidArgumentException(
"The customFieldsToUpdate argument to updateTasks contains invalid key " + key);
}
}
LOGGER.debug("exit from validateCustomFields()"); LOGGER.debug("exit from validateCustomFields()");
} }

View File

@ -24,16 +24,13 @@ public class AttachmentImpl extends AttachmentSummaryImpl implements Attachment
} }
@Override @Override
public Map<String, String> getCustomAttributes() { public Map<String, String> getCustomAttributeMap() {
if (customAttributes == null) { return getCustomAttributes();
customAttributes = new HashMap<>();
}
return customAttributes;
} }
@Override @Override
public void setCustomAttributes(Map<String, String> customAttributes) { public void setCustomAttributeMap(Map<String, String> customAttributes) {
this.customAttributes = customAttributes; setCustomAttributes(customAttributes);
} }
@Override @Override
@ -50,6 +47,17 @@ public class AttachmentImpl extends AttachmentSummaryImpl implements Attachment
return summary; return summary;
} }
public Map<String, String> getCustomAttributes() {
if (customAttributes == null) {
customAttributes = new HashMap<>();
}
return customAttributes;
}
public void setCustomAttributes(Map<String, String> customAttributes) {
this.customAttributes = customAttributes;
}
@Override @Override
public AttachmentImpl copy() { public AttachmentImpl copy() {
return new AttachmentImpl(this); return new AttachmentImpl(this);

View File

@ -31,10 +31,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
received = copyFrom.received; received = copyFrom.received;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getId()
*/
@Override @Override
public String getId() { public String getId() {
return id; return id;
@ -44,10 +40,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.id = id; this.id = id;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getTaskId()
*/
@Override @Override
public String getTaskId() { public String getTaskId() {
return taskId; return taskId;
@ -57,10 +49,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.taskId = taskId; this.taskId = taskId;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getCreated()
*/
@Override @Override
public Instant getCreated() { public Instant getCreated() {
return created; return created;
@ -70,10 +58,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.created = created; this.created = created;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getModified()
*/
@Override @Override
public Instant getModified() { public Instant getModified() {
return modified; return modified;
@ -83,10 +67,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.modified = modified; this.modified = modified;
} }
/*
* (non-Javadoc)
* @see pro.taskana.AttachmentSummary#getObjectReference()
*/
@Override @Override
public ObjectReference getObjectReference() { public ObjectReference getObjectReference() {
return objectReference; return objectReference;
@ -96,10 +76,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.objectReference = objectReference; this.objectReference = objectReference;
} }
/*
* (non-Javadoc)
* @see pro.taskana.AttachmentSummary#getChannel()
*/
@Override @Override
public String getChannel() { public String getChannel() {
return channel; return channel;
@ -109,10 +85,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.channel = channel; this.channel = channel;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getClassification()
*/
@Override @Override
public ClassificationSummary getClassificationSummary() { public ClassificationSummary getClassificationSummary() {
return classificationSummary; return classificationSummary;
@ -122,10 +94,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.classificationSummary = classificationSummary; this.classificationSummary = classificationSummary;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getReceived()
*/
@Override @Override
public Instant getReceived() { public Instant getReceived() {
return received; return received;

View File

@ -9,19 +9,17 @@ import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import pro.taskana.classification.internal.models.ClassificationSummaryImpl; import pro.taskana.classification.internal.models.ClassificationSummaryImpl;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.task.api.CallbackState; import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.models.Attachment; import pro.taskana.task.api.models.Attachment;
import pro.taskana.task.api.models.AttachmentSummary; import pro.taskana.task.api.models.AttachmentSummary;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl; import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl;
/** Task entity. */
public class TaskImpl extends TaskSummaryImpl implements Task { public class TaskImpl extends TaskSummaryImpl implements Task {
private static final String NOT_A_VALID_NUMBER_SET =
"Argument '%s' of setCustomAttribute() cannot be converted to a number between 1 and 16";
// All objects have to be serializable // All objects have to be serializable
private Map<String, String> customAttributes = Collections.emptyMap(); private Map<String, String> customAttributes = Collections.emptyMap();
private Map<String, String> callbackInfo = Collections.emptyMap(); private Map<String, String> callbackInfo = Collections.emptyMap();
@ -38,6 +36,14 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
attachments = copyFrom.attachments.stream().map(Attachment::copy).collect(Collectors.toList()); attachments = copyFrom.attachments.stream().map(Attachment::copy).collect(Collectors.toList());
} }
public Map<String, String> getCustomAttributes() {
return customAttributes;
}
public void setCustomAttributes(Map<String, String> customAttributes) {
this.customAttributes = customAttributes;
}
public String getClassificationId() { public String getClassificationId() {
return classificationSummary == null ? null : classificationSummary.getId(); return classificationSummary == null ? null : classificationSummary.getId();
} }
@ -73,13 +79,13 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
} }
@Override @Override
public Map<String, String> getCustomAttributes() { public Map<String, String> getCustomAttributeMap() {
return customAttributes; return getCustomAttributes();
} }
@Override @Override
public void setCustomAttributes(Map<String, String> customAttributes) { public void setCustomAttributeMap(Map<String, String> customAttributes) {
this.customAttributes = customAttributes; setCustomAttributes(customAttributes);
} }
public CallbackState getCallbackState() { public CallbackState getCallbackState() {
@ -104,66 +110,58 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
} }
@Override @Override
public void setCustomAttribute(String number, String value) throws InvalidArgumentException { public void setCustomAttribute(TaskCustomField customField, String value) {
int num; switch (customField) {
try { case CUSTOM_1:
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
String.format(NOT_A_VALID_NUMBER_SET, number), e.getCause());
}
switch (num) {
case 1:
custom1 = value; custom1 = value;
break; break;
case 2: case CUSTOM_2:
custom2 = value; custom2 = value;
break; break;
case 3: case CUSTOM_3:
custom3 = value; custom3 = value;
break; break;
case 4: case CUSTOM_4:
custom4 = value; custom4 = value;
break; break;
case 5: case CUSTOM_5:
custom5 = value; custom5 = value;
break; break;
case 6: case CUSTOM_6:
custom6 = value; custom6 = value;
break; break;
case 7: case CUSTOM_7:
custom7 = value; custom7 = value;
break; break;
case 8: case CUSTOM_8:
custom8 = value; custom8 = value;
break; break;
case 9: case CUSTOM_9:
custom9 = value; custom9 = value;
break; break;
case 10: case CUSTOM_10:
custom10 = value; custom10 = value;
break; break;
case 11: case CUSTOM_11:
custom11 = value; custom11 = value;
break; break;
case 12: case CUSTOM_12:
custom12 = value; custom12 = value;
break; break;
case 13: case CUSTOM_13:
custom13 = value; custom13 = value;
break; break;
case 14: case CUSTOM_14:
custom14 = value; custom14 = value;
break; break;
case 15: case CUSTOM_15:
custom15 = value; custom15 = value;
break; break;
case 16: case CUSTOM_16:
custom16 = value; custom16 = value;
break; break;
default: default:
throw new InvalidArgumentException(String.format(NOT_A_VALID_NUMBER_SET, number)); throw new SystemException("Unknown customField '" + customField + "'");
} }
} }
@ -306,7 +304,15 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
@Override @Override
public String toString() { public String toString() {
return "TaskImpl [id=" return "TaskImpl [customAttributes="
+ customAttributes
+ ", callbackInfo="
+ callbackInfo
+ ", callbackState="
+ callbackState
+ ", attachments="
+ attachments
+ ", id="
+ id + id
+ ", externalId=" + ", externalId="
+ externalId + externalId
@ -326,10 +332,10 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
+ name + name
+ ", creator=" + ", creator="
+ creator + creator
+ ", description="
+ description
+ ", note=" + ", note="
+ note + note
+ ", description="
+ description
+ ", priority=" + ", priority="
+ priority + priority
+ ", state=" + ", state="
@ -350,14 +356,8 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
+ isRead + isRead
+ ", isTransferred=" + ", isTransferred="
+ isTransferred + isTransferred
+ ", customAttributes=" + ", attachmentSummaries="
+ customAttributes + attachmentSummaries
+ ", callbackInfo="
+ callbackInfo
+ ", callbackState="
+ callbackState
+ ", attachments="
+ attachments
+ ", custom1=" + ", custom1="
+ custom1 + custom1
+ ", custom2=" + ", custom2="

View File

@ -7,7 +7,8 @@ import java.util.Objects;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.classification.internal.models.ClassificationSummaryImpl; import pro.taskana.classification.internal.models.ClassificationSummaryImpl;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.models.AttachmentSummary; import pro.taskana.task.api.models.AttachmentSummary;
import pro.taskana.task.api.models.ObjectReference; import pro.taskana.task.api.models.ObjectReference;
@ -18,9 +19,6 @@ import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl;
/** Entity which contains the most important informations about a Task. */ /** Entity which contains the most important informations about a Task. */
public class TaskSummaryImpl implements TaskSummary { public class TaskSummaryImpl implements TaskSummary {
private static final String NOT_A_VALID_NUMBER_GET =
"Argument '%s' of getCustomAttribute() cannot be converted to a number between 1 and 16";
protected String id; protected String id;
protected String externalId; protected String externalId;
protected Instant created; protected Instant created;
@ -104,10 +102,6 @@ public class TaskSummaryImpl implements TaskSummary {
custom16 = copyFrom.custom16; custom16 = copyFrom.custom16;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getTaskId()
*/
@Override @Override
public String getId() { public String getId() {
return id; return id;
@ -117,10 +111,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.id = id; this.id = id;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getExternalId()
*/
@Override @Override
public String getExternalId() { public String getExternalId() {
return externalId; return externalId;
@ -130,10 +120,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.externalId = externalId; this.externalId = externalId;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreator()
*/
@Override @Override
public String getCreator() { public String getCreator() {
return creator; return creator;
@ -143,10 +129,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.creator = creator; this.creator = creator;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreated()
*/
@Override @Override
public Instant getCreated() { public Instant getCreated() {
return created; return created;
@ -156,10 +138,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.created = created; this.created = created;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getClaimed()
*/
@Override @Override
public Instant getClaimed() { public Instant getClaimed() {
return claimed; return claimed;
@ -169,10 +147,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.claimed = claimed; this.claimed = claimed;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCompleted()
*/
@Override @Override
public Instant getCompleted() { public Instant getCompleted() {
return completed; return completed;
@ -182,10 +156,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.completed = completed; this.completed = completed;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getModified()
*/
@Override @Override
public Instant getModified() { public Instant getModified() {
return modified; return modified;
@ -195,10 +165,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.modified = modified; this.modified = modified;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getPlanned()
*/
@Override @Override
public Instant getPlanned() { public Instant getPlanned() {
return planned; return planned;
@ -208,10 +174,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.planned = planned; this.planned = planned;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getDue()
*/
@Override @Override
public Instant getDue() { public Instant getDue() {
return due; return due;
@ -221,10 +183,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.due = due; this.due = due;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getName()
*/
@Override @Override
public String getName() { public String getName() {
return name; return name;
@ -234,10 +192,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.name = name; this.name = name;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getNote()
*/
@Override @Override
public String getNote() { public String getNote() {
return note; return note;
@ -247,10 +201,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.note = note; this.note = note;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getDescription()
*/
@Override @Override
public String getDescription() { public String getDescription() {
return description; return description;
@ -260,10 +210,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.description = description; this.description = description;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getPriority()
*/
@Override @Override
public int getPriority() { public int getPriority() {
return priority; return priority;
@ -273,10 +219,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.priority = priority; this.priority = priority;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getState()
*/
@Override @Override
public TaskState getState() { public TaskState getState() {
return state; return state;
@ -286,10 +228,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.state = state; this.state = state;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getClassificationSummary()
*/
@Override @Override
public ClassificationSummary getClassificationSummary() { public ClassificationSummary getClassificationSummary() {
return classificationSummary; return classificationSummary;
@ -299,10 +237,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.classificationSummary = classificationSummary; this.classificationSummary = classificationSummary;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getWorkbasketSummary()
*/
@Override @Override
public WorkbasketSummary getWorkbasketSummary() { public WorkbasketSummary getWorkbasketSummary() {
return workbasketSummary; return workbasketSummary;
@ -321,10 +255,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.attachmentSummaries = attachmentSummaries; this.attachmentSummaries = attachmentSummaries;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getDomain()
*/
@Override @Override
public String getDomain() { public String getDomain() {
return workbasketSummary == null ? null : workbasketSummary.getDomain(); return workbasketSummary == null ? null : workbasketSummary.getDomain();
@ -337,10 +267,6 @@ public class TaskSummaryImpl implements TaskSummary {
((WorkbasketSummaryImpl) this.workbasketSummary).setDomain(domain); ((WorkbasketSummaryImpl) this.workbasketSummary).setDomain(domain);
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getBusinessProcessId()
*/
@Override @Override
public String getBusinessProcessId() { public String getBusinessProcessId() {
return businessProcessId; return businessProcessId;
@ -350,10 +276,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.businessProcessId = businessProcessId; this.businessProcessId = businessProcessId;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getParentBusinessProcessId()
*/
@Override @Override
public String getParentBusinessProcessId() { public String getParentBusinessProcessId() {
return parentBusinessProcessId; return parentBusinessProcessId;
@ -363,10 +285,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.parentBusinessProcessId = parentBusinessProcessId; this.parentBusinessProcessId = parentBusinessProcessId;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getOwner()
*/
@Override @Override
public String getOwner() { public String getOwner() {
return owner; return owner;
@ -376,10 +294,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.owner = owner; this.owner = owner;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getPrimaryObjRef()
*/
@Override @Override
public ObjectReference getPrimaryObjRef() { public ObjectReference getPrimaryObjRef() {
return primaryObjRef; return primaryObjRef;
@ -389,10 +303,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.primaryObjRef = primaryObjRef; this.primaryObjRef = primaryObjRef;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#isRead()
*/
@Override @Override
public boolean isRead() { public boolean isRead() {
return isRead; return isRead;
@ -402,10 +312,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.isRead = isRead; this.isRead = isRead;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#isTransferred()
*/
@Override @Override
public boolean isTransferred() { public boolean isTransferred() {
return isTransferred; return isTransferred;
@ -415,55 +321,44 @@ public class TaskSummaryImpl implements TaskSummary {
this.isTransferred = isTransferred; this.isTransferred = isTransferred;
} }
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCustomAttribute(String number)
*/
@Override @Override
public String getCustomAttribute(String number) throws InvalidArgumentException { public String getCustomAttribute(TaskCustomField customField) {
int num = 0;
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
String.format(NOT_A_VALID_NUMBER_GET, number), e.getCause());
}
switch (num) { switch (customField) {
case 1: case CUSTOM_1:
return custom1; return custom1;
case 2: case CUSTOM_2:
return custom2; return custom2;
case 3: case CUSTOM_3:
return custom3; return custom3;
case 4: case CUSTOM_4:
return custom4; return custom4;
case 5: case CUSTOM_5:
return custom5; return custom5;
case 6: case CUSTOM_6:
return custom6; return custom6;
case 7: case CUSTOM_7:
return custom7; return custom7;
case 8: case CUSTOM_8:
return custom8; return custom8;
case 9: case CUSTOM_9:
return custom9; return custom9;
case 10: case CUSTOM_10:
return custom10; return custom10;
case 11: case CUSTOM_11:
return custom11; return custom11;
case 12: case CUSTOM_12:
return custom12; return custom12;
case 13: case CUSTOM_13:
return custom13; return custom13;
case 14: case CUSTOM_14:
return custom14; return custom14;
case 15: case CUSTOM_15:
return custom15; return custom15;
case 16: case CUSTOM_16:
return custom16; return custom16;
default: default:
throw new InvalidArgumentException(String.format(NOT_A_VALID_NUMBER_GET, number)); throw new SystemException("Unknown custom field '" + customField + "'");
} }
} }

View File

@ -0,0 +1,8 @@
package pro.taskana.workbasket.api;
public enum WorkbasketCustomField {
CUSTOM_1,
CUSTOM_2,
CUSTOM_3,
CUSTOM_4
}

View File

@ -227,40 +227,15 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary, Workbasket
WorkbasketQuery domainLike(String... domain); WorkbasketQuery domainLike(String... domain);
/** /**
* Sort the query result by custom property 1. * This method sorts the query result according to the value of a custom field.
* *
* @param customField identifies which custom attribute is affected.
* @param sortDirection Determines whether the result is sorted in ascending or descending order. * @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order * If sortDirection is null, the result is sorted in ascending order
* @return the query * @return the query
*/ */
WorkbasketQuery orderByCustom1(SortDirection sortDirection); WorkbasketQuery orderByCustomAttribute(
WorkbasketCustomField customField, SortDirection sortDirection);
/**
* Sort the query result by custom property 2.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom2(SortDirection sortDirection);
/**
* Sort the query result by custom property 3.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom3(SortDirection sortDirection);
/**
* Sort the query result by custom property 4.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom4(SortDirection sortDirection);
/** /**
* Sort the query result by organization level 1. * Sort the query result by organization level 1.
@ -299,76 +274,24 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary, Workbasket
WorkbasketQuery orderByOrgLevel4(SortDirection sortDirection); WorkbasketQuery orderByOrgLevel4(SortDirection sortDirection);
/** /**
* Add the 1st custom property to your query. * Add the values of custom attributes for exact matching to your query.
* *
* @param custom1 the 1st custom property as String * @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched for tasks
* @return the query * @return the query
*/ */
WorkbasketQuery custom1In(String... custom1); WorkbasketQuery customAttributeIn(WorkbasketCustomField customField, String... searchArguments);
/** /**
* Add the 1st custom property for pattern matching to your query. It will be compared in SQL with * Add the values of custom attributes for pattern matching to your query. They will be compared
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify * in SQL with the LIKE operator. You may use a wildcard like % to specify the pattern. If you
* multiple arguments they are combined with the OR keyword. * specify multiple arguments they are combined with the OR keyword.
* *
* @param custom1 the 1st custom property of workbaskets as Strings * @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched-for tasks
* @return the query * @return the query
*/ */
WorkbasketQuery custom1Like(String... custom1); WorkbasketQuery customAttributeLike(WorkbasketCustomField customField, String... searchArguments);
/**
* Add the 2nd custom property to your query.
*
* @param custom2 the 2nd custom property as String
* @return the query
*/
WorkbasketQuery custom2In(String... custom2);
/**
* Add the 2nd custom property for pattern matching to your query. It will be compared in SQL with
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param custom2 the 2nd custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom2Like(String... custom2);
/**
* Add the 3rd custom property to your query.
*
* @param custom3 the 3rd custom property as String
* @return the query
*/
WorkbasketQuery custom3In(String... custom3);
/**
* Add the 3rd custom property for pattern matching to your query. It will be compared in SQL with
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param custom3 the 3rd custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom3Like(String... custom3);
/**
* Add the 4th custom property to your query.
*
* @param custom4 the 4th custom property as String
* @return the query
*/
WorkbasketQuery custom4In(String... custom4);
/**
* Add the 4th custom property for pattern matching to your query. It will be compared in SQL with
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param custom4 the 4th custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom4Like(String... custom4);
/** /**
* Add the 1st organization level to your query. * Add the 1st organization level to your query.

View File

@ -2,6 +2,7 @@ package pro.taskana.workbasket.api.models;
import java.time.Instant; import java.time.Instant;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
/** Workbasket entity interface. */ /** Workbasket entity interface. */
@ -29,32 +30,12 @@ public interface Workbasket extends WorkbasketSummary {
void setType(WorkbasketType type); void setType(WorkbasketType type);
/** /**
* Sets the value for custom1 Attribute. * Sets the value for custom Attribute.
* *
* @param custom1 the custom1 property of the workbasket * @param customField identifies which custom attribute is to be set.
* @param value the value of the custom attribute to be set
*/ */
void setCustom1(String custom1); void setCustomAttribute(WorkbasketCustomField customField, String value);
/**
* Sets the value for custom2 attribute.
*
* @param custom2 the custom2 property of the workbasket
*/
void setCustom2(String custom2);
/**
* Sets the value for custom3 attribute.
*
* @param custom3 the custom3 property of the workbasket
*/
void setCustom3(String custom3);
/**
* Sets the value for custom4 attribute.
*
* @param custom4 the custom4 property of the workbasket
*/
void setCustom4(String custom4);
/** /**
* Sets the value for orgLevel1 attribute. * Sets the value for orgLevel1 attribute.

View File

@ -1,5 +1,7 @@
package pro.taskana.workbasket.api.models; package pro.taskana.workbasket.api.models;
import pro.taskana.workbasket.api.WorkbasketPermission;
/** /**
* Interface for WorkbasketAccessItem. This interface is used to control access of users to * Interface for WorkbasketAccessItem. This interface is used to control access of users to
* workbaskets. * workbaskets.
@ -55,266 +57,20 @@ public interface WorkbasketAccessItem {
void setAccessName(String name); void setAccessName(String name);
/** /**
* Returns whether read of the referenced workbasket is permitted. * Sets a given permission for the referenced workbasket.
* *
* @return read permission for the referenced workbasket * @param permission the permission which is set.
* @param value the value for the permission.
*/ */
boolean isPermRead(); void setPermission(WorkbasketPermission permission, boolean value);
/** /**
* Sets read permission for the referenced workbasket. * Returns weather the given permission is permitted or not.
* *
* @param permRead specifies whether read is permitted for the referenced workbasket. * @param permission the permission in question.
* @return True, when the given permission is permitted. Otherwise false.
*/ */
void setPermRead(boolean permRead); boolean getPermission(WorkbasketPermission permission);
/**
* Returns whether open of the referenced workbasket is permitted.
*
* @return open permission for the referenced workbasket
*/
boolean isPermOpen();
/**
* Sets open permission for the referenced workbasket.
*
* @param permOpen specifies whether open is permitted for the referenced workbasket.
*/
void setPermOpen(boolean permOpen);
/**
* Returns whether append to the referenced workbasket is permitted.
*
* @return append permission for the referenced workbasket
*/
boolean isPermAppend();
/**
* Sets append permission for the referenced workbasket.
*
* @param permAppend specifies whether append to the referenced workbasket is permitted.
*/
void setPermAppend(boolean permAppend);
/**
* Returns whether transfer from the referenced workbasket is permitted.
*
* @return transfer permission for the referenced workbasket
*/
boolean isPermTransfer();
/**
* Sets transfer permission for the referenced workbasket.
*
* @param permTransfer specifies whether transfer from the referenced workbasket is permitted.
*/
void setPermTransfer(boolean permTransfer);
/**
* Returns whether distribute from the referenced workbasket is permitted.
*
* @return distribute permission for the referenced workbasket
*/
boolean isPermDistribute();
/**
* Sets distribute permission for the referenced workbasket.
*
* @param permDistribute specifies whether distribute from the referenced workbasket is permitted.
*/
void setPermDistribute(boolean permDistribute);
/**
* Returns whether custom1 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom1 permission for the referenced workbasket
*/
boolean isPermCustom1();
/**
* Sets the custom1 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom1 specifies whether custom1 permission is granted
*/
void setPermCustom1(boolean permCustom1);
/**
* Returns whether custom2 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom2 permission for the referenced workbasket
*/
boolean isPermCustom2();
/**
* Sets the custom2 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom2 specifies whether custom2 permission is granted
*/
void setPermCustom2(boolean permCustom2);
/**
* Returns whether custom3 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom3 permission for the referenced workbasket
*/
boolean isPermCustom3();
/**
* Sets the custom3 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom3 specifies whether custom3 permission is granted
*/
void setPermCustom3(boolean permCustom3);
/**
* Returns whether custom4 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom4 permission for the referenced workbasket
*/
boolean isPermCustom4();
/**
* Sets the custom4 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom4 specifies whether custom4 permission is granted
*/
void setPermCustom4(boolean permCustom4);
/**
* Returns whether custom5 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom5 permission for the referenced workbasket
*/
boolean isPermCustom5();
/**
* Sets the custom5 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom5 specifies whether custom5 permission is granted
*/
void setPermCustom5(boolean permCustom5);
/**
* Returns whether custom6 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom6 permission for the referenced workbasket
*/
boolean isPermCustom6();
/**
* Sets the custom6 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom6 specifies whether custom6 permission is granted
*/
void setPermCustom6(boolean permCustom6);
/**
* Returns whether custom7 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom7 permission for the referenced workbasket
*/
boolean isPermCustom7();
/**
* Sets the custom7 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom7 specifies whether custom7 permission is granted
*/
void setPermCustom7(boolean permCustom7);
/**
* Returns whether custom8 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom8 permission for the referenced workbasket
*/
boolean isPermCustom8();
/**
* Sets the custom8 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom8 specifies whether custom8 permission is granted
*/
void setPermCustom8(boolean permCustom8);
/**
* Returns whether custom9 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom9 permission for the referenced workbasket
*/
boolean isPermCustom9();
/**
* Sets the custom9 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom9 specifies whether custom9 permission is granted
*/
void setPermCustom9(boolean permCustom9);
/**
* Returns whether custom10 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom10 permission for the referenced workbasket
*/
boolean isPermCustom10();
/**
* Sets the custom10 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom10 specifies whether custom10 permission is granted
*/
void setPermCustom10(boolean permCustom10);
/**
* Returns whether custom11 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom11 permission for the referenced workbasket
*/
boolean isPermCustom11();
/**
* Sets the custom11 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom11 specifies whether custom11 permission is granted
*/
void setPermCustom11(boolean permCustom11);
/**
* Returns whether custom12 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom12 permission for the referenced workbasket
*/
boolean isPermCustom12();
/**
* Sets the custom12 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom12 specifies whether custom12 permission is granted
*/
void setPermCustom12(boolean permCustom12);
/** /**
* Duplicates this WorkbasketAccessItem without the id. * Duplicates this WorkbasketAccessItem without the id.

View File

@ -1,5 +1,6 @@
package pro.taskana.workbasket.api.models; package pro.taskana.workbasket.api.models;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
/** /**
@ -58,32 +59,12 @@ public interface WorkbasketSummary {
WorkbasketType getType(); WorkbasketType getType();
/** /**
* Gets the custom1 property of the workbasket. * Gets the custom attribute of the workbasket.
* *
* @return the workbasket's custom1 property. * @param customField identifies which custom attribute is requested.
* @return the value for the given customField
*/ */
String getCustom1(); String getCustomAttribute(WorkbasketCustomField customField);
/**
* Gets the custom2 property of the workbasket.
*
* @return the workbasket's custom2 property.
*/
String getCustom2();
/**
* Gets the custom3 property of the workbasket.
*
* @return the workbasket's custom3 property.
*/
String getCustom3();
/**
* Gets the custom4 property of the workbasket.
*
* @return the workbasket's custom4 property.
*/
String getCustom4();
/** /**
* Gets the orglevel1 property of the workbasket. * Gets the orglevel1 property of the workbasket.

View File

@ -13,9 +13,11 @@ import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaRuntimeException; import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.security.CurrentUserContext; import pro.taskana.common.internal.security.CurrentUserContext;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketQuery; import pro.taskana.workbasket.api.WorkbasketQuery;
import pro.taskana.workbasket.api.WorkbasketQueryColumnName; import pro.taskana.workbasket.api.WorkbasketQueryColumnName;
@ -240,23 +242,9 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
} }
@Override @Override
public WorkbasketQuery orderByCustom1(SortDirection sortDirection) { public WorkbasketQuery orderByCustomAttribute(
return addOrderCriteria("CUSTOM_1", sortDirection); WorkbasketCustomField customField, SortDirection sortDirection) {
} return addOrderCriteria(customField.name(), 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 @Override
@ -280,50 +268,46 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
} }
@Override @Override
public WorkbasketQuery custom1In(String... custom1) { public WorkbasketQuery customAttributeIn(
this.custom1In = custom1; WorkbasketCustomField customField, String... searchArguments) {
switch (customField) {
case CUSTOM_1:
custom1In = searchArguments;
break;
case CUSTOM_2:
custom2In = searchArguments;
break;
case CUSTOM_3:
custom3In = searchArguments;
break;
case CUSTOM_4:
custom4In = searchArguments;
break;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
return this; return this;
} }
@Override @Override
public WorkbasketQuery custom1Like(String... custom1) { public WorkbasketQuery customAttributeLike(
this.custom1Like = toUpperCopy(custom1); WorkbasketCustomField customField, String... searchArguments) {
return this; switch (customField) {
case CUSTOM_1:
custom1Like = toUpperCopy(searchArguments);
break;
case CUSTOM_2:
custom2Like = toUpperCopy(searchArguments);
break;
case CUSTOM_3:
custom3Like = toUpperCopy(searchArguments);
break;
case CUSTOM_4:
custom4Like = toUpperCopy(searchArguments);
break;
default:
throw new SystemException("Unknown customField '" + customField + "'");
} }
@Override
public WorkbasketQuery custom2In(String... custom2) {
this.custom2In = custom2;
return this;
}
@Override
public WorkbasketQuery custom2Like(String... custom2) {
this.custom2Like = toUpperCopy(custom2);
return this;
}
@Override
public WorkbasketQuery custom3In(String... custom3) {
this.custom3In = custom3;
return this;
}
@Override
public WorkbasketQuery custom3Like(String... custom3) {
this.custom3Like = toUpperCopy(custom3);
return this;
}
@Override
public WorkbasketQuery custom4In(String... custom4) {
this.custom4In = custom4;
return this;
}
@Override
public WorkbasketQuery custom4Like(String... custom4) {
this.custom4Like = toUpperCopy(custom4);
return this; return this;
} }
@ -683,8 +667,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
if (this.accessId == null) { if (this.accessId == null) {
String[] accessIds = new String[0]; String[] accessIds = new String[0];
List<String> ucAccessIds = CurrentUserContext.getAccessIds(); List<String> ucAccessIds = CurrentUserContext.getAccessIds();
if (ucAccessIds != null && !ucAccessIds.isEmpty()) { if (!ucAccessIds.isEmpty()) {
accessIds = new String[ucAccessIds.size()];
accessIds = ucAccessIds.toArray(accessIds); accessIds = ucAccessIds.toArray(accessIds);
} }
this.accessId = accessIds; this.accessId = accessIds;
@ -704,83 +687,88 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
@Override @Override
public String toString() { public String toString() {
return "WorkbasketQueryImpl [" return "WorkbasketQueryImpl [columnName="
+ "columnName=" + columnName
+ this.columnName
+ ", accessId=" + ", accessId="
+ Arrays.toString(this.accessId) + Arrays.toString(accessId)
+ ", idIn=" + ", idIn="
+ Arrays.toString(this.idIn) + Arrays.toString(idIn)
+ ", permission=" + ", permission="
+ this.permission + permission
+ ", nameIn=" + ", nameIn="
+ Arrays.toString(this.nameIn) + Arrays.toString(nameIn)
+ ", nameLike=" + ", nameLike="
+ Arrays.toString(this.nameLike) + Arrays.toString(nameLike)
+ ", keyIn=" + ", keyIn="
+ Arrays.toString(this.keyIn) + Arrays.toString(keyIn)
+ ", keyLike=" + ", keyLike="
+ Arrays.toString(this.keyLike) + Arrays.toString(keyLike)
+ ", keyOrNameLike=" + ", keyOrNameLike="
+ Arrays.toString(this.keyOrNameLike) + Arrays.toString(keyOrNameLike)
+ ", domainIn=" + ", domainIn="
+ Arrays.toString(this.domainIn) + Arrays.toString(domainIn)
+ ", domainLike=" + ", domainLike="
+ Arrays.toString(this.domainLike) + Arrays.toString(domainLike)
+ ", type=" + ", type="
+ Arrays.toString(this.type) + Arrays.toString(type)
+ ", createdIn=" + ", createdIn="
+ Arrays.toString(this.createdIn) + Arrays.toString(createdIn)
+ ", modifiedIn=" + ", modifiedIn="
+ Arrays.toString(this.modifiedIn) + Arrays.toString(modifiedIn)
+ ", descriptionLike=" + ", descriptionLike="
+ Arrays.toString(this.descriptionLike) + Arrays.toString(descriptionLike)
+ ", ownerIn=" + ", ownerIn="
+ Arrays.toString(this.ownerIn) + Arrays.toString(ownerIn)
+ ", ownerLike=" + ", ownerLike="
+ Arrays.toString(this.ownerLike) + Arrays.toString(ownerLike)
+ ", custom1In=" + ", custom1In="
+ Arrays.toString(this.custom1In) + Arrays.toString(custom1In)
+ ", custom1Like=" + ", custom1Like="
+ Arrays.toString(this.custom1Like) + Arrays.toString(custom1Like)
+ ", custom2In=" + ", custom2In="
+ Arrays.toString(this.custom2In) + Arrays.toString(custom2In)
+ ", custom2Like=" + ", custom2Like="
+ Arrays.toString(this.custom2Like) + Arrays.toString(custom2Like)
+ ", custom3In=" + ", custom3In="
+ Arrays.toString(this.custom3In) + Arrays.toString(custom3In)
+ ", custom3Like=" + ", custom3Like="
+ Arrays.toString(this.custom3Like) + Arrays.toString(custom3Like)
+ ", custom4In=" + ", custom4In="
+ Arrays.toString(this.custom4In) + Arrays.toString(custom4In)
+ ", custom4Like=" + ", custom4Like="
+ Arrays.toString(this.custom4Like) + Arrays.toString(custom4Like)
+ ", orgLevel1In=" + ", orgLevel1In="
+ Arrays.toString(this.orgLevel1In) + Arrays.toString(orgLevel1In)
+ ", orgLevel1Like=" + ", orgLevel1Like="
+ Arrays.toString(this.orgLevel1Like) + Arrays.toString(orgLevel1Like)
+ ", orgLevel2In=" + ", orgLevel2In="
+ Arrays.toString(this.orgLevel2In) + Arrays.toString(orgLevel2In)
+ ", orgLevel2Like=" + ", orgLevel2Like="
+ Arrays.toString(this.orgLevel2Like) + Arrays.toString(orgLevel2Like)
+ ", orgLevel3In=" + ", orgLevel3In="
+ Arrays.toString(this.orgLevel3In) + Arrays.toString(orgLevel3In)
+ ", orgLevel3Like=" + ", orgLevel3Like="
+ Arrays.toString(this.orgLevel3Like) + Arrays.toString(orgLevel3Like)
+ ", orgLevel4In=" + ", orgLevel4In="
+ Arrays.toString(this.orgLevel4In) + Arrays.toString(orgLevel4In)
+ ", orgLevel4Like=" + ", orgLevel4Like="
+ Arrays.toString(this.orgLevel4Like) + Arrays.toString(orgLevel4Like)
+ ", markedForDeletion=" + ", markedForDeletion="
+ this.markedForDeletion + markedForDeletion
+ ", taskanaEngine="
+ taskanaEngine
+ ", orderBy=" + ", orderBy="
+ this.orderBy + orderBy
+ ", orderColumns="
+ orderColumns
+ ", joinWithAccessList=" + ", joinWithAccessList="
+ this.joinWithAccessList + joinWithAccessList
+ ", checkReadPermission=" + ", checkReadPermission="
+ this.checkReadPermission + checkReadPermission
+ ", usedToAugmentTasks=" + ", usedToAugmentTasks="
+ this.usedToAugmentTasks + usedToAugmentTasks
+ ", callerRolesAndAccessIdsAlreadyHandled="
+ callerRolesAndAccessIdsAlreadyHandled
+ "]"; + "]";
} }
} }

View File

@ -963,56 +963,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
if (workbasketAccessItem == null) { if (workbasketAccessItem == null) {
return permissions; return permissions;
} }
if (workbasketAccessItem.isPermOpen()) { for (WorkbasketPermission permission : WorkbasketPermission.values()) {
permissions.add(WorkbasketPermission.OPEN); if (workbasketAccessItem.getPermission(permission)) {
permissions.add(permission);
} }
if (workbasketAccessItem.isPermRead()) {
permissions.add(WorkbasketPermission.READ);
}
if (workbasketAccessItem.isPermAppend()) {
permissions.add(WorkbasketPermission.APPEND);
}
if (workbasketAccessItem.isPermTransfer()) {
permissions.add(WorkbasketPermission.TRANSFER);
}
if (workbasketAccessItem.isPermDistribute()) {
permissions.add(WorkbasketPermission.DISTRIBUTE);
}
if (workbasketAccessItem.isPermCustom1()) {
permissions.add(WorkbasketPermission.CUSTOM_1);
}
if (workbasketAccessItem.isPermCustom2()) {
permissions.add(WorkbasketPermission.CUSTOM_2);
}
if (workbasketAccessItem.isPermCustom3()) {
permissions.add(WorkbasketPermission.CUSTOM_3);
}
if (workbasketAccessItem.isPermCustom4()) {
permissions.add(WorkbasketPermission.CUSTOM_4);
}
if (workbasketAccessItem.isPermCustom5()) {
permissions.add(WorkbasketPermission.CUSTOM_5);
}
if (workbasketAccessItem.isPermCustom6()) {
permissions.add(WorkbasketPermission.CUSTOM_6);
}
if (workbasketAccessItem.isPermCustom7()) {
permissions.add(WorkbasketPermission.CUSTOM_7);
}
if (workbasketAccessItem.isPermCustom8()) {
permissions.add(WorkbasketPermission.CUSTOM_8);
}
if (workbasketAccessItem.isPermCustom9()) {
permissions.add(WorkbasketPermission.CUSTOM_9);
}
if (workbasketAccessItem.isPermCustom10()) {
permissions.add(WorkbasketPermission.CUSTOM_10);
}
if (workbasketAccessItem.isPermCustom11()) {
permissions.add(WorkbasketPermission.CUSTOM_11);
}
if (workbasketAccessItem.isPermCustom12()) {
permissions.add(WorkbasketPermission.CUSTOM_12);
} }
return permissions; return permissions;
} }

View File

@ -2,6 +2,8 @@ package pro.taskana.workbasket.internal.models;
import java.util.Objects; import java.util.Objects;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem; import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/** WorkbasketAccessItemImpl Entity. */ /** WorkbasketAccessItemImpl Entity. */
@ -56,10 +58,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
permCustom12 = copyFrom.permCustom12; permCustom12 = copyFrom.permCustom12;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getId()
*/
@Override @Override
public String getId() { public String getId() {
return id; return id;
@ -69,10 +67,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.id = id; this.id = id;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getWorkbasketId()
*/
@Override @Override
public String getWorkbasketId() { public String getWorkbasketId() {
return workbasketId; return workbasketId;
@ -91,10 +85,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.workbasketKey = workbasketKey; this.workbasketKey = workbasketKey;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getAccessId()
*/
@Override @Override
public String getAccessId() { public String getAccessId() {
return accessId; return accessId;
@ -104,326 +94,249 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.accessId = accessId; this.accessId = accessId;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getAccessName()
*/
@Override @Override
public String getAccessName() { public String getAccessName() {
return accessName; return accessName;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setAccessName()
*/
@Override @Override
public void setAccessName(String accessName) { public void setAccessName(String accessName) {
this.accessName = accessName; this.accessName = accessName;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermRead()
*/
@Override @Override
public void setPermission(WorkbasketPermission permission, boolean value) {
switch (permission) {
case READ:
permRead = value;
break;
case OPEN:
permOpen = value;
break;
case APPEND:
permAppend = value;
break;
case TRANSFER:
permTransfer = value;
break;
case DISTRIBUTE:
permDistribute = value;
break;
case CUSTOM_1:
permCustom1 = value;
break;
case CUSTOM_2:
permCustom2 = value;
break;
case CUSTOM_3:
permCustom3 = value;
break;
case CUSTOM_4:
permCustom4 = value;
break;
case CUSTOM_5:
permCustom5 = value;
break;
case CUSTOM_6:
permCustom6 = value;
break;
case CUSTOM_7:
permCustom7 = value;
break;
case CUSTOM_8:
permCustom8 = value;
break;
case CUSTOM_9:
permCustom9 = value;
break;
case CUSTOM_10:
permCustom10 = value;
break;
case CUSTOM_11:
permCustom11 = value;
break;
case CUSTOM_12:
permCustom12 = value;
break;
default:
throw new SystemException("Unknown permission '" + permission + "'");
}
}
@Override
public boolean getPermission(WorkbasketPermission permission) {
switch (permission) {
case READ:
return permRead;
case OPEN:
return permOpen;
case APPEND:
return permAppend;
case TRANSFER:
return permTransfer;
case DISTRIBUTE:
return permDistribute;
case CUSTOM_1:
return permCustom1;
case CUSTOM_2:
return permCustom2;
case CUSTOM_3:
return permCustom3;
case CUSTOM_4:
return permCustom4;
case CUSTOM_5:
return permCustom5;
case CUSTOM_6:
return permCustom6;
case CUSTOM_7:
return permCustom7;
case CUSTOM_8:
return permCustom8;
case CUSTOM_9:
return permCustom9;
case CUSTOM_10:
return permCustom10;
case CUSTOM_11:
return permCustom11;
case CUSTOM_12:
return permCustom12;
default:
throw new SystemException("Unknown permission '" + permission + "'");
}
}
public boolean isPermRead() { public boolean isPermRead() {
return permRead; return permRead;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermRead(boolean)
*/
@Override
public void setPermRead(boolean permRead) { public void setPermRead(boolean permRead) {
this.permRead = permRead; this.permRead = permRead;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermOpen()
*/
@Override
public boolean isPermOpen() { public boolean isPermOpen() {
return permOpen; return permOpen;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermOpen(boolean)
*/
@Override
public void setPermOpen(boolean permOpen) { public void setPermOpen(boolean permOpen) {
this.permOpen = permOpen; this.permOpen = permOpen;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermAppend()
*/
@Override
public boolean isPermAppend() { public boolean isPermAppend() {
return permAppend; return permAppend;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermAppend(boolean)
*/
@Override
public void setPermAppend(boolean permAppend) { public void setPermAppend(boolean permAppend) {
this.permAppend = permAppend; this.permAppend = permAppend;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermTransfer()
*/
@Override
public boolean isPermTransfer() { public boolean isPermTransfer() {
return permTransfer; return permTransfer;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermTransfer(boolean)
*/
@Override
public void setPermTransfer(boolean permTransfer) { public void setPermTransfer(boolean permTransfer) {
this.permTransfer = permTransfer; this.permTransfer = permTransfer;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermDistribute()
*/
@Override
public boolean isPermDistribute() { public boolean isPermDistribute() {
return permDistribute; return permDistribute;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermDistribute(boolean)
*/
@Override
public void setPermDistribute(boolean permDistribute) { public void setPermDistribute(boolean permDistribute) {
this.permDistribute = permDistribute; this.permDistribute = permDistribute;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom1()
*/
@Override
public boolean isPermCustom1() { public boolean isPermCustom1() {
return permCustom1; return permCustom1;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom1(boolean)
*/
@Override
public void setPermCustom1(boolean permCustom1) { public void setPermCustom1(boolean permCustom1) {
this.permCustom1 = permCustom1; this.permCustom1 = permCustom1;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom2()
*/
@Override
public boolean isPermCustom2() { public boolean isPermCustom2() {
return permCustom2; return permCustom2;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom2(boolean)
*/
@Override
public void setPermCustom2(boolean permCustom2) { public void setPermCustom2(boolean permCustom2) {
this.permCustom2 = permCustom2; this.permCustom2 = permCustom2;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom3()
*/
@Override
public boolean isPermCustom3() { public boolean isPermCustom3() {
return permCustom3; return permCustom3;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom3(boolean)
*/
@Override
public void setPermCustom3(boolean permCustom3) { public void setPermCustom3(boolean permCustom3) {
this.permCustom3 = permCustom3; this.permCustom3 = permCustom3;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom4()
*/
@Override
public boolean isPermCustom4() { public boolean isPermCustom4() {
return permCustom4; return permCustom4;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom4(boolean)
*/
@Override
public void setPermCustom4(boolean permCustom4) { public void setPermCustom4(boolean permCustom4) {
this.permCustom4 = permCustom4; this.permCustom4 = permCustom4;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom5()
*/
@Override
public boolean isPermCustom5() { public boolean isPermCustom5() {
return permCustom5; return permCustom5;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom5(boolean)
*/
@Override
public void setPermCustom5(boolean permCustom5) { public void setPermCustom5(boolean permCustom5) {
this.permCustom5 = permCustom5; this.permCustom5 = permCustom5;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom6()
*/
@Override
public boolean isPermCustom6() { public boolean isPermCustom6() {
return permCustom6; return permCustom6;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom6(boolean)
*/
@Override
public void setPermCustom6(boolean permCustom6) { public void setPermCustom6(boolean permCustom6) {
this.permCustom6 = permCustom6; this.permCustom6 = permCustom6;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom7()
*/
@Override
public boolean isPermCustom7() { public boolean isPermCustom7() {
return permCustom7; return permCustom7;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom7(boolean)
*/
@Override
public void setPermCustom7(boolean permCustom7) { public void setPermCustom7(boolean permCustom7) {
this.permCustom7 = permCustom7; this.permCustom7 = permCustom7;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom8()
*/
@Override
public boolean isPermCustom8() { public boolean isPermCustom8() {
return permCustom8; return permCustom8;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom8(boolean)
*/
@Override
public void setPermCustom8(boolean permCustom8) { public void setPermCustom8(boolean permCustom8) {
this.permCustom8 = permCustom8; this.permCustom8 = permCustom8;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom9()
*/
@Override
public boolean isPermCustom9() { public boolean isPermCustom9() {
return permCustom9; return permCustom9;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom9(boolean)
*/
@Override
public void setPermCustom9(boolean permCustom9) { public void setPermCustom9(boolean permCustom9) {
this.permCustom9 = permCustom9; this.permCustom9 = permCustom9;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom10()
*/
@Override
public boolean isPermCustom10() { public boolean isPermCustom10() {
return permCustom10; return permCustom10;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom10(boolean)
*/
@Override
public void setPermCustom10(boolean permCustom10) { public void setPermCustom10(boolean permCustom10) {
this.permCustom10 = permCustom10; this.permCustom10 = permCustom10;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom11()
*/
@Override
public boolean isPermCustom11() { public boolean isPermCustom11() {
return permCustom11; return permCustom11;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom11(boolean)
*/
@Override
public void setPermCustom11(boolean permCustom11) { public void setPermCustom11(boolean permCustom11) {
this.permCustom11 = permCustom11; this.permCustom11 = permCustom11;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom12()
*/
@Override
public boolean isPermCustom12() { public boolean isPermCustom12() {
return permCustom12; return permCustom12;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom12(boolean)
*/
@Override
public void setPermCustom12(boolean permCustom12) { public void setPermCustom12(boolean permCustom12) {
this.permCustom12 = permCustom12; this.permCustom12 = permCustom12;
} }

View File

@ -3,6 +3,8 @@ package pro.taskana.workbasket.internal.models;
import java.time.Instant; import java.time.Instant;
import java.util.Objects; import java.util.Objects;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ -21,6 +23,26 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket
this.key = key; this.key = key;
} }
@Override
public void setCustomAttribute(WorkbasketCustomField customField, String value) {
switch (customField) {
case CUSTOM_1:
custom1 = value;
break;
case CUSTOM_2:
custom2 = value;
break;
case CUSTOM_3:
custom3 = value;
break;
case CUSTOM_4:
custom4 = value;
break;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
}
@Override @Override
public WorkbasketImpl copy(String key) { public WorkbasketImpl copy(String key) {
return new WorkbasketImpl(this, key); return new WorkbasketImpl(this, key);
@ -113,14 +135,14 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket
@Override @Override
public String toString() { public String toString() {
return "WorkbasketImpl [id=" return "WorkbasketImpl [created="
+ id
+ ", key="
+ key
+ ", created="
+ created + created
+ ", modified=" + ", modified="
+ modified + modified
+ ", id="
+ id
+ ", key="
+ key
+ ", name=" + ", name="
+ name + name
+ ", description=" + ", description="

View File

@ -2,6 +2,8 @@ package pro.taskana.workbasket.internal.models;
import java.util.Objects; import java.util.Objects;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ -44,10 +46,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
markedForDeletion = copyFrom.markedForDeletion; markedForDeletion = copyFrom.markedForDeletion;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getId()
*/
@Override @Override
public String getId() { public String getId() {
return id; return id;
@ -57,10 +55,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.id = id; this.id = id;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getKey()
*/
@Override @Override
public String getKey() { public String getKey() {
return key; return key;
@ -70,10 +64,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.key = key; this.key = key;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getName()
*/
@Override @Override
public String getName() { public String getName() {
return name; return name;
@ -83,10 +73,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.name = name; this.name = name;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getDescription()
*/
@Override @Override
public String getDescription() { public String getDescription() {
return description; return description;
@ -96,10 +82,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.description = description; this.description = description;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOwner()
*/
@Override @Override
public String getOwner() { public String getOwner() {
return owner; return owner;
@ -109,10 +91,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.owner = owner; this.owner = owner;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getDomain()
*/
@Override @Override
public String getDomain() { public String getDomain() {
return domain; return domain;
@ -122,10 +100,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.domain = domain; this.domain = domain;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getType()
*/
@Override @Override
public WorkbasketType getType() { public WorkbasketType getType() {
return type; return type;
@ -135,11 +109,22 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.type = type; this.type = type;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom1()
*/
@Override @Override
public String getCustomAttribute(WorkbasketCustomField customField) {
switch (customField) {
case CUSTOM_1:
return custom1;
case CUSTOM_2:
return custom2;
case CUSTOM_3:
return custom3;
case CUSTOM_4:
return custom4;
default:
throw new SystemException("Unknown customField '" + customField + "'");
}
}
public String getCustom1() { public String getCustom1() {
return custom1; return custom1;
} }
@ -148,11 +133,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom1 = custom1; this.custom1 = custom1;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom2()
*/
@Override
public String getCustom2() { public String getCustom2() {
return custom2; return custom2;
} }
@ -161,11 +141,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom2 = custom2; this.custom2 = custom2;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom3()
*/
@Override
public String getCustom3() { public String getCustom3() {
return custom3; return custom3;
} }
@ -174,11 +149,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom3 = custom3; this.custom3 = custom3;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom4()
*/
@Override
public String getCustom4() { public String getCustom4() {
return custom4; return custom4;
} }
@ -187,10 +157,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom4 = custom4; this.custom4 = custom4;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel1()
*/
@Override @Override
public String getOrgLevel1() { public String getOrgLevel1() {
return orgLevel1; return orgLevel1;
@ -200,10 +166,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.orgLevel1 = orgLevel1; this.orgLevel1 = orgLevel1;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel2()
*/
@Override @Override
public String getOrgLevel2() { public String getOrgLevel2() {
return orgLevel2; return orgLevel2;
@ -213,10 +175,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.orgLevel2 = orgLevel2; this.orgLevel2 = orgLevel2;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel3()
*/
@Override @Override
public String getOrgLevel3() { public String getOrgLevel3() {
return orgLevel3; return orgLevel3;
@ -226,10 +184,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.orgLevel3 = orgLevel3; this.orgLevel3 = orgLevel3;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel4()
*/
@Override @Override
public String getOrgLevel4() { public String getOrgLevel4() {
return orgLevel4; return orgLevel4;

View File

@ -70,7 +70,7 @@ public abstract class AbstractAccTest {
return objectReference; return objectReference;
} }
protected Map<String, String> createSimpleCustomProperties(int propertiesCount) { protected Map<String, String> createSimpleCustomPropertyMap(int propertiesCount) {
return IntStream.rangeClosed(1, propertiesCount) return IntStream.rangeClosed(1, propertiesCount)
.mapToObj(String::valueOf) .mapToObj(String::valueOf)
.collect(Collectors.toMap("Property_"::concat, "Property Value of Property_"::concat)); .collect(Collectors.toMap("Property_"::concat, "Property Value of Property_"::concat));
@ -102,7 +102,7 @@ public abstract class AbstractAccTest {
} }
attachment.setReceived(receivedTimestamp); attachment.setReceived(receivedTimestamp);
if (customAttributes != null) { if (customAttributes != null) {
attachment.setCustomAttributes(customAttributes); attachment.setCustomAttributeMap(customAttributes);
} }
return attachment; return attachment;

View File

@ -2,6 +2,14 @@ package acceptance.classification;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_1;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_2;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_3;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_4;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_5;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_6;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_7;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_8;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import java.util.List; import java.util.List;
@ -43,14 +51,14 @@ class GetClassificationAccTest extends AbstractAccTest {
assertThat(classification.getPriority()).isEqualTo(2); assertThat(classification.getPriority()).isEqualTo(2);
assertThat(classification.getServiceLevel()).isEqualTo("P2D"); assertThat(classification.getServiceLevel()).isEqualTo("P2D");
assertThat(classification.getApplicationEntryPoint()).isEqualTo("point0815"); assertThat(classification.getApplicationEntryPoint()).isEqualTo("point0815");
assertThat(classification.getCustom1()).isEqualTo("VNR"); assertThat(classification.getCustomAttribute(CUSTOM_1)).isEqualTo("VNR");
assertThat(classification.getCustom2()).isEqualTo("custom2"); assertThat(classification.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(classification.getCustom3()).isEqualTo("custom3"); assertThat(classification.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(classification.getCustom4()).isEqualTo("custom4"); assertThat(classification.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
assertThat(classification.getCustom5()).isEqualTo("custom5"); assertThat(classification.getCustomAttribute(CUSTOM_5)).isEqualTo("custom5");
assertThat(classification.getCustom6()).isEqualTo("custom6"); assertThat(classification.getCustomAttribute(CUSTOM_6)).isEqualTo("custom6");
assertThat(classification.getCustom7()).isEqualTo("custom7"); assertThat(classification.getCustomAttribute(CUSTOM_7)).isEqualTo("custom7");
assertThat(classification.getCustom8()).isEqualTo("custom8"); assertThat(classification.getCustomAttribute(CUSTOM_8)).isEqualTo("custom8");
} }
@Test @Test
@ -68,14 +76,14 @@ class GetClassificationAccTest extends AbstractAccTest {
assertThat(classification.getPriority()).isEqualTo(2); assertThat(classification.getPriority()).isEqualTo(2);
assertThat(classification.getServiceLevel()).isEqualTo("P2D"); assertThat(classification.getServiceLevel()).isEqualTo("P2D");
assertThat(classification.getApplicationEntryPoint()).isEqualTo("point0815"); assertThat(classification.getApplicationEntryPoint()).isEqualTo("point0815");
assertThat(classification.getCustom1()).isEqualTo("VNR"); assertThat(classification.getCustomAttribute(CUSTOM_1)).isEqualTo("VNR");
assertThat(classification.getCustom2()).isEqualTo("custom2"); assertThat(classification.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(classification.getCustom3()).isEqualTo("custom3"); assertThat(classification.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(classification.getCustom4()).isEqualTo("custom4"); assertThat(classification.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
assertThat(classification.getCustom5()).isEqualTo("custom5"); assertThat(classification.getCustomAttribute(CUSTOM_5)).isEqualTo("custom5");
assertThat(classification.getCustom6()).isEqualTo("custom6"); assertThat(classification.getCustomAttribute(CUSTOM_6)).isEqualTo("custom6");
assertThat(classification.getCustom7()).isEqualTo("custom7"); assertThat(classification.getCustomAttribute(CUSTOM_7)).isEqualTo("custom7");
assertThat(classification.getCustom8()).isEqualTo("custom8"); assertThat(classification.getCustomAttribute(CUSTOM_8)).isEqualTo("custom8");
} }
@Test @Test

View File

@ -2,6 +2,14 @@ package acceptance.classification;
import static java.lang.String.CASE_INSENSITIVE_ORDER; import static java.lang.String.CASE_INSENSITIVE_ORDER;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_1;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_2;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_3;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_4;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_5;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_6;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_7;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_8;
import static pro.taskana.classification.api.ClassificationQueryColumnName.CREATED; import static pro.taskana.classification.api.ClassificationQueryColumnName.CREATED;
import static pro.taskana.classification.api.ClassificationQueryColumnName.NAME; import static pro.taskana.classification.api.ClassificationQueryColumnName.NAME;
import static pro.taskana.classification.api.ClassificationQueryColumnName.TYPE; import static pro.taskana.classification.api.ClassificationQueryColumnName.TYPE;
@ -12,14 +20,21 @@ import static pro.taskana.common.api.BaseQuery.SortDirection.DESCENDING;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import java.text.Collator; import java.text.Collator;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Stream;
import org.assertj.core.api.Condition; import org.assertj.core.api.Condition;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationService; import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
@ -174,7 +189,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
List<ClassificationSummary> classifications = List<ClassificationSummary> classifications =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.customAttributeIn("1", "VNR,RVNR,KOLVNR", "VNR") .customAttributeIn(CUSTOM_1, "VNR,RVNR,KOLVNR", "VNR")
.domainIn("DOMAIN_A") .domainIn("DOMAIN_A")
.list(); .list();
assertThat(classifications).hasSize(14); assertThat(classifications).hasSize(14);
@ -185,7 +200,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
List<ClassificationSummary> classifications = List<ClassificationSummary> classifications =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.customAttributeLike("1", "%RVNR%") .customAttributeLike(CUSTOM_1, "%RVNR%")
.domainIn("DOMAIN_A") .domainIn("DOMAIN_A")
.typeIn("TASK") .typeIn("TASK")
.list(); .list();
@ -198,7 +213,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.parentIdIn("CLI:100000000000000000000000000000000004") .parentIdIn("CLI:100000000000000000000000000000000004")
.customAttributeIn("2", "TEXT_1", "TEXT_2") .customAttributeIn(CUSTOM_2, "TEXT_1", "TEXT_2")
.list(); .list();
assertThat(classifications).hasSize(3); assertThat(classifications).hasSize(3);
@ -308,7 +323,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.customAttributeIn("1", "VNR,RVNR,KOLVNR, ANR", "VNR") .customAttributeIn(CUSTOM_1, "VNR,RVNR,KOLVNR, ANR", "VNR")
.list(); .list();
assertThat(results).hasSize(17); assertThat(results).hasSize(17);
} }
@ -318,7 +333,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.customAttributeIn("2", "CUSTOM2", "custom2") .customAttributeIn(CUSTOM_2, "CUSTOM2", "custom2")
.list(); .list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@ -328,7 +343,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.customAttributeIn("3", "Custom3", "custom3") .customAttributeIn(CUSTOM_3, "Custom3", "custom3")
.list(); .list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@ -336,21 +351,30 @@ class QueryClassificationAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom4In() throws Exception { void testQueryForCustom4In() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeIn("4", "custom4").list(); classificationService
.createClassificationQuery()
.customAttributeIn(CUSTOM_4, "custom4")
.list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@Test @Test
void testQueryForCustom5In() throws Exception { void testQueryForCustom5In() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeIn("5", "custom5").list(); classificationService
.createClassificationQuery()
.customAttributeIn(CUSTOM_5, "custom5")
.list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@Test @Test
void testQueryForCustom6In() throws Exception { void testQueryForCustom6In() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeIn("6", "custom6").list(); classificationService
.createClassificationQuery()
.customAttributeIn(CUSTOM_6, "custom6")
.list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@ -359,7 +383,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.customAttributeIn("7", "custom7", "custom_7") .customAttributeIn(CUSTOM_7, "custom7", "custom_7")
.list(); .list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@ -369,7 +393,7 @@ class QueryClassificationAccTest extends AbstractAccTest {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.customAttributeIn("8", "custom_8", "custom8") .customAttributeIn(CUSTOM_8, "custom_8", "custom8")
.list(); .list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@ -377,49 +401,70 @@ class QueryClassificationAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom2Like() throws Exception { void testQueryForCustom2Like() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("2", "cus%").list(); classificationService
.createClassificationQuery()
.customAttributeLike(CUSTOM_2, "cus%")
.list();
assertThat(results).hasSize(6); assertThat(results).hasSize(6);
} }
@Test @Test
void testQueryForCustom3Like() throws Exception { void testQueryForCustom3Like() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("3", "cus%").list(); classificationService
.createClassificationQuery()
.customAttributeLike(CUSTOM_3, "cus%")
.list();
assertThat(results).hasSize(6); assertThat(results).hasSize(6);
} }
@Test @Test
void testQueryForCustom4Like() throws Exception { void testQueryForCustom4Like() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("4", "cus%").list(); classificationService
.createClassificationQuery()
.customAttributeLike(CUSTOM_4, "cus%")
.list();
assertThat(results).hasSize(6); assertThat(results).hasSize(6);
} }
@Test @Test
void testQueryForCustom5Like() throws Exception { void testQueryForCustom5Like() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("5", "cus%").list(); classificationService
.createClassificationQuery()
.customAttributeLike(CUSTOM_5, "cus%")
.list();
assertThat(results).hasSize(6); assertThat(results).hasSize(6);
} }
@Test @Test
void testQueryForCustom6Like() throws Exception { void testQueryForCustom6Like() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("6", "cus%").list(); classificationService
.createClassificationQuery()
.customAttributeLike(CUSTOM_6, "cus%")
.list();
assertThat(results).hasSize(6); assertThat(results).hasSize(6);
} }
@Test @Test
void testQueryForCustom7Like() throws Exception { void testQueryForCustom7Like() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("7", "cus%").list(); classificationService
.createClassificationQuery()
.customAttributeLike(CUSTOM_7, "cus%")
.list();
assertThat(results).hasSize(6); assertThat(results).hasSize(6);
} }
@Test @Test
void testQueryForCustom8Like() throws Exception { void testQueryForCustom8Like() throws Exception {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService.createClassificationQuery().customAttributeLike("8", "cus%").list(); classificationService
.createClassificationQuery()
.customAttributeLike(CUSTOM_8, "cus%")
.list();
assertThat(results).hasSize(6); assertThat(results).hasSize(6);
} }
@ -545,115 +590,41 @@ class QueryClassificationAccTest extends AbstractAccTest {
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER); .isSortedAccordingTo(CASE_INSENSITIVE_ORDER);
} }
@Test @TestFactory
void testQueryForOrderByCustom1Desc() throws Exception { Stream<DynamicTest> should_SortQueryAsc_When_OrderingByCustomAttribute() {
Iterator<ClassificationCustomField> iterator = Arrays.stream(ClassificationCustomField.values())
.iterator();
ThrowingConsumer<ClassificationCustomField> test = customField -> {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.orderByCustomAttribute("1", DESCENDING) .orderByCustomAttribute(customField, ASCENDING)
.list(); .list();
assertThat(results) assertThat(results)
.hasSizeGreaterThan(2) .hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom1) .extracting(c -> c.getCustomAttribute(customField))
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed());
}
@Test
void testQueryForOrderByCustom2Asc() throws Exception {
List<ClassificationSummary> results =
classificationService
.createClassificationQuery()
.orderByCustomAttribute("2", ASCENDING)
.list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom2)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER); .isSortedAccordingTo(CASE_INSENSITIVE_ORDER);
};
return DynamicTest.stream(iterator, c -> "for " + c, test);
} }
@Test @TestFactory
void testQueryForOrderByCustom3Desc() throws Exception { Stream<DynamicTest> should_SortQueryDesc_When_OrderingByCustomAttribute() {
Iterator<ClassificationCustomField> iterator = Arrays.stream(ClassificationCustomField.values())
.iterator();
ThrowingConsumer<ClassificationCustomField> test = customField -> {
List<ClassificationSummary> results = List<ClassificationSummary> results =
classificationService classificationService
.createClassificationQuery() .createClassificationQuery()
.orderByCustomAttribute("3", DESCENDING) .orderByCustomAttribute(customField, DESCENDING)
.list(); .list();
assertThat(results) assertThat(results)
.hasSizeGreaterThan(2) .hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom3) .extracting(c -> c.getCustomAttribute(customField))
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed()); .isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed());
} };
return DynamicTest.stream(iterator, c -> "for " + c, test);
@Test
void testQueryForOrderByCustom4Asc() throws Exception {
List<ClassificationSummary> results =
classificationService
.createClassificationQuery()
.orderByCustomAttribute("4", ASCENDING)
.list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom4)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER);
}
@Test
void testQueryForOrderByCustom5Desc() throws Exception {
List<ClassificationSummary> results =
classificationService
.createClassificationQuery()
.orderByCustomAttribute("5", DESCENDING)
.list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom5)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed());
}
@Test
void testQueryForOrderByCustom6Asc() throws Exception {
List<ClassificationSummary> results =
classificationService
.createClassificationQuery()
.orderByCustomAttribute("6", ASCENDING)
.list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom6)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER);
}
@Test
void testQueryForOrderByCustom7Desc() throws Exception {
List<ClassificationSummary> results =
classificationService
.createClassificationQuery()
.orderByCustomAttribute("7", DESCENDING)
.list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom7)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed());
}
@Test
void testQueryForOrderByCustom8Asc() throws Exception {
List<ClassificationSummary> results =
classificationService
.createClassificationQuery()
.orderByCustomAttribute("8", ASCENDING)
.list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(ClassificationSummary::getCustom8)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER);
} }
} }

View File

@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationService; import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException; import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.classification.api.models.Classification; import pro.taskana.classification.api.models.Classification;
@ -48,14 +49,14 @@ class UpdateClassificationAccTest extends AbstractAccTest {
classification.setApplicationEntryPoint(newEntryPoint); classification.setApplicationEntryPoint(newEntryPoint);
classification.setCategory("PROCESS"); classification.setCategory("PROCESS");
classification.setCustom1("newCustom1"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_1, "newCustom1");
classification.setCustom2("newCustom2"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_2, "newCustom2");
classification.setCustom3("newCustom3"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_3, "newCustom3");
classification.setCustom4("newCustom4"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_4, "newCustom4");
classification.setCustom5("newCustom5"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_5, "newCustom5");
classification.setCustom6("newCustom6"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_6, "newCustom6");
classification.setCustom7("newCustom7"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_7, "newCustom7");
classification.setCustom8("newCustom8"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_8, "newCustom8");
classification.setDescription("newDescription"); classification.setDescription("newDescription");
classification.setIsValidInDomain(false); classification.setIsValidInDomain(false);
classification.setName(newName); classification.setName(newName);
@ -79,7 +80,7 @@ class UpdateClassificationAccTest extends AbstractAccTest {
@Test @Test
void should_ThrowException_When_UserIsNotAuthorized() throws Exception { void should_ThrowException_When_UserIsNotAuthorized() throws Exception {
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A"); Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
classification.setCustom1("newCustom1"); classification.setCustomAttribute(ClassificationCustomField.CUSTOM_1, "newCustom1");
ThrowingCallable call = () -> classificationService.updateClassification(classification); ThrowingCallable call = () -> classificationService.updateClassification(classification);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }

View File

@ -18,9 +18,12 @@ import pro.taskana.common.api.ScheduledJob;
import pro.taskana.common.internal.JobServiceImpl; import pro.taskana.common.internal.JobServiceImpl;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
@ -61,10 +64,10 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
newTask.setClassificationKey("T2100"); newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef( newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
for (int i = 1; i < 16; i++) { for (TaskCustomField taskCustomField : TaskCustomField.values()) {
newTask.setCustomAttribute(Integer.toString(i), "VALUE " + i); newTask.setCustomAttribute(taskCustomField, taskCustomField.name());
} }
newTask.setCustomAttributes(createSimpleCustomProperties(5)); newTask.setCustomAttributeMap(createSimpleCustomPropertyMap(5));
newTask.setDescription("Description of test task"); newTask.setDescription("Description of test task");
newTask.setNote("My note"); newTask.setNote("My note");
newTask.addAttachment( newTask.addAttachment(
@ -78,7 +81,7 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
TimeZone originalZone = TimeZone.getDefault(); TimeZone originalZone = TimeZone.getDefault();
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
@ -134,7 +137,7 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = Workbasket workbasket =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000001"); workbasketService.getWorkbasket("WBI:100000000000000000000000000000000001");
workbasket.setCustom1("bla"); workbasket.setCustomAttribute(WorkbasketCustomField.CUSTOM_1, "bla");
TimeZone originalZone = TimeZone.getDefault(); TimeZone originalZone = TimeZone.getDefault();
Workbasket updatedWorkbasket = workbasketService.updateWorkbasket(workbasket); Workbasket updatedWorkbasket = workbasketService.updateWorkbasket(workbasket);
@ -157,7 +160,7 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai = WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2"); workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2");
wbai.setPermRead(true); wbai.setPermission(WorkbasketPermission.READ, true);
workbasketService.createWorkbasketAccessItem(wbai); workbasketService.createWorkbasketAccessItem(wbai);
int after = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size(); int after = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();

View File

@ -16,7 +16,7 @@ import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
/** Acceptance test for all "classification report" scenarios. */ /** Acceptance test for all "classification report" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
@ -29,7 +29,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
() -> { () -> {
monitorService monitorService
.createWorkbasketReportBuilder() .createWorkbasketReportBuilder()
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_2); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_2);
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }
@ -43,7 +43,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
monitorService monitorService
.createWorkbasketReportBuilder() .createWorkbasketReportBuilder()
.workbasketIdIn(Collections.singletonList("WBI:000000000000000000000000000000000001")) .workbasketIdIn(Collections.singletonList("WBI:000000000000000000000000000000000001"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_2); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_2);
assertThat(values).containsOnly("Vollkasko", "Teilkasko"); assertThat(values).containsOnly("Vollkasko", "Teilkasko");
} }
@ -57,7 +57,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
monitorService monitorService
.createWorkbasketReportBuilder() .createWorkbasketReportBuilder()
.domainIn(Collections.singletonList("DOMAIN_A")) .domainIn(Collections.singletonList("DOMAIN_A"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_16);
assertThat(values).hasSize(26); assertThat(values).hasSize(26);
} }
@ -66,15 +66,15 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
void testGetCustomAttributeValuesForCustomAttribute() throws Exception { void testGetCustomAttributeValuesForCustomAttribute() throws Exception {
MonitorService monitorService = taskanaEngine.getMonitorService(); MonitorService monitorService = taskanaEngine.getMonitorService();
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_2, "Vollkasko"); customAttributeFilter.put(TaskCustomField.CUSTOM_2, "Vollkasko");
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<String> values = List<String> values =
monitorService monitorService
.createClassificationCategoryReportBuilder() .createClassificationCategoryReportBuilder()
.customAttributeFilterIn(customAttributeFilter) .customAttributeFilterIn(customAttributeFilter)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_16);
assertThat(values).hasSize(12); assertThat(values).hasSize(12);
} }
@ -92,7 +92,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
.domainIn(domains) .domainIn(domains)
.excludedClassificationIdIn( .excludedClassificationIdIn(
Collections.singletonList("CLI:000000000000000000000000000000000003")) Collections.singletonList("CLI:000000000000000000000000000000000003"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_16);
assertThat(values).hasSize(43); assertThat(values).hasSize(43);
} }

View File

@ -20,7 +20,7 @@ import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.SelectedItem; import pro.taskana.monitor.api.SelectedItem;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Acceptance test for all "get task ids of category report" scenarios. */ /** Acceptance test for all "get task ids of category report" scenarios. */
@ -272,8 +272,8 @@ class GetTaskIdsOfClassificationCategoryReportAccTest extends AbstractReportAccT
void testGetTaskIdsOfCategoryReportWithCustomFieldValueFilter() throws Exception { void testGetTaskIdsOfCategoryReportWithCustomFieldValueFilter() throws Exception {
final MonitorService monitorService = taskanaEngine.getMonitorService(); final MonitorService monitorService = taskanaEngine.getMonitorService();
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); final List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
final List<SelectedItem> selectedItems = new ArrayList<>(); final List<SelectedItem> selectedItems = new ArrayList<>();

View File

@ -20,12 +20,12 @@ import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.SelectedItem; import pro.taskana.monitor.api.SelectedItem;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Acceptance test for all "get task ids of category report" scenarios. */ /** Acceptance test for all "get task ids of category report" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest { class GetTaskIdsOfTaskCustomFieldValueReportAccTest extends AbstractReportAccTest {
@Test @Test
void testRoleCheck() { void testRoleCheck() {
@ -34,11 +34,10 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<SelectedItem> selectedItems = new ArrayList<>(); List<SelectedItem> selectedItems = new ArrayList<>();
ThrowingCallable call = ThrowingCallable call =
() -> { () ->
monitorService monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.listTaskIdsForSelectedItems(selectedItems); .listTaskIdsForSelectedItems(selectedItems);
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }
@ -71,7 +70,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids = List<String> ids =
monitorService monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.listTaskIdsForSelectedItems(selectedItems); .listTaskIdsForSelectedItems(selectedItems);
@ -119,7 +118,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids = List<String> ids =
monitorService monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.workbasketIdIn(workbasketIds) .workbasketIdIn(workbasketIds)
@ -161,7 +160,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids = List<String> ids =
monitorService monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.stateIn(Collections.singletonList(TaskState.READY)) .stateIn(Collections.singletonList(TaskState.READY))
@ -208,7 +207,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids = List<String> ids =
monitorService monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.classificationCategoryIn(categories) .classificationCategoryIn(categories)
@ -249,7 +248,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids = List<String> ids =
monitorService monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.domainIn(Collections.singletonList("DOMAIN_A")) .domainIn(Collections.singletonList("DOMAIN_A"))
@ -266,8 +265,8 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testGetTaskIdsOfCustomFieldValueReportWithCustomFieldValueFilter() throws Exception { void testGetTaskIdsOfCustomFieldValueReportWithCustomFieldValueFilter() throws Exception {
final MonitorService monitorService = taskanaEngine.getMonitorService(); final MonitorService monitorService = taskanaEngine.getMonitorService();
final Map<CustomField, String> customAttributeFilter = new HashMap<>(); final Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); final List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
final List<SelectedItem> selectedItems = new ArrayList<>(); final List<SelectedItem> selectedItems = new ArrayList<>();
@ -292,7 +291,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids = List<String> ids =
monitorService monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.customAttributeFilterIn(customAttributeFilter) .customAttributeFilterIn(customAttributeFilter)
@ -322,12 +321,11 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
selectedItems.add(s1); selectedItems.add(s1);
ThrowingCallable call = ThrowingCallable call =
() -> { () ->
monitorService monitorService
.createClassificationCategoryReportBuilder() .createClassificationCategoryReportBuilder()
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.listTaskIdsForSelectedItems(selectedItems); .listTaskIdsForSelectedItems(selectedItems);
};
assertThatThrownBy(call).isInstanceOf(InvalidArgumentException.class); assertThatThrownBy(call).isInstanceOf(InvalidArgumentException.class);
} }

View File

@ -26,7 +26,7 @@ import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.ClassificationCategoryReport; import pro.taskana.monitor.api.reports.ClassificationCategoryReport;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Acceptance test for all "category report" scenarios. */ /** Acceptance test for all "category report" scenarios. */
@ -295,8 +295,8 @@ class ProvideClassificationCategoryReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testEachItemOfCategoryReportWithCustomFieldValueFilter() throws Exception { void testEachItemOfCategoryReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationCategoryReport report = ClassificationCategoryReport report =

View File

@ -26,7 +26,7 @@ import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.ClassificationReport; import pro.taskana.monitor.api.reports.ClassificationReport;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Acceptance test for all "classification report" scenarios. */ /** Acceptance test for all "classification report" scenarios. */
@ -332,8 +332,8 @@ class ProvideClassificationReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testEachItemOfClassificationReportWithCustomFieldValueFilter() throws Exception { void testEachItemOfClassificationReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = ClassificationReport report =

View File

@ -30,7 +30,7 @@ import pro.taskana.monitor.api.reports.item.DetailedMonitorQueryItem;
import pro.taskana.monitor.api.reports.row.DetailedClassificationRow; import pro.taskana.monitor.api.reports.row.DetailedClassificationRow;
import pro.taskana.monitor.api.reports.row.FoldableRow; import pro.taskana.monitor.api.reports.row.FoldableRow;
import pro.taskana.monitor.api.reports.row.Row; import pro.taskana.monitor.api.reports.row.Row;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Acceptance test for all "detailed classification report" scenarios. */ /** Acceptance test for all "detailed classification report" scenarios. */
@ -556,8 +556,8 @@ class ProvideDetailedClassificationReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testEachItemOfDetailedClassificationReportWithCustomFieldValueFilter() throws Exception { void testEachItemOfDetailedClassificationReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = DetailedClassificationReport report =

View File

@ -24,14 +24,14 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.CustomFieldValueReport; import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Acceptance test for all "classification report" scenarios. */ /** Acceptance test for all "classification report" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest { class ProvideTaskCustomFieldValueReportAccTest extends AbstractReportAccTest {
private static final MonitorService MONITOR_SERVICE = taskanaEngine.getMonitorService(); private static final MonitorService MONITOR_SERVICE = taskanaEngine.getMonitorService();
@ -39,7 +39,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testRoleCheck() { void testRoleCheck() {
ThrowingCallable call = ThrowingCallable call =
() -> { () -> {
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1).buildReport(); MONITOR_SERVICE
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.buildReport();
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }
@ -47,8 +49,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void should_augmentDisplayNames_When_ReportIsBuild() throws Exception { void should_augmentDisplayNames_When_ReportIsBuild() throws Exception {
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1).buildReport(); MONITOR_SERVICE.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1).buildReport();
assertThat(report.getRows()).hasSize(3); assertThat(report.getRows()).hasSize(3);
assertThat(report.getRow("Geschaeftsstelle A").getDisplayName()) assertThat(report.getRow("Geschaeftsstelle A").getDisplayName())
@ -62,8 +64,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testGetTotalNumbersOfTasksOfCustomFieldValueReportForCustom1() throws Exception { void testGetTotalNumbersOfTasksOfCustomFieldValueReportForCustom1() throws Exception {
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1).buildReport(); MONITOR_SERVICE.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1).buildReport();
assertThat(report).isNotNull(); assertThat(report).isNotNull();
assertThat(report.rowSize()).isEqualTo(3); assertThat(report.rowSize()).isEqualTo(3);
@ -71,9 +73,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
assertThat(report.getRow("Geschaeftsstelle A").getTotalValue()).isEqualTo(25); assertThat(report.getRow("Geschaeftsstelle A").getTotalValue()).isEqualTo(25);
assertThat(report.getRow("Geschaeftsstelle B").getTotalValue()).isEqualTo(10); assertThat(report.getRow("Geschaeftsstelle B").getTotalValue()).isEqualTo(10);
assertThat(report.getRow("Geschaeftsstelle C").getTotalValue()).isEqualTo(15); assertThat(report.getRow("Geschaeftsstelle C").getTotalValue()).isEqualTo(15);
assertThat(report.getRow("Geschaeftsstelle A").getCells().length).isEqualTo(0); assertThat(report.getRow("Geschaeftsstelle A").getCells()).isEmpty();
assertThat(report.getRow("Geschaeftsstelle B").getCells().length).isEqualTo(0); assertThat(report.getRow("Geschaeftsstelle B").getCells()).isEmpty();
assertThat(report.getRow("Geschaeftsstelle C").getCells().length).isEqualTo(0); assertThat(report.getRow("Geschaeftsstelle C").getCells()).isEmpty();
assertThat(report.getSumRow().getTotalValue()).isEqualTo(50); assertThat(report.getSumRow().getTotalValue()).isEqualTo(50);
} }
@ -81,8 +83,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testGetTotalNumbersOfTasksOfCustomFieldValueReportForCustom2() throws Exception { void testGetTotalNumbersOfTasksOfCustomFieldValueReportForCustom2() throws Exception {
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_2).buildReport(); MONITOR_SERVICE.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_2).buildReport();
assertThat(report).isNotNull(); assertThat(report).isNotNull();
assertThat(report.rowSize()).isEqualTo(2); assertThat(report.rowSize()).isEqualTo(2);
@ -90,8 +92,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
assertThat(report.getRow("Vollkasko").getTotalValue()).isEqualTo(21); assertThat(report.getRow("Vollkasko").getTotalValue()).isEqualTo(21);
assertThat(report.getRow("Teilkasko").getTotalValue()).isEqualTo(29); assertThat(report.getRow("Teilkasko").getTotalValue()).isEqualTo(29);
assertThat(report.getRow("Vollkasko").getCells().length).isEqualTo(0); assertThat(report.getRow("Vollkasko").getCells()).isEmpty();
assertThat(report.getRow("Teilkasko").getCells().length).isEqualTo(0); assertThat(report.getRow("Teilkasko").getCells()).isEmpty();
assertThat(report.getSumRow().getTotalValue()).isEqualTo(50); assertThat(report.getSumRow().getTotalValue()).isEqualTo(50);
} }
@ -99,12 +101,12 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testGetCustomFieldValueReportWithReportLineItemDefinitions() throws Exception { void testGetCustomFieldValueReportWithReportLineItemDefinitions() throws Exception {
CustomField customField = CustomField.CUSTOM_1; TaskCustomField taskCustomField = TaskCustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(customField) .createCustomFieldValueReportBuilder(taskCustomField)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.buildReport(); .buildReport();
@ -130,7 +132,7 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
ThrowingCallable callable = ThrowingCallable callable =
() -> () ->
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.buildReport(timestamp); .buildReport(timestamp);
assertThatCode(callable).doesNotThrowAnyException(); assertThatCode(callable).doesNotThrowAnyException();
}; };
@ -142,9 +144,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testEachItemOfCustomFieldValueReport() throws Exception { void testEachItemOfCustomFieldValueReport() throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.buildReport(); .buildReport();
@ -167,9 +169,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void should_computeNumbersAccordingToPlannedDate_When_BuildReportForPlanned() throws Exception { void should_computeNumbersAccordingToPlannedDate_When_BuildReportForPlanned() throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.buildReport(TaskTimestamp.PLANNED); .buildReport(TaskTimestamp.PLANNED);
@ -192,9 +194,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testEachItemOfCustomFieldValueReportNotInWorkingDays() throws Exception { void testEachItemOfCustomFieldValueReportNotInWorkingDays() throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.buildReport(); .buildReport();
@ -218,9 +220,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
Collections.singletonList("WBI:000000000000000000000000000000000001"); Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.workbasketIdIn(workbasketIds) .workbasketIdIn(workbasketIds)
@ -245,9 +247,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<TaskState> states = Collections.singletonList(TaskState.READY); List<TaskState> states = Collections.singletonList(TaskState.READY);
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.stateIn(states) .stateIn(states)
@ -272,9 +274,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL"); List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.classificationCategoryIn(categories) .classificationCategoryIn(categories)
@ -299,9 +301,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> domains = Collections.singletonList("DOMAIN_A"); List<String> domains = Collections.singletonList("DOMAIN_A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()
.domainIn(domains) .domainIn(domains)
@ -323,13 +325,13 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testEachItemOfCustomFieldValueReportWithCustomFieldValueFilter() throws Exception { void testEachItemOfCustomFieldValueReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = TaskCustomFieldValueReport report =
MONITOR_SERVICE MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) .createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.customAttributeFilterIn(customAttributeFilter) .customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.inWorkingDays() .inWorkingDays()

View File

@ -27,7 +27,7 @@ import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.WorkbasketReport; import pro.taskana.monitor.api.reports.WorkbasketReport;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Acceptance test for all "workbasket level report" scenarios. */ /** Acceptance test for all "workbasket level report" scenarios. */
@ -283,8 +283,8 @@ class ProvideWorkbasketReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")
@Test @Test
void testEachItemOfWorkbasketReportWithCustomFieldValueFilter() throws Exception { void testEachItemOfWorkbasketReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketReport report = WorkbasketReport report =

View File

@ -20,10 +20,6 @@ import pro.taskana.common.internal.security.WithAccessId;
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class ClassificationQueryAccTest extends AbstractAccTest { class ClassificationQueryAccTest extends AbstractAccTest {
ClassificationQueryAccTest() {
super();
}
@Test @Test
void testFindClassificationsByDomainUnauthenticated() { void testFindClassificationsByDomainUnauthenticated() {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();

View File

@ -21,6 +21,7 @@ import pro.taskana.common.internal.TaskanaEngineProxyForTest;
import pro.taskana.common.internal.security.CurrentUserContext; import pro.taskana.common.internal.security.CurrentUserContext;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskAlreadyExistException; import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
@ -174,8 +175,8 @@ class CreateTaskAccTest extends AbstractAccTest {
newTask.setClassificationKey("T2100"); newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef( newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Map<String, String> customAttributesForCreate = createSimpleCustomProperties(13); Map<String, String> customAttributesForCreate = createSimpleCustomPropertyMap(13);
newTask.setCustomAttributes(customAttributesForCreate); newTask.setCustomAttributeMap(customAttributesForCreate);
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
Instant expectedPlanned = moveForwardToWorkingDay(createdTask.getCreated()); Instant expectedPlanned = moveForwardToWorkingDay(createdTask.getCreated());
@ -226,7 +227,7 @@ class CreateTaskAccTest extends AbstractAccTest {
} }
// verify that the map is correctly retrieved from the database // verify that the map is correctly retrieved from the database
Task retrievedTask = taskService.getTask(createdTask.getId()); Task retrievedTask = taskService.getTask(createdTask.getId());
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes(); Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributeMap();
assertThat(customAttributesFromDb).isNotNull(); assertThat(customAttributesFromDb).isNotNull();
assertThat(customAttributesForCreate).isEqualTo(customAttributesFromDb); assertThat(customAttributesForCreate).isEqualTo(customAttributesFromDb);
} }
@ -237,7 +238,7 @@ class CreateTaskAccTest extends AbstractAccTest {
Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A"); Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A");
newTask.setClassificationKey("L12010"); newTask.setClassificationKey("L12010");
Map<String, String> customAttributesForCreate = createSimpleCustomProperties(27); Map<String, String> customAttributesForCreate = createSimpleCustomPropertyMap(27);
newTask.addAttachment( newTask.addAttachment(
createAttachment( createAttachment(
"DOCTYPE_DEFAULT", "DOCTYPE_DEFAULT",
@ -309,7 +310,7 @@ class CreateTaskAccTest extends AbstractAccTest {
assertThat(readTask.getAttachments().get(0).getObjectReference()).isNotNull(); assertThat(readTask.getAttachments().get(0).getObjectReference()).isNotNull();
// verify that the map is correctly retrieved from the database // verify that the map is correctly retrieved from the database
Map<String, String> customAttributesFromDb = Map<String, String> customAttributesFromDb =
readTask.getAttachments().get(0).getCustomAttributes(); readTask.getAttachments().get(0).getCustomAttributeMap();
assertThat(customAttributesFromDb).isNotNull(); assertThat(customAttributesFromDb).isNotNull();
assertThat(customAttributesForCreate).isEqualTo(customAttributesFromDb); assertThat(customAttributesForCreate).isEqualTo(customAttributesFromDb);
} }
@ -333,7 +334,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
newTask.addAttachment( newTask.addAttachment(
createAttachment( createAttachment(
"DOCTYPE_DEFAULT", "DOCTYPE_DEFAULT",
@ -345,7 +346,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
assertThat(createdTask.getId()).isNotNull(); assertThat(createdTask.getId()).isNotNull();
@ -384,7 +385,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
newTask.addAttachment( newTask.addAttachment(
createAttachment( createAttachment(
"L1060", // prio 1, SL P1D "L1060", // prio 1, SL P1D
@ -396,7 +397,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
assertThat(createdTask.getId()).isNotNull(); assertThat(createdTask.getId()).isNotNull();
@ -439,7 +440,7 @@ class CreateTaskAccTest extends AbstractAccTest {
testCreateTask.accept( testCreateTask.accept(
createAttachment( createAttachment(
"DOCTYPE_DEFAULT", null, "E-MAIL", "2018-01-15", createSimpleCustomProperties(3))); "DOCTYPE_DEFAULT", null, "E-MAIL", "2018-01-15", createSimpleCustomPropertyMap(3)));
testCreateTask.accept( testCreateTask.accept(
createAttachment( createAttachment(
@ -447,7 +448,7 @@ class CreateTaskAccTest extends AbstractAccTest {
createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", null), createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", null),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
testCreateTask.accept( testCreateTask.accept(
createAttachment( createAttachment(
@ -460,7 +461,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
testCreateTask.accept( testCreateTask.accept(
createAttachment( createAttachment(
@ -473,7 +474,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@ -588,10 +589,10 @@ class CreateTaskAccTest extends AbstractAccTest {
newTask.setClassificationKey("T2100"); newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef( newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
for (int i = 1; i < 16; i++) { for (TaskCustomField taskCustomField : TaskCustomField.values()) {
newTask.setCustomAttribute(Integer.toString(i), "VALUE " + i); newTask.setCustomAttribute(taskCustomField, taskCustomField.name());
} }
newTask.setCustomAttributes(createSimpleCustomProperties(5)); newTask.setCustomAttributeMap(createSimpleCustomPropertyMap(5));
newTask.setDescription("Description of test task"); newTask.setDescription("Description of test task");
newTask.setNote("My note"); newTask.setNote("My note");
newTask.addAttachment( newTask.addAttachment(
@ -605,7 +606,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
Task readTask = taskService.getTask(createdTask.getId()); Task readTask = taskService.getTask(createdTask.getId());
@ -621,7 +622,7 @@ class CreateTaskAccTest extends AbstractAccTest {
newTask.setPrimaryObjRef( newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Map<String, String> callbackInfo = createSimpleCustomProperties(10); Map<String, String> callbackInfo = createSimpleCustomPropertyMap(10);
newTask.setCallbackInfo(callbackInfo); newTask.setCallbackInfo(callbackInfo);
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
Instant expectedPlanned = moveForwardToWorkingDay(createdTask.getCreated()); Instant expectedPlanned = moveForwardToWorkingDay(createdTask.getCreated());

View File

@ -13,6 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
@ -59,23 +60,23 @@ class GetTaskAccTest extends AbstractAccTest {
assertThat(task.isRead()).isTrue(); assertThat(task.isRead()).isTrue();
assertThat(task.isTransferred()).isFalse(); assertThat(task.isTransferred()).isFalse();
assertThat(task.getCallbackInfo()).isEqualTo(new HashMap<String, String>()); assertThat(task.getCallbackInfo()).isEqualTo(new HashMap<String, String>());
assertThat(task.getCustomAttributes()).isEqualTo(new HashMap<String, String>()); assertThat(task.getCustomAttributeMap()).isEqualTo(new HashMap<String, String>());
assertThat(task.getCustomAttribute("1")).isEqualTo("custom1"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_1)).isEqualTo("custom1");
assertThat(task.getCustomAttribute("2")).isEqualTo("custom2"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_2)).isEqualTo("custom2");
assertThat(task.getCustomAttribute("3")).isEqualTo("custom3"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_3)).isEqualTo("custom3");
assertThat(task.getCustomAttribute("4")).isEqualTo("custom4"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_4)).isEqualTo("custom4");
assertThat(task.getCustomAttribute("5")).isEqualTo("custom5"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_5)).isEqualTo("custom5");
assertThat(task.getCustomAttribute("6")).isEqualTo("custom6"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_6)).isEqualTo("custom6");
assertThat(task.getCustomAttribute("7")).isEqualTo("custom7"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_7)).isEqualTo("custom7");
assertThat(task.getCustomAttribute("8")).isEqualTo("custom8"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_8)).isEqualTo("custom8");
assertThat(task.getCustomAttribute("9")).isEqualTo("custom9"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_9)).isEqualTo("custom9");
assertThat(task.getCustomAttribute("10")).isEqualTo("custom10"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_10)).isEqualTo("custom10");
assertThat(task.getCustomAttribute("11")).isEqualTo("custom11"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_11)).isEqualTo("custom11");
assertThat(task.getCustomAttribute("12")).isEqualTo("custom12"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_12)).isEqualTo("custom12");
assertThat(task.getCustomAttribute("13")).isEqualTo("custom13"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_13)).isEqualTo("custom13");
assertThat(task.getCustomAttribute("14")).isEqualTo("abc"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_14)).isEqualTo("abc");
assertThat(task.getCustomAttribute("15")).isEqualTo("custom15"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_15)).isEqualTo("custom15");
assertThat(task.getCustomAttribute("16")).isEqualTo("custom16"); assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_16)).isEqualTo("custom16");
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@ -83,8 +84,6 @@ class GetTaskAccTest extends AbstractAccTest {
void should_ThrowException_When_RequestedTaskByIdIsNotExisting() { void should_ThrowException_When_RequestedTaskByIdIsNotExisting() {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
// Assertions.assertThrows(TaskNotFoundException.class, () ->
// taskService.getTask("INVALID"));
ThrowingCallable call = ThrowingCallable call =
() -> { () -> {
taskService.getTask("INVALID"); taskService.getTask("INVALID");

View File

@ -11,6 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Attachment; import pro.taskana.task.api.models.Attachment;
import pro.taskana.task.api.models.AttachmentSummary; import pro.taskana.task.api.models.AttachmentSummary;
@ -96,7 +97,7 @@ class QueryTaskWithAttachmentAccTest extends AbstractAccTest {
taskService taskService
.createTaskQuery() .createTaskQuery()
.classificationKeyIn("T2000") .classificationKeyIn("T2000")
.customAttributeIn("1", "custom1") .customAttributeIn(TaskCustomField.CUSTOM_1, "custom1")
.list(); .list();
assertThat(tasks).hasSize(1); assertThat(tasks).hasSize(1);
List<AttachmentSummary> queryAttachmentSummaries = tasks.get(0).getAttachmentSummaries(); List<AttachmentSummary> queryAttachmentSummaries = tasks.get(0).getAttachmentSummaries();

View File

@ -5,7 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static pro.taskana.common.api.BaseQuery.SortDirection.ASCENDING; import static pro.taskana.common.api.BaseQuery.SortDirection.ASCENDING;
import static pro.taskana.common.api.BaseQuery.SortDirection.DESCENDING; import static pro.taskana.common.api.BaseQuery.SortDirection.DESCENDING;
import static pro.taskana.common.internal.util.CheckedFunction.wrap; import static pro.taskana.task.api.TaskCustomField.CUSTOM_7;
import static pro.taskana.task.api.TaskQueryColumnName.A_CHANNEL; import static pro.taskana.task.api.TaskQueryColumnName.A_CHANNEL;
import static pro.taskana.task.api.TaskQueryColumnName.A_CLASSIFICATION_ID; import static pro.taskana.task.api.TaskQueryColumnName.A_CLASSIFICATION_ID;
import static pro.taskana.task.api.TaskQueryColumnName.A_REF_VALUE; import static pro.taskana.task.api.TaskQueryColumnName.A_REF_VALUE;
@ -20,7 +20,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
@ -40,6 +39,7 @@ import pro.taskana.common.internal.TaskanaEngineProxyForTest;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.common.internal.util.Triplet; import pro.taskana.common.internal.util.Triplet;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskQuery; import pro.taskana.task.api.TaskQuery;
import pro.taskana.task.api.TaskQueryColumnName; import pro.taskana.task.api.TaskQueryColumnName;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
@ -224,7 +224,7 @@ class QueryTasksAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3)); createSimpleCustomPropertyMap(3));
Task task = taskService.getTask("TKI:000000000000000000000000000000000000"); Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.addAttachment(attachment); task.addAttachment(attachment);
@ -266,49 +266,51 @@ class QueryTasksAccTest extends AbstractAccTest {
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@TestFactory @TestFactory
Stream<DynamicTest> testQueryForCustomX() { Stream<DynamicTest> testQueryForCustomX() {
List<Triplet<String, String[], Integer>> list = List<Triplet<TaskCustomField, String[], Integer>> list =
Arrays.asList( Arrays.asList(
new Triplet<>("1", new String[] {"custom%", "p%", "%xyz%", "efg"}, 3), new Triplet<>(
new Triplet<>("2", new String[] {"custom%", "a%"}, 2), TaskCustomField.CUSTOM_1, new String[] {"custom%", "p%", "%xyz%", "efg"}, 3),
new Triplet<>("3", new String[] {"ffg"}, 1), new Triplet<>(TaskCustomField.CUSTOM_2, new String[] {"custom%", "a%"}, 2),
new Triplet<>("4", new String[] {"%ust%", "%ty"}, 2), new Triplet<>(TaskCustomField.CUSTOM_3, new String[] {"ffg"}, 1),
new Triplet<>("5", new String[] {"ew", "al"}, 6), new Triplet<>(TaskCustomField.CUSTOM_4, new String[] {"%ust%", "%ty"}, 2),
new Triplet<>("6", new String[] {"%custom6%", "%vvg%", "11%"}, 5), new Triplet<>(TaskCustomField.CUSTOM_5, new String[] {"ew", "al"}, 6),
new Triplet<>("7", new String[] {"%"}, 2), new Triplet<>(TaskCustomField.CUSTOM_6, new String[] {"%custom6%", "%vvg%", "11%"}, 5),
new Triplet<>("8", new String[] {"%"}, 2), new Triplet<>(TaskCustomField.CUSTOM_7, new String[] {"%"}, 2),
new Triplet<>("9", new String[] {"%"}, 2), new Triplet<>(TaskCustomField.CUSTOM_8, new String[] {"%"}, 2),
new Triplet<>("10", new String[] {"%"}, 3), new Triplet<>(TaskCustomField.CUSTOM_9, new String[] {"%"}, 2),
new Triplet<>("11", new String[] {"%"}, 3), new Triplet<>(TaskCustomField.CUSTOM_10, new String[] {"%"}, 3),
new Triplet<>("12", new String[] {"%"}, 3), new Triplet<>(TaskCustomField.CUSTOM_11, new String[] {"%"}, 3),
new Triplet<>("13", new String[] {"%"}, 3), new Triplet<>(TaskCustomField.CUSTOM_12, new String[] {"%"}, 3),
new Triplet<>("14", new String[] {"%"}, 87), new Triplet<>(TaskCustomField.CUSTOM_13, new String[] {"%"}, 3),
new Triplet<>("15", new String[] {"%"}, 3), new Triplet<>(TaskCustomField.CUSTOM_14, new String[] {"%"}, 87),
new Triplet<>("16", new String[] {"%"}, 3)); new Triplet<>(TaskCustomField.CUSTOM_15, new String[] {"%"}, 3),
new Triplet<>(TaskCustomField.CUSTOM_16, new String[] {"%"}, 3));
assertThat(list).hasSameSizeAs(TaskCustomField.values());
return DynamicTest.stream( return DynamicTest.stream(
list.iterator(), list.iterator(),
t -> ("custom" + t.getLeft()), t -> t.getLeft().name(),
t -> testQueryForCustomX(t.getLeft(), t.getMiddle(), t.getRight())); t -> testQueryForCustomX(t.getLeft(), t.getMiddle(), t.getRight()));
} }
void testQueryForCustomX(String customValue, String[] searchArguments, int expectedResult) void testQueryForCustomX(
throws Exception { TaskCustomField customField, String[] searchArguments, int expectedResult) throws Exception {
List<TaskSummary> results = List<TaskSummary> results =
taskService.createTaskQuery().customAttributeLike(customValue, searchArguments).list(); taskService.createTaskQuery().customAttributeLike(customField, searchArguments).list();
assertThat(results).hasSize(expectedResult); assertThat(results).hasSize(expectedResult);
String[] ids = String[] ids =
results.stream().map(wrap(t -> t.getCustomAttribute(customValue))).toArray(String[]::new); results.stream().map(t -> t.getCustomAttribute(customField)).toArray(String[]::new);
List<TaskSummary> result2 = List<TaskSummary> result2 =
taskService.createTaskQuery().customAttributeIn(customValue, ids).list(); taskService.createTaskQuery().customAttributeIn(customField, ids).list();
assertThat(result2).hasSize(expectedResult); assertThat(result2).hasSize(expectedResult);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@Test @Test
void testQueryForCustom7WithExceptionInLike() { void testQueryForCustom7WithExceptionInLike() {
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeLike("7").list()) assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeLike(CUSTOM_7).list())
.isInstanceOf(InvalidArgumentException.class); .isInstanceOf(InvalidArgumentException.class);
} }
@ -316,23 +318,24 @@ class QueryTasksAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom7WithExceptionInIn() throws Exception { void testQueryForCustom7WithExceptionInIn() throws Exception {
List<TaskSummary> results = List<TaskSummary> results =
taskService.createTaskQuery().customAttributeLike("7", "fsdhfshk%").list(); taskService.createTaskQuery().customAttributeLike(CUSTOM_7, "fsdhfshk%").list();
assertThat(results).isEmpty(); assertThat(results).isEmpty();
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeIn("7").list()) assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeIn(CUSTOM_7).list())
.isInstanceOf(InvalidArgumentException.class); .isInstanceOf(InvalidArgumentException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@Test @Test
void testQueryForCustom7WithException() throws Exception { void testQueryForCustom7WithException() throws Exception {
List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("7", "%").list(); List<TaskSummary> results =
taskService.createTaskQuery().customAttributeLike(CUSTOM_7, "%").list();
assertThat(results).hasSize(2); assertThat(results).hasSize(2);
String[] ids = String[] ids = results.stream().map(t -> t.getCustomAttribute(CUSTOM_7)).toArray(String[]::new);
results.stream().map(wrap(t -> t.getCustomAttribute("7"))).toArray(String[]::new);
List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("7", ids).list(); List<TaskSummary> result2 =
taskService.createTaskQuery().customAttributeIn(CUSTOM_7, ids).list();
assertThat(result2).hasSize(2); assertThat(result2).hasSize(2);
} }
@ -344,8 +347,8 @@ class QueryTasksAccTest extends AbstractAccTest {
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setClassificationKey("T2100"); newTask.setClassificationKey("T2100");
Map<String, String> customAttributesForCreate = Map<String, String> customAttributesForCreate =
createSimpleCustomProperties(20000); // about 1 Meg createSimpleCustomPropertyMap(20000); // about 1 Meg
newTask.setCustomAttributes(customAttributesForCreate); newTask.setCustomAttributeMap(customAttributesForCreate);
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
assertThat(createdTask).isNotNull(); assertThat(createdTask).isNotNull();
@ -369,8 +372,7 @@ class QueryTasksAccTest extends AbstractAccTest {
assertThat(retrievedTask.getId()).isEqualTo(createdTask.getId()); assertThat(retrievedTask.getId()).isEqualTo(createdTask.getId());
// verify that the map is correctly retrieved from the database // verify that the map is correctly retrieved from the database
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes(); Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributeMap();
assertThat(customAttributesFromDb).isNotNull();
assertThat(customAttributesFromDb).isEqualTo(customAttributesForCreate); assertThat(customAttributesFromDb).isEqualTo(customAttributesForCreate);
} finally { } finally {
@ -589,35 +591,34 @@ class QueryTasksAccTest extends AbstractAccTest {
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@TestFactory @TestFactory
Stream<DynamicTest> testQueryForOrderByCustomXAsc() { Stream<DynamicTest> testQueryForOrderByCustomXAsc() {
Iterator<String> iterator = IntStream.rangeClosed(1, 16).mapToObj(String::valueOf).iterator(); Iterator<TaskCustomField> iterator = Arrays.stream(TaskCustomField.values()).iterator();
return DynamicTest.stream( return DynamicTest.stream(
iterator, iterator,
s -> String.format("order by custom%s asc", s), s -> String.format("order by %s asc", s),
s -> testQueryForOrderByCustomX(s, ASCENDING)); s -> testQueryForOrderByCustomX(s, ASCENDING));
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@TestFactory @TestFactory
Stream<DynamicTest> testQueryForOrderByCustomXDesc() { Stream<DynamicTest> testQueryForOrderByCustomXDesc() {
Iterator<String> iterator = IntStream.rangeClosed(1, 16).mapToObj(String::valueOf).iterator(); Iterator<TaskCustomField> iterator = Arrays.stream(TaskCustomField.values()).iterator();
return DynamicTest.stream( return DynamicTest.stream(
iterator, iterator,
s -> String.format("order by custom%s desc", s), s -> String.format("order by %s desc", s),
s -> testQueryForOrderByCustomX(s, DESCENDING)); s -> testQueryForOrderByCustomX(s, DESCENDING));
} }
void testQueryForOrderByCustomX(String customValue, SortDirection sortDirection) void testQueryForOrderByCustomX(TaskCustomField customField, SortDirection sortDirection) {
throws Exception {
List<TaskSummary> results = List<TaskSummary> results =
taskService.createTaskQuery().orderByCustomAttribute(customValue, sortDirection).list(); taskService.createTaskQuery().orderByCustomAttribute(customField, sortDirection).list();
Comparator<String> comparator = Comparator<String> comparator =
sortDirection == ASCENDING ? CASE_INSENSITIVE_ORDER : CASE_INSENSITIVE_ORDER.reversed(); sortDirection == ASCENDING ? CASE_INSENSITIVE_ORDER : CASE_INSENSITIVE_ORDER.reversed();
assertThat(results) assertThat(results)
.hasSizeGreaterThan(2) .hasSizeGreaterThan(2)
.extracting(t -> t.getCustomAttribute(customValue)) .extracting(t -> t.getCustomAttribute(customField))
.filteredOn(Objects::nonNull) .filteredOn(Objects::nonNull)
.isSortedAccordingTo(comparator); .isSortedAccordingTo(comparator);
} }

View File

@ -3,6 +3,15 @@ package acceptance.task;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_1;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_10;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_12;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_14;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_16;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_2;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_3;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_5;
import static pro.taskana.task.api.TaskCustomField.CUSTOM_7;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import java.time.Instant; import java.time.Instant;
@ -20,6 +29,7 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
@ -120,10 +130,10 @@ class UpdateTaskAccTest extends AbstractAccTest {
Task task = taskService.getTask("TKI:000000000000000000000000000000000000"); Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
final Task task2 = taskService.getTask("TKI:000000000000000000000000000000000000"); final Task task2 = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setCustomAttribute("1", "willi"); task.setCustomAttribute(CUSTOM_1, "willi");
Thread.sleep(10); Thread.sleep(10);
taskService.updateTask(task); taskService.updateTask(task);
task2.setCustomAttribute("2", "Walter"); task2.setCustomAttribute(CUSTOM_2, "Walter");
// TODO flaky test ... if speed is too high, // TODO flaky test ... if speed is too high,
assertThatThrownBy(() -> taskService.updateTask(task2)) assertThatThrownBy(() -> taskService.updateTask(task2))
.isInstanceOf(ConcurrencyException.class) .isInstanceOf(ConcurrencyException.class)
@ -184,7 +194,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
@Test @Test
void should_UpdateTask_When_CustomPropertiesOfTaskWereChanged() throws Exception { void should_UpdateTask_When_CustomPropertiesOfTaskWereChanged() throws Exception {
Task task = taskService.getTask("TKI:000000000000000000000000000000000000"); Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setCustomAttribute("1", "T2100"); task.setCustomAttribute(CUSTOM_1, "T2100");
Task updatedTask = taskService.updateTask(task); Task updatedTask = taskService.updateTask(task);
updatedTask = taskService.getTask(updatedTask.getId()); updatedTask = taskService.getTask(updatedTask.getId());
@ -212,11 +222,11 @@ class UpdateTaskAccTest extends AbstractAccTest {
por.setSystemInstance("00"); por.setSystemInstance("00");
por.setType("VNR"); por.setType("VNR");
por.setValue("22334455"); por.setValue("22334455");
Map<String, String> customProperties = new HashMap<>(); Map<TaskCustomField, String> customProperties = new HashMap<>();
customProperties.put("7", "This is modifiedValue 7"); customProperties.put(CUSTOM_7, "This is modifiedValue 7");
customProperties.put("14", null); customProperties.put(CUSTOM_14, null);
customProperties.put("3", "This is modifiedValue 3"); customProperties.put(CUSTOM_3, "This is modifiedValue 3");
customProperties.put("16", "This is modifiedValue 16"); customProperties.put(CUSTOM_16, "This is modifiedValue 16");
List<String> taskIds = taskService.updateTasks(por, customProperties); List<String> taskIds = taskService.updateTasks(por, customProperties);
assertThat(taskIds).isEmpty(); assertThat(taskIds).isEmpty();
@ -231,20 +241,20 @@ class UpdateTaskAccTest extends AbstractAccTest {
por.setSystemInstance("00"); por.setSystemInstance("00");
por.setType("VNR"); por.setType("VNR");
por.setValue("22334455"); por.setValue("22334455");
Map<String, String> customProperties = new HashMap<>(); Map<TaskCustomField, String> customProperties = new HashMap<>();
customProperties.put("7", "This is modifiedValue 7"); customProperties.put(CUSTOM_7, "This is modifiedValue 7");
customProperties.put("14", null); customProperties.put(CUSTOM_14, null);
customProperties.put("3", "This is modifiedValue 3"); customProperties.put(CUSTOM_3, "This is modifiedValue 3");
customProperties.put("16", "This is modifiedValue 16"); customProperties.put(CUSTOM_16, "This is modifiedValue 16");
List<String> taskIds = taskService.updateTasks(por, customProperties); List<String> taskIds = taskService.updateTasks(por, customProperties);
assertThat(taskIds).hasSize(6); assertThat(taskIds).hasSize(6);
for (String taskId : taskIds) { for (String taskId : taskIds) {
Task task = taskService.getTask(taskId); Task task = taskService.getTask(taskId);
assertThat(task.getCustomAttribute("3")).isEqualTo("This is modifiedValue 3"); assertThat(task.getCustomAttribute(CUSTOM_3)).isEqualTo("This is modifiedValue 3");
assertThat(task.getCustomAttribute("7")).isEqualTo("This is modifiedValue 7"); assertThat(task.getCustomAttribute(CUSTOM_7)).isEqualTo("This is modifiedValue 7");
assertThat(task.getCustomAttribute("16")).isEqualTo("This is modifiedValue 16"); assertThat(task.getCustomAttribute(CUSTOM_16)).isEqualTo("This is modifiedValue 16");
assertThat(task.getCustomAttribute("14")).isNull(); assertThat(task.getCustomAttribute(CUSTOM_14)).isNull();
} }
} }
@ -256,21 +266,21 @@ class UpdateTaskAccTest extends AbstractAccTest {
"TKI:000000000000000000000000000000000008", "TKI:000000000000000000000000000000000008",
"TKI:000000000000000000000000000000000009", "TKI:000000000000000000000000000000000009",
"TKI:000000000000000000000000000000000010"); "TKI:000000000000000000000000000000000010");
Map<String, String> customProperties = new HashMap<>(); Map<TaskCustomField, String> customProperties = new HashMap<>();
customProperties.put("1", "This is modifiedValue 1"); customProperties.put(CUSTOM_1, "This is modifiedValue 1");
customProperties.put("5", "This is modifiedValue 5"); customProperties.put(CUSTOM_5, "This is modifiedValue 5");
customProperties.put("10", "This is modifiedValue 10"); customProperties.put(CUSTOM_10, "This is modifiedValue 10");
customProperties.put("12", "This is modifiedValue 12"); customProperties.put(CUSTOM_12, "This is modifiedValue 12");
List<String> changedTasks = taskService.updateTasks(taskIds, customProperties); List<String> changedTasks = taskService.updateTasks(taskIds, customProperties);
assertThat(changedTasks).hasSize(3); assertThat(changedTasks).hasSize(3);
for (String taskId : changedTasks) { for (String taskId : changedTasks) {
Task task = taskService.getTask(taskId); Task task = taskService.getTask(taskId);
assertThat(task.getCustomAttribute("1")).isEqualTo("This is modifiedValue 1"); assertThat(task.getCustomAttribute(CUSTOM_1)).isEqualTo("This is modifiedValue 1");
assertThat(task.getCustomAttribute("5")).isEqualTo("This is modifiedValue 5"); assertThat(task.getCustomAttribute(CUSTOM_5)).isEqualTo("This is modifiedValue 5");
assertThat(task.getCustomAttribute("10")).isEqualTo("This is modifiedValue 10"); assertThat(task.getCustomAttribute(CUSTOM_10)).isEqualTo("This is modifiedValue 10");
assertThat(task.getCustomAttribute("12")).isEqualTo("This is modifiedValue 12"); assertThat(task.getCustomAttribute(CUSTOM_12)).isEqualTo("This is modifiedValue 12");
assertThat(task.getCustomAttribute("2")).isNull(); assertThat(task.getCustomAttribute(CUSTOM_2)).isNull();
} }
} }

View File

@ -56,7 +56,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3)); createSimpleCustomPropertyMap(3));
task.getAttachments().clear(); task.getAttachments().clear();
taskService.updateTask(task); taskService.updateTask(task);
assertThat(task).isNotNull(); assertThat(task).isNotNull();
@ -291,7 +291,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"ABC45678901234567890123456789012345678901234567890"), "ABC45678901234567890123456789012345678901234567890"),
"ROHRPOST", "ROHRPOST",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(4)); createSimpleCustomPropertyMap(4));
task.addAttachment(attachment2); task.addAttachment(attachment2);
task = taskService.updateTask(task); task = taskService.updateTask(task);
task = taskService.getTask(task.getId()); task = taskService.getTask(task.getId());
@ -304,12 +304,12 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
.areExactly( .areExactly(
1, 1,
new Condition<>( new Condition<>(
e -> "E-MAIL".equals(e.getChannel()) && e.getCustomAttributes().size() == 3, e -> "E-MAIL".equals(e.getChannel()) && e.getCustomAttributeMap().size() == 3,
"E-MAIL with 3 custom attributes")) "E-MAIL with 3 custom attributes"))
.areExactly( .areExactly(
1, 1,
new Condition<>( new Condition<>(
e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributes().size() == 4, e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributeMap().size() == 4,
"ROHRPOST with 4 custom attributes")); "ROHRPOST with 4 custom attributes"));
ClassificationSummary newClassificationSummary = ClassificationSummary newClassificationSummary =
@ -320,7 +320,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
// modify existing attachment // modify existing attachment
for (Attachment att : task.getAttachments()) { for (Attachment att : task.getAttachments()) {
att.setClassificationSummary(newClassificationSummary); att.setClassificationSummary(newClassificationSummary);
if (att.getCustomAttributes().size() == 3) { if (att.getCustomAttributeMap().size() == 3) {
att.setChannel("FAX"); att.setChannel("FAX");
} }
} }
@ -337,12 +337,12 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
.areExactly( .areExactly(
1, 1,
new Condition<>( new Condition<>(
e -> "FAX".equals(e.getChannel()) && e.getCustomAttributes().size() == 3, e -> "FAX".equals(e.getChannel()) && e.getCustomAttributeMap().size() == 3,
"FAX with 3 custom attributes")) "FAX with 3 custom attributes"))
.areExactly( .areExactly(
1, 1,
new Condition<>( new Condition<>(
e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributes().size() == 4, e -> "ROHRPOST".equals(e.getChannel()) && e.getCustomAttributeMap().size() == 4,
"ROHRPOST with 4 custom attributes")); "ROHRPOST with 4 custom attributes"));
} }
@ -363,7 +363,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"ABC45678901234567890123456789012345678901234567890"), "ABC45678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(4)); createSimpleCustomPropertyMap(4));
task.addAttachment(attachment2); task.addAttachment(attachment2);
task = taskService.updateTask(task); task = taskService.updateTask(task);
task = taskService.getTask(task.getId()); task = taskService.getTask(task.getId());
@ -382,7 +382,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"ABC4567890123456789012345678901234567890DEF"), "ABC4567890123456789012345678901234567890DEF"),
"DHL", "DHL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(4)); createSimpleCustomPropertyMap(4));
// replace existing attachments by new via addAttachment call // replace existing attachments by new via addAttachment call
task.getAttachments().clear(); task.getAttachments().clear();
@ -425,7 +425,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
newTask.addAttachment( newTask.addAttachment(
createAttachment( createAttachment(
"L1060", // prio 1, SL P1D "L1060", // prio 1, SL P1D
@ -437,7 +437,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"), "12345678901234567890123456789012345678901234567890"),
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
createSimpleCustomProperties(3))); createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask); Task createdTask = taskService.createTask(newTask);
assertThat(createdTask.getId()).isNotNull(); assertThat(createdTask.getId()).isNotNull();
@ -483,7 +483,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"E-MAIL", "E-MAIL",
"2018-01-15", "2018-01-15",
null); null);
attachment.getCustomAttributes().put("TEST_KEY", "TEST_VALUE"); attachment.getCustomAttributeMap().put("TEST_KEY", "TEST_VALUE");
task.addAttachment(attachment); task.addAttachment(attachment);
taskService.updateTask(task); taskService.updateTask(task);
Task updatedTask = taskService.getTask("TKI:000000000000000000000000000000000000"); Task updatedTask = taskService.getTask("TKI:000000000000000000000000000000000000");
@ -494,6 +494,6 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
.orElse(null); .orElse(null);
assertThat(updatedAttachment).isNotNull(); assertThat(updatedAttachment).isNotNull();
assertThat(updatedTask.getModified()).isEqualTo(updatedAttachment.getModified()); assertThat(updatedTask.getModified()).isEqualTo(updatedAttachment.getModified());
assertThat(updatedAttachment.getCustomAttributes().get("TEST_KEY")).isEqualTo("TEST_VALUE"); assertThat(updatedAttachment.getCustomAttributeMap().get("TEST_KEY")).isEqualTo("TEST_VALUE");
} }
} }

View File

@ -10,6 +10,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
@ -61,7 +62,7 @@ class TaskRoutingAccTest extends AbstractAccTest {
newTask.setClassificationKey("L12010"); newTask.setClassificationKey("L12010");
newTask.setPrimaryObjRef( newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setCustomAttribute("7", "noRouting"); newTask.setCustomAttribute(TaskCustomField.CUSTOM_7, "noRouting");
assertThatThrownBy(() -> taskService.createTask(newTask)) assertThatThrownBy(() -> taskService.createTask(newTask))
.isInstanceOf(InvalidArgumentException.class); .isInstanceOf(InvalidArgumentException.class);
} }
@ -75,7 +76,7 @@ class TaskRoutingAccTest extends AbstractAccTest {
newTask.setClassificationKey("L12010"); newTask.setClassificationKey("L12010");
newTask.setPrimaryObjRef( newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setCustomAttribute("7", "multipleWorkbaskets"); newTask.setCustomAttribute(TaskCustomField.CUSTOM_7, "multipleWorkbaskets");
assertThatThrownBy(() -> taskService.createTask(newTask)) assertThatThrownBy(() -> taskService.createTask(newTask))
.isInstanceOf(InvalidArgumentException.class); .isInstanceOf(InvalidArgumentException.class);
} }
@ -88,7 +89,6 @@ class TaskRoutingAccTest extends AbstractAccTest {
newTask.setPrimaryObjRef( newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
TaskImpl createdTask = (TaskImpl) taskService.createTask(newTask); return (TaskImpl) taskService.createTask(newTask);
return createdTask;
} }
} }

View File

@ -1,32 +1,21 @@
package acceptance.taskrouting; package acceptance.taskrouting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.spi.routing.api.TaskRoutingProvider; import pro.taskana.spi.routing.api.TaskRoutingProvider;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
/** This is a sample implementation of TaskRouter. */ /** This is a sample implementation of TaskRouter. */
public class TestTaskRoutingProviderForDomainA implements TaskRoutingProvider { public class TestTaskRoutingProviderForDomainA implements TaskRoutingProvider {
private static final Logger LOGGER =
LoggerFactory.getLogger(TestTaskRoutingProviderForDomainA.class);
TaskanaEngine theEngine;
@Override @Override
public void initialize(TaskanaEngine taskanaEngine) { public void initialize(TaskanaEngine taskanaEngine) {
theEngine = taskanaEngine; // no-op
} }
@Override @Override
public String determineWorkbasketId(Task task) { public String determineWorkbasketId(Task task) {
String att7 = ""; String att7 = task.getCustomAttribute(TaskCustomField.CUSTOM_7);
try {
att7 = task.getCustomAttribute("7");
} catch (InvalidArgumentException ex) {
LOGGER.warn("caught exception ", ex);
}
if (att7 != null && att7.equals("multipleWorkbaskets")) { if (att7 != null && att7.equals("multipleWorkbaskets")) {
return "WBI:100000000000000000000000000000000005"; return "WBI:100000000000000000000000000000000005";

View File

@ -14,6 +14,7 @@ import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException; import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException;
@ -43,7 +44,7 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai = WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2"); workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2");
wbai.setPermRead(true); wbai.setPermission(WorkbasketPermission.READ, true);
workbasketService.createWorkbasketAccessItem(wbai); workbasketService.createWorkbasketAccessItem(wbai);
int after = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size(); int after = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
@ -109,58 +110,46 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket.setType(WorkbasketType.GROUP); workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company"); workbasket.setOrgLevel1("company");
// missing key // missing key
ThrowingCallable call = () -> workbasketService.createWorkbasket(workbasket); assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket))
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class); .isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket2 = workbasketService.newWorkbasket("key", "novatec"); Workbasket workbasket2 = workbasketService.newWorkbasket("key", "novatec");
workbasket2.setType(WorkbasketType.GROUP); workbasket2.setType(WorkbasketType.GROUP);
workbasket2.setOrgLevel1("company"); workbasket2.setOrgLevel1("company");
// missing name // missing name
call = assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket2))
() -> { .isInstanceOf(InvalidWorkbasketException.class);
workbasketService.createWorkbasket(workbasket2);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket3 = workbasketService.newWorkbasket("key", "novatec"); Workbasket workbasket3 = workbasketService.newWorkbasket("key", "novatec");
workbasket3.setName("Megabasket"); workbasket3.setName("Megabasket");
workbasket3.setOrgLevel1("company"); workbasket3.setOrgLevel1("company");
// missing type // missing type
call = () -> workbasketService.createWorkbasket(workbasket3); assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket3))
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class); .isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket4 = workbasketService.newWorkbasket("key", null); Workbasket workbasket4 = workbasketService.newWorkbasket("key", null);
workbasket4.setName("Megabasket"); workbasket4.setName("Megabasket");
workbasket4.setType(WorkbasketType.GROUP); workbasket4.setType(WorkbasketType.GROUP);
workbasket4.setOrgLevel1("company"); workbasket4.setOrgLevel1("company");
// missing domain // missing domain
call = assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket4))
() -> { .isInstanceOf(InvalidWorkbasketException.class);
workbasketService.createWorkbasket(workbasket4);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket5 = workbasketService.newWorkbasket("", "novatec"); Workbasket workbasket5 = workbasketService.newWorkbasket("", "novatec");
workbasket5.setName("Megabasket"); workbasket5.setName("Megabasket");
workbasket5.setType(WorkbasketType.GROUP); workbasket5.setType(WorkbasketType.GROUP);
workbasket5.setOrgLevel1("company"); workbasket5.setOrgLevel1("company");
// empty key // empty key
call = assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket5))
() -> { .isInstanceOf(InvalidWorkbasketException.class);
workbasketService.createWorkbasket(workbasket5);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket6 = workbasketService.newWorkbasket("key", "novatec"); Workbasket workbasket6 = workbasketService.newWorkbasket("key", "novatec");
workbasket6.setName(""); workbasket6.setName("");
workbasket6.setType(WorkbasketType.GROUP); workbasket6.setType(WorkbasketType.GROUP);
workbasket6.setOrgLevel1("company"); workbasket6.setOrgLevel1("company");
// empty name // empty name
call = assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket))
() -> { .isInstanceOf(InvalidWorkbasketException.class);
workbasketService.createWorkbasket(workbasket);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -178,11 +167,8 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
duplicateWorkbasketWithSmallX.setName("Personal Workbasket for UID X123456"); duplicateWorkbasketWithSmallX.setName("Personal Workbasket for UID X123456");
duplicateWorkbasketWithSmallX.setType(WorkbasketType.PERSONAL); duplicateWorkbasketWithSmallX.setType(WorkbasketType.PERSONAL);
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.createWorkbasket(duplicateWorkbasketWithSmallX))
() -> { .isInstanceOf(WorkbasketAlreadyExistException.class);
workbasketService.createWorkbasket(duplicateWorkbasketWithSmallX);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketAlreadyExistException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -201,18 +187,14 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
sameKeyAndDomain.setType(WorkbasketType.TOPIC); sameKeyAndDomain.setType(WorkbasketType.TOPIC);
sameKeyAndDomain.setName("new name"); sameKeyAndDomain.setName("new name");
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.createWorkbasket(sameKeyAndDomain))
() -> { .isInstanceOf(WorkbasketAlreadyExistException.class);
workbasketService.createWorkbasket(sameKeyAndDomain);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketAlreadyExistException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@Test @Test
void testWorkbasketAccessItemSetName() throws Exception { void testWorkbasketAccessItemSetName() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
Workbasket workbasket = workbasketService.newWorkbasket("WBAIT1234", "DOMAIN_A"); Workbasket workbasket = workbasketService.newWorkbasket("WBAIT1234", "DOMAIN_A");
workbasket.setName("MyNewBasket"); workbasket.setName("MyNewBasket");
@ -221,7 +203,7 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai = WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2"); workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2");
wbai.setPermRead(true); wbai.setPermission(WorkbasketPermission.READ, true);
wbai.setAccessName("Karl Napf"); wbai.setAccessName("Karl Napf");
workbasketService.createWorkbasketAccessItem(wbai); workbasketService.createWorkbasketAccessItem(wbai);
@ -233,7 +215,10 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasketService.getWorkbasketAccessItems(createdWorkbasket.getId()); workbasketService.getWorkbasketAccessItems(createdWorkbasket.getId());
WorkbasketAccessItem item = WorkbasketAccessItem item =
accessItems.stream().filter(t -> wbai.getId().equals(t.getId())).findFirst().orElse(null); accessItems.stream().filter(t -> wbai.getId().equals(t.getId())).findFirst().orElse(null);
assertThat("Karl Napf").isEqualTo(item.getAccessName()); assertThat(item)
.isNotNull()
.extracting(WorkbasketAccessItem::getAccessName)
.isEqualTo("Karl Napf");
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -248,13 +233,10 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai = WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-3-2"); workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-3-2");
wbai.setPermRead(true); wbai.setPermission(WorkbasketPermission.READ, true);
workbasketService.createWorkbasketAccessItem(wbai); workbasketService.createWorkbasketAccessItem(wbai);
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.createWorkbasketAccessItem(wbai))
() -> { .isInstanceOf(WorkbasketAccessItemAlreadyExistException.class);
workbasketService.createWorkbasketAccessItem(wbai);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketAccessItemAlreadyExistException.class);
} }
} }

View File

@ -3,13 +3,13 @@ package acceptance.workbasket;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem; import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
@ -25,13 +25,10 @@ class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem( workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000001", "user1"); "WBI:100000000000000000000000000000000001", "user1");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermCustom11(true); accessItem.setPermission(WorkbasketPermission.CUSTOM_11, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.createWorkbasketAccessItem(accessItem))
() -> { .isInstanceOf(NotAuthorizedException.class);
workbasketService.createWorkbasketAccessItem(accessItem);
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }
} }

View File

@ -17,6 +17,7 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException; import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
@ -75,12 +76,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testGetWorkbasketNotAuthorized() { void testGetWorkbasketNotAuthorized() {
assertThatThrownBy(() -> workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A"))
ThrowingCallable call = .isInstanceOf(NotAuthorizedException.class);
() -> {
workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A");
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -109,22 +106,14 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testDeleteWorkbasketWithNullOrEmptyParam() { void testDeleteWorkbasketWithNullOrEmptyParam() {
// Test Null-Value // Test Null-Value
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.deleteWorkbasket(null))
() -> {
workbasketService.deleteWorkbasket(null);
};
assertThatThrownBy(call)
.describedAs( .describedAs(
"delete() should have thrown an InvalidArgumentException, " "delete() should have thrown an InvalidArgumentException, "
+ "when the param ID is null.") + "when the param ID is null.")
.isInstanceOf(InvalidArgumentException.class); .isInstanceOf(InvalidArgumentException.class);
// Test EMPTY-Value // Test EMPTY-Value
call = assertThatThrownBy(() -> workbasketService.deleteWorkbasket(""))
() -> {
workbasketService.deleteWorkbasket("");
};
assertThatThrownBy(call)
.describedAs( .describedAs(
"delete() should have thrown an InvalidArgumentException, \"\n" "delete() should have thrown an InvalidArgumentException, \"\n"
+ " + \"when the param ID is EMPTY-String.") + " + \"when the param ID is EMPTY-String.")
@ -134,11 +123,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@Test @Test
void testDeleteWorkbasketButNotExisting() { void testDeleteWorkbasketButNotExisting() {
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.deleteWorkbasket("SOME NOT EXISTING ID"))
() -> { .isInstanceOf(WorkbasketNotFoundException.class);
workbasketService.deleteWorkbasket("SOME NOT EXISTING ID");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
} }
@WithAccessId(user = "user-1-2", groups = "businessadmin") @WithAccessId(user = "user-1-2", groups = "businessadmin")
@ -146,11 +132,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
void testDeleteWorkbasketWhichIsUsed() throws Exception { void testDeleteWorkbasketWhichIsUsed() throws Exception {
Workbasket wb = Workbasket wb =
workbasketService.getWorkbasket("user-1-2", "DOMAIN_A"); // all rights, DOMAIN_A with Tasks workbasketService.getWorkbasket("user-1-2", "DOMAIN_A"); // all rights, DOMAIN_A with Tasks
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.deleteWorkbasket(wb.getId()))
() -> { .isInstanceOf(WorkbasketInUseException.class);
workbasketService.deleteWorkbasket(wb.getId());
};
assertThatThrownBy(call).isInstanceOf(WorkbasketInUseException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -160,14 +143,14 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
String wbId = wb.getId(); String wbId = wb.getId();
// create 2 access Items // create 2 access Items
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wbId, "TEAMLEAD-2"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wbId, "TEAMLEAD-2");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem); workbasketService.createWorkbasketAccessItem(accessItem);
accessItem = workbasketService.newWorkbasketAccessItem(wbId, "elena"); accessItem = workbasketService.newWorkbasketAccessItem(wbId, "elena");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem); workbasketService.createWorkbasketAccessItem(accessItem);
List<WorkbasketAccessItem> accessItemsBefore = workbasketService.getWorkbasketAccessItems(wbId); List<WorkbasketAccessItem> accessItemsBefore = workbasketService.getWorkbasketAccessItems(wbId);
assertThat(accessItemsBefore).hasSize(5); assertThat(accessItemsBefore).hasSize(5);

View File

@ -2,6 +2,10 @@ package acceptance.workbasket;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_1;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_2;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_3;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_4;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import java.util.List; import java.util.List;
@ -24,17 +28,14 @@ import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class GetWorkbasketAccTest extends AbstractAccTest { class GetWorkbasketAccTest extends AbstractAccTest {
GetWorkbasketAccTest() { private static final WorkbasketService WORKBASKET_SERVICE = taskanaEngine.getWorkbasketService();
super();
}
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@Test @Test
void testGetWorkbasketById() throws Exception { void testGetWorkbasketById() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = Workbasket workbasket =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007"); WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000007");
assertThat(workbasket.getDomain()).isEqualTo("DOMAIN_A"); assertThat(workbasket.getDomain()).isEqualTo("DOMAIN_A");
assertThat(workbasket.getDescription()).isEqualTo("PPK User 2 KSC 1"); assertThat(workbasket.getDescription()).isEqualTo("PPK User 2 KSC 1");
@ -46,10 +47,10 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(workbasket.getOrgLevel2()).isEqualTo("abteilung"); assertThat(workbasket.getOrgLevel2()).isEqualTo("abteilung");
assertThat(workbasket.getOrgLevel3()).isEqualTo("projekt"); assertThat(workbasket.getOrgLevel3()).isEqualTo("projekt");
assertThat(workbasket.getOrgLevel4()).isEqualTo("team"); assertThat(workbasket.getOrgLevel4()).isEqualTo("team");
assertThat(workbasket.getCustom1()).isEqualTo("custom1"); assertThat(workbasket.getCustomAttribute(CUSTOM_1)).isEqualTo("custom1");
assertThat(workbasket.getCustom2()).isEqualTo("custom2"); assertThat(workbasket.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(workbasket.getCustom3()).isEqualTo("custom3"); assertThat(workbasket.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(workbasket.getCustom4()).isEqualTo("custom4"); assertThat(workbasket.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@ -59,10 +60,8 @@ class GetWorkbasketAccTest extends AbstractAccTest {
void should_ReturnWorkbasketByKeyAndDomain_When_NoExplicitPermissionButUserHasAdministrativeRole() void should_ReturnWorkbasketByKeyAndDomain_When_NoExplicitPermissionButUserHasAdministrativeRole()
throws Exception { throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket retrievedWorkbasket = Workbasket retrievedWorkbasket =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007"); WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000007");
assertThat(retrievedWorkbasket).isNotNull(); assertThat(retrievedWorkbasket).isNotNull();
assertThat(retrievedWorkbasket.getOwner()).isEqualTo("Peter Maier"); assertThat(retrievedWorkbasket.getOwner()).isEqualTo("Peter Maier");
@ -75,9 +74,7 @@ class GetWorkbasketAccTest extends AbstractAccTest {
void should_ReturnWorkbasketById_When_NoExplicitPermissionsButUserIsInAdministrativeRole() void should_ReturnWorkbasketById_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws Exception { throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); Workbasket retrievedWorkbasket = WORKBASKET_SERVICE.getWorkbasket("USER-1-2", "DOMAIN_A");
Workbasket retrievedWorkbasket = workbasketService.getWorkbasket("USER-1-2", "DOMAIN_A");
assertThat(retrievedWorkbasket.getOwner()).isEqualTo("Peter Maier"); assertThat(retrievedWorkbasket.getOwner()).isEqualTo("Peter Maier");
assertThat(retrievedWorkbasket).isNotNull(); assertThat(retrievedWorkbasket).isNotNull();
@ -86,9 +83,8 @@ class GetWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@Test @Test
void testGetWorkbasketByKeyAndDomain() throws Exception { void testGetWorkbasketByKeyAndDomain() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER-1-2", "DOMAIN_A"); Workbasket workbasket = WORKBASKET_SERVICE.getWorkbasket("USER-1-2", "DOMAIN_A");
assertThat(workbasket.getId()).isEqualTo("WBI:100000000000000000000000000000000007"); assertThat(workbasket.getId()).isEqualTo("WBI:100000000000000000000000000000000007");
assertThat(workbasket.getDescription()).isEqualTo("PPK User 2 KSC 1"); assertThat(workbasket.getDescription()).isEqualTo("PPK User 2 KSC 1");
@ -99,18 +95,17 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(workbasket.getOrgLevel2()).isEqualTo("abteilung"); assertThat(workbasket.getOrgLevel2()).isEqualTo("abteilung");
assertThat(workbasket.getOrgLevel3()).isEqualTo("projekt"); assertThat(workbasket.getOrgLevel3()).isEqualTo("projekt");
assertThat(workbasket.getOrgLevel4()).isEqualTo("team"); assertThat(workbasket.getOrgLevel4()).isEqualTo("team");
assertThat(workbasket.getCustom1()).isEqualTo("custom1"); assertThat(workbasket.getCustomAttribute(CUSTOM_1)).isEqualTo("custom1");
assertThat(workbasket.getCustom2()).isEqualTo("custom2"); assertThat(workbasket.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(workbasket.getCustom3()).isEqualTo("custom3"); assertThat(workbasket.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(workbasket.getCustom4()).isEqualTo("custom4"); assertThat(workbasket.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
} }
@WithAccessId(user = "user-1-1", groups = GROUP_1_DN) @WithAccessId(user = "user-1-1", groups = GROUP_1_DN)
@Test @Test
void testGetWorkbasketPermissions() { void testGetWorkbasketPermissions() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketPermission> permissions = List<WorkbasketPermission> permissions =
workbasketService.getPermissionsForWorkbasket("WBI:100000000000000000000000000000000007"); WORKBASKET_SERVICE.getPermissionsForWorkbasket("WBI:100000000000000000000000000000000007");
assertThat(permissions).hasSize(4); assertThat(permissions).hasSize(4);
assertThat(permissions.contains(WorkbasketPermission.READ)).isTrue(); assertThat(permissions.contains(WorkbasketPermission.READ)).isTrue();
@ -122,9 +117,8 @@ class GetWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@Test @Test
void testGetWorkbasketPermissionsForInvalidWorkbasketId() { void testGetWorkbasketPermissionsForInvalidWorkbasketId() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketPermission> permissions = List<WorkbasketPermission> permissions =
workbasketService.getPermissionsForWorkbasket("WBI:invalid"); WORKBASKET_SERVICE.getPermissionsForWorkbasket("WBI:invalid");
assertThat(permissions).isEmpty(); assertThat(permissions).isEmpty();
} }
@ -132,10 +126,9 @@ class GetWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@Test @Test
void testGetWorkbasketAsSummary() throws Exception { void testGetWorkbasketAsSummary() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketSummary workbasketSummary = WorkbasketSummary workbasketSummary =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007").asSummary(); WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000007").asSummary();
assertThat(workbasketSummary.getDomain()).isEqualTo("DOMAIN_A"); assertThat(workbasketSummary.getDomain()).isEqualTo("DOMAIN_A");
assertThat(workbasketSummary.getDescription()).isEqualTo("PPK User 2 KSC 1"); assertThat(workbasketSummary.getDescription()).isEqualTo("PPK User 2 KSC 1");
@ -147,62 +140,43 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(workbasketSummary.getOrgLevel2()).isEqualTo("abteilung"); assertThat(workbasketSummary.getOrgLevel2()).isEqualTo("abteilung");
assertThat(workbasketSummary.getOrgLevel3()).isEqualTo("projekt"); assertThat(workbasketSummary.getOrgLevel3()).isEqualTo("projekt");
assertThat(workbasketSummary.getOrgLevel4()).isEqualTo("team"); assertThat(workbasketSummary.getOrgLevel4()).isEqualTo("team");
assertThat(workbasketSummary.getCustom1()).isEqualTo("custom1"); assertThat(workbasketSummary.getCustomAttribute(CUSTOM_1)).isEqualTo("custom1");
assertThat(workbasketSummary.getCustom2()).isEqualTo("custom2"); assertThat(workbasketSummary.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(workbasketSummary.getCustom3()).isEqualTo("custom3"); assertThat(workbasketSummary.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(workbasketSummary.getCustom4()).isEqualTo("custom4"); assertThat(workbasketSummary.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
assertThat(workbasketSummary.isMarkedForDeletion()).isEqualTo(false); assertThat(workbasketSummary.isMarkedForDeletion()).isEqualTo(false);
} }
@Test @Test
void testThrowsExceptionIfIdIsInvalid() { void testThrowsExceptionIfIdIsInvalid() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("INVALID_ID"))
ThrowingCallable call = .isInstanceOf(WorkbasketNotFoundException.class);
() -> {
workbasketService.getWorkbasket("INVALID_ID");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
} }
@Test @Test
void testThrowsExceptionIfKeyOrDomainIsInvalid() { void testThrowsExceptionIfKeyOrDomainIsInvalid() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call = assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("INVALID_KEY", "INVALID_DOMAIN"))
() -> { .isInstanceOf(WorkbasketNotFoundException.class);
workbasketService.getWorkbasket("INVALID_KEY", "INVALID_DOMAIN");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
} }
@Test @Test
void testGetByIdNotAuthorized() { void testGetByIdNotAuthorized() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call = ThrowingCallable call =
() -> { () -> WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000001");
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000001");
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }
@Test @Test
void testGetByKeyDomainNotAuthorized() { void testGetByKeyDomainNotAuthorized() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("GPK_KSC", "DOMAIN_A"))
ThrowingCallable call = .isInstanceOf(NotAuthorizedException.class);
() -> {
workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@Test @Test
void testGetWorkbasketByIdNotExisting() { void testGetWorkbasketByIdNotExisting() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("NOT EXISTING ID"))
ThrowingCallable call = .isInstanceOf(WorkbasketNotFoundException.class);
() -> {
workbasketService.getWorkbasket("NOT EXISTING ID");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
} }
} }

View File

@ -8,13 +8,19 @@ import static pro.taskana.workbasket.api.WorkbasketQueryColumnName.NAME;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketQuery; import pro.taskana.workbasket.api.WorkbasketQuery;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
@ -359,7 +365,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom1In() { void testQueryForCustom1In() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom1In("ABCQVW").list(); workbasketService
.createWorkbasketQuery()
.customAttributeIn(WorkbasketCustomField.CUSTOM_1, "ABCQVW")
.list();
assertThat(results).hasSize(1); assertThat(results).hasSize(1);
assertThat(results.get(0).getId()).isEqualTo("WBI:100000000000000000000000000000000001"); assertThat(results.get(0).getId()).isEqualTo("WBI:100000000000000000000000000000000001");
@ -369,7 +378,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom1Like() { void testQueryForCustom1Like() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom1Like("custo%").list(); workbasketService
.createWorkbasketQuery()
.customAttributeLike(WorkbasketCustomField.CUSTOM_1, "custo%")
.list();
assertThat(results).hasSize(2); assertThat(results).hasSize(2);
} }
@ -377,7 +389,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom2In() { void testQueryForCustom2In() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom2In("cust2", "custom2").list(); workbasketService
.createWorkbasketQuery()
.customAttributeIn(WorkbasketCustomField.CUSTOM_2, "cust2", "custom2")
.list();
assertThat(results).hasSize(3); assertThat(results).hasSize(3);
} }
@ -385,7 +400,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom2Like() { void testQueryForCustom2Like() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom2Like("cusTo%").list(); workbasketService
.createWorkbasketQuery()
.customAttributeLike(WorkbasketCustomField.CUSTOM_2, "cusTo%")
.list();
assertThat(results).hasSize(3); assertThat(results).hasSize(3);
} }
@ -393,7 +411,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom3In() { void testQueryForCustom3In() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom3In("custom3").list(); workbasketService
.createWorkbasketQuery()
.customAttributeLike(WorkbasketCustomField.CUSTOM_3, "custom3")
.list();
assertThat(results).hasSize(2); assertThat(results).hasSize(2);
} }
@ -401,7 +422,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom3Like() { void testQueryForCustom3Like() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom3Like("cu%").list(); workbasketService
.createWorkbasketQuery()
.customAttributeLike(WorkbasketCustomField.CUSTOM_3, "cu%")
.list();
assertThat(results).hasSize(3); assertThat(results).hasSize(3);
} }
@ -409,7 +433,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom4In() { void testQueryForCustom4In() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom4In("custom4", "team").list(); workbasketService
.createWorkbasketQuery()
.customAttributeIn(WorkbasketCustomField.CUSTOM_4, "custom4", "team")
.list();
assertThat(results).hasSize(3); assertThat(results).hasSize(3);
} }
@ -417,7 +444,10 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
@Test @Test
void testQueryForCustom4Like() { void testQueryForCustom4Like() {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().custom4Like("%u%").list(); workbasketService
.createWorkbasketQuery()
.customAttributeLike(WorkbasketCustomField.CUSTOM_4, "%u%")
.list();
assertThat(results).hasSize(5); assertThat(results).hasSize(5);
} }
@ -534,50 +564,46 @@ class QueryWorkbasketAccTest extends AbstractAccTest {
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@Test @TestFactory
void testQueryForOrderByCustom1Asc() { Stream<DynamicTest> should_SortQueryAsc_When_OrderingByCustomAttribute() {
Iterator<WorkbasketCustomField> iterator = Arrays.stream(WorkbasketCustomField.values())
.iterator();
ThrowingConsumer<WorkbasketCustomField> test = customField -> {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().orderByCustom1(ASCENDING).list(); workbasketService
.createWorkbasketQuery()
.orderByCustomAttribute(customField, ASCENDING)
.list();
assertThat(results) assertThat(results)
.hasSizeGreaterThan(2) .hasSizeGreaterThan(2)
.extracting(WorkbasketSummary::getCustom1) .extracting(w -> w.getCustomAttribute(customField))
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER); .isSortedAccordingTo(CASE_INSENSITIVE_ORDER);
};
return DynamicTest.stream(iterator, c -> "for " + c,
test);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@Test @TestFactory
void testQueryForOrderByCustom2Desc() { Stream<DynamicTest> should_SortQueryDesc_When_OrderingByCustomAttribute() {
Iterator<WorkbasketCustomField> iterator = Arrays.stream(WorkbasketCustomField.values())
.iterator();
ThrowingConsumer<WorkbasketCustomField> test = customField -> {
List<WorkbasketSummary> results = List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().orderByCustom2(DESCENDING).list(); workbasketService
.createWorkbasketQuery()
.orderByCustomAttribute(customField, DESCENDING)
.list();
assertThat(results) assertThat(results)
.hasSizeGreaterThan(2) .hasSizeGreaterThan(2)
.extracting(WorkbasketSummary::getCustom2) .extracting(w -> w.getCustomAttribute(customField))
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed());
}
@WithAccessId(user = "admin")
@Test
void testQueryForOrderByCustom3Asc() {
List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().orderByCustom3(ASCENDING).list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(WorkbasketSummary::getCustom3)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER);
}
@WithAccessId(user = "admin")
@Test
void testQueryForOrderByCustom4Desc() {
List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().orderByCustom4(DESCENDING).list();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(WorkbasketSummary::getCustom4)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed()); .isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed());
};
return DynamicTest.stream(iterator, c -> "for " + c,
test);
} }
} }

View File

@ -15,6 +15,7 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension; import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
@ -40,10 +41,10 @@ class UpdateWorkbasketAccTest extends AbstractAccTest {
workbasket.setOrgLevel2("new level 2"); workbasket.setOrgLevel2("new level 2");
workbasket.setOrgLevel3("new level 3"); workbasket.setOrgLevel3("new level 3");
workbasket.setOrgLevel4("new level 4"); workbasket.setOrgLevel4("new level 4");
workbasket.setCustom1("new custom 1"); workbasket.setCustomAttribute(WorkbasketCustomField.CUSTOM_1, "new custom 1");
workbasket.setCustom2("new custom 2"); workbasket.setCustomAttribute(WorkbasketCustomField.CUSTOM_2, "new custom 2");
workbasket.setCustom3("new custom 3"); workbasket.setCustomAttribute(WorkbasketCustomField.CUSTOM_3, "new custom 3");
workbasket.setCustom4("new custom 4"); workbasket.setCustomAttribute(WorkbasketCustomField.CUSTOM_4, "new custom 4");
workbasket.setDescription("new description"); workbasket.setDescription("new description");
workbasketService.updateWorkbasket(workbasket); workbasketService.updateWorkbasket(workbasket);

View File

@ -6,6 +6,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
@ -21,6 +22,7 @@ import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.NotAuthorizedToQueryWorkbasketException; import pro.taskana.workbasket.api.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem; import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
@ -30,10 +32,6 @@ import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest { class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
UpdateWorkbasketAuthorizationsAccTest() {
super();
}
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")
@TestTemplate @TestTemplate
@ -45,14 +43,10 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
workbasketService.newWorkbasketAccessItem( workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000008", "newAccessIdForUpdate"); "WBI:100000000000000000000000000000000008", "newAccessIdForUpdate");
workbasketAccessItem.setPermCustom1(true); workbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_1, true);
ThrowingCallable updateWorkbasketAccessItemCall = assertThatThrownBy(() -> workbasketService.updateWorkbasketAccessItem(workbasketAccessItem))
() -> { .isInstanceOf(NotAuthorizedException.class);
workbasketService.updateWorkbasketAccessItem(workbasketAccessItem);
};
assertThatThrownBy(updateWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -62,14 +56,14 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem( workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000002", "user1"); "WBI:100000000000000000000000000000000002", "user1");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermCustom11(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.CUSTOM_11, true);
accessItem = workbasketService.createWorkbasketAccessItem(accessItem); accessItem = workbasketService.createWorkbasketAccessItem(accessItem);
final WorkbasketAccessItem newItem = accessItem; final WorkbasketAccessItem newItem = accessItem;
accessItem.setPermCustom1(true); accessItem.setPermission(WorkbasketPermission.CUSTOM_1, true);
accessItem.setPermAppend(false); accessItem.setPermission(WorkbasketPermission.APPEND, false);
accessItem.setAccessName("Rojas, Miguel"); accessItem.setAccessName("Rojas, Miguel");
workbasketService.updateWorkbasketAccessItem(accessItem); workbasketService.updateWorkbasketAccessItem(accessItem);
List<WorkbasketAccessItem> items = List<WorkbasketAccessItem> items =
@ -80,11 +74,11 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
assertThat(updatedItem).isNotNull(); assertThat(updatedItem).isNotNull();
assertThat(updatedItem.getAccessName()).isEqualTo("Rojas, Miguel"); assertThat(updatedItem.getAccessName()).isEqualTo("Rojas, Miguel");
assertThat(updatedItem.isPermAppend()).isFalse(); assertThat(updatedItem.getPermission(WorkbasketPermission.APPEND)).isFalse();
assertThat(updatedItem.isPermRead()).isTrue(); assertThat(updatedItem.getPermission(WorkbasketPermission.READ)).isTrue();
assertThat(updatedItem.isPermCustom11()).isTrue(); assertThat(updatedItem.getPermission(WorkbasketPermission.CUSTOM_11)).isTrue();
assertThat(updatedItem.isPermCustom1()).isTrue(); assertThat(updatedItem.getPermission(WorkbasketPermission.CUSTOM_1)).isTrue();
assertThat(updatedItem.isPermCustom2()).isFalse(); assertThat(updatedItem.getPermission(WorkbasketPermission.CUSTOM_2)).isFalse();
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -94,40 +88,32 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem( workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000001", "user1"); "WBI:100000000000000000000000000000000001", "user1");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermCustom11(true); accessItem.setPermission(WorkbasketPermission.CUSTOM_11, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
WorkbasketAccessItem accessItemCreated = WorkbasketAccessItem accessItemCreated =
workbasketService.createWorkbasketAccessItem(accessItem); workbasketService.createWorkbasketAccessItem(accessItem);
accessItemCreated.setPermCustom1(true); accessItemCreated.setPermission(WorkbasketPermission.CUSTOM_1, true);
accessItemCreated.setPermAppend(false); accessItemCreated.setPermission(WorkbasketPermission.APPEND, false);
((WorkbasketAccessItemImpl) accessItemCreated).setAccessId("willi"); ((WorkbasketAccessItemImpl) accessItemCreated).setAccessId("willi");
ThrowingCallable call = assertThatThrownBy(() -> workbasketService.updateWorkbasketAccessItem(accessItemCreated))
() -> {
workbasketService.updateWorkbasketAccessItem(accessItemCreated);
};
assertThatThrownBy(call)
.describedAs("InvalidArgumentException was expected because access id was changed") .describedAs("InvalidArgumentException was expected because access id was changed")
.isInstanceOf(InvalidArgumentException.class); .isInstanceOf(InvalidArgumentException.class);
((WorkbasketAccessItemImpl) accessItemCreated).setAccessId("user1"); ((WorkbasketAccessItemImpl) accessItemCreated).setAccessId("user1");
WorkbasketAccessItem accessItemUpdated = WorkbasketAccessItem accessItemUpdated =
workbasketService.updateWorkbasketAccessItem(accessItemCreated); workbasketService.updateWorkbasketAccessItem(accessItemCreated);
assertThat(accessItemUpdated.isPermAppend()).isFalse(); assertThat(accessItemUpdated.getPermission(WorkbasketPermission.APPEND)).isFalse();
assertThat(accessItemUpdated.isPermRead()).isTrue(); assertThat(accessItemUpdated.getPermission(WorkbasketPermission.READ)).isTrue();
assertThat(accessItemUpdated.isPermCustom11()).isTrue(); assertThat(accessItemUpdated.getPermission(WorkbasketPermission.CUSTOM_11)).isTrue();
assertThat(accessItemUpdated.isPermCustom1()).isTrue(); assertThat(accessItemUpdated.getPermission(WorkbasketPermission.CUSTOM_1)).isTrue();
assertThat(accessItemUpdated.isPermCustom2()).isFalse(); assertThat(accessItemUpdated.getPermission(WorkbasketPermission.CUSTOM_2)).isFalse();
((WorkbasketAccessItemImpl) accessItemUpdated).setWorkbasketId("2"); ((WorkbasketAccessItemImpl) accessItemUpdated).setWorkbasketId("2");
call = assertThatThrownBy(() -> workbasketService.updateWorkbasketAccessItem(accessItemUpdated))
() -> {
workbasketService.updateWorkbasketAccessItem(accessItemUpdated);
};
assertThatThrownBy(call)
.describedAs("InvalidArgumentException was expected because key was changed") .describedAs("InvalidArgumentException was expected because key was changed")
.isInstanceOf(InvalidArgumentException.class); .isInstanceOf(InvalidArgumentException.class);
} }
@ -140,7 +126,6 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
String wbKey = "USER-2-1"; String wbKey = "USER-2-1";
String wbDomain = "DOMAIN_A"; String wbDomain = "DOMAIN_A";
final String groupName = GROUP_2_DN;
Task newTask = taskService.newTask(wbKey, wbDomain); Task newTask = taskService.newTask(wbKey, wbDomain);
newTask.setClassificationKey("T2100"); newTask.setClassificationKey("T2100");
@ -156,21 +141,20 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008"); workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
WorkbasketAccessItem theAccessItem = WorkbasketAccessItem theAccessItem =
accessItems.stream() accessItems.stream()
.filter(x -> groupName.equalsIgnoreCase(x.getAccessId())) .filter(x -> GROUP_2_DN.equalsIgnoreCase(x.getAccessId()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
assertThat(theAccessItem).isNotNull(); assertThat(theAccessItem).isNotNull();
theAccessItem.setPermOpen(false); theAccessItem.setPermission(WorkbasketPermission.OPEN, false);
workbasketService.updateWorkbasketAccessItem(theAccessItem); workbasketService.updateWorkbasketAccessItem(theAccessItem);
ThrowingCallable call = ThrowingCallable call =
() -> { () ->
taskService taskService
.createTaskQuery() .createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)) .workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain))
.list(); .list();
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedToQueryWorkbasketException.class); assertThatThrownBy(call).isInstanceOf(NotAuthorizedToQueryWorkbasketException.class);
} }
@ -180,36 +164,38 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
final String wbId = "WBI:100000000000000000000000000000000004"; final String wbId = "WBI:100000000000000000000000000000000004";
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(wbId); List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(wbId);
final int countBefore = accessItems.size();
// update some values // update some values
WorkbasketAccessItem item0 = accessItems.get(0); WorkbasketAccessItem item0 = accessItems.get(0);
item0.setPermAppend(false); item0.setPermission(WorkbasketPermission.APPEND, false);
item0.setPermOpen(false); item0.setPermission(WorkbasketPermission.OPEN, false);
item0.setPermTransfer(false); item0.setPermission(WorkbasketPermission.TRANSFER, false);
final String updateId0 = item0.getId();
WorkbasketAccessItem item1 = accessItems.get(1); WorkbasketAccessItem item1 = accessItems.get(1);
item1.setPermAppend(false); item1.setPermission(WorkbasketPermission.APPEND, false);
item1.setPermOpen(false); item1.setPermission(WorkbasketPermission.OPEN, false);
item1.setPermTransfer(false); item1.setPermission(WorkbasketPermission.TRANSFER, false);
final String updateId1 = item1.getId();
workbasketService.setWorkbasketAccessItems(wbId, accessItems); workbasketService.setWorkbasketAccessItems(wbId, accessItems);
List<WorkbasketAccessItem> updatedAccessItems = List<WorkbasketAccessItem> updatedAccessItems =
workbasketService.getWorkbasketAccessItems(wbId); workbasketService.getWorkbasketAccessItems(wbId);
int countAfter = updatedAccessItems.size(); assertThat(updatedAccessItems)
assertThat(countAfter).isEqualTo(countBefore); .hasSameSizeAs(accessItems)
.usingElementComparator(Comparator.comparing(WorkbasketAccessItem::getId))
.contains(item0, item1);
item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get(); WorkbasketAccessItem item =
assertThat(item0.isPermAppend()).isFalse(); updatedAccessItems.stream().filter(i -> i.getId().equals(item0.getId())).findFirst().get();
assertThat(item0.isPermOpen()).isFalse(); assertThat(item.getPermission(WorkbasketPermission.APPEND)).isFalse();
assertThat(item0.isPermTransfer()).isFalse(); assertThat(item.getPermission(WorkbasketPermission.OPEN)).isFalse();
assertThat(item.getPermission(WorkbasketPermission.TRANSFER)).isFalse();
item1 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId1)).findFirst().get(); item =
assertThat(item1.isPermAppend()).isFalse(); updatedAccessItems.stream().filter(i -> i.getId().equals(item1.getId())).findFirst().get();
assertThat(item1.isPermOpen()).isFalse(); assertThat(item.getPermission(WorkbasketPermission.APPEND)).isFalse();
assertThat(item1.isPermTransfer()).isFalse(); assertThat(item.getPermission(WorkbasketPermission.OPEN)).isFalse();
assertThat(item.getPermission(WorkbasketPermission.TRANSFER)).isFalse();
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -222,30 +208,27 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
// update some values // update some values
WorkbasketAccessItem item0 = accessItems.get(0); WorkbasketAccessItem item0 = accessItems.get(0);
item0.setPermAppend(false); item0.setPermission(WorkbasketPermission.APPEND, false);
item0.setPermOpen(false); item0.setPermission(WorkbasketPermission.OPEN, false);
item0.setPermTransfer(false); item0.setPermission(WorkbasketPermission.TRANSFER, false);
final String updateId0 = item0.getId(); final String updateId0 = item0.getId();
// insert new entry // insert new entry
WorkbasketAccessItem newItem = workbasketService.newWorkbasketAccessItem(wbId, "dummyUser1"); WorkbasketAccessItem newItem = workbasketService.newWorkbasketAccessItem(wbId, "dummyUser1");
newItem.setPermRead(true); newItem.setPermission(WorkbasketPermission.READ, true);
newItem.setPermOpen(true); newItem.setPermission(WorkbasketPermission.OPEN, true);
newItem.setPermCustom12(true); newItem.setPermission(WorkbasketPermission.CUSTOM_12, true);
accessItems.add(newItem); accessItems.add(newItem);
workbasketService.setWorkbasketAccessItems(wbId, accessItems); workbasketService.setWorkbasketAccessItems(wbId, accessItems);
List<WorkbasketAccessItem> updatedAccessItems = List<WorkbasketAccessItem> updatedAccessItems =
workbasketService.getWorkbasketAccessItems(wbId); workbasketService.getWorkbasketAccessItems(wbId);
int countAfter = updatedAccessItems.size(); assertThat(updatedAccessItems).hasSize(countBefore + 1);
assertThat(countAfter).isEqualTo((countBefore + 1));
item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get(); item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
assertThat(item0.isPermAppend()).isFalse(); assertThat(item0.getPermission(WorkbasketPermission.APPEND)).isFalse();
assertThat(item0.isPermOpen()).isFalse(); assertThat(item0.getPermission(WorkbasketPermission.OPEN)).isFalse();
assertThat(item0.isPermTransfer()).isFalse(); assertThat(item0.getPermission(WorkbasketPermission.TRANSFER)).isFalse();
assertThat(item0.isPermAppend()).isFalse();
assertThat(item0.isPermTransfer()).isFalse();
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -36,7 +36,7 @@ class PojoTest {
@Test @Test
void testsThatPojoClassesAreFound() { void testsThatPojoClassesAreFound() {
assertThat(pojoClasses.stream().count() > 0).isTrue(); assertThat(pojoClasses).isNotEmpty();
} }
@TestFactory @TestFactory

View File

@ -1,203 +0,0 @@
package pro.taskana.classification.internal;
import java.util.ArrayList;
import java.util.List;
import pro.taskana.classification.api.ClassificationQuery;
import pro.taskana.classification.api.ClassificationQueryColumnName;
import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.classification.internal.models.ClassificationSummaryImpl;
import pro.taskana.common.api.TimeInterval;
/** Created by BV on 26.10.2017. */
public class TestClassificationQuery implements ClassificationQuery {
private List<ClassificationSummaryImpl> classifications;
private String[] parentId;
private String[] parentKey;
private String description;
public TestClassificationQuery(List<ClassificationSummaryImpl> classifications) {
this.classifications = classifications;
}
@Override
public ClassificationQuery keyIn(String... key) {
return this;
}
@Override
public ClassificationQuery idIn(String... id) {
return this;
}
@Override
public ClassificationQuery parentIdIn(String... parentId) {
this.parentId = parentId;
return this;
}
@Override
public ClassificationQuery parentKeyIn(String... parentKey) {
this.parentKey = parentKey;
return this;
}
@Override
public ClassificationQuery categoryIn(String... category) {
return this;
}
@Override
public ClassificationQuery typeIn(String... type) {
return this;
}
@Override
public ClassificationQuery domainIn(String... domain) {
return this;
}
@Override
public ClassificationQuery validInDomainEquals(Boolean validInDomain) {
return this;
}
@Override
public ClassificationQuery createdWithin(TimeInterval... created) {
return this;
}
@Override
public ClassificationQuery modifiedWithin(TimeInterval... modifiedIn) {
return this;
}
@Override
public ClassificationQuery nameIn(String... name) {
return this;
}
@Override
public ClassificationQuery nameLike(String... nameLike) {
return this;
}
@Override
public ClassificationQuery descriptionLike(String description) {
return this;
}
@Override
public ClassificationQuery priorityIn(int... priorities) {
return this;
}
@Override
public ClassificationQuery serviceLevelIn(String... serviceLevel) {
return this;
}
@Override
public ClassificationQuery serviceLevelLike(String... serviceLevelLike) {
return this;
}
@Override
public ClassificationQuery applicationEntryPointIn(String... applicationEntryPoint) {
return null;
}
@Override
public ClassificationQuery applicationEntryPointLike(String... applicationEntryPointLike) {
return this;
}
@Override
public ClassificationQuery customAttributeIn(String num, String... customFields) {
return this;
}
@Override
public ClassificationQuery customAttributeLike(String num, String... custom1Like) {
return this;
}
@Override
public ClassificationQuery orderByKey(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByParentId(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByParentKey(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByCategory(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByDomain(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByName(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByServiceLevel(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByPriority(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection) {
return this;
}
@Override
public ClassificationQuery orderByCustomAttribute(String num, SortDirection sortDirection) {
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 List<String> listValues(
ClassificationQueryColumnName dbColumnName, SortDirection sortDirection) {
return new ArrayList<>();
}
@Override
public ClassificationSummary single() {
return null;
}
@Override
public long count() {
return 0;
}
}

View File

@ -1,6 +1,14 @@
package pro.taskana.classification.internal.models; package pro.taskana.classification.internal.models;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_1;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_2;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_3;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_4;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_5;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_6;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_7;
import static pro.taskana.classification.api.ClassificationCustomField.CUSTOM_8;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -13,14 +21,14 @@ class ClassificationModelsCloneTest {
Classification dummyClassificationForSummaryTest = new ClassificationImpl(); Classification dummyClassificationForSummaryTest = new ClassificationImpl();
dummyClassificationForSummaryTest.setApplicationEntryPoint("dummyEntryPoint"); dummyClassificationForSummaryTest.setApplicationEntryPoint("dummyEntryPoint");
dummyClassificationForSummaryTest.setCategory("dummyCategory"); dummyClassificationForSummaryTest.setCategory("dummyCategory");
dummyClassificationForSummaryTest.setCustom1("dummyCustom1"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_1, "dummyCustom1");
dummyClassificationForSummaryTest.setCustom2("dummyCustom2"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_2, "dummyCustom2");
dummyClassificationForSummaryTest.setCustom3("dummyCustom3"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_3, "dummyCustom3");
dummyClassificationForSummaryTest.setCustom4("dummyCustom4"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_4, "dummyCustom4");
dummyClassificationForSummaryTest.setCustom5("dummyCustom5"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_5, "dummyCustom5");
dummyClassificationForSummaryTest.setCustom6("dummyCustom6"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_6, "dummyCustom6");
dummyClassificationForSummaryTest.setCustom7("dummyCustom7"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_7, "dummyCustom7");
dummyClassificationForSummaryTest.setCustom8("dummyCustom8"); dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_8, "dummyCustom8");
dummyClassificationForSummaryTest.setDescription("dummyDescription"); dummyClassificationForSummaryTest.setDescription("dummyDescription");
dummyClassificationForSummaryTest.setIsValidInDomain(true); dummyClassificationForSummaryTest.setIsValidInDomain(true);
dummyClassificationForSummaryTest.setParentId("dummyParentId"); dummyClassificationForSummaryTest.setParentId("dummyParentId");
@ -46,14 +54,14 @@ class ClassificationModelsCloneTest {
dummyClassification.setId("dummyId"); dummyClassification.setId("dummyId");
dummyClassification.setApplicationEntryPoint("dummyEntryPoint"); dummyClassification.setApplicationEntryPoint("dummyEntryPoint");
dummyClassification.setCategory("dummyCategory"); dummyClassification.setCategory("dummyCategory");
dummyClassification.setCustom1("dummyCustom1"); dummyClassification.setCustomAttribute(CUSTOM_1, "dummyCustom1");
dummyClassification.setCustom2("dummyCustom2"); dummyClassification.setCustomAttribute(CUSTOM_2, "dummyCustom2");
dummyClassification.setCustom3("dummyCustom3"); dummyClassification.setCustomAttribute(CUSTOM_3, "dummyCustom3");
dummyClassification.setCustom4("dummyCustom4"); dummyClassification.setCustomAttribute(CUSTOM_4, "dummyCustom4");
dummyClassification.setCustom5("dummyCustom5"); dummyClassification.setCustomAttribute(CUSTOM_5, "dummyCustom5");
dummyClassification.setCustom6("dummyCustom6"); dummyClassification.setCustomAttribute(CUSTOM_6, "dummyCustom6");
dummyClassification.setCustom7("dummyCustom7"); dummyClassification.setCustomAttribute(CUSTOM_7, "dummyCustom7");
dummyClassification.setCustom8("dummyCustom8"); dummyClassification.setCustomAttribute(CUSTOM_8, "dummyCustom8");
dummyClassification.setDescription("dummyDescription"); dummyClassification.setDescription("dummyDescription");
dummyClassification.setIsValidInDomain(true); dummyClassification.setIsValidInDomain(true);
dummyClassification.setParentId("dummyParentId"); dummyClassification.setParentId("dummyParentId");

View File

@ -29,7 +29,7 @@ import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.ClassificationCategoryReport; import pro.taskana.monitor.api.reports.ClassificationCategoryReport;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem; import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Unit Test for CategoryBuilderImpl. */ /** Unit Test for CategoryBuilderImpl. */
@ -60,8 +60,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>(); List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem(); MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
@ -117,8 +117,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -179,8 +179,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
final Map<CustomField, String> customAttributeFilter = new HashMap<>(); final Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -252,8 +252,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -271,7 +271,7 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
CustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
final List<String> actualResult = final List<String> actualResult =
@ -284,7 +284,7 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds) .excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter) .customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection(); verify(internalTaskanaEngineMock).openConnection();
verify(internalTaskanaEngineMock, times(2)).getEngine(); verify(internalTaskanaEngineMock, times(2)).getEngine();
@ -307,7 +307,7 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
List<String> result = List<String> result =
cut.createClassificationCategoryReportBuilder() cut.createClassificationCategoryReportBuilder()
.workbasketIdIn(Collections.singletonList("DieGibtsSicherNed")) .workbasketIdIn(Collections.singletonList("DieGibtsSicherNed"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
assertThat(result).isNotNull(); assertThat(result).isNotNull();
} }
} }

View File

@ -35,7 +35,7 @@ import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.DetailedMonitorQueryItem; import pro.taskana.monitor.api.reports.item.DetailedMonitorQueryItem;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem; import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.monitor.api.reports.row.FoldableRow; import pro.taskana.monitor.api.reports.row.FoldableRow;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Unit Test for ClassificationReportBuilderImpl. */ /** Unit Test for ClassificationReportBuilderImpl. */
@ -74,8 +74,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<MonitorQueryItem> expectedResult = new ArrayList<>(); final List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem(); MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
@ -126,7 +126,7 @@ class ClassificationReportBuilderImplTest {
assertThat(actualResult).isNotNull(); assertThat(actualResult).isNotNull();
assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue()) assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue())
.isEqualTo(1); .isEqualTo(1);
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue()); assertThat(actualResult.getSumRow().getTotalValue()).isOne();
} }
@Test @Test
@ -138,8 +138,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -192,10 +192,10 @@ class ClassificationReportBuilderImplTest {
assertThat(actualResult).isNotNull(); assertThat(actualResult).isNotNull();
assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue()) assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue())
.isEqualTo(1); .isOne();
assertThat(1) assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getCells())
.isEqualTo(actualResult.getRow("CLI:000000000000000000000000000000000001").getCells()[0]); .isEqualTo(new int[] {1});
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue()); assertThat(actualResult.getSumRow().getTotalValue()).isOne();
} }
@Test @Test
@ -207,8 +207,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>(); final List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem(); DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
@ -259,10 +259,10 @@ class ClassificationReportBuilderImplTest {
FoldableRow<DetailedMonitorQueryItem> line = FoldableRow<DetailedMonitorQueryItem> line =
actualResult.getRow("CLI:000000000000000000000000000000000001"); actualResult.getRow("CLI:000000000000000000000000000000000001");
assertThat(actualResult).isNotNull(); assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(line.getTotalValue()); assertThat(line.getTotalValue()).isOne();
assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getTotalValue()) assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getTotalValue())
.isEqualTo(1); .isOne();
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue()); assertThat(actualResult.getSumRow().getTotalValue()).isOne();
} }
@Test @Test
@ -274,8 +274,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -330,14 +330,14 @@ class ClassificationReportBuilderImplTest {
FoldableRow<DetailedMonitorQueryItem> line = FoldableRow<DetailedMonitorQueryItem> line =
actualResult.getRow("CLI:000000000000000000000000000000000001"); actualResult.getRow("CLI:000000000000000000000000000000000001");
assertThat(actualResult).isNotNull(); assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(line.getTotalValue()); assertThat(line.getTotalValue()).isOne();
assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getTotalValue()) assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getTotalValue())
.isEqualTo(1); .isOne();
assertThat(1).isEqualTo(line.getCells()[0]); assertThat(line.getCells()).isEqualTo(new int[] {1});
assertThat(1) assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getCells())
.isEqualTo(line.getFoldableRow("CLI:000000000000000000000000000000000006").getCells()[0]); .isEqualTo(new int[] {1});
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue()); assertThat(actualResult.getSumRow().getTotalValue()).isOne();
assertThat(1).isEqualTo(actualResult.getSumRow().getCells()[0]); assertThat(actualResult.getSumRow().getCells()).isEqualTo(new int[] {1});
} }
@Test @Test
@ -349,8 +349,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -424,8 +424,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -443,7 +443,7 @@ class ClassificationReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
CustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
final List<String> actualResult = final List<String> actualResult =
@ -456,7 +456,7 @@ class ClassificationReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds) .excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter) .customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection(); verify(internalTaskanaEngineMock).openConnection();
verify(taskanaEngineMock).checkRoleMembership(any()); verify(taskanaEngineMock).checkRoleMembership(any());
@ -478,7 +478,7 @@ class ClassificationReportBuilderImplTest {
List<String> result = List<String> result =
cut.createClassificationReportBuilder() cut.createClassificationReportBuilder()
.workbasketIdIn(Collections.singletonList("DieGibtsGarantiertNed")) .workbasketIdIn(Collections.singletonList("DieGibtsGarantiertNed"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_10); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_10);
assertThat(result).isNotNull(); assertThat(result).isNotNull();
} }
} }

View File

@ -25,15 +25,15 @@ import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.SelectedItem; import pro.taskana.monitor.api.SelectedItem;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.CustomFieldValueReport; import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem; import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Unit Test for CustomFieldValueReportBuilderImpl. */ /** Unit Test for CustomFieldValueReportBuilderImpl. */
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
class CustomFieldValueReportBuilderImplTest { class TaskCustomFieldValueReportBuilderImplTest {
@InjectMocks private MonitorServiceImpl cut; @InjectMocks private MonitorServiceImpl cut;
@ -59,8 +59,8 @@ class CustomFieldValueReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<MonitorQueryItem> expectedResult = new ArrayList<>(); final List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem(); MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
@ -68,7 +68,7 @@ class CustomFieldValueReportBuilderImplTest {
monitorQueryItem.setNumberOfTasks(1); monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem); expectedResult.add(monitorQueryItem);
when(monitorMapperMock.getTaskCountOfCustomFieldValues( when(monitorMapperMock.getTaskCountOfCustomFieldValues(
CustomField.CUSTOM_1, TaskCustomField.CUSTOM_1,
workbasketIds, workbasketIds,
states, states,
categories, categories,
@ -79,8 +79,8 @@ class CustomFieldValueReportBuilderImplTest {
customAttributeFilter)) customAttributeFilter))
.thenReturn(expectedResult); .thenReturn(expectedResult);
final CustomFieldValueReport actualResult = final TaskCustomFieldValueReport actualResult =
cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) cut.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds) .workbasketIdIn(workbasketIds)
.stateIn(states) .stateIn(states)
.classificationCategoryIn(categories) .classificationCategoryIn(categories)
@ -105,8 +105,8 @@ class CustomFieldValueReportBuilderImplTest {
taskanaEngineConfigurationMock); taskanaEngineConfigurationMock);
assertThat(actualResult).isNotNull(); assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(actualResult.getRow("Geschaeftsstelle A").getTotalValue()); assertThat(actualResult.getRow("Geschaeftsstelle A").getTotalValue()).isOne();
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue()); assertThat(actualResult.getSumRow().getTotalValue()).isOne();
} }
@Test @Test
@ -118,8 +118,8 @@ class CustomFieldValueReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -130,7 +130,7 @@ class CustomFieldValueReportBuilderImplTest {
monitorQueryItem.setNumberOfTasks(1); monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem); expectedResult.add(monitorQueryItem);
when(monitorMapperMock.getTaskCountOfCustomFieldValues( when(monitorMapperMock.getTaskCountOfCustomFieldValues(
CustomField.CUSTOM_1, TaskCustomField.CUSTOM_1,
workbasketIds, workbasketIds,
states, states,
categories, categories,
@ -141,8 +141,8 @@ class CustomFieldValueReportBuilderImplTest {
customAttributeFilter)) customAttributeFilter))
.thenReturn(expectedResult); .thenReturn(expectedResult);
final CustomFieldValueReport actualResult = final TaskCustomFieldValueReport actualResult =
cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) cut.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds) .workbasketIdIn(workbasketIds)
.stateIn(states) .stateIn(states)
.classificationCategoryIn(categories) .classificationCategoryIn(categories)
@ -168,9 +168,9 @@ class CustomFieldValueReportBuilderImplTest {
taskanaEngineConfigurationMock); taskanaEngineConfigurationMock);
assertThat(actualResult).isNotNull(); assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(actualResult.getRow("Geschaeftsstelle A").getTotalValue()); assertThat(actualResult.getRow("Geschaeftsstelle A").getTotalValue()).isOne();
assertThat(1).isEqualTo(actualResult.getRow("Geschaeftsstelle A").getCells()[0]); assertThat(actualResult.getRow("Geschaeftsstelle A").getCells()[0]).isOne();
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue()); assertThat(actualResult.getSumRow().getTotalValue()).isOne();
} }
@Test @Test
@ -182,8 +182,8 @@ class CustomFieldValueReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -201,11 +201,11 @@ class CustomFieldValueReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
CustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
final List<String> actualResult = final List<String> actualResult =
cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1) cut.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds) .workbasketIdIn(workbasketIds)
.stateIn(states) .stateIn(states)
.classificationCategoryIn(categories) .classificationCategoryIn(categories)
@ -214,7 +214,7 @@ class CustomFieldValueReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds) .excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter) .customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection(); verify(internalTaskanaEngineMock).openConnection();
verify(taskanaEngineMock).checkRoleMembership(any()); verify(taskanaEngineMock).checkRoleMembership(any());
@ -229,7 +229,6 @@ class CustomFieldValueReportBuilderImplTest {
monitorMapperMock, monitorMapperMock,
taskanaEngineConfigurationMock); taskanaEngineConfigurationMock);
assertThat(actualResult).isNotNull();
assertThat(actualResult).isEqualTo(expectedResult); assertThat(actualResult).isEqualTo(expectedResult);
} }
} }

View File

@ -33,7 +33,7 @@ import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.WorkbasketReport; import pro.taskana.monitor.api.reports.WorkbasketReport;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem; import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.task.api.CustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Unit Test for WorkbasketReportBuilderImpl. */ /** Unit Test for WorkbasketReportBuilderImpl. */
@ -62,8 +62,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<CombinedClassificationFilter> combinedClassificationFilter = final List<CombinedClassificationFilter> combinedClassificationFilter =
Collections.singletonList( Collections.singletonList(
new CombinedClassificationFilter( new CombinedClassificationFilter(
@ -126,8 +126,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<CombinedClassificationFilter> combinedClassificationFilter = final List<CombinedClassificationFilter> combinedClassificationFilter =
Collections.singletonList( Collections.singletonList(
new CombinedClassificationFilter( new CombinedClassificationFilter(
@ -195,8 +195,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -271,8 +271,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0)); Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -290,7 +290,7 @@ class WorkbasketReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
CustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
final List<String> actualResult = final List<String> actualResult =
@ -303,7 +303,7 @@ class WorkbasketReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds) .excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter) .customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection(); verify(internalTaskanaEngineMock).openConnection();
verify(taskanaEngineMock).checkRoleMembership(any()); verify(taskanaEngineMock).checkRoleMembership(any());
@ -324,7 +324,7 @@ class WorkbasketReportBuilderImplTest {
List<String> result = List<String> result =
cut.createWorkbasketReportBuilder() cut.createWorkbasketReportBuilder()
.workbasketIdIn(Arrays.asList("GibtsSicherNed")) .workbasketIdIn(Arrays.asList("GibtsSicherNed"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_14); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_14);
assertThat(result).isNotNull(); assertThat(result).isNotNull();
} }
@ -337,8 +337,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A"); final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000"); final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000"); final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>(); Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A"); customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<CombinedClassificationFilter> combinedClassificationFilter = final List<CombinedClassificationFilter> combinedClassificationFilter =
Collections.singletonList( Collections.singletonList(
new CombinedClassificationFilter( new CombinedClassificationFilter(

View File

@ -28,12 +28,14 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.ObjectReference; import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
@ -50,7 +52,6 @@ class TaskServiceImplIntAutocommitTest {
private static SampleDataGenerator sampleDataGenerator; private static SampleDataGenerator sampleDataGenerator;
private static TaskanaEngineConfiguration taskanaEngineConfiguration; private static TaskanaEngineConfiguration taskanaEngineConfiguration;
private DataSource dataSource;
private TaskServiceImpl taskServiceImpl; private TaskServiceImpl taskServiceImpl;
private TaskanaEngine taskanaEngine; private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngineImpl;
@ -132,11 +133,8 @@ class TaskServiceImplIntAutocommitTest {
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine(); TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService(); TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
ThrowingCallable call = assertThatThrownBy(() -> taskServiceImpl2.getTask(wb.getId()))
() -> { .isInstanceOf(TaskNotFoundException.class);
taskServiceImpl2.getTask(wb.getId());
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
} }
@Test @Test
@ -165,7 +163,7 @@ class TaskServiceImplIntAutocommitTest {
.workbasketKeyDomainIn( .workbasketKeyDomainIn(
new KeyDomain("asd", "novatec"), new KeyDomain("asdasdasd", "DOMAIN_A")) new KeyDomain("asd", "novatec"), new KeyDomain("asdasdasd", "DOMAIN_A"))
.ownerIn("test", "test2", "bla") .ownerIn("test", "test2", "bla")
.customAttributeIn("16", "test") .customAttributeIn(TaskCustomField.CUSTOM_16, "test")
.classificationKeyIn("pId1", "pId2") .classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh") .primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys") .primaryObjectReferenceSystemIn("sys")
@ -229,12 +227,8 @@ class TaskServiceImplIntAutocommitTest {
@Test @Test
void shouldNotTransferAnyTask() { void shouldNotTransferAnyTask() {
assertThatThrownBy(() -> taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"))
ThrowingCallable call = .isInstanceOf(TaskNotFoundException.class);
() -> {
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
} }
@WithAccessId(user = "user-1-1", groups = "businessadmin") @WithAccessId(user = "user-1-1", groups = "businessadmin")
@ -243,7 +237,7 @@ class TaskServiceImplIntAutocommitTest {
final String user = CurrentUserContext.getUserid(); final String user = CurrentUserContext.getUserid();
// Set up Security for this Test // Set up Security for this Test
dataSource = TaskanaEngineTestConfiguration.getDataSource(); DataSource dataSource = TaskanaEngineTestConfiguration.getDataSource();
taskanaEngineConfiguration = taskanaEngineConfiguration =
new TaskanaEngineConfiguration( new TaskanaEngineConfiguration(
dataSource, false, true, TaskanaEngineTestConfiguration.getSchemaName()); dataSource, false, true, TaskanaEngineTestConfiguration.getSchemaName());
@ -299,9 +293,7 @@ class TaskServiceImplIntAutocommitTest {
TaskImpl taskCreated = (TaskImpl) taskServiceImpl.createTask(task); TaskImpl taskCreated = (TaskImpl) taskServiceImpl.createTask(task);
ThrowingCallable call = ThrowingCallable call =
() -> { () -> taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
};
assertThatThrownBy(call) assertThatThrownBy(call)
.describedAs( .describedAs(
"Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.") "Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.")
@ -320,11 +312,7 @@ class TaskServiceImplIntAutocommitTest {
TaskImpl taskCreated2 = (TaskImpl) taskServiceImpl.createTask(taskCreated); TaskImpl taskCreated2 = (TaskImpl) taskServiceImpl.createTask(taskCreated);
call = assertThatThrownBy(() -> taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId()))
() -> {
taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId());
};
assertThatThrownBy(call)
.describedAs( .describedAs(
"Transfer Task should be FAILED, because there are no TRANSFER-Rights on current WB.") "Transfer Task should be FAILED, because there are no TRANSFER-Rights on current WB.")
.isInstanceOf(NotAuthorizedException.class) .isInstanceOf(NotAuthorizedException.class)
@ -376,10 +364,10 @@ class TaskServiceImplIntAutocommitTest {
throws Exception { throws Exception {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(wb.getId(), accessId); workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermission(WorkbasketPermission.OPEN, permOpen);
accessItem.setPermRead(permRead); accessItem.setPermission(WorkbasketPermission.READ, permRead);
accessItem.setPermAppend(permAppend); accessItem.setPermission(WorkbasketPermission.APPEND, permAppend);
accessItem.setPermTransfer(permTransfer); accessItem.setPermission(WorkbasketPermission.TRANSFER, permTransfer);
workbasketService.createWorkbasketAccessItem(accessItem); workbasketService.createWorkbasketAccessItem(accessItem);
} }
} }

View File

@ -32,11 +32,13 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.WorkbasketAccessItemAlreadyExistException; import pro.taskana.workbasket.api.exceptions.WorkbasketAccessItemAlreadyExistException;
@ -116,9 +118,9 @@ class TaskServiceImplIntExplicitTest {
taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket); taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem); workbasketService.createWorkbasketAccessItem(accessItem);
taskanaEngineImpl.getClassificationService().createClassification(classification); taskanaEngineImpl.getClassificationService().createClassification(classification);
@ -133,11 +135,8 @@ class TaskServiceImplIntExplicitTest {
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine(); TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService(); TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
ThrowingCallable call = assertThatThrownBy(() -> taskServiceImpl2.getTask(workbasket.getId()))
() -> { .isInstanceOf(TaskNotFoundException.class);
taskServiceImpl2.getTask(workbasket.getId());
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
connection.commit(); connection.commit();
} }
} }
@ -152,9 +151,9 @@ class TaskServiceImplIntExplicitTest {
connection.commit(); connection.commit();
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem); workbasketService.createWorkbasketAccessItem(accessItem);
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef()); task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
@ -177,11 +176,8 @@ class TaskServiceImplIntExplicitTest {
Task test = this.generateDummyTask(); Task test = this.generateDummyTask();
((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2"); ((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2");
ThrowingCallable call = assertThatThrownBy(() -> taskServiceImpl.createTask(test))
() -> { .isInstanceOf(WorkbasketNotFoundException.class);
taskServiceImpl.createTask(test);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
} }
} }
@ -208,11 +204,8 @@ class TaskServiceImplIntExplicitTest {
((TaskImpl) task).setWorkbasketSummary(wb.asSummary()); ((TaskImpl) task).setWorkbasketSummary(wb.asSummary());
task.setClassificationKey(classification.getKey()); task.setClassificationKey(classification.getKey());
ThrowingCallable call = assertThatThrownBy(() -> taskServiceImpl.createTask(task))
() -> { .isInstanceOf(ClassificationNotFoundException.class);
taskServiceImpl.createTask(task);
};
assertThatThrownBy(call).isInstanceOf(ClassificationNotFoundException.class);
} }
} }
@ -232,9 +225,9 @@ class TaskServiceImplIntExplicitTest {
workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket); workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1");
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem); workbasketService.createWorkbasketAccessItem(accessItem);
Task task = taskServiceImpl.newTask(workbasket.getId()); Task task = taskServiceImpl.newTask(workbasket.getId());
@ -252,7 +245,7 @@ class TaskServiceImplIntExplicitTest {
.stateIn(TaskState.CLAIMED) .stateIn(TaskState.CLAIMED)
.workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A")) .workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A"))
.ownerIn("test", "test2", "bla") .ownerIn("test", "test2", "bla")
.customAttributeLike("13", "test") .customAttributeLike(TaskCustomField.CUSTOM_13, "test")
.classificationKeyIn("pId1", "pId2") .classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh") .primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys") .primaryObjectReferenceSystemIn("sys")
@ -287,11 +280,10 @@ class TaskServiceImplIntExplicitTest {
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true)); createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true));
connection.commit(); connection.commit();
ThrowingCallable call = ThrowingCallable call =
() -> { () ->
workbasketService.createWorkbasketAccessItem( workbasketService.createWorkbasketAccessItem(
createWorkbasketWithSecurity( createWorkbasketWithSecurity(
sourceWB, sourceWB.getOwner(), false, false, false, false)); sourceWB, sourceWB.getOwner(), false, false, false, false));
};
assertThatThrownBy(call).isInstanceOf(WorkbasketAccessItemAlreadyExistException.class); assertThatThrownBy(call).isInstanceOf(WorkbasketAccessItemAlreadyExistException.class);
connection.rollback(); connection.rollback();
@ -345,11 +337,8 @@ class TaskServiceImplIntExplicitTest {
try (Connection connection = dataSource.getConnection()) { try (Connection connection = dataSource.getConnection()) {
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
ThrowingCallable call = assertThatThrownBy(() -> taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"))
() -> { .isInstanceOf(TaskNotFoundException.class);
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
} }
} }
@ -419,9 +408,7 @@ class TaskServiceImplIntExplicitTest {
// Check failing with missing APPEND // Check failing with missing APPEND
ThrowingCallable call = ThrowingCallable call =
() -> { () -> taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
};
assertThatThrownBy(call) assertThatThrownBy(call)
.describedAs( .describedAs(
"Transfer Task should be FAILED, " "Transfer Task should be FAILED, "
@ -439,11 +426,7 @@ class TaskServiceImplIntExplicitTest {
taskCreated.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId()); taskCreated.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
taskCreated.setExternalId(IdGenerator.generateWithPrefix("TST")); taskCreated.setExternalId(IdGenerator.generateWithPrefix("TST"));
TaskImpl taskCreated2 = (TaskImpl) taskServiceImpl.createTask(taskCreated); TaskImpl taskCreated2 = (TaskImpl) taskServiceImpl.createTask(taskCreated);
call = assertThatThrownBy(() -> taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId()))
() -> {
taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId());
};
assertThatThrownBy(call)
.describedAs( .describedAs(
"Transfer Task should be FAILED, because there are no TRANSFER-Rights on current WB.") "Transfer Task should be FAILED, because there are no TRANSFER-Rights on current WB.")
.isInstanceOf(NotAuthorizedException.class) .isInstanceOf(NotAuthorizedException.class)
@ -485,10 +468,10 @@ class TaskServiceImplIntExplicitTest {
boolean permTransfer) { boolean permTransfer) {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(wb.getId(), accessId); workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermission(WorkbasketPermission.OPEN, permOpen);
accessItem.setPermRead(permRead); accessItem.setPermission(WorkbasketPermission.READ, permRead);
accessItem.setPermAppend(permAppend); accessItem.setPermission(WorkbasketPermission.APPEND, permAppend);
accessItem.setPermTransfer(permTransfer); accessItem.setPermission(WorkbasketPermission.TRANSFER, permTransfer);
return accessItem; return accessItem;
} }
} }

View File

@ -127,7 +127,7 @@ class TaskServiceImplTest {
Map<String, String> customAttriutes = new HashMap<>(); Map<String, String> customAttriutes = new HashMap<>();
customAttriutes.put("new key", "new value"); customAttriutes.put("new key", "new value");
newTask.setCustomAttributes(customAttriutes); newTask.setCustomAttributeMap(customAttriutes);
JSONArray changedAttributes = JSONArray changedAttributes =
new JSONObject(cut.determineChangesInTaskAttributes(oldTask, newTask)) new JSONObject(cut.determineChangesInTaskAttributes(oldTask, newTask))

View File

@ -51,7 +51,7 @@ class TaskModelsCloneTest {
"dummyTaskId", "dummyTaskName", "workbasketKey", createDummyClassification()); "dummyTaskId", "dummyTaskName", "workbasketKey", createDummyClassification());
Map<String, String> dummyCustomAttributesPreClone = new HashMap<>(); Map<String, String> dummyCustomAttributesPreClone = new HashMap<>();
dummyCustomAttributesPreClone.put("dummyAttributeKey", "dummyAttributeValue"); dummyCustomAttributesPreClone.put("dummyAttributeKey", "dummyAttributeValue");
dummyTask.setCustomAttributes(dummyCustomAttributesPreClone); dummyTask.setCustomAttributeMap(dummyCustomAttributesPreClone);
Map<String, String> dummyCallbackInfoPreClone = new HashMap<>(); Map<String, String> dummyCallbackInfoPreClone = new HashMap<>();
dummyCallbackInfoPreClone.put("dummyCallbackKey", "dummyCallbackValue"); dummyCallbackInfoPreClone.put("dummyCallbackKey", "dummyCallbackValue");
dummyTask.setCallbackInfo(dummyCallbackInfoPreClone); dummyTask.setCallbackInfo(dummyCallbackInfoPreClone);
@ -156,7 +156,7 @@ class TaskModelsCloneTest {
Map<String, String> dummyMapPreClone = new HashMap<>(); Map<String, String> dummyMapPreClone = new HashMap<>();
dummyMapPreClone.put("dummyString1", "dummyString2"); dummyMapPreClone.put("dummyString1", "dummyString2");
dummyAttachment.setCustomAttributes(dummyMapPreClone); dummyAttachment.setCustomAttributeMap(dummyMapPreClone);
AttachmentImpl dummyAttachmentCloned = dummyAttachment.copy(); AttachmentImpl dummyAttachmentCloned = dummyAttachment.copy();
assertThat(dummyAttachmentCloned).isNotEqualTo(dummyAttachment); assertThat(dummyAttachmentCloned).isNotEqualTo(dummyAttachment);

View File

@ -3,11 +3,10 @@ package pro.taskana.workbasket.internal;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -21,6 +20,7 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
@ -38,7 +38,6 @@ import pro.taskana.workbasket.internal.models.WorkbasketImpl;
class WorkbasketServiceImplIntAutocommitTest { class WorkbasketServiceImplIntAutocommitTest {
private static final int SLEEP_TIME = 100; private static final int SLEEP_TIME = 100;
private TaskanaEngine taskanaEngine;
private WorkbasketService workBasketService; private WorkbasketService workBasketService;
@BeforeAll @BeforeAll
@ -54,7 +53,7 @@ class WorkbasketServiceImplIntAutocommitTest {
String schemaName = TaskanaEngineTestConfiguration.getSchemaName(); String schemaName = TaskanaEngineTestConfiguration.getSchemaName();
TaskanaEngineConfiguration taskanaEngineConfiguration = TaskanaEngineConfiguration taskanaEngineConfiguration =
new TaskanaEngineConfiguration(dataSource, false, schemaName); new TaskanaEngineConfiguration(dataSource, false, schemaName);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine(); TaskanaEngine taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngine.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT); taskanaEngine.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(dataSource, schemaName); SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(dataSource, schemaName);
@ -63,11 +62,8 @@ class WorkbasketServiceImplIntAutocommitTest {
@Test @Test
void testGetWorkbasketFail() { void testGetWorkbasketFail() {
ThrowingCallable call = assertThatThrownBy(() -> workBasketService.getWorkbasket("fail"))
() -> { .isInstanceOf(WorkbasketNotFoundException.class);
workBasketService.getWorkbasket("fail");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
} }
@WithAccessId(user = "user-1-1", groups = "businessadmin") @WithAccessId(user = "user-1-1", groups = "businessadmin")
@ -90,8 +86,7 @@ class WorkbasketServiceImplIntAutocommitTest {
createTestWorkbasket(id2, "key2", "DOMAIN_A", "Hyperbasket", WorkbasketType.GROUP); createTestWorkbasket(id2, "key2", "DOMAIN_A", "Hyperbasket", WorkbasketType.GROUP);
workbasket2 = workBasketService.createWorkbasket(workbasket2); workbasket2 = workBasketService.createWorkbasket(workbasket2);
createWorkbasketWithSecurity(workbasket2, "user-1-1", true, true, false, false); createWorkbasketWithSecurity(workbasket2, "user-1-1", true, true, false, false);
List<String> distTargets = List<String> distTargets = Arrays.asList(workbasket0.getId(), workbasket1.getId());
new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
Thread.sleep(SLEEP_TIME); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets); workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
@ -102,7 +97,7 @@ class WorkbasketServiceImplIntAutocommitTest {
workbasket3 = workBasketService.createWorkbasket(workbasket3); workbasket3 = workBasketService.createWorkbasket(workbasket3);
createWorkbasketWithSecurity(workbasket3, "user-1-1", true, true, false, false); createWorkbasketWithSecurity(workbasket3, "user-1-1", true, true, false, false);
List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId())); List<String> newDistTargets = Collections.singletonList(workbasket3.getId());
Thread.sleep(SLEEP_TIME); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets); workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets);
@ -136,15 +131,13 @@ class WorkbasketServiceImplIntAutocommitTest {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workBasketService.newWorkbasketAccessItem( workBasketService.newWorkbasketAccessItem(
"k100000000000000000000000000000000000000", "Arthur Dent"); "k100000000000000000000000000000000000000", "Arthur Dent");
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
workBasketService.createWorkbasketAccessItem(accessItem); workBasketService.createWorkbasketAccessItem(accessItem);
assertThat(1) assertThat(
.isEqualTo( workBasketService.getWorkbasketAccessItems("k100000000000000000000000000000000000000"))
workBasketService .hasSize(1);
.getWorkbasketAccessItems("k100000000000000000000000000000000000000")
.size());
} }
@WithAccessId(user = "user-1-1", groups = "businessadmin") @WithAccessId(user = "user-1-1", groups = "businessadmin")
@ -160,17 +153,15 @@ class WorkbasketServiceImplIntAutocommitTest {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workBasketService.newWorkbasketAccessItem( workBasketService.newWorkbasketAccessItem(
"k200000000000000000000000000000000000000", "Zaphod Beeblebrox"); "k200000000000000000000000000000000000000", "Zaphod Beeblebrox");
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
workBasketService.createWorkbasketAccessItem(accessItem); workBasketService.createWorkbasketAccessItem(accessItem);
assertThat(1) assertThat(
.isEqualTo( workBasketService.getWorkbasketAccessItems("k200000000000000000000000000000000000000"))
workBasketService .hasSize(1);
.getWorkbasketAccessItems("k200000000000000000000000000000000000000")
.size());
accessItem.setPermAppend(true); accessItem.setPermission(WorkbasketPermission.APPEND, true);
workBasketService.updateWorkbasketAccessItem(accessItem); workBasketService.updateWorkbasketAccessItem(accessItem);
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) { if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
@ -190,10 +181,10 @@ class WorkbasketServiceImplIntAutocommitTest {
throws Exception { throws Exception {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workBasketService.newWorkbasketAccessItem(wb.getId(), accessId); workBasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermission(WorkbasketPermission.OPEN, permOpen);
accessItem.setPermRead(permRead); accessItem.setPermission(WorkbasketPermission.READ, permRead);
accessItem.setPermAppend(permAppend); accessItem.setPermission(WorkbasketPermission.APPEND, permAppend);
accessItem.setPermTransfer(permTransfer); accessItem.setPermission(WorkbasketPermission.TRANSFER, permTransfer);
workBasketService.createWorkbasketAccessItem(accessItem); workBasketService.createWorkbasketAccessItem(accessItem);
} }

View File

@ -3,8 +3,8 @@ package pro.taskana.workbasket.internal;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import java.sql.Connection; import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
@ -22,6 +22,7 @@ import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId; import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
@ -39,10 +40,7 @@ class WorkbasketServiceImplIntExplicitTest {
private static final int SLEEP_TIME = 100; private static final int SLEEP_TIME = 100;
static int counter = 0;
private DataSource dataSource; private DataSource dataSource;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine; private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngineImpl;
private WorkbasketService workBasketService; private WorkbasketService workBasketService;
@ -58,7 +56,8 @@ class WorkbasketServiceImplIntExplicitTest {
void setup() throws Exception { void setup() throws Exception {
dataSource = TaskanaEngineTestConfiguration.getDataSource(); dataSource = TaskanaEngineTestConfiguration.getDataSource();
String schemaName = TaskanaEngineTestConfiguration.getSchemaName(); String schemaName = TaskanaEngineTestConfiguration.getSchemaName();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaName); TaskanaEngineConfiguration taskanaEngineConfiguration =
new TaskanaEngineConfiguration(dataSource, false, schemaName);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine(); taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.EXPLICIT); taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.EXPLICIT);
@ -90,8 +89,7 @@ class WorkbasketServiceImplIntExplicitTest {
workbasket2 = workBasketService.createWorkbasket(workbasket2); workbasket2 = workBasketService.createWorkbasket(workbasket2);
createWorkbasketWithSecurity(workbasket2, "user-1-1", true, true, false, false); createWorkbasketWithSecurity(workbasket2, "user-1-1", true, true, false, false);
List<String> distTargets = List<String> distTargets = Arrays.asList(workbasket0.getId(), workbasket1.getId());
new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
Thread.sleep(SLEEP_TIME); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets); workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
@ -102,7 +100,7 @@ class WorkbasketServiceImplIntExplicitTest {
workbasket3 = workBasketService.createWorkbasket(workbasket3); workbasket3 = workBasketService.createWorkbasket(workbasket3);
createWorkbasketWithSecurity(workbasket3, "user-1-1", true, true, false, false); createWorkbasketWithSecurity(workbasket3, "user-1-1", true, true, false, false);
List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId())); List<String> newDistTargets = Collections.singletonList(workbasket3.getId());
Thread.sleep(SLEEP_TIME); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets); workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets);
@ -133,8 +131,8 @@ class WorkbasketServiceImplIntExplicitTest {
workBasketService.createWorkbasket(wb); workBasketService.createWorkbasket(wb);
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workBasketService.newWorkbasketAccessItem("id1", "Arthur Dent"); workBasketService.newWorkbasketAccessItem("id1", "Arthur Dent");
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
workBasketService.createWorkbasketAccessItem(accessItem); workBasketService.createWorkbasketAccessItem(accessItem);
assertThat(workBasketService.getWorkbasketAccessItems("id1")).hasSize(1); assertThat(workBasketService.getWorkbasketAccessItems("id1")).hasSize(1);
@ -154,8 +152,8 @@ class WorkbasketServiceImplIntExplicitTest {
workBasketService.createWorkbasket(wb); workBasketService.createWorkbasket(wb);
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workBasketService.newWorkbasketAccessItem("key2", "Zaphod Beeblebrox"); workBasketService.newWorkbasketAccessItem("key2", "Zaphod Beeblebrox");
accessItem.setPermOpen(true); accessItem.setPermission(WorkbasketPermission.OPEN, true);
accessItem.setPermRead(true); accessItem.setPermission(WorkbasketPermission.READ, true);
workBasketService.createWorkbasketAccessItem(accessItem); workBasketService.createWorkbasketAccessItem(accessItem);
assertThat(workBasketService.getWorkbasketAccessItems("key2")).hasSize(1); assertThat(workBasketService.getWorkbasketAccessItems("key2")).hasSize(1);
@ -179,10 +177,10 @@ class WorkbasketServiceImplIntExplicitTest {
throws Exception { throws Exception {
WorkbasketAccessItem accessItem = WorkbasketAccessItem accessItem =
workBasketService.newWorkbasketAccessItem(wb.getId(), accessId); workBasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermission(WorkbasketPermission.OPEN, permOpen);
accessItem.setPermRead(permRead); accessItem.setPermission(WorkbasketPermission.READ, permRead);
accessItem.setPermAppend(permAppend); accessItem.setPermission(WorkbasketPermission.APPEND, permAppend);
accessItem.setPermTransfer(permTransfer); accessItem.setPermission(WorkbasketPermission.TRANSFER, permTransfer);
workBasketService.createWorkbasketAccessItem(accessItem); workBasketService.createWorkbasketAccessItem(accessItem);
} }

View File

@ -1,9 +1,14 @@
package pro.taskana.workbasket.internal.models; package pro.taskana.workbasket.internal.models;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_1;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_2;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_3;
import static pro.taskana.workbasket.api.WorkbasketCustomField.CUSTOM_4;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
class WorkbasketModelsCloneTest { class WorkbasketModelsCloneTest {
@ -11,10 +16,10 @@ class WorkbasketModelsCloneTest {
@Test @Test
void should_CopyWithoutId_When_WorkbasketSummaryClone() { void should_CopyWithoutId_When_WorkbasketSummaryClone() {
Workbasket dummyWorkbasketForSummaryTest = new WorkbasketImpl(); Workbasket dummyWorkbasketForSummaryTest = new WorkbasketImpl();
dummyWorkbasketForSummaryTest.setCustom1("dummyCustom1"); dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_1, "dummyCustom1");
dummyWorkbasketForSummaryTest.setCustom2("dummyCustom2"); dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_2, "dummyCustom2");
dummyWorkbasketForSummaryTest.setCustom3("dummyCustom3"); dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_3, "dummyCustom3");
dummyWorkbasketForSummaryTest.setCustom4("dummyCustom4"); dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_4, "dummyCustom4");
dummyWorkbasketForSummaryTest.setDescription("dummyDescription"); dummyWorkbasketForSummaryTest.setDescription("dummyDescription");
dummyWorkbasketForSummaryTest.setMarkedForDeletion(false); dummyWorkbasketForSummaryTest.setMarkedForDeletion(false);
dummyWorkbasketForSummaryTest.setName("dummyName"); dummyWorkbasketForSummaryTest.setName("dummyName");
@ -65,23 +70,23 @@ class WorkbasketModelsCloneTest {
WorkbasketAccessItemImpl dummyWorkbasketAccessItem = new WorkbasketAccessItemImpl(); WorkbasketAccessItemImpl dummyWorkbasketAccessItem = new WorkbasketAccessItemImpl();
dummyWorkbasketAccessItem.setId("dummyId"); dummyWorkbasketAccessItem.setId("dummyId");
dummyWorkbasketAccessItem.setAccessName("dummyAccessName"); dummyWorkbasketAccessItem.setAccessName("dummyAccessName");
dummyWorkbasketAccessItem.setPermAppend(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.OPEN, false);
dummyWorkbasketAccessItem.setPermCustom1(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.READ, false);
dummyWorkbasketAccessItem.setPermCustom2(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.APPEND, false);
dummyWorkbasketAccessItem.setPermCustom3(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.TRANSFER, false);
dummyWorkbasketAccessItem.setPermCustom4(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.DISTRIBUTE, false);
dummyWorkbasketAccessItem.setPermCustom5(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_1, false);
dummyWorkbasketAccessItem.setPermCustom6(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_2, false);
dummyWorkbasketAccessItem.setPermCustom7(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_3, false);
dummyWorkbasketAccessItem.setPermCustom8(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_4, false);
dummyWorkbasketAccessItem.setPermCustom9(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_5, false);
dummyWorkbasketAccessItem.setPermCustom10(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_6, false);
dummyWorkbasketAccessItem.setPermCustom11(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_7, false);
dummyWorkbasketAccessItem.setPermCustom12(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_8, false);
dummyWorkbasketAccessItem.setPermDistribute(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_9, false);
dummyWorkbasketAccessItem.setPermOpen(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_10, false);
dummyWorkbasketAccessItem.setPermRead(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_11, false);
dummyWorkbasketAccessItem.setPermTransfer(false); dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_12, false);
WorkbasketAccessItemImpl dummyWorkbasketAccessItemCloned = dummyWorkbasketAccessItem.copy(); WorkbasketAccessItemImpl dummyWorkbasketAccessItemCloned = dummyWorkbasketAccessItem.copy();

View File

@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationQuery; import pro.taskana.classification.api.ClassificationQuery;
import pro.taskana.classification.api.ClassificationService; import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.exceptions.ClassificationAlreadyExistException; import pro.taskana.classification.api.exceptions.ClassificationAlreadyExistException;
@ -48,6 +49,7 @@ public class ClassificationController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class);
private static final String LIKE = "%"; private static final String LIKE = "%";
private static final String NAME = "name"; private static final String NAME = "name";
private static final String NAME_LIKE = "name-like"; private static final String NAME_LIKE = "name-like";
@ -55,14 +57,6 @@ public class ClassificationController extends AbstractPagingController {
private static final String DOMAIN = "domain"; private static final String DOMAIN = "domain";
private static final String CATEGORY = "category"; private static final String CATEGORY = "category";
private static final String TYPE = "type"; private static final String TYPE = "type";
private static final String CUSTOM_1_LIKE = "custom-1-like";
private static final String CUSTOM_2_LIKE = "custom-2-like";
private static final String CUSTOM_3_LIKE = "custom-3-like";
private static final String CUSTOM_4_LIKE = "custom-4-like";
private static final String CUSTOM_5_LIKE = "custom-5-like";
private static final String CUSTOM_6_LIKE = "custom-6-like";
private static final String CUSTOM_7_LIKE = "custom-7-like";
private static final String CUSTOM_8_LIKE = "custom-8-like";
private final ClassificationService classificationService; private final ClassificationService classificationService;
private final ClassificationRepresentationModelAssembler modelAssembler; private final ClassificationRepresentationModelAssembler modelAssembler;
@ -88,8 +82,8 @@ public class ClassificationController extends AbstractPagingController {
} }
ClassificationQuery query = classificationService.createClassificationQuery(); ClassificationQuery query = classificationService.createClassificationQuery();
query = applyFilterParams(query, params); applyFilterParams(query, params);
query = applySortingParams(query, params); applySortingParams(query, params);
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata); List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata);
@ -188,8 +182,7 @@ public class ClassificationController extends AbstractPagingController {
return response; return response;
} }
private ClassificationQuery applySortingParams( private void applySortingParams(ClassificationQuery query, MultiValueMap<String, String> params)
ClassificationQuery query, MultiValueMap<String, String> params)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(query= {}, params= {})", query, params); LOGGER.debug("Entry to applySortingParams(query= {}, params= {})", query, params);
@ -219,11 +212,9 @@ public class ClassificationController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applySortingParams(), returning {}", query); LOGGER.debug("Exit from applySortingParams(), returning {}", query);
} }
return query;
} }
private ClassificationQuery applyFilterParams( private void applyFilterParams(ClassificationQuery query, MultiValueMap<String, String> params)
ClassificationQuery query, MultiValueMap<String, String> params)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params); LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
@ -258,42 +249,21 @@ public class ClassificationController extends AbstractPagingController {
query.typeIn(names); query.typeIn(names);
params.remove(TYPE); params.remove(TYPE);
} }
if (params.containsKey(CUSTOM_1_LIKE)) {
query.customAttributeLike("1", LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE); for (ClassificationCustomField customField : ClassificationCustomField.values()) {
params.remove(CUSTOM_1_LIKE); List<String> customFieldParams =
params.remove(customField.name().replace("_", "-").toLowerCase() + "-like");
if (customFieldParams != null) {
String[] customValues = extractCommaSeparatedFields(customFieldParams);
for (int i = 0; i < customValues.length; i++) {
customValues[i] = LIKE + customValues[i] + LIKE;
} }
if (params.containsKey(CUSTOM_2_LIKE)) { query.customAttributeLike(customField, customValues);
query.customAttributeLike("2", LIKE + params.get(CUSTOM_2_LIKE).get(0) + LIKE);
params.remove(CUSTOM_2_LIKE);
} }
if (params.containsKey(CUSTOM_3_LIKE)) {
query.customAttributeLike("3", LIKE + params.get(CUSTOM_3_LIKE).get(0) + LIKE);
params.remove(CUSTOM_3_LIKE);
}
if (params.containsKey(CUSTOM_4_LIKE)) {
query.customAttributeLike("4", LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE);
params.remove(CUSTOM_4_LIKE);
}
if (params.containsKey(CUSTOM_5_LIKE)) {
query.customAttributeLike("5", LIKE + params.get(CUSTOM_5_LIKE).get(0) + LIKE);
params.remove(CUSTOM_5_LIKE);
}
if (params.containsKey(CUSTOM_6_LIKE)) {
query.customAttributeLike("6", LIKE + params.get(CUSTOM_6_LIKE).get(0) + LIKE);
params.remove(CUSTOM_6_LIKE);
}
if (params.containsKey(CUSTOM_7_LIKE)) {
query.customAttributeLike("7", LIKE + params.get(CUSTOM_7_LIKE).get(0) + LIKE);
params.remove(CUSTOM_7_LIKE);
}
if (params.containsKey(CUSTOM_8_LIKE)) {
query.customAttributeLike("8", LIKE + params.get(CUSTOM_8_LIKE).get(0) + LIKE);
params.remove(CUSTOM_8_LIKE);
} }
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
return query;
} }
} }

Some files were not shown because too many files have changed in this diff Show More