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 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.query.HistoryQuery;
import pro.taskana.simplehistory.query.HistoryQueryColumnName;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
/** Implementation for generating dynamic sql. */
public class HistoryQueryImpl implements HistoryQuery {
private static final Logger LOGGER = LoggerFactory.getLogger(HistoryQueryImpl.class);
private TaskanaHistoryEngineImpl taskanaHistoryEngine;
private HistoryQueryMapper historyQueryMapper;
private final TaskanaHistoryEngineImpl taskanaHistoryEngine;
private final HistoryQueryMapper historyQueryMapper;
private HistoryQueryColumnName columnName;
private List<String> orderBy;
private List<String> orderColumns;
private final List<String> orderBy;
private final List<String> orderColumns;
private int
maxRows; // limit for rows. used to make list(offset, limit) and single() more efficient.
private HistoryQueryColumnName columnName;
private String[] idIn;
private String[] businessProcessIdIn;
private String[] parentBusinessProcessIdIn;
@ -195,30 +196,6 @@ public class HistoryQueryImpl implements HistoryQuery {
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
public HistoryQuery businessProcessIdLike(String... businessProcessId) {
this.businessProcessIdLike = toUpperCopy(businessProcessId);
@ -322,26 +299,46 @@ public class HistoryQueryImpl implements HistoryQuery {
}
@Override
public HistoryQuery custom1Like(String... custom1) {
this.custom1Like = toUpperCopy(custom1);
public HistoryQuery customAttributeIn(
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;
}
@Override
public HistoryQuery custom2Like(String... custom2) {
this.custom2Like = toUpperCopy(custom2);
return this;
}
@Override
public HistoryQuery custom3Like(String... custom3) {
this.custom3Like = toUpperCopy(custom3);
return this;
}
@Override
public HistoryQuery custom4Like(String... custom4) {
this.custom4Like = toUpperCopy(custom4);
public HistoryQuery customAttributeLike(
TaskHistoryCustomField customField, String... searchArguments) {
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 + "'");
}
return this;
}
@ -436,22 +433,9 @@ public class HistoryQueryImpl implements HistoryQuery {
}
@Override
public HistoryQuery orderByCustomAttribute(int num, SortDirection sortDirection)
throws InvalidArgumentException {
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);
}
public HistoryQuery orderByCustomAttribute(
TaskHistoryCustomField customField, SortDirection sortDirection) {
return addOrderCriteria(customField.name(), sortDirection);
}
@Override
@ -512,7 +496,6 @@ public class HistoryQueryImpl implements HistoryQuery {
this);
List<String> result = new ArrayList<>();
this.columnName = dbColumnName;
List<String> cacheOrderBy = this.orderBy;
this.orderBy.clear();
this.addOrderCriteria(columnName.toString(), sortDirection);
@ -529,8 +512,6 @@ public class HistoryQueryImpl implements HistoryQuery {
LOGGER.error("No History Event found.");
return result;
} finally {
this.orderBy = cacheOrderBy;
this.columnName = null;
this.orderColumns.remove(orderColumns.size() - 1);
taskanaHistoryEngine.returnConnection();
}

View File

@ -2,8 +2,8 @@ package pro.taskana.simplehistory.query;
import pro.taskana.common.api.BaseQuery;
import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
/** HistoryQuery for generating dynamic sql. */
public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryColumnName> {
@ -161,38 +161,6 @@ public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryCo
*/
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
* 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);
/**
* Add your custom1 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.
* Add the values of custom attributes for exact matching to your query.
*
* @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
*/
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
* like % then it will be transmitted to the database.
* 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 custom2 as String
* @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched-for tasks
* @return the query
*/
HistoryQuery custom2Like(String... custom2);
/**
* 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);
HistoryQuery customAttributeLike(TaskHistoryCustomField customField, String... searchArguments);
/**
* Sort the query result by businessProcessId.
@ -545,14 +497,13 @@ public interface HistoryQuery extends BaseQuery<HistoryEventImpl, HistoryQueryCo
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.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect.
*/
HistoryQuery orderByCustomAttribute(int num, SortDirection sortDirection)
throws InvalidArgumentException;
HistoryQuery orderByCustomAttribute(
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.query.HistoryQuery;
import pro.taskana.simplehistory.query.HistoryQueryColumnName;
import pro.taskana.spi.history.api.events.TaskHistoryCustomField;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Test for History queries. */
class QueryHistoryAccTest extends AbstractAccTest {
public QueryHistoryAccTest() {
super();
}
@Test
void should_ConfirmEquality_When_UsingListValuesAscendingAndDescending() {
List<String> defaultList =
@ -166,16 +163,32 @@ class QueryHistoryAccTest extends AbstractAccTest {
.list();
assertThat(returnValues).hasSize(6);
returnValues = getHistoryService().createHistoryQuery().custom1In("custom1").list();
returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_1, "custom1")
.list();
assertThat(returnValues).hasSize(13);
returnValues = getHistoryService().createHistoryQuery().custom2In("custom2").list();
returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_2, "custom2")
.list();
assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().custom3In("custom3").list();
returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_3, "custom3")
.list();
assertThat(returnValues).hasSize(7);
returnValues = getHistoryService().createHistoryQuery().custom4In("custom4").list();
returnValues =
getHistoryService()
.createHistoryQuery()
.customAttributeIn(TaskHistoryCustomField.CUSTOM_4, "custom4")
.list();
assertThat(returnValues).hasSize(1);
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.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.query.HistoryQuery;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventListResource;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventListResourceAssembler;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResource;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResourceAssembler;
import pro.taskana.simplehistory.rest.assembler.TaskHistoryEventListResourceAssembler;
import pro.taskana.simplehistory.rest.assembler.TaskHistoryEventRepresentationModelAssembler;
import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
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.exceptions.TaskanaHistoryEventNotFoundException;
@ -76,28 +77,26 @@ public class TaskHistoryEventController extends AbstractPagingController {
private static final String ATTACHMENT_CLASSIFICATION_KEY_LIKE =
"attachment-classification-key-like";
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_LIKE = "custom-2-like";
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_LIKE = "custom-4-like";
private static final String PAGING_PAGE = "page";
private static final String PAGING_PAGE_SIZE = "page-size";
private final SimpleHistoryServiceImpl simpleHistoryService;
private final TaskHistoryEventResourceAssembler taskHistoryEventResourceAssembler;
private final TaskHistoryEventRepresentationModelAssembler
taskHistoryEventRepresentationModelAssembler;
@Autowired
public TaskHistoryEventController(
TaskanaEngineConfiguration taskanaEngineConfiguration,
SimpleHistoryServiceImpl simpleHistoryServiceImpl,
TaskHistoryEventResourceAssembler taskHistoryEventResourceAssembler) {
TaskHistoryEventRepresentationModelAssembler taskHistoryEventRepresentationModelAssembler) {
this.simpleHistoryService = simpleHistoryServiceImpl;
this.simpleHistoryService.initialize(taskanaEngineConfiguration);
this.taskHistoryEventResourceAssembler = taskHistoryEventResourceAssembler;
this.taskHistoryEventRepresentationModelAssembler =
taskHistoryEventRepresentationModelAssembler;
}
@GetMapping
@ -109,8 +108,8 @@ public class TaskHistoryEventController extends AbstractPagingController {
}
HistoryQuery query = simpleHistoryService.createHistoryQuery();
query = applySortingParams(query, params);
query = applyFilterParams(query, params);
applySortingParams(query, params);
applyFilterParams(query, params);
PageMetadata pageMetadata = null;
List<HistoryEventImpl> historyEvents;
@ -144,7 +143,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
@GetMapping(path = "/{historyEventId}", produces = "application/hal+json")
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskHistoryEventResource> getTaskHistoryEvent(
public ResponseEntity<TaskHistoryEventRepresentationModel> getTaskHistoryEvent(
@PathVariable String historyEventId) throws TaskanaHistoryEventNotFoundException {
if (LOGGER.isDebugEnabled()) {
@ -153,8 +152,8 @@ public class TaskHistoryEventController extends AbstractPagingController {
TaskanaHistoryEvent resultEvent = simpleHistoryService.getHistoryEvent(historyEventId);
TaskHistoryEventResource taskEventResource =
taskHistoryEventResourceAssembler.toModel(resultEvent);
TaskHistoryEventRepresentationModel taskEventResource =
taskHistoryEventRepresentationModelAssembler.toModel(resultEvent);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -165,7 +164,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
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 {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(params= {})", params);
@ -175,65 +174,65 @@ public class TaskHistoryEventController extends AbstractPagingController {
params,
(sortBy, sortDirection) -> {
switch (sortBy) {
case (BUSINESS_PROCESS_ID):
case BUSINESS_PROCESS_ID:
query.orderByBusinessProcessId(sortDirection);
break;
case (PARENT_BUSINESS_PROCESS_ID):
case PARENT_BUSINESS_PROCESS_ID:
query.orderByParentBusinessProcessId(sortDirection);
break;
case (TASK_ID):
case TASK_ID:
query.orderByTaskId(sortDirection);
break;
case (EVENT_TYPE):
case EVENT_TYPE:
query.orderByEventType(sortDirection);
break;
case (CREATED):
case CREATED:
query.orderByCreated(sortDirection);
break;
case (USER_ID):
case USER_ID:
query.orderByUserId(sortDirection);
break;
case (DOMAIN):
case DOMAIN:
query.orderByDomain(sortDirection);
break;
case (WORKBASKET_KEY):
case WORKBASKET_KEY:
query.orderByWorkbasketKey(sortDirection);
break;
case (POR_COMPANY):
case POR_COMPANY:
query.orderByPorCompany(sortDirection);
break;
case (POR_SYSTEM):
case POR_SYSTEM:
query.orderByPorSystem(sortDirection);
break;
case (POR_INSTANCE):
case POR_INSTANCE:
query.orderByPorInstance(sortDirection);
break;
case (POR_TYPE):
case POR_TYPE:
query.orderByPorType(sortDirection);
break;
case (POR_VALUE):
case POR_VALUE:
query.orderByPorValue(sortDirection);
break;
case (TASK_CLASSIFICATION_KEY):
case TASK_CLASSIFICATION_KEY:
query.orderByTaskClassificationKey(sortDirection);
break;
case (TASK_CLASSIFICATION_CATEGORY):
case TASK_CLASSIFICATION_CATEGORY:
query.orderByTaskClassificationCategory(sortDirection);
break;
case (ATTACHMENT_CLASSIFICATION_KEY):
case ATTACHMENT_CLASSIFICATION_KEY:
query.orderByAttachmentClassificationKey(sortDirection);
break;
case (CUSTOM_1):
query.orderByCustomAttribute(1, sortDirection);
case CUSTOM_1:
query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_1, sortDirection);
break;
case (CUSTOM_2):
query.orderByCustomAttribute(2, sortDirection);
case CUSTOM_2:
query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_2, sortDirection);
break;
case (CUSTOM_3):
query.orderByCustomAttribute(3, sortDirection);
case CUSTOM_3:
query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_3, sortDirection);
break;
case (CUSTOM_4):
query.orderByCustomAttribute(4, sortDirection);
case CUSTOM_4:
query.orderByCustomAttribute(TaskHistoryCustomField.CUSTOM_4, sortDirection);
break;
default:
throw new IllegalArgumentException("Unknown order '" + sortBy + "'");
@ -243,11 +242,9 @@ public class TaskHistoryEventController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) {
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()) {
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);
params.remove(ATTACHMENT_CLASSIFICATION_KEY_LIKE);
}
if (params.containsKey(CUSTOM_1)) {
String[] custom1 = extractCommaSeparatedFields(params.get(CUSTOM_1));
query.custom1In(custom1);
params.remove(CUSTOM_1);
}
if (params.containsKey(CUSTOM_1_LIKE)) {
query.custom1Like(LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE);
params.remove(CUSTOM_1_LIKE);
}
if (params.containsKey(CUSTOM_2)) {
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);
for (TaskHistoryCustomField customField : TaskHistoryCustomField.values()) {
List<String> list = params.remove(customField.name().replace("_", "-").toLowerCase());
if (list != null) {
query.customAttributeIn(customField, extractCommaSeparatedFields(list));
}
list = params.remove(customField.name().replace("_", "-").toLowerCase() + "-like");
if (list != null) {
String[] values = extractCommaSeparatedFields(list);
for (int i = 0; i < values.length; i++) {
values[i] = LIKE + values[i] + LIKE;
}
query.customAttributeLike(customField, values);
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
}
return query;
}
private TimeInterval getTimeIntervalOf(String[] created) {

View File

@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
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
@ -20,7 +20,7 @@ public class TaskHistoryRestConfiguration {
}
@Bean
public TaskHistoryEventResourceAssembler getTaskHistoryEventResourceAssembler() {
return new TaskHistoryEventResourceAssembler();
public TaskHistoryEventRepresentationModelAssembler getTaskHistoryEventResourceAssembler() {
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;
@ -11,6 +11,8 @@ import org.springframework.hateoas.PagedModel.PageMetadata;
import pro.taskana.resource.rest.AbstractRessourcesAssembler;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
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. */
public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAssembler {
@ -18,8 +20,9 @@ public class TaskHistoryEventListResourceAssembler extends AbstractRessourcesAss
public TaskHistoryEventListResource toResources(
List<HistoryEventImpl> historyEvents, PageMetadata pageMetadata) {
TaskHistoryEventResourceAssembler assembler = new TaskHistoryEventResourceAssembler();
List<TaskHistoryEventResource> resources =
TaskHistoryEventRepresentationModelAssembler assembler =
new TaskHistoryEventRepresentationModelAssembler();
List<TaskHistoryEventRepresentationModel> resources =
new ArrayList<>(assembler.toCollectionModel(historyEvents).getContent());
TaskHistoryEventListResource pagedResources =
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 pro.taskana.spi.history.api.events.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 parentBusinessProcessId;
private String taskId;
private String eventType;
private String created;
private Instant created;
private String userId;
private String domain;
private String workbasketKey;
@ -33,11 +35,11 @@ public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEve
private String details;
public String getTaskHistoryId() {
return taskHistoryEventId;
return taskHistoryId;
}
public void setTaskHistoryId(String taskHistoryId) {
this.taskHistoryEventId = taskHistoryId;
this.taskHistoryId = taskHistoryId;
}
public String getBusinessProcessId() {
@ -72,11 +74,11 @@ public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEve
this.eventType = eventType;
}
public String getCreated() {
public Instant getCreated() {
return created;
}
public void setCreated(String created) {
public void setCreated(Instant created) {
this.created = created;
}
@ -226,31 +228,54 @@ public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEve
@Override
public String toString() {
return "TaskHistoryEventResource ["
+ "taskHistoryEventId= "
+ this.taskHistoryEventId
+ "businessProcessId= "
+ this.businessProcessId
+ "parentBusinessProcessId= "
+ this.parentBusinessProcessId
+ "taskId= "
+ this.taskId
+ "eventType= "
+ this.eventType
+ "created= "
+ this.created
+ "userId= "
+ this.userId
+ "domain= "
+ this.domain
+ "workbasketKey= "
+ this.workbasketKey
+ "oldValue= "
+ this.oldValue
+ "newValue= "
+ this.newValue
+ "details= "
+ this.details
return "TaskHistoryEventRepresentationModel [taskHistoryEventId="
+ taskHistoryId
+ ", businessProcessId="
+ businessProcessId
+ ", parentBusinessProcessId="
+ parentBusinessProcessId
+ ", taskId="
+ taskId
+ ", eventType="
+ eventType
+ ", created="
+ created
+ ", userId="
+ userId
+ ", domain="
+ domain
+ ", workbasketKey="
+ workbasketKey
+ ", porCompany="
+ porCompany
+ ", porType="
+ porType
+ ", porSystem="
+ porSystem
+ ", 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 HashMap<String, String> taskHistoryEventFieldDescriptionsMap = new HashMap<>();
private final HashMap<String, String> taskHistoryEventFieldDescriptionsMap = new HashMap<>();
private FieldDescriptor[] allTaskHistoryEventFieldDescriptors;

View File

@ -1,4 +1,4 @@
package pro.taskana.rest;
package pro.taskana.simplehistory.rest;
import java.sql.SQLException;
import javax.sql.DataSource;
@ -15,7 +15,6 @@ import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import pro.taskana.simplehistory.rest.TaskHistoryRestConfiguration;
import pro.taskana.simplehistory.rest.sampledata.SampleDataGenerator;
/** 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.assertThatThrownBy;
import com.fasterxml.jackson.databind.DeserializationFeature;
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.util.Collections;
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.core.ParameterizedTypeReference;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity;
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.RestTemplate;
import pro.taskana.simplehistory.rest.TaskHistoryRestConfiguration;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventListResource;
import pro.taskana.simplehistory.rest.resource.TaskHistoryEventResource;
import pro.taskana.simplehistory.rest.models.TaskHistoryEventListResource;
import pro.taskana.simplehistory.rest.models.TaskHistoryEventRepresentationModel;
/** Controller for integration test. */
@ExtendWith(SpringExtension.class)
@ -56,6 +59,7 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getContent()).hasSize(45);
}
@ -70,15 +74,14 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getContent()).hasSize(3);
assertThat(
response
.getBody()
.getRequiredLink(IanaLinkRelations.SELF)
.getHref()
.endsWith(parameters))
.isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
.isNotNull()
.get()
.extracting(Link::getHref)
.asString()
.endsWith(parameters);
}
@Test
@ -92,38 +95,36 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getLinks()).isNotNull();
assertThat(response.getBody().getMetadata()).isNotNull();
assertThat(response.getBody().getContent()).hasSize(1);
assertThat(response.getBody().getContent().stream().findFirst().get().getDetails()).isNull();
assertThat(response.getBody().getContent().iterator().next().getDetails()).isNull();
}
@Test
void should_ReturnSpecificTaskHistoryEventWithDetails_When_SingleEventIsQueried() {
ResponseEntity<TaskHistoryEventResource> response =
ResponseEntity<TaskHistoryEventRepresentationModel> response =
template.exchange(
server + port + "/api/v1/task-history-event/HEI:000000000000000000000000000000000000",
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventResource.class));
ParameterizedTypeReference.forType(TaskHistoryEventRepresentationModel.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getLinks()).isNotNull();
assertThat(response.getBody().getDetails()).isNotNull();
}
@Test
void testThrowsExceptionIfInvalidFilterIsUsed() {
ThrowingCallable httpCall =
() -> {
template.exchange(
server + port + "/api/v1/task-history-event?invalid=BPI:01",
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
};
() ->
template.exchange(
server + port + "/api/v1/task-history-event?invalid=BPI:01",
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("[invalid]")
@ -136,13 +137,12 @@ class TaskHistoryEventControllerIntTest {
String currentTime = LocalDateTime.now().toString();
final String finalCurrentTime = currentTime;
ThrowingCallable httpCall =
() -> {
template.exchange(
server + port + "/api/v1/task-history-event?created=" + finalCurrentTime,
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
};
() ->
template.exchange(
server + port + "/api/v1/task-history-event?created=" + finalCurrentTime,
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining(currentTime)
@ -157,6 +157,7 @@ class TaskHistoryEventControllerIntTest {
HttpMethod.GET,
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getContent()).hasSize(23);
}
@ -172,25 +173,23 @@ class TaskHistoryEventControllerIntTest {
request,
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getContent()).hasSize(2);
assertThat(response.getBody().getContent().iterator().next().getWorkbasketKey())
.isEqualTo("WBI:100000000000000000000000000000000002");
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(
response
.getBody()
.getRequiredLink(IanaLinkRelations.SELF)
.getHref()
.endsWith(parameters))
.isTrue();
assertThat(response.getBody().getLink("allTaskHistoryEvent")).isNotNull();
assertThat(
response
.getBody()
.getRequiredLink("allTaskHistoryEvent")
.getHref()
.endsWith("/api/v1/task-history-event"))
.isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
.isNotNull()
.get()
.extracting(Link::getHref)
.asString()
.endsWith(parameters);
assertThat(response.getBody().getLink("allTaskHistoryEvent"))
.isNotNull()
.get()
.extracting(Link::getHref)
.asString()
.endsWith("/api/v1/task-history-event");
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
}
@ -204,6 +203,10 @@ class TaskHistoryEventControllerIntTest {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule());
mapper
.registerModule(new ParameterNamesModule())
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
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);
/**
* 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 customIn filter for this custom
* @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched for tasks
* @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;
/**
* 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 customLike filter for this custom with a LIKE-query
* @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched-for tasks
* @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;
/**
@ -260,14 +264,13 @@ public interface ClassificationQuery
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.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect.
*/
ClassificationQuery orderByCustomAttribute(String num, SortDirection sortDirection)
throws InvalidArgumentException;
ClassificationQuery orderByCustomAttribute(
ClassificationCustomField customField, SortDirection sortDirection);
}

View File

@ -2,6 +2,8 @@ package pro.taskana.classification.api.models;
import java.time.Instant;
import pro.taskana.classification.api.ClassificationCustomField;
/** Interface used to specify the Classification-Model. */
public interface Classification extends ClassificationSummary {
@ -123,60 +125,12 @@ public interface Classification extends ClassificationSummary {
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);
/**
* 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);
void setCustomAttribute(ClassificationCustomField customField, String value);
/**
* Return a summary of the current Classification.

View File

@ -1,5 +1,7 @@
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
* the most important informations. Specific ones can be load afterwards via ID.
@ -85,60 +87,12 @@ public interface ClassificationSummary {
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();
/**
* 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();
String getCustomAttribute(ClassificationCustomField customField);
/**
* 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.LoggerFactory;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationQuery;
import pro.taskana.classification.api.ClassificationQueryColumnName;
import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.TimeInterval;
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.internal.InternalTaskanaEngine;
@ -31,7 +33,9 @@ public class ClassificationQueryImpl implements ClassificationQuery {
"pro.taskana.classification.internal.ClassificationQueryMapper."
+ "queryClassificationColumnValues";
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 String[] key;
private String[] idIn;
@ -67,8 +71,6 @@ public class ClassificationQueryImpl implements ClassificationQuery {
private String[] custom7Like;
private String[] custom8In;
private String[] custom8Like;
private List<String> orderBy;
private List<String> orderColumns;
ClassificationQueryImpl(InternalTaskanaEngine taskanaEngine) {
this.taskanaEngine = taskanaEngine;
@ -195,106 +197,80 @@ public class ClassificationQueryImpl implements ClassificationQuery {
}
@Override
public ClassificationQuery customAttributeIn(String number, 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());
}
public ClassificationQuery customAttributeIn(
ClassificationCustomField customField, String... customIn) throws InvalidArgumentException {
if (customIn.length == 0) {
throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter");
}
switch (num) {
case 1:
switch (customField) {
case CUSTOM_1:
this.custom1In = customIn;
break;
case 2:
case CUSTOM_2:
this.custom2In = customIn;
break;
case 3:
case CUSTOM_3:
this.custom3In = customIn;
break;
case 4:
case CUSTOM_4:
this.custom4In = customIn;
break;
case 5:
case CUSTOM_5:
this.custom5In = customIn;
break;
case 6:
case CUSTOM_6:
this.custom6In = customIn;
break;
case 7:
case CUSTOM_7:
this.custom7In = customIn;
break;
case 8:
case CUSTOM_8:
this.custom8In = customIn;
break;
default:
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute does not represent a number between 1 and 8");
throw new SystemException("Unknown customField '" + customField + "'");
}
return this;
}
@Override
public ClassificationQuery customAttributeLike(String number, 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());
}
public ClassificationQuery customAttributeLike(
ClassificationCustomField customField, String... customLike) throws InvalidArgumentException {
if (customLike.length == 0) {
throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter");
}
switch (num) {
case 1:
switch (customField) {
case CUSTOM_1:
this.custom1Like = toUpperCopy(customLike);
break;
case 2:
case CUSTOM_2:
this.custom2Like = toUpperCopy(customLike);
break;
case 3:
case CUSTOM_3:
this.custom3Like = toUpperCopy(customLike);
break;
case 4:
case CUSTOM_4:
this.custom4Like = toUpperCopy(customLike);
break;
case 5:
case CUSTOM_5:
this.custom5Like = toUpperCopy(customLike);
break;
case 6:
case CUSTOM_6:
this.custom6Like = toUpperCopy(customLike);
break;
case 7:
case CUSTOM_7:
this.custom7Like = toUpperCopy(customLike);
break;
case 8:
case CUSTOM_8:
this.custom8Like = toUpperCopy(customLike);
break;
default:
throw new InvalidArgumentException(
"Argument '"
+ number
+ "' to getCustomAttribute does not represent a number between 1 and 16");
throw new SystemException("Unknown customField '" + customField + "'");
}
return this;
@ -346,42 +322,9 @@ public class ClassificationQueryImpl implements ClassificationQuery {
}
@Override
public ClassificationQuery orderByCustomAttribute(String number, SortDirection sortDirection)
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());
}
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");
}
public ClassificationQuery orderByCustomAttribute(
ClassificationCustomField customField, SortDirection sortDirection) {
return addOrderCriteria(customField.name(), sortDirection);
}
@Override
@ -410,15 +353,13 @@ public class ClassificationQueryImpl implements ClassificationQuery {
RowBounds rowBounds = new RowBounds(offset, limit);
result = taskanaEngine.getSqlSession().selectList(LINK_TO_SUMMARYMAPPER, this, rowBounds);
return result;
} catch (Exception e) {
if (e instanceof PersistenceException) {
if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex =
new TaskanaRuntimeException(
"The offset beginning was set over the amount of result-rows.", e.getCause());
ex.setStackTrace(e.getStackTrace());
throw ex;
}
} catch (PersistenceException e) {
if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex =
new TaskanaRuntimeException(
"The offset beginning was set over the amount of result-rows.", e.getCause());
ex.setStackTrace(e.getStackTrace());
throw ex;
}
throw e;
} finally {

View File

@ -3,8 +3,10 @@ package pro.taskana.classification.internal.models;
import java.time.Instant;
import java.util.Objects;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.models.Classification;
import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.SystemException;
/** Classification entity. */
public class ClassificationImpl extends ClassificationSummaryImpl implements Classification {
@ -78,6 +80,38 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
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
public ClassificationSummary asSummary() {
ClassificationSummaryImpl summary = new ClassificationSummaryImpl();

View File

@ -2,7 +2,9 @@ package pro.taskana.classification.internal.models;
import java.util.Objects;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.SystemException;
/** Implementation for the short summaries of a classification entity. */
public class ClassificationSummaryImpl implements ClassificationSummary {
@ -149,6 +151,29 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
@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() {
return custom1;
}
@ -157,7 +182,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom1 = custom1;
}
@Override
public String getCustom2() {
return custom2;
}
@ -166,7 +190,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom2 = custom2;
}
@Override
public String getCustom3() {
return custom3;
}
@ -175,7 +198,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom3 = custom3;
}
@Override
public String getCustom4() {
return custom4;
}
@ -184,7 +206,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom4 = custom4;
}
@Override
public String getCustom5() {
return custom5;
}
@ -193,7 +214,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom5 = custom5;
}
@Override
public String getCustom6() {
return custom6;
}
@ -202,7 +222,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom6 = custom6;
}
@Override
public String getCustom7() {
return custom7;
}
@ -211,7 +230,6 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom7 = custom7;
}
@Override
public String getCustom8() {
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.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.TimestampReport;
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. */
public interface MonitorService {
@ -38,13 +38,14 @@ public interface MonitorService {
ClassificationReport.Builder createClassificationReportBuilder();
/**
* Provides a {@link CustomFieldValueReport.Builder} for creating a {@link CustomFieldValueReport}
* and list the values of an entered custom attribute.
* Provides a {@link TaskCustomFieldValueReport.Builder} for creating a {@link
* TaskCustomFieldValueReport} and list the values of an entered custom attribute.
*
* @param customField the customField whose values should appear in the report
* @return a {@link CustomFieldValueReport.Builder}
* @param taskCustomField the customField whose values should appear in the report
* @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}.

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
* 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) {
super(timeIntervalColumnHeaders, new String[] {"CUSTOM FIELDS"});
public TaskCustomFieldValueReport(List<TimeIntervalColumnHeader> timeIntervalColumnHeaders) {
super(timeIntervalColumnHeaders, new String[] {"TASK CUSTOM FIELDS"});
}
/** Builder for {@link CustomFieldValueReport}. */
/** Builder for {@link TaskCustomFieldValueReport}. */
public interface Builder
extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> {
@Override
CustomFieldValueReport buildReport() throws NotAuthorizedException, InvalidArgumentException;
TaskCustomFieldValueReport buildReport()
throws NotAuthorizedException, InvalidArgumentException;
@Override
CustomFieldValueReport buildReport(TaskTimestamp timestamp)
TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp)
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.reports.header.TimeIntervalColumnHeader;
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;
/**
@ -102,7 +102,7 @@ public interface TimeIntervalReportBuilder<
* @param customAttributeFilter a map of custom attributes and custom attribute value
* @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.
@ -118,11 +118,11 @@ public interface TimeIntervalReportBuilder<
/**
* 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
* @throws NotAuthorizedException if the user has no rights to access the monitor
*/
List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
List<String> listCustomAttributeValuesForCustomAttributeName(TaskCustomField taskCustomField)
throws NotAuthorizedException;
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.TaskQueryItem;
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;
/** This class is the mybatis mapping of task monitoring. */
@ -74,7 +74,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter,
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter,
@Param("combinedClassificationFilter")
List<CombinedClassificationFilter> combinedClassificationFilter);
@ -125,7 +125,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select(
"<script>"
@ -174,7 +174,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select(
"<script>"
@ -224,7 +224,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select(
"<script>"
@ -266,7 +266,7 @@ public interface MonitorMapper {
@Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")
})
List<MonitorQueryItem> getTaskCountOfCustomFieldValues(
@Param("customField") CustomField customField,
@Param("customField") TaskCustomField taskCustomField,
@Param("workbasketIds") List<String> workbasketIds,
@Param("states") List<TaskState> states,
@Param("classificationCategories") List<String> classificationCategories,
@ -274,7 +274,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter);
@Select(
"<script>"
@ -333,7 +333,7 @@ public interface MonitorMapper {
@Param("domains") List<String> domains,
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter,
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter,
@Param("groupedBy") String groupedBy,
@Param("selectedItems") List<SelectedItem> selectedItems,
@Param("joinWithAttachments") boolean joinWithAttachments);
@ -395,8 +395,8 @@ public interface MonitorMapper {
@Param("domains") List<String> domains,
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter,
@Param("customField") CustomField customField);
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter,
@Param("customField") TaskCustomField taskCustomField);
@Select(
"<script>"
@ -452,5 +452,5 @@ public interface MonitorMapper {
@Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
@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.reports.ClassificationCategoryReport;
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.TimestampReport;
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.TimestampReportBuilderImpl;
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. */
public class MonitorServiceImpl implements MonitorService {
@ -44,9 +44,9 @@ public class MonitorServiceImpl implements MonitorService {
}
@Override
public CustomFieldValueReport.Builder createCustomFieldValueReportBuilder(
CustomField customField) {
return new CustomFieldValueReportBuilderImpl(taskanaEngine, monitorMapper, customField);
public TaskCustomFieldValueReport.Builder createCustomFieldValueReportBuilder(
TaskCustomField taskCustomField) {
return new CustomFieldValueReportBuilderImpl(taskanaEngine, monitorMapper, taskCustomField);
}
@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.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.CustomFieldValueReport;
import pro.taskana.monitor.api.reports.CustomFieldValueReport.Builder;
import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport.Builder;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.monitor.api.reports.item.MonitorQueryItem;
import pro.taskana.monitor.internal.MonitorMapper;
import pro.taskana.monitor.internal.preprocessor.DaysToWorkingDaysReportPreProcessor;
import pro.taskana.task.api.CustomField;
import pro.taskana.task.api.TaskCustomField;
/** The implementation of CustomFieldValueReportBuilder. */
public class CustomFieldValueReportBuilderImpl
extends TimeIntervalReportBuilderImpl<Builder, MonitorQueryItem, TimeIntervalColumnHeader>
implements CustomFieldValueReport.Builder {
implements TaskCustomFieldValueReport.Builder {
private static final Logger LOGGER =
LoggerFactory.getLogger(CustomFieldValueReportBuilderImpl.class);
private final CustomField customField;
private final TaskCustomField taskCustomField;
public CustomFieldValueReportBuilderImpl(
InternalTaskanaEngine taskanaEngine, MonitorMapper monitorMapper, CustomField customField) {
InternalTaskanaEngine taskanaEngine,
MonitorMapper monitorMapper,
TaskCustomField taskCustomField) {
super(taskanaEngine, monitorMapper);
this.customField = customField;
this.taskCustomField = taskCustomField;
}
@Override
public CustomFieldValueReport buildReport()
public TaskCustomFieldValueReport buildReport()
throws NotAuthorizedException, InvalidArgumentException {
return buildReport(TaskTimestamp.DUE);
}
@Override
public CustomFieldValueReport buildReport(TaskTimestamp timestamp)
public TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp)
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);
try {
this.taskanaEngine.openConnection();
CustomFieldValueReport report = new CustomFieldValueReport(this.columnHeaders);
TaskCustomFieldValueReport report = new TaskCustomFieldValueReport(this.columnHeaders);
List<MonitorQueryItem> monitorQueryItems =
this.monitorMapper.getTaskCountOfCustomFieldValues(
this.customField,
this.taskCustomField,
this.workbasketIds,
this.states,
this.classificationCategory,
@ -71,12 +73,12 @@ public class CustomFieldValueReportBuilderImpl
}
@Override
protected CustomFieldValueReport.Builder _this() {
protected TaskCustomFieldValueReport.Builder _this() {
return this;
}
@Override
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.internal.MonitorMapper;
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;
/**
@ -48,7 +48,7 @@ abstract class TimeIntervalReportBuilderImpl<
protected List<String> domains;
protected List<String> classificationIds;
protected List<String> excludedClassificationIds;
protected Map<CustomField, String> customAttributeFilter;
protected Map<TaskCustomField, String> customAttributeFilter;
protected WorkingDaysToDaysConverter converter;
TimeIntervalReportBuilderImpl(InternalTaskanaEngine taskanaEngine, MonitorMapper monitorMapper) {
@ -107,7 +107,7 @@ abstract class TimeIntervalReportBuilderImpl<
}
@Override
public B customAttributeFilterIn(Map<CustomField, String> customAttributeFilter) {
public B customAttributeFilterIn(Map<TaskCustomField, String> customAttributeFilter) {
this.customAttributeFilter = new HashMap<>(customAttributeFilter);
return _this();
}
@ -156,11 +156,12 @@ abstract class TimeIntervalReportBuilderImpl<
}
@Override
public List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
public List<String> listCustomAttributeValuesForCustomAttributeName(
TaskCustomField taskCustomField)
throws NotAuthorizedException {
LOGGER.debug(
"entry to listCustomAttributeValuesForCustomAttributeName(customField = {}), this = {}",
customField,
taskCustomField,
this);
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR);
try {
@ -173,7 +174,7 @@ abstract class TimeIntervalReportBuilderImpl<
this.classificationIds,
this.excludedClassificationIds,
this.customAttributeFilter,
customField);
taskCustomField);
} finally {
this.taskanaEngine.returnConnection();
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 pro.taskana.common.api.exceptions.SystemException;
/** Super class for all specific events from the TASKANA engine. */
public class TaskanaHistoryEvent {
@ -38,6 +40,40 @@ public class TaskanaHistoryEvent {
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() {
return id;
}
@ -190,38 +226,6 @@ public class TaskanaHistoryEvent {
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() {
return details;
}

View File

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

View File

@ -428,31 +428,27 @@ public interface TaskQuery extends BaseQuery<TaskSummary, TaskQueryColumnName> {
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
* 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 searchArguments the custom_num values of the searched for tasks
* @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched for tasks
* @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;
/**
* Add the values of custom attribute number num 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.
* 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 identifies which custom attribute is affected. Taskana concatenates "custom_" with
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @param searchArguments the custom_num values of the searched-for tasks
* @param customField identifies which custom attribute is affected.
* @param searchArguments the customField values of the searched-for tasks
* @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;
/**
@ -812,19 +808,14 @@ public interface TaskQuery extends BaseQuery<TaskSummary, TaskQueryColumnName> {
TaskQuery orderByWorkbasketKey(SortDirection sortDirection);
/**
* This method sorts the query result according to the value of a custom field. The custom field
* is choosen by parameter num.
* This method sorts the query result according to the value of a custom field.
*
* @param num identifies which custom attribute is affected. Taskana concatenates "custom_" with
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @param customField identifies which custom attribute is affected.
* @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
* @throws InvalidArgumentException when number is not a valid number between 1 and 16
*/
TaskQuery orderByCustomAttribute(String num, SortDirection sortDirection)
throws InvalidArgumentException;
TaskQuery orderByCustomAttribute(TaskCustomField customField, SortDirection sortDirection);
/**
* 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 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
* identification of the custom field must be a String with value "1", "2" ... "16" as in the
* setCustomAttribute or getCustomAttribute method of {@link Task}
* field and as value the corresponding new value of that custom field.
* @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException If the customFieldsToUpdate map contains an invalid key or if
* the selectionCriteria is invalid
* @throws InvalidArgumentException if the given selectionCriteria is invalid or the given
* customFieldsToUpdate are null or empty.
*/
List<String> updateTasks(
ObjectReference selectionCriteria, Map<String, String> customFieldsToUpdate)
ObjectReference selectionCriteria, Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException;
/**
@ -389,14 +387,11 @@ public interface TaskService {
*
* @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
* field and as value the corresponding new value of that custom field. The key for
* identification of the custom field must be a String with value "1", "2" ... "16" as in the
* setCustomAttribute or getCustomAttribute method of {@link Task}
* field and as value the corresponding new value of that custom field.
* @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException If the customFieldsToUpdate map contains an invalid key or if
* the selectionCriteria is invalid
* @throws InvalidArgumentException if the given customFieldsToUpdate are null or empty.
*/
List<String> updateTasks(List<String> taskIds, Map<String, String> customFieldsToUpdate)
List<String> updateTasks(List<String> taskIds, Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException;
/**

View File

@ -41,7 +41,7 @@ public interface Attachment extends AttachmentSummary {
*
* @return customAttributes as {@link Map}
*/
Map<String, String> getCustomAttributes();
Map<String, String> getCustomAttributeMap();
/**
* 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
* key, value pairs
*/
void setCustomAttributes(Map<String, String> customAttributes);
void setCustomAttributeMap(Map<String, String> customAttributes);
/**
* Return a summary of the current Attachment.

View File

@ -5,7 +5,7 @@ import java.util.List;
import java.util.Map;
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;
/** task-Interface to specify attribute interactions. */
@ -77,14 +77,14 @@ public interface Task extends TaskSummary {
*
* @return customAttributes as {@link Map}
*/
Map<String, String> getCustomAttributes();
Map<String, String> getCustomAttributeMap();
/**
* Sets a Map of 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.
@ -101,15 +101,12 @@ public interface Task extends TaskSummary {
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
* 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 customField identifies which custom attribute is 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>

View File

@ -4,7 +4,7 @@ import java.time.Instant;
import java.util.List;
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.workbasket.api.models.WorkbasketSummary;
@ -183,15 +183,12 @@ public interface TaskSummary {
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
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @return the value of custom attribute number num
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16"
* @param customField identifies which custom attribute is requested.
* @return the value for the given customField
*/
String getCustomAttribute(String num) throws InvalidArgumentException;
String getCustomAttribute(TaskCustomField customField);
/**
* 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.
*
* @author bbr
*/
public class CustomPropertySelector {
public class TaskCustomPropertySelector {
boolean custom1 = false;
boolean custom2 = false;
@ -26,70 +25,58 @@ public class CustomPropertySelector {
boolean custom15 = false;
boolean custom16 = false;
public void setCustomProperty(String propertyNumber, boolean value)
throws InvalidArgumentException {
int num = 0;
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:
public void setCustomProperty(TaskCustomField customField, boolean value) {
switch (customField) {
case CUSTOM_1:
this.setCustom1(value);
break;
case 2:
case CUSTOM_2:
this.setCustom2(value);
break;
case 3:
case CUSTOM_3:
this.setCustom3(value);
break;
case 4:
case CUSTOM_4:
this.setCustom4(value);
break;
case 5:
case CUSTOM_5:
this.setCustom5(value);
break;
case 6:
case CUSTOM_6:
this.setCustom6(value);
break;
case 7:
case CUSTOM_7:
this.setCustom7(value);
break;
case 8:
case CUSTOM_8:
this.setCustom8(value);
break;
case 9:
case CUSTOM_9:
this.setCustom9(value);
break;
case 10:
case CUSTOM_10:
this.setCustom10(value);
break;
case 11:
case CUSTOM_11:
this.setCustom11(value);
break;
case 12:
case CUSTOM_12:
this.setCustom12(value);
break;
case 13:
case CUSTOM_13:
this.setCustom13(value);
break;
case 14:
case CUSTOM_14:
this.setCustom14(value);
break;
case 15:
case CUSTOM_15:
this.setCustom15(value);
break;
case 16:
case CUSTOM_16:
this.setCustom16(value);
break;
default:
throw new InvalidArgumentException(
"propertyNumber '" + propertyNumber + "' does not represent a number between 1 and 16");
throw new SystemException("Unknown customField '" + customField + "'");
}
}

View File

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

View File

@ -2,7 +2,7 @@ package pro.taskana.task.internal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.EnumSet;
import java.util.List;
import org.apache.ibatis.exceptions.PersistenceException;
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.exceptions.InvalidArgumentException;
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.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.configuration.DB;
import pro.taskana.common.internal.security.CurrentUserContext;
import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.ObjectReferenceQuery;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskQuery;
import pro.taskana.task.api.TaskQueryColumnName;
import pro.taskana.task.api.TaskState;
@ -34,9 +36,6 @@ import pro.taskana.workbasket.internal.WorkbasketQueryImpl;
/** TaskQuery for generating dynamic sql. */
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 =
"pro.taskana.task.internal.TaskQueryMapper.queryTaskSummaries";
private static final String LINK_TO_MAPPER_DB2 =
@ -45,13 +44,15 @@ public class TaskQueryImpl implements TaskQuery {
"pro.taskana.task.internal.TaskQueryMapper.countQueryTasks";
private static final String LINK_TO_COUNTER_DB2 =
"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";
private static final String TIME_INTERVAL = "TimeInterval ";
private static final String IS_INVALID = " is invalid.";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryImpl.class);
private InternalTaskanaEngine taskanaEngine;
private TaskServiceImpl taskService;
private final InternalTaskanaEngine taskanaEngine;
private final TaskServiceImpl taskService;
private final List<String> orderBy;
private final List<String> orderColumns;
private TaskQueryColumnName columnName;
private String[] nameIn;
private String[] nameLike;
@ -145,8 +146,6 @@ public class TaskQueryImpl implements TaskQuery {
private TimeInterval[] modifiedIn;
private TimeInterval[] plannedIn;
private TimeInterval[] dueIn;
private List<String> orderBy;
private List<String> orderColumns;
private WildcardSearchField[] wildcardSearchFieldIn;
private String wildcardSearchValueLike;
private boolean selectAndClaim;
@ -229,12 +228,8 @@ public class TaskQueryImpl implements TaskQuery {
@Override
public TaskQuery stateNotIn(TaskState... states) {
// No benefit in introducing a new variable
List<TaskState> stateIn = new LinkedList<>(Arrays.asList(TaskState.values()));
for (TaskState state : states) {
stateIn.remove(state);
}
this.stateIn = stateIn.toArray(new TaskState[0]);
this.stateIn =
EnumSet.complementOf(EnumSet.copyOf(Arrays.asList(states))).toArray(new TaskState[0]);
return this;
}
@ -480,147 +475,127 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery customAttributeIn(String number, String... strings)
public TaskQuery customAttributeIn(TaskCustomField customField, String... strings)
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) {
throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter");
}
switch (num) {
case 1:
switch (customField) {
case CUSTOM_1:
this.custom1In = strings;
break;
case 2:
case CUSTOM_2:
this.custom2In = strings;
break;
case 3:
case CUSTOM_3:
this.custom3In = strings;
break;
case 4:
case CUSTOM_4:
this.custom4In = strings;
break;
case 5:
case CUSTOM_5:
this.custom5In = strings;
break;
case 6:
case CUSTOM_6:
this.custom6In = strings;
break;
case 7:
case CUSTOM_7:
this.custom7In = strings;
break;
case 8:
case CUSTOM_8:
this.custom8In = strings;
break;
case 9:
case CUSTOM_9:
this.custom9In = strings;
break;
case 10:
case CUSTOM_10:
this.custom10In = strings;
break;
case 11:
case CUSTOM_11:
this.custom11In = strings;
break;
case 12:
case CUSTOM_12:
this.custom12In = strings;
break;
case 13:
case CUSTOM_13:
this.custom13In = strings;
break;
case 14:
case CUSTOM_14:
this.custom14In = strings;
break;
case 15:
case CUSTOM_15:
this.custom15In = strings;
break;
case 16:
case CUSTOM_16:
this.custom16In = strings;
break;
default:
throw new InvalidArgumentException(
ARGUMENT + number + GET_CUSTOM_ATTRIBUTE_NOT_A_NUMBER_BETWEEN_1_AND_16);
throw new SystemException("Unknown custom attribute '" + customField + "'");
}
return this;
}
@Override
public TaskQuery customAttributeLike(String number, String... strings)
public TaskQuery customAttributeLike(TaskCustomField customField, String... strings)
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) {
throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter");
}
switch (num) {
case 1:
switch (customField) {
case CUSTOM_1:
this.custom1Like = toUpperCopy(strings);
break;
case 2:
case CUSTOM_2:
this.custom2Like = toUpperCopy(strings);
break;
case 3:
case CUSTOM_3:
this.custom3Like = toUpperCopy(strings);
break;
case 4:
case CUSTOM_4:
this.custom4Like = toUpperCopy(strings);
break;
case 5:
case CUSTOM_5:
this.custom5Like = toUpperCopy(strings);
break;
case 6:
case CUSTOM_6:
this.custom6Like = toUpperCopy(strings);
break;
case 7:
case CUSTOM_7:
this.custom7Like = toUpperCopy(strings);
break;
case 8:
case CUSTOM_8:
this.custom8Like = toUpperCopy(strings);
break;
case 9:
case CUSTOM_9:
this.custom9Like = toUpperCopy(strings);
break;
case 10:
case CUSTOM_10:
this.custom10Like = toUpperCopy(strings);
break;
case 11:
case CUSTOM_11:
this.custom11Like = toUpperCopy(strings);
break;
case 12:
case CUSTOM_12:
this.custom12Like = toUpperCopy(strings);
break;
case 13:
case CUSTOM_13:
this.custom13Like = toUpperCopy(strings);
break;
case 14:
case CUSTOM_14:
this.custom14Like = toUpperCopy(strings);
break;
case 15:
case CUSTOM_15:
this.custom15Like = toUpperCopy(strings);
break;
case 16:
case CUSTOM_16:
this.custom16Like = toUpperCopy(strings);
break;
default:
throw new InvalidArgumentException(
ARGUMENT + number + GET_CUSTOM_ATTRIBUTE_NOT_A_NUMBER_BETWEEN_1_AND_16);
throw new SystemException("Unknown custom field '" + customField + "'");
}
return this;
@ -858,56 +833,9 @@ public class TaskQueryImpl implements TaskQuery {
}
@Override
public TaskQuery orderByCustomAttribute(String number, SortDirection sortDirection)
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());
}
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);
}
public TaskQuery orderByCustomAttribute(
TaskCustomField customField, SortDirection sortDirection) {
return addOrderCriteria(customField.name(), sortDirection);
}
@Override
@ -1056,7 +984,7 @@ public class TaskQueryImpl implements TaskQuery {
}
setupJoinAndOrderParameters();
result = taskanaEngine.getSqlSession().selectList(LINK_TO_VALUEMAPPER, this);
result = taskanaEngine.getSqlSession().selectList(LINK_TO_VALUE_MAPPER, this);
return result;
} finally {
taskanaEngine.returnConnection();
@ -1743,7 +1671,11 @@ public class TaskQueryImpl implements TaskQuery {
@Override
public String toString() {
return "TaskQueryImpl [columnName="
return "TaskQueryImpl [taskanaEngine="
+ taskanaEngine
+ ", taskService="
+ taskService
+ ", columnName="
+ columnName
+ ", nameIn="
+ Arrays.toString(nameIn)
@ -1825,6 +1757,8 @@ public class TaskQueryImpl implements TaskQuery {
+ Arrays.toString(businessProcessIdIn)
+ ", businessProcessIdLike="
+ Arrays.toString(businessProcessIdLike)
+ ", callbackStateIn="
+ Arrays.toString(callbackStateIn)
+ ", custom1In="
+ Arrays.toString(custom1In)
+ ", custom1Like="
@ -1931,11 +1865,19 @@ public class TaskQueryImpl implements TaskQuery {
+ orderBy
+ ", orderColumns="
+ orderColumns
+ ", wildcardSearchFieldIn="
+ Arrays.toString(wildcardSearchFieldIn)
+ ", wildcardSearchValueLike="
+ wildcardSearchValueLike
+ ", selectAndClaim="
+ selectAndClaim
+ ", useDistinctKeyword="
+ useDistinctKeyword
+ ", joinWithAttachments="
+ joinWithAttachments
+ ", joinWithClassifications="
+ joinWithClassifications
+ ", joinWithAttachmentsClassifications="
+ ", joinWithAttachmentClassifications="
+ joinWithAttachmentClassifications
+ ", addAttachmentColumnsToSelectClauseForOrdering="
+ addAttachmentColumnsToSelectClauseForOrdering
@ -1943,12 +1885,6 @@ public class TaskQueryImpl implements TaskQuery {
+ addClassificationNameToSelectClauseForOrdering
+ ", 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.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.apache.ibatis.exceptions.PersistenceException;
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.SystemException;
import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.CustomPropertySelector;
import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.security.CurrentUserContext;
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.internal.HistoryEventManager;
import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskQuery;
import pro.taskana.task.api.TaskService;
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";
private static final String TASK_WITH_ID_IS_ALREADY_CLAIMED_BY =
"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 THE_WORKBASKET = "The workbasket ";
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_EXT_TASK_ID = "ETI";
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 TASK_WITH_ID_IS_ALREADY_IN_END_STATE =
"Task with Id %s is already in an end state.";
private final InternalTaskanaEngine taskanaEngine;
private final WorkbasketService workbasketService;
private final ClassificationService classificationService;
@ -112,8 +109,8 @@ public class TaskServiceImpl implements TaskService {
private final TaskCommentServiceImpl taskCommentService;
private final ServiceLevelHandler serviceLevelHandler;
private final AttachmentHandler attachmentHandler;
private AttachmentMapper attachmentMapper;
private HistoryEventManager historyEventManager;
private final AttachmentMapper attachmentMapper;
private final HistoryEventManager historyEventManager;
public TaskServiceImpl(
InternalTaskanaEngine taskanaEngine,
@ -579,7 +576,7 @@ public class TaskServiceImpl implements TaskService {
@Override
public List<String> updateTasks(
ObjectReference selectionCriteria, Map<String, String> customFieldsToUpdate)
ObjectReference selectionCriteria, Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -589,7 +586,7 @@ public class TaskServiceImpl implements TaskService {
}
ObjectReference.validate(selectionCriteria, "ObjectReference", "updateTasks call");
validateCustomFields(customFieldsToUpdate);
CustomPropertySelector fieldSelector = new CustomPropertySelector();
TaskCustomPropertySelector fieldSelector = new TaskCustomPropertySelector();
TaskImpl updated = initUpdatedTask(customFieldsToUpdate, fieldSelector);
try {
@ -617,7 +614,8 @@ public class TaskServiceImpl implements TaskService {
}
@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 {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -627,7 +625,7 @@ public class TaskServiceImpl implements TaskService {
}
validateCustomFields(customFieldsToUpdate);
CustomPropertySelector fieldSelector = new CustomPropertySelector();
TaskCustomPropertySelector fieldSelector = new TaskCustomPropertySelector();
TaskImpl updatedTask = initUpdatedTask(customFieldsToUpdate, fieldSelector);
try {
@ -743,9 +741,7 @@ public class TaskServiceImpl implements TaskService {
.map(MinimalTaskSummary::getTaskId)
.collect(Collectors.toList());
bulkLog.addAllErrors(resultsPair.getRight());
if (taskIds.isEmpty()) {
return bulkLog;
} else {
if (!taskIds.isEmpty()) {
final int numberOfAffectedTasks = taskMapper.setOwnerOfTasks(owner, taskIds, Instant.now());
if (numberOfAffectedTasks != taskIds.size()) { // all tasks were updated
// check the outcome
@ -761,8 +757,8 @@ public class TaskServiceImpl implements TaskService {
bulkLog.getFailedIds().size());
}
}
return bulkLog;
}
return bulkLog;
} finally {
LOGGER.debug("exit from setOwnerOfTasks()");
taskanaEngine.returnConnection();
@ -1389,7 +1385,7 @@ public class TaskServiceImpl implements TaskService {
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);
if (taskanaEngine.getEngine().isHistoryEnabled()
@ -1825,8 +1821,7 @@ public class TaskServiceImpl implements TaskService {
}
private TaskImpl initUpdatedTask(
Map<String, String> customFieldsToUpdate, CustomPropertySelector fieldSelector)
throws InvalidArgumentException {
Map<TaskCustomField, String> customFieldsToUpdate, TaskCustomPropertySelector fieldSelector) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"entry to initUpdatedTask(customFieldsToUpdate = {}, fieldSelector = {})",
@ -1837,8 +1832,8 @@ public class TaskServiceImpl implements TaskService {
TaskImpl newTask = new TaskImpl();
newTask.setModified(Instant.now());
for (Map.Entry<String, String> entry : customFieldsToUpdate.entrySet()) {
String key = entry.getKey();
for (Map.Entry<TaskCustomField, String> entry : customFieldsToUpdate.entrySet()) {
TaskCustomField key = entry.getKey();
fieldSelector.setCustomProperty(key, true);
newTask.setCustomAttribute(key, entry.getValue());
}
@ -1849,7 +1844,7 @@ public class TaskServiceImpl implements TaskService {
return newTask;
}
private void validateCustomFields(Map<String, String> customFieldsToUpdate)
private void validateCustomFields(Map<TaskCustomField, String> customFieldsToUpdate)
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -1860,14 +1855,6 @@ public class TaskServiceImpl implements TaskService {
throw new InvalidArgumentException(
"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()");
}

View File

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

View File

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

View File

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

View File

@ -7,7 +7,8 @@ import java.util.Objects;
import pro.taskana.classification.api.models.ClassificationSummary;
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.models.AttachmentSummary;
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. */
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 externalId;
protected Instant created;
@ -104,10 +102,6 @@ public class TaskSummaryImpl implements TaskSummary {
custom16 = copyFrom.custom16;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getTaskId()
*/
@Override
public String getId() {
return id;
@ -117,10 +111,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.id = id;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getExternalId()
*/
@Override
public String getExternalId() {
return externalId;
@ -130,10 +120,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.externalId = externalId;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreator()
*/
@Override
public String getCreator() {
return creator;
@ -143,10 +129,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.creator = creator;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCreated()
*/
@Override
public Instant getCreated() {
return created;
@ -156,10 +138,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.created = created;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getClaimed()
*/
@Override
public Instant getClaimed() {
return claimed;
@ -169,10 +147,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.claimed = claimed;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCompleted()
*/
@Override
public Instant getCompleted() {
return completed;
@ -182,10 +156,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.completed = completed;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getModified()
*/
@Override
public Instant getModified() {
return modified;
@ -195,10 +165,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.modified = modified;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getPlanned()
*/
@Override
public Instant getPlanned() {
return planned;
@ -208,10 +174,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.planned = planned;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getDue()
*/
@Override
public Instant getDue() {
return due;
@ -221,10 +183,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.due = due;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getName()
*/
@Override
public String getName() {
return name;
@ -234,10 +192,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.name = name;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getNote()
*/
@Override
public String getNote() {
return note;
@ -247,10 +201,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.note = note;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getDescription()
*/
@Override
public String getDescription() {
return description;
@ -260,10 +210,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.description = description;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getPriority()
*/
@Override
public int getPriority() {
return priority;
@ -273,10 +219,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.priority = priority;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getState()
*/
@Override
public TaskState getState() {
return state;
@ -286,10 +228,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.state = state;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getClassificationSummary()
*/
@Override
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
@ -299,10 +237,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.classificationSummary = classificationSummary;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getWorkbasketSummary()
*/
@Override
public WorkbasketSummary getWorkbasketSummary() {
return workbasketSummary;
@ -321,10 +255,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.attachmentSummaries = attachmentSummaries;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getDomain()
*/
@Override
public String getDomain() {
return workbasketSummary == null ? null : workbasketSummary.getDomain();
@ -337,10 +267,6 @@ public class TaskSummaryImpl implements TaskSummary {
((WorkbasketSummaryImpl) this.workbasketSummary).setDomain(domain);
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getBusinessProcessId()
*/
@Override
public String getBusinessProcessId() {
return businessProcessId;
@ -350,10 +276,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.businessProcessId = businessProcessId;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getParentBusinessProcessId()
*/
@Override
public String getParentBusinessProcessId() {
return parentBusinessProcessId;
@ -363,10 +285,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.parentBusinessProcessId = parentBusinessProcessId;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getOwner()
*/
@Override
public String getOwner() {
return owner;
@ -376,10 +294,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.owner = owner;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getPrimaryObjRef()
*/
@Override
public ObjectReference getPrimaryObjRef() {
return primaryObjRef;
@ -389,10 +303,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.primaryObjRef = primaryObjRef;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#isRead()
*/
@Override
public boolean isRead() {
return isRead;
@ -402,10 +312,6 @@ public class TaskSummaryImpl implements TaskSummary {
this.isRead = isRead;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#isTransferred()
*/
@Override
public boolean isTransferred() {
return isTransferred;
@ -415,55 +321,44 @@ public class TaskSummaryImpl implements TaskSummary {
this.isTransferred = isTransferred;
}
/*
* (non-Javadoc)
* @see pro.taskana.TaskSummary#getCustomAttribute(String number)
*/
@Override
public String getCustomAttribute(String number) throws InvalidArgumentException {
int num = 0;
try {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
String.format(NOT_A_VALID_NUMBER_GET, number), e.getCause());
}
public String getCustomAttribute(TaskCustomField customField) {
switch (num) {
case 1:
switch (customField) {
case CUSTOM_1:
return custom1;
case 2:
case CUSTOM_2:
return custom2;
case 3:
case CUSTOM_3:
return custom3;
case 4:
case CUSTOM_4:
return custom4;
case 5:
case CUSTOM_5:
return custom5;
case 6:
case CUSTOM_6:
return custom6;
case 7:
case CUSTOM_7:
return custom7;
case 8:
case CUSTOM_8:
return custom8;
case 9:
case CUSTOM_9:
return custom9;
case 10:
case CUSTOM_10:
return custom10;
case 11:
case CUSTOM_11:
return custom11;
case 12:
case CUSTOM_12:
return custom12;
case 13:
case CUSTOM_13:
return custom13;
case 14:
case CUSTOM_14:
return custom14;
case 15:
case CUSTOM_15:
return custom15;
case 16:
case CUSTOM_16:
return custom16;
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);
/**
* 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.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom1(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);
WorkbasketQuery orderByCustomAttribute(
WorkbasketCustomField customField, SortDirection sortDirection);
/**
* Sort the query result by organization level 1.
@ -299,76 +274,24 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary, Workbasket
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
*/
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
* 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.
* 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 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
*/
WorkbasketQuery custom1Like(String... custom1);
/**
* 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);
WorkbasketQuery customAttributeLike(WorkbasketCustomField customField, String... searchArguments);
/**
* 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 pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketType;
/** Workbasket entity interface. */
@ -29,32 +30,12 @@ public interface Workbasket extends WorkbasketSummary {
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);
/**
* 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);
void setCustomAttribute(WorkbasketCustomField customField, String value);
/**
* Sets the value for orgLevel1 attribute.

View File

@ -1,5 +1,7 @@
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
* workbaskets.
@ -55,266 +57,20 @@ public interface WorkbasketAccessItem {
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);
/**
* 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);
boolean getPermission(WorkbasketPermission permission);
/**
* Duplicates this WorkbasketAccessItem without the id.

View File

@ -1,5 +1,6 @@
package pro.taskana.workbasket.api.models;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketType;
/**
@ -58,32 +59,12 @@ public interface WorkbasketSummary {
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();
/**
* 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();
String getCustomAttribute(WorkbasketCustomField customField);
/**
* 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.exceptions.InvalidArgumentException;
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.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.security.CurrentUserContext;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketQuery;
import pro.taskana.workbasket.api.WorkbasketQueryColumnName;
@ -240,23 +242,9 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
}
@Override
public WorkbasketQuery orderByCustom1(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_1", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom2(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_2", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom3(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_3", sortDirection);
}
@Override
public WorkbasketQuery orderByCustom4(SortDirection sortDirection) {
return addOrderCriteria("CUSTOM_4", sortDirection);
public WorkbasketQuery orderByCustomAttribute(
WorkbasketCustomField customField, SortDirection sortDirection) {
return addOrderCriteria(customField.name(), sortDirection);
}
@Override
@ -280,50 +268,46 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
}
@Override
public WorkbasketQuery custom1In(String... custom1) {
this.custom1In = custom1;
public WorkbasketQuery customAttributeIn(
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;
}
@Override
public WorkbasketQuery custom1Like(String... custom1) {
this.custom1Like = toUpperCopy(custom1);
return this;
}
@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);
public WorkbasketQuery customAttributeLike(
WorkbasketCustomField customField, String... searchArguments) {
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 + "'");
}
return this;
}
@ -683,8 +667,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
if (this.accessId == null) {
String[] accessIds = new String[0];
List<String> ucAccessIds = CurrentUserContext.getAccessIds();
if (ucAccessIds != null && !ucAccessIds.isEmpty()) {
accessIds = new String[ucAccessIds.size()];
if (!ucAccessIds.isEmpty()) {
accessIds = ucAccessIds.toArray(accessIds);
}
this.accessId = accessIds;
@ -704,83 +687,88 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
@Override
public String toString() {
return "WorkbasketQueryImpl ["
+ "columnName="
+ this.columnName
return "WorkbasketQueryImpl [columnName="
+ columnName
+ ", accessId="
+ Arrays.toString(this.accessId)
+ Arrays.toString(accessId)
+ ", idIn="
+ Arrays.toString(this.idIn)
+ Arrays.toString(idIn)
+ ", permission="
+ this.permission
+ permission
+ ", nameIn="
+ Arrays.toString(this.nameIn)
+ Arrays.toString(nameIn)
+ ", nameLike="
+ Arrays.toString(this.nameLike)
+ Arrays.toString(nameLike)
+ ", keyIn="
+ Arrays.toString(this.keyIn)
+ Arrays.toString(keyIn)
+ ", keyLike="
+ Arrays.toString(this.keyLike)
+ Arrays.toString(keyLike)
+ ", keyOrNameLike="
+ Arrays.toString(this.keyOrNameLike)
+ Arrays.toString(keyOrNameLike)
+ ", domainIn="
+ Arrays.toString(this.domainIn)
+ Arrays.toString(domainIn)
+ ", domainLike="
+ Arrays.toString(this.domainLike)
+ Arrays.toString(domainLike)
+ ", type="
+ Arrays.toString(this.type)
+ Arrays.toString(type)
+ ", createdIn="
+ Arrays.toString(this.createdIn)
+ Arrays.toString(createdIn)
+ ", modifiedIn="
+ Arrays.toString(this.modifiedIn)
+ Arrays.toString(modifiedIn)
+ ", descriptionLike="
+ Arrays.toString(this.descriptionLike)
+ Arrays.toString(descriptionLike)
+ ", ownerIn="
+ Arrays.toString(this.ownerIn)
+ Arrays.toString(ownerIn)
+ ", ownerLike="
+ Arrays.toString(this.ownerLike)
+ Arrays.toString(ownerLike)
+ ", custom1In="
+ Arrays.toString(this.custom1In)
+ Arrays.toString(custom1In)
+ ", custom1Like="
+ Arrays.toString(this.custom1Like)
+ Arrays.toString(custom1Like)
+ ", custom2In="
+ Arrays.toString(this.custom2In)
+ Arrays.toString(custom2In)
+ ", custom2Like="
+ Arrays.toString(this.custom2Like)
+ Arrays.toString(custom2Like)
+ ", custom3In="
+ Arrays.toString(this.custom3In)
+ Arrays.toString(custom3In)
+ ", custom3Like="
+ Arrays.toString(this.custom3Like)
+ Arrays.toString(custom3Like)
+ ", custom4In="
+ Arrays.toString(this.custom4In)
+ Arrays.toString(custom4In)
+ ", custom4Like="
+ Arrays.toString(this.custom4Like)
+ Arrays.toString(custom4Like)
+ ", orgLevel1In="
+ Arrays.toString(this.orgLevel1In)
+ Arrays.toString(orgLevel1In)
+ ", orgLevel1Like="
+ Arrays.toString(this.orgLevel1Like)
+ Arrays.toString(orgLevel1Like)
+ ", orgLevel2In="
+ Arrays.toString(this.orgLevel2In)
+ Arrays.toString(orgLevel2In)
+ ", orgLevel2Like="
+ Arrays.toString(this.orgLevel2Like)
+ Arrays.toString(orgLevel2Like)
+ ", orgLevel3In="
+ Arrays.toString(this.orgLevel3In)
+ Arrays.toString(orgLevel3In)
+ ", orgLevel3Like="
+ Arrays.toString(this.orgLevel3Like)
+ Arrays.toString(orgLevel3Like)
+ ", orgLevel4In="
+ Arrays.toString(this.orgLevel4In)
+ Arrays.toString(orgLevel4In)
+ ", orgLevel4Like="
+ Arrays.toString(this.orgLevel4Like)
+ Arrays.toString(orgLevel4Like)
+ ", markedForDeletion="
+ this.markedForDeletion
+ markedForDeletion
+ ", taskanaEngine="
+ taskanaEngine
+ ", orderBy="
+ this.orderBy
+ orderBy
+ ", orderColumns="
+ orderColumns
+ ", joinWithAccessList="
+ this.joinWithAccessList
+ joinWithAccessList
+ ", checkReadPermission="
+ this.checkReadPermission
+ checkReadPermission
+ ", usedToAugmentTasks="
+ this.usedToAugmentTasks
+ usedToAugmentTasks
+ ", callerRolesAndAccessIdsAlreadyHandled="
+ callerRolesAndAccessIdsAlreadyHandled
+ "]";
}
}

View File

@ -963,56 +963,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
if (workbasketAccessItem == null) {
return permissions;
}
if (workbasketAccessItem.isPermOpen()) {
permissions.add(WorkbasketPermission.OPEN);
}
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);
for (WorkbasketPermission permission : WorkbasketPermission.values()) {
if (workbasketAccessItem.getPermission(permission)) {
permissions.add(permission);
}
}
return permissions;
}

View File

@ -2,6 +2,8 @@ package pro.taskana.workbasket.internal.models;
import java.util.Objects;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/** WorkbasketAccessItemImpl Entity. */
@ -56,10 +58,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
permCustom12 = copyFrom.permCustom12;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getId()
*/
@Override
public String getId() {
return id;
@ -69,10 +67,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.id = id;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getWorkbasketId()
*/
@Override
public String getWorkbasketId() {
return workbasketId;
@ -91,10 +85,6 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.workbasketKey = workbasketKey;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getAccessId()
*/
@Override
public String getAccessId() {
return accessId;
@ -104,326 +94,249 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.accessId = accessId;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#getAccessName()
*/
@Override
public String getAccessName() {
return accessName;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setAccessName()
*/
@Override
public void setAccessName(String accessName) {
this.accessName = accessName;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermRead()
*/
@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() {
return permRead;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermRead(boolean)
*/
@Override
public void setPermRead(boolean permRead) {
this.permRead = permRead;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermOpen()
*/
@Override
public boolean isPermOpen() {
return permOpen;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermOpen(boolean)
*/
@Override
public void setPermOpen(boolean permOpen) {
this.permOpen = permOpen;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermAppend()
*/
@Override
public boolean isPermAppend() {
return permAppend;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermAppend(boolean)
*/
@Override
public void setPermAppend(boolean permAppend) {
this.permAppend = permAppend;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermTransfer()
*/
@Override
public boolean isPermTransfer() {
return permTransfer;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermTransfer(boolean)
*/
@Override
public void setPermTransfer(boolean permTransfer) {
this.permTransfer = permTransfer;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermDistribute()
*/
@Override
public boolean isPermDistribute() {
return permDistribute;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermDistribute(boolean)
*/
@Override
public void setPermDistribute(boolean permDistribute) {
this.permDistribute = permDistribute;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom1()
*/
@Override
public boolean isPermCustom1() {
return permCustom1;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom1(boolean)
*/
@Override
public void setPermCustom1(boolean permCustom1) {
this.permCustom1 = permCustom1;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom2()
*/
@Override
public boolean isPermCustom2() {
return permCustom2;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom2(boolean)
*/
@Override
public void setPermCustom2(boolean permCustom2) {
this.permCustom2 = permCustom2;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom3()
*/
@Override
public boolean isPermCustom3() {
return permCustom3;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom3(boolean)
*/
@Override
public void setPermCustom3(boolean permCustom3) {
this.permCustom3 = permCustom3;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom4()
*/
@Override
public boolean isPermCustom4() {
return permCustom4;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom4(boolean)
*/
@Override
public void setPermCustom4(boolean permCustom4) {
this.permCustom4 = permCustom4;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom5()
*/
@Override
public boolean isPermCustom5() {
return permCustom5;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom5(boolean)
*/
@Override
public void setPermCustom5(boolean permCustom5) {
this.permCustom5 = permCustom5;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom6()
*/
@Override
public boolean isPermCustom6() {
return permCustom6;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom6(boolean)
*/
@Override
public void setPermCustom6(boolean permCustom6) {
this.permCustom6 = permCustom6;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom7()
*/
@Override
public boolean isPermCustom7() {
return permCustom7;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom7(boolean)
*/
@Override
public void setPermCustom7(boolean permCustom7) {
this.permCustom7 = permCustom7;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom8()
*/
@Override
public boolean isPermCustom8() {
return permCustom8;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom8(boolean)
*/
@Override
public void setPermCustom8(boolean permCustom8) {
this.permCustom8 = permCustom8;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom9()
*/
@Override
public boolean isPermCustom9() {
return permCustom9;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom9(boolean)
*/
@Override
public void setPermCustom9(boolean permCustom9) {
this.permCustom9 = permCustom9;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom10()
*/
@Override
public boolean isPermCustom10() {
return permCustom10;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom10(boolean)
*/
@Override
public void setPermCustom10(boolean permCustom10) {
this.permCustom10 = permCustom10;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom11()
*/
@Override
public boolean isPermCustom11() {
return permCustom11;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom11(boolean)
*/
@Override
public void setPermCustom11(boolean permCustom11) {
this.permCustom11 = permCustom11;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom12()
*/
@Override
public boolean isPermCustom12() {
return permCustom12;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom12(boolean)
*/
@Override
public void setPermCustom12(boolean permCustom12) {
this.permCustom12 = permCustom12;
}

View File

@ -3,6 +3,8 @@ package pro.taskana.workbasket.internal.models;
import java.time.Instant;
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.WorkbasketSummary;
@ -21,6 +23,26 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket
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
public WorkbasketImpl copy(String key) {
return new WorkbasketImpl(this, key);
@ -113,14 +135,14 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket
@Override
public String toString() {
return "WorkbasketImpl [id="
+ id
+ ", key="
+ key
+ ", created="
return "WorkbasketImpl [created="
+ created
+ ", modified="
+ modified
+ ", id="
+ id
+ ", key="
+ key
+ ", name="
+ name
+ ", description="

View File

@ -2,6 +2,8 @@ package pro.taskana.workbasket.internal.models;
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.models.WorkbasketSummary;
@ -44,10 +46,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
markedForDeletion = copyFrom.markedForDeletion;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getId()
*/
@Override
public String getId() {
return id;
@ -57,10 +55,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.id = id;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getKey()
*/
@Override
public String getKey() {
return key;
@ -70,10 +64,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.key = key;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getName()
*/
@Override
public String getName() {
return name;
@ -83,10 +73,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.name = name;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getDescription()
*/
@Override
public String getDescription() {
return description;
@ -96,10 +82,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.description = description;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOwner()
*/
@Override
public String getOwner() {
return owner;
@ -109,10 +91,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.owner = owner;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getDomain()
*/
@Override
public String getDomain() {
return domain;
@ -122,10 +100,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.domain = domain;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getType()
*/
@Override
public WorkbasketType getType() {
return type;
@ -135,11 +109,22 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.type = type;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom1()
*/
@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() {
return custom1;
}
@ -148,11 +133,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom1 = custom1;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom2()
*/
@Override
public String getCustom2() {
return custom2;
}
@ -161,11 +141,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom2 = custom2;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom3()
*/
@Override
public String getCustom3() {
return custom3;
}
@ -174,11 +149,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom3 = custom3;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getCustom4()
*/
@Override
public String getCustom4() {
return custom4;
}
@ -187,10 +157,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.custom4 = custom4;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel1()
*/
@Override
public String getOrgLevel1() {
return orgLevel1;
@ -200,10 +166,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.orgLevel1 = orgLevel1;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel2()
*/
@Override
public String getOrgLevel2() {
return orgLevel2;
@ -213,10 +175,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.orgLevel2 = orgLevel2;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel3()
*/
@Override
public String getOrgLevel3() {
return orgLevel3;
@ -226,10 +184,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.orgLevel3 = orgLevel3;
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.WorkbasketSummary#getOrgLevel4()
*/
@Override
public String getOrgLevel4() {
return orgLevel4;

View File

@ -70,7 +70,7 @@ public abstract class AbstractAccTest {
return objectReference;
}
protected Map<String, String> createSimpleCustomProperties(int propertiesCount) {
protected Map<String, String> createSimpleCustomPropertyMap(int propertiesCount) {
return IntStream.rangeClosed(1, propertiesCount)
.mapToObj(String::valueOf)
.collect(Collectors.toMap("Property_"::concat, "Property Value of Property_"::concat));
@ -102,7 +102,7 @@ public abstract class AbstractAccTest {
}
attachment.setReceived(receivedTimestamp);
if (customAttributes != null) {
attachment.setCustomAttributes(customAttributes);
attachment.setCustomAttributeMap(customAttributes);
}
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.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 java.util.List;
@ -43,14 +51,14 @@ class GetClassificationAccTest extends AbstractAccTest {
assertThat(classification.getPriority()).isEqualTo(2);
assertThat(classification.getServiceLevel()).isEqualTo("P2D");
assertThat(classification.getApplicationEntryPoint()).isEqualTo("point0815");
assertThat(classification.getCustom1()).isEqualTo("VNR");
assertThat(classification.getCustom2()).isEqualTo("custom2");
assertThat(classification.getCustom3()).isEqualTo("custom3");
assertThat(classification.getCustom4()).isEqualTo("custom4");
assertThat(classification.getCustom5()).isEqualTo("custom5");
assertThat(classification.getCustom6()).isEqualTo("custom6");
assertThat(classification.getCustom7()).isEqualTo("custom7");
assertThat(classification.getCustom8()).isEqualTo("custom8");
assertThat(classification.getCustomAttribute(CUSTOM_1)).isEqualTo("VNR");
assertThat(classification.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(classification.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(classification.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
assertThat(classification.getCustomAttribute(CUSTOM_5)).isEqualTo("custom5");
assertThat(classification.getCustomAttribute(CUSTOM_6)).isEqualTo("custom6");
assertThat(classification.getCustomAttribute(CUSTOM_7)).isEqualTo("custom7");
assertThat(classification.getCustomAttribute(CUSTOM_8)).isEqualTo("custom8");
}
@Test
@ -68,14 +76,14 @@ class GetClassificationAccTest extends AbstractAccTest {
assertThat(classification.getPriority()).isEqualTo(2);
assertThat(classification.getServiceLevel()).isEqualTo("P2D");
assertThat(classification.getApplicationEntryPoint()).isEqualTo("point0815");
assertThat(classification.getCustom1()).isEqualTo("VNR");
assertThat(classification.getCustom2()).isEqualTo("custom2");
assertThat(classification.getCustom3()).isEqualTo("custom3");
assertThat(classification.getCustom4()).isEqualTo("custom4");
assertThat(classification.getCustom5()).isEqualTo("custom5");
assertThat(classification.getCustom6()).isEqualTo("custom6");
assertThat(classification.getCustom7()).isEqualTo("custom7");
assertThat(classification.getCustom8()).isEqualTo("custom8");
assertThat(classification.getCustomAttribute(CUSTOM_1)).isEqualTo("VNR");
assertThat(classification.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(classification.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(classification.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
assertThat(classification.getCustomAttribute(CUSTOM_5)).isEqualTo("custom5");
assertThat(classification.getCustomAttribute(CUSTOM_6)).isEqualTo("custom6");
assertThat(classification.getCustomAttribute(CUSTOM_7)).isEqualTo("custom7");
assertThat(classification.getCustomAttribute(CUSTOM_8)).isEqualTo("custom8");
}
@Test

View File

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

View File

@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.classification.api.models.Classification;
@ -48,14 +49,14 @@ class UpdateClassificationAccTest extends AbstractAccTest {
classification.setApplicationEntryPoint(newEntryPoint);
classification.setCategory("PROCESS");
classification.setCustom1("newCustom1");
classification.setCustom2("newCustom2");
classification.setCustom3("newCustom3");
classification.setCustom4("newCustom4");
classification.setCustom5("newCustom5");
classification.setCustom6("newCustom6");
classification.setCustom7("newCustom7");
classification.setCustom8("newCustom8");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_1, "newCustom1");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_2, "newCustom2");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_3, "newCustom3");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_4, "newCustom4");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_5, "newCustom5");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_6, "newCustom6");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_7, "newCustom7");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_8, "newCustom8");
classification.setDescription("newDescription");
classification.setIsValidInDomain(false);
classification.setName(newName);
@ -79,7 +80,7 @@ class UpdateClassificationAccTest extends AbstractAccTest {
@Test
void should_ThrowException_When_UserIsNotAuthorized() throws Exception {
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
classification.setCustom1("newCustom1");
classification.setCustomAttribute(ClassificationCustomField.CUSTOM_1, "newCustom1");
ThrowingCallable call = () -> classificationService.updateClassification(classification);
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.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Task;
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.WorkbasketType;
import pro.taskana.workbasket.api.models.Workbasket;
@ -61,10 +64,10 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
for (int i = 1; i < 16; i++) {
newTask.setCustomAttribute(Integer.toString(i), "VALUE " + i);
for (TaskCustomField taskCustomField : TaskCustomField.values()) {
newTask.setCustomAttribute(taskCustomField, taskCustomField.name());
}
newTask.setCustomAttributes(createSimpleCustomProperties(5));
newTask.setCustomAttributeMap(createSimpleCustomPropertyMap(5));
newTask.setDescription("Description of test task");
newTask.setNote("My note");
newTask.addAttachment(
@ -78,7 +81,7 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
TimeZone originalZone = TimeZone.getDefault();
Task createdTask = taskService.createTask(newTask);
@ -134,7 +137,7 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000001");
workbasket.setCustom1("bla");
workbasket.setCustomAttribute(WorkbasketCustomField.CUSTOM_1, "bla");
TimeZone originalZone = TimeZone.getDefault();
Workbasket updatedWorkbasket = workbasketService.updateWorkbasket(workbasket);
@ -157,7 +160,7 @@ class UpdateObjectsUseUtcTimeStampsAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2");
wbai.setPermRead(true);
wbai.setPermission(WorkbasketPermission.READ, true);
workbasketService.createWorkbasketAccessItem(wbai);
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.WithAccessId;
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. */
@ExtendWith(JaasExtension.class)
@ -29,7 +29,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
() -> {
monitorService
.createWorkbasketReportBuilder()
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_2);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_2);
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@ -43,7 +43,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
monitorService
.createWorkbasketReportBuilder()
.workbasketIdIn(Collections.singletonList("WBI:000000000000000000000000000000000001"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_2);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_2);
assertThat(values).containsOnly("Vollkasko", "Teilkasko");
}
@ -57,7 +57,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
monitorService
.createWorkbasketReportBuilder()
.domainIn(Collections.singletonList("DOMAIN_A"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_16);
assertThat(values).hasSize(26);
}
@ -66,15 +66,15 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
void testGetCustomAttributeValuesForCustomAttribute() throws Exception {
MonitorService monitorService = taskanaEngine.getMonitorService();
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_2, "Vollkasko");
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_2, "Vollkasko");
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<String> values =
monitorService
.createClassificationCategoryReportBuilder()
.customAttributeFilterIn(customAttributeFilter)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_16);
assertThat(values).hasSize(12);
}
@ -92,7 +92,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
.domainIn(domains)
.excludedClassificationIdIn(
Collections.singletonList("CLI:000000000000000000000000000000000003"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_16);
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.SelectedItem;
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;
/** Acceptance test for all "get task ids of category report" scenarios. */
@ -272,8 +272,8 @@ class GetTaskIdsOfClassificationCategoryReportAccTest extends AbstractReportAccT
void testGetTaskIdsOfCategoryReportWithCustomFieldValueFilter() throws Exception {
final MonitorService monitorService = taskanaEngine.getMonitorService();
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
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.SelectedItem;
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;
/** Acceptance test for all "get task ids of category report" scenarios. */
@ExtendWith(JaasExtension.class)
class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
class GetTaskIdsOfTaskCustomFieldValueReportAccTest extends AbstractReportAccTest {
@Test
void testRoleCheck() {
@ -34,11 +34,10 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<SelectedItem> selectedItems = new ArrayList<>();
ThrowingCallable call =
() -> {
monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.listTaskIdsForSelectedItems(selectedItems);
};
() ->
monitorService
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.listTaskIdsForSelectedItems(selectedItems);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@ -71,7 +70,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids =
monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.listTaskIdsForSelectedItems(selectedItems);
@ -119,7 +118,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids =
monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.workbasketIdIn(workbasketIds)
@ -161,7 +160,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids =
monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.stateIn(Collections.singletonList(TaskState.READY))
@ -208,7 +207,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids =
monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.classificationCategoryIn(categories)
@ -249,7 +248,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids =
monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.domainIn(Collections.singletonList("DOMAIN_A"))
@ -266,8 +265,8 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testGetTaskIdsOfCustomFieldValueReportWithCustomFieldValueFilter() throws Exception {
final MonitorService monitorService = taskanaEngine.getMonitorService();
final Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
final Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
final List<SelectedItem> selectedItems = new ArrayList<>();
@ -292,7 +291,7 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> ids =
monitorService
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.customAttributeFilterIn(customAttributeFilter)
@ -322,12 +321,11 @@ class GetTaskIdsOfCustomFieldValueReportAccTest extends AbstractReportAccTest {
selectedItems.add(s1);
ThrowingCallable call =
() -> {
monitorService
.createClassificationCategoryReportBuilder()
.withColumnHeaders(columnHeaders)
.listTaskIdsForSelectedItems(selectedItems);
};
() ->
monitorService
.createClassificationCategoryReportBuilder()
.withColumnHeaders(columnHeaders)
.listTaskIdsForSelectedItems(selectedItems);
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.reports.ClassificationCategoryReport;
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;
/** Acceptance test for all "category report" scenarios. */
@ -295,8 +295,8 @@ class ProvideClassificationCategoryReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void testEachItemOfCategoryReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
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.reports.ClassificationReport;
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;
/** Acceptance test for all "classification report" scenarios. */
@ -332,8 +332,8 @@ class ProvideClassificationReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void testEachItemOfClassificationReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
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.FoldableRow;
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;
/** Acceptance test for all "detailed classification report" scenarios. */
@ -556,8 +556,8 @@ class ProvideDetailedClassificationReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void testEachItemOfDetailedClassificationReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
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.monitor.api.MonitorService;
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.task.api.CustomField;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState;
/** Acceptance test for all "classification report" scenarios. */
@ExtendWith(JaasExtension.class)
class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
class ProvideTaskCustomFieldValueReportAccTest extends AbstractReportAccTest {
private static final MonitorService MONITOR_SERVICE = taskanaEngine.getMonitorService();
@ -39,7 +39,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testRoleCheck() {
ThrowingCallable call =
() -> {
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1).buildReport();
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.buildReport();
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@ -47,8 +49,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void should_augmentDisplayNames_When_ReportIsBuild() throws Exception {
CustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1).buildReport();
TaskCustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1).buildReport();
assertThat(report.getRows()).hasSize(3);
assertThat(report.getRow("Geschaeftsstelle A").getDisplayName())
@ -62,8 +64,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void testGetTotalNumbersOfTasksOfCustomFieldValueReportForCustom1() throws Exception {
CustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1).buildReport();
TaskCustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1).buildReport();
assertThat(report).isNotNull();
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 B").getTotalValue()).isEqualTo(10);
assertThat(report.getRow("Geschaeftsstelle C").getTotalValue()).isEqualTo(15);
assertThat(report.getRow("Geschaeftsstelle A").getCells().length).isEqualTo(0);
assertThat(report.getRow("Geschaeftsstelle B").getCells().length).isEqualTo(0);
assertThat(report.getRow("Geschaeftsstelle C").getCells().length).isEqualTo(0);
assertThat(report.getRow("Geschaeftsstelle A").getCells()).isEmpty();
assertThat(report.getRow("Geschaeftsstelle B").getCells()).isEmpty();
assertThat(report.getRow("Geschaeftsstelle C").getCells()).isEmpty();
assertThat(report.getSumRow().getTotalValue()).isEqualTo(50);
}
@ -81,8 +83,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void testGetTotalNumbersOfTasksOfCustomFieldValueReportForCustom2() throws Exception {
CustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(CustomField.CUSTOM_2).buildReport();
TaskCustomFieldValueReport report =
MONITOR_SERVICE.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_2).buildReport();
assertThat(report).isNotNull();
assertThat(report.rowSize()).isEqualTo(2);
@ -90,8 +92,8 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
assertThat(report.getRow("Vollkasko").getTotalValue()).isEqualTo(21);
assertThat(report.getRow("Teilkasko").getTotalValue()).isEqualTo(29);
assertThat(report.getRow("Vollkasko").getCells().length).isEqualTo(0);
assertThat(report.getRow("Teilkasko").getCells().length).isEqualTo(0);
assertThat(report.getRow("Vollkasko").getCells()).isEmpty();
assertThat(report.getRow("Teilkasko").getCells()).isEmpty();
assertThat(report.getSumRow().getTotalValue()).isEqualTo(50);
}
@ -99,12 +101,12 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void testGetCustomFieldValueReportWithReportLineItemDefinitions() throws Exception {
CustomField customField = CustomField.CUSTOM_1;
TaskCustomField taskCustomField = TaskCustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(customField)
.createCustomFieldValueReportBuilder(taskCustomField)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
@ -130,7 +132,7 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
ThrowingCallable callable =
() ->
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.buildReport(timestamp);
assertThatCode(callable).doesNotThrowAnyException();
};
@ -142,9 +144,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testEachItemOfCustomFieldValueReport() throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
@ -167,9 +169,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void should_computeNumbersAccordingToPlannedDate_When_BuildReportForPlanned() throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport(TaskTimestamp.PLANNED);
@ -192,9 +194,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
void testEachItemOfCustomFieldValueReportNotInWorkingDays() throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.buildReport();
@ -218,9 +220,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.workbasketIdIn(workbasketIds)
@ -245,9 +247,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<TaskState> states = Collections.singletonList(TaskState.READY);
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.stateIn(states)
@ -272,9 +274,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.classificationCategoryIn(categories)
@ -299,9 +301,9 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
List<String> domains = Collections.singletonList("DOMAIN_A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.domainIn(domains)
@ -323,13 +325,13 @@ class ProvideCustomFieldValueReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void testEachItemOfCustomFieldValueReportWithCustomFieldValueFilter() throws Exception {
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report =
TaskCustomFieldValueReport report =
MONITOR_SERVICE
.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.inWorkingDays()

View File

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

View File

@ -20,10 +20,6 @@ import pro.taskana.common.internal.security.WithAccessId;
@ExtendWith(JaasExtension.class)
class ClassificationQueryAccTest extends AbstractAccTest {
ClassificationQueryAccTest() {
super();
}
@Test
void testFindClassificationsByDomainUnauthenticated() {
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.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
@ -174,8 +175,8 @@ class CreateTaskAccTest extends AbstractAccTest {
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Map<String, String> customAttributesForCreate = createSimpleCustomProperties(13);
newTask.setCustomAttributes(customAttributesForCreate);
Map<String, String> customAttributesForCreate = createSimpleCustomPropertyMap(13);
newTask.setCustomAttributeMap(customAttributesForCreate);
Task createdTask = taskService.createTask(newTask);
Instant expectedPlanned = moveForwardToWorkingDay(createdTask.getCreated());
@ -226,7 +227,7 @@ class CreateTaskAccTest extends AbstractAccTest {
}
// verify that the map is correctly retrieved from the database
Task retrievedTask = taskService.getTask(createdTask.getId());
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes();
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributeMap();
assertThat(customAttributesFromDb).isNotNull();
assertThat(customAttributesForCreate).isEqualTo(customAttributesFromDb);
}
@ -237,7 +238,7 @@ class CreateTaskAccTest extends AbstractAccTest {
Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A");
newTask.setClassificationKey("L12010");
Map<String, String> customAttributesForCreate = createSimpleCustomProperties(27);
Map<String, String> customAttributesForCreate = createSimpleCustomPropertyMap(27);
newTask.addAttachment(
createAttachment(
"DOCTYPE_DEFAULT",
@ -309,7 +310,7 @@ class CreateTaskAccTest extends AbstractAccTest {
assertThat(readTask.getAttachments().get(0).getObjectReference()).isNotNull();
// verify that the map is correctly retrieved from the database
Map<String, String> customAttributesFromDb =
readTask.getAttachments().get(0).getCustomAttributes();
readTask.getAttachments().get(0).getCustomAttributeMap();
assertThat(customAttributesFromDb).isNotNull();
assertThat(customAttributesForCreate).isEqualTo(customAttributesFromDb);
}
@ -333,7 +334,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
newTask.addAttachment(
createAttachment(
"DOCTYPE_DEFAULT",
@ -345,7 +346,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask);
assertThat(createdTask.getId()).isNotNull();
@ -384,7 +385,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
newTask.addAttachment(
createAttachment(
"L1060", // prio 1, SL P1D
@ -396,7 +397,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask);
assertThat(createdTask.getId()).isNotNull();
@ -439,7 +440,7 @@ class CreateTaskAccTest extends AbstractAccTest {
testCreateTask.accept(
createAttachment(
"DOCTYPE_DEFAULT", null, "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
"DOCTYPE_DEFAULT", null, "E-MAIL", "2018-01-15", createSimpleCustomPropertyMap(3)));
testCreateTask.accept(
createAttachment(
@ -447,7 +448,7 @@ class CreateTaskAccTest extends AbstractAccTest {
createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", null),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
testCreateTask.accept(
createAttachment(
@ -460,7 +461,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
testCreateTask.accept(
createAttachment(
@ -473,7 +474,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
}
@WithAccessId(user = "user-1-1")
@ -588,10 +589,10 @@ class CreateTaskAccTest extends AbstractAccTest {
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
for (int i = 1; i < 16; i++) {
newTask.setCustomAttribute(Integer.toString(i), "VALUE " + i);
for (TaskCustomField taskCustomField : TaskCustomField.values()) {
newTask.setCustomAttribute(taskCustomField, taskCustomField.name());
}
newTask.setCustomAttributes(createSimpleCustomProperties(5));
newTask.setCustomAttributeMap(createSimpleCustomPropertyMap(5));
newTask.setDescription("Description of test task");
newTask.setNote("My note");
newTask.addAttachment(
@ -605,7 +606,7 @@ class CreateTaskAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask);
Task readTask = taskService.getTask(createdTask.getId());
@ -621,7 +622,7 @@ class CreateTaskAccTest extends AbstractAccTest {
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Map<String, String> callbackInfo = createSimpleCustomProperties(10);
Map<String, String> callbackInfo = createSimpleCustomPropertyMap(10);
newTask.setCallbackInfo(callbackInfo);
Task createdTask = taskService.createTask(newTask);
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.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
@ -59,23 +60,23 @@ class GetTaskAccTest extends AbstractAccTest {
assertThat(task.isRead()).isTrue();
assertThat(task.isTransferred()).isFalse();
assertThat(task.getCallbackInfo()).isEqualTo(new HashMap<String, String>());
assertThat(task.getCustomAttributes()).isEqualTo(new HashMap<String, String>());
assertThat(task.getCustomAttribute("1")).isEqualTo("custom1");
assertThat(task.getCustomAttribute("2")).isEqualTo("custom2");
assertThat(task.getCustomAttribute("3")).isEqualTo("custom3");
assertThat(task.getCustomAttribute("4")).isEqualTo("custom4");
assertThat(task.getCustomAttribute("5")).isEqualTo("custom5");
assertThat(task.getCustomAttribute("6")).isEqualTo("custom6");
assertThat(task.getCustomAttribute("7")).isEqualTo("custom7");
assertThat(task.getCustomAttribute("8")).isEqualTo("custom8");
assertThat(task.getCustomAttribute("9")).isEqualTo("custom9");
assertThat(task.getCustomAttribute("10")).isEqualTo("custom10");
assertThat(task.getCustomAttribute("11")).isEqualTo("custom11");
assertThat(task.getCustomAttribute("12")).isEqualTo("custom12");
assertThat(task.getCustomAttribute("13")).isEqualTo("custom13");
assertThat(task.getCustomAttribute("14")).isEqualTo("abc");
assertThat(task.getCustomAttribute("15")).isEqualTo("custom15");
assertThat(task.getCustomAttribute("16")).isEqualTo("custom16");
assertThat(task.getCustomAttributeMap()).isEqualTo(new HashMap<String, String>());
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_1)).isEqualTo("custom1");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_2)).isEqualTo("custom2");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_3)).isEqualTo("custom3");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_4)).isEqualTo("custom4");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_5)).isEqualTo("custom5");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_6)).isEqualTo("custom6");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_7)).isEqualTo("custom7");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_8)).isEqualTo("custom8");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_9)).isEqualTo("custom9");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_10)).isEqualTo("custom10");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_11)).isEqualTo("custom11");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_12)).isEqualTo("custom12");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_13)).isEqualTo("custom13");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_14)).isEqualTo("abc");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_15)).isEqualTo("custom15");
assertThat(task.getCustomAttribute(TaskCustomField.CUSTOM_16)).isEqualTo("custom16");
}
@WithAccessId(user = "user-1-1")
@ -83,8 +84,6 @@ class GetTaskAccTest extends AbstractAccTest {
void should_ThrowException_When_RequestedTaskByIdIsNotExisting() {
TaskService taskService = taskanaEngine.getTaskService();
// Assertions.assertThrows(TaskNotFoundException.class, () ->
// taskService.getTask("INVALID"));
ThrowingCallable call =
() -> {
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.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Attachment;
import pro.taskana.task.api.models.AttachmentSummary;
@ -96,7 +97,7 @@ class QueryTaskWithAttachmentAccTest extends AbstractAccTest {
taskService
.createTaskQuery()
.classificationKeyIn("T2000")
.customAttributeIn("1", "custom1")
.customAttributeIn(TaskCustomField.CUSTOM_1, "custom1")
.list();
assertThat(tasks).hasSize(1);
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 pro.taskana.common.api.BaseQuery.SortDirection.ASCENDING;
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_CLASSIFICATION_ID;
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.Map;
import java.util.Objects;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.apache.ibatis.session.Configuration;
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.WithAccessId;
import pro.taskana.common.internal.util.Triplet;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskQuery;
import pro.taskana.task.api.TaskQueryColumnName;
import pro.taskana.task.api.TaskService;
@ -224,7 +224,7 @@ class QueryTasksAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3));
createSimpleCustomPropertyMap(3));
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.addAttachment(attachment);
@ -266,49 +266,51 @@ class QueryTasksAccTest extends AbstractAccTest {
@WithAccessId(user = "admin")
@TestFactory
Stream<DynamicTest> testQueryForCustomX() {
List<Triplet<String, String[], Integer>> list =
List<Triplet<TaskCustomField, String[], Integer>> list =
Arrays.asList(
new Triplet<>("1", new String[] {"custom%", "p%", "%xyz%", "efg"}, 3),
new Triplet<>("2", new String[] {"custom%", "a%"}, 2),
new Triplet<>("3", new String[] {"ffg"}, 1),
new Triplet<>("4", new String[] {"%ust%", "%ty"}, 2),
new Triplet<>("5", new String[] {"ew", "al"}, 6),
new Triplet<>("6", new String[] {"%custom6%", "%vvg%", "11%"}, 5),
new Triplet<>("7", new String[] {"%"}, 2),
new Triplet<>("8", new String[] {"%"}, 2),
new Triplet<>("9", new String[] {"%"}, 2),
new Triplet<>("10", new String[] {"%"}, 3),
new Triplet<>("11", new String[] {"%"}, 3),
new Triplet<>("12", new String[] {"%"}, 3),
new Triplet<>("13", new String[] {"%"}, 3),
new Triplet<>("14", new String[] {"%"}, 87),
new Triplet<>("15", new String[] {"%"}, 3),
new Triplet<>("16", new String[] {"%"}, 3));
new Triplet<>(
TaskCustomField.CUSTOM_1, new String[] {"custom%", "p%", "%xyz%", "efg"}, 3),
new Triplet<>(TaskCustomField.CUSTOM_2, new String[] {"custom%", "a%"}, 2),
new Triplet<>(TaskCustomField.CUSTOM_3, new String[] {"ffg"}, 1),
new Triplet<>(TaskCustomField.CUSTOM_4, new String[] {"%ust%", "%ty"}, 2),
new Triplet<>(TaskCustomField.CUSTOM_5, new String[] {"ew", "al"}, 6),
new Triplet<>(TaskCustomField.CUSTOM_6, new String[] {"%custom6%", "%vvg%", "11%"}, 5),
new Triplet<>(TaskCustomField.CUSTOM_7, new String[] {"%"}, 2),
new Triplet<>(TaskCustomField.CUSTOM_8, new String[] {"%"}, 2),
new Triplet<>(TaskCustomField.CUSTOM_9, new String[] {"%"}, 2),
new Triplet<>(TaskCustomField.CUSTOM_10, new String[] {"%"}, 3),
new Triplet<>(TaskCustomField.CUSTOM_11, new String[] {"%"}, 3),
new Triplet<>(TaskCustomField.CUSTOM_12, new String[] {"%"}, 3),
new Triplet<>(TaskCustomField.CUSTOM_13, new String[] {"%"}, 3),
new Triplet<>(TaskCustomField.CUSTOM_14, new String[] {"%"}, 87),
new Triplet<>(TaskCustomField.CUSTOM_15, new String[] {"%"}, 3),
new Triplet<>(TaskCustomField.CUSTOM_16, new String[] {"%"}, 3));
assertThat(list).hasSameSizeAs(TaskCustomField.values());
return DynamicTest.stream(
list.iterator(),
t -> ("custom" + t.getLeft()),
t -> t.getLeft().name(),
t -> testQueryForCustomX(t.getLeft(), t.getMiddle(), t.getRight()));
}
void testQueryForCustomX(String customValue, String[] searchArguments, int expectedResult)
throws Exception {
void testQueryForCustomX(
TaskCustomField customField, String[] searchArguments, int expectedResult) throws Exception {
List<TaskSummary> results =
taskService.createTaskQuery().customAttributeLike(customValue, searchArguments).list();
taskService.createTaskQuery().customAttributeLike(customField, searchArguments).list();
assertThat(results).hasSize(expectedResult);
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 =
taskService.createTaskQuery().customAttributeIn(customValue, ids).list();
taskService.createTaskQuery().customAttributeIn(customField, ids).list();
assertThat(result2).hasSize(expectedResult);
}
@WithAccessId(user = "admin")
@Test
void testQueryForCustom7WithExceptionInLike() {
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeLike("7").list())
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeLike(CUSTOM_7).list())
.isInstanceOf(InvalidArgumentException.class);
}
@ -316,23 +318,24 @@ class QueryTasksAccTest extends AbstractAccTest {
@Test
void testQueryForCustom7WithExceptionInIn() throws Exception {
List<TaskSummary> results =
taskService.createTaskQuery().customAttributeLike("7", "fsdhfshk%").list();
taskService.createTaskQuery().customAttributeLike(CUSTOM_7, "fsdhfshk%").list();
assertThat(results).isEmpty();
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeIn("7").list())
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeIn(CUSTOM_7).list())
.isInstanceOf(InvalidArgumentException.class);
}
@WithAccessId(user = "admin")
@Test
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);
String[] ids =
results.stream().map(wrap(t -> t.getCustomAttribute("7"))).toArray(String[]::new);
String[] ids = results.stream().map(t -> t.getCustomAttribute(CUSTOM_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);
}
@ -344,8 +347,8 @@ class QueryTasksAccTest extends AbstractAccTest {
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setClassificationKey("T2100");
Map<String, String> customAttributesForCreate =
createSimpleCustomProperties(20000); // about 1 Meg
newTask.setCustomAttributes(customAttributesForCreate);
createSimpleCustomPropertyMap(20000); // about 1 Meg
newTask.setCustomAttributeMap(customAttributesForCreate);
Task createdTask = taskService.createTask(newTask);
assertThat(createdTask).isNotNull();
@ -369,8 +372,7 @@ class QueryTasksAccTest extends AbstractAccTest {
assertThat(retrievedTask.getId()).isEqualTo(createdTask.getId());
// verify that the map is correctly retrieved from the database
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes();
assertThat(customAttributesFromDb).isNotNull();
Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributeMap();
assertThat(customAttributesFromDb).isEqualTo(customAttributesForCreate);
} finally {
@ -589,35 +591,34 @@ class QueryTasksAccTest extends AbstractAccTest {
@WithAccessId(user = "admin")
@TestFactory
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(
iterator,
s -> String.format("order by custom%s asc", s),
s -> String.format("order by %s asc", s),
s -> testQueryForOrderByCustomX(s, ASCENDING));
}
@WithAccessId(user = "admin")
@TestFactory
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(
iterator,
s -> String.format("order by custom%s desc", s),
s -> String.format("order by %s desc", s),
s -> testQueryForOrderByCustomX(s, DESCENDING));
}
void testQueryForOrderByCustomX(String customValue, SortDirection sortDirection)
throws Exception {
void testQueryForOrderByCustomX(TaskCustomField customField, SortDirection sortDirection) {
List<TaskSummary> results =
taskService.createTaskQuery().orderByCustomAttribute(customValue, sortDirection).list();
taskService.createTaskQuery().orderByCustomAttribute(customField, sortDirection).list();
Comparator<String> comparator =
sortDirection == ASCENDING ? CASE_INSENSITIVE_ORDER : CASE_INSENSITIVE_ORDER.reversed();
assertThat(results)
.hasSizeGreaterThan(2)
.extracting(t -> t.getCustomAttribute(customValue))
.extracting(t -> t.getCustomAttribute(customField))
.filteredOn(Objects::nonNull)
.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.assertThatCode;
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 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.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
@ -120,10 +130,10 @@ class UpdateTaskAccTest extends AbstractAccTest {
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
final Task task2 = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setCustomAttribute("1", "willi");
task.setCustomAttribute(CUSTOM_1, "willi");
Thread.sleep(10);
taskService.updateTask(task);
task2.setCustomAttribute("2", "Walter");
task2.setCustomAttribute(CUSTOM_2, "Walter");
// TODO flaky test ... if speed is too high,
assertThatThrownBy(() -> taskService.updateTask(task2))
.isInstanceOf(ConcurrencyException.class)
@ -184,7 +194,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
@Test
void should_UpdateTask_When_CustomPropertiesOfTaskWereChanged() throws Exception {
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
task.setCustomAttribute("1", "T2100");
task.setCustomAttribute(CUSTOM_1, "T2100");
Task updatedTask = taskService.updateTask(task);
updatedTask = taskService.getTask(updatedTask.getId());
@ -212,11 +222,11 @@ class UpdateTaskAccTest extends AbstractAccTest {
por.setSystemInstance("00");
por.setType("VNR");
por.setValue("22334455");
Map<String, String> customProperties = new HashMap<>();
customProperties.put("7", "This is modifiedValue 7");
customProperties.put("14", null);
customProperties.put("3", "This is modifiedValue 3");
customProperties.put("16", "This is modifiedValue 16");
Map<TaskCustomField, String> customProperties = new HashMap<>();
customProperties.put(CUSTOM_7, "This is modifiedValue 7");
customProperties.put(CUSTOM_14, null);
customProperties.put(CUSTOM_3, "This is modifiedValue 3");
customProperties.put(CUSTOM_16, "This is modifiedValue 16");
List<String> taskIds = taskService.updateTasks(por, customProperties);
assertThat(taskIds).isEmpty();
@ -231,20 +241,20 @@ class UpdateTaskAccTest extends AbstractAccTest {
por.setSystemInstance("00");
por.setType("VNR");
por.setValue("22334455");
Map<String, String> customProperties = new HashMap<>();
customProperties.put("7", "This is modifiedValue 7");
customProperties.put("14", null);
customProperties.put("3", "This is modifiedValue 3");
customProperties.put("16", "This is modifiedValue 16");
Map<TaskCustomField, String> customProperties = new HashMap<>();
customProperties.put(CUSTOM_7, "This is modifiedValue 7");
customProperties.put(CUSTOM_14, null);
customProperties.put(CUSTOM_3, "This is modifiedValue 3");
customProperties.put(CUSTOM_16, "This is modifiedValue 16");
List<String> taskIds = taskService.updateTasks(por, customProperties);
assertThat(taskIds).hasSize(6);
for (String taskId : taskIds) {
Task task = taskService.getTask(taskId);
assertThat(task.getCustomAttribute("3")).isEqualTo("This is modifiedValue 3");
assertThat(task.getCustomAttribute("7")).isEqualTo("This is modifiedValue 7");
assertThat(task.getCustomAttribute("16")).isEqualTo("This is modifiedValue 16");
assertThat(task.getCustomAttribute("14")).isNull();
assertThat(task.getCustomAttribute(CUSTOM_3)).isEqualTo("This is modifiedValue 3");
assertThat(task.getCustomAttribute(CUSTOM_7)).isEqualTo("This is modifiedValue 7");
assertThat(task.getCustomAttribute(CUSTOM_16)).isEqualTo("This is modifiedValue 16");
assertThat(task.getCustomAttribute(CUSTOM_14)).isNull();
}
}
@ -256,21 +266,21 @@ class UpdateTaskAccTest extends AbstractAccTest {
"TKI:000000000000000000000000000000000008",
"TKI:000000000000000000000000000000000009",
"TKI:000000000000000000000000000000000010");
Map<String, String> customProperties = new HashMap<>();
customProperties.put("1", "This is modifiedValue 1");
customProperties.put("5", "This is modifiedValue 5");
customProperties.put("10", "This is modifiedValue 10");
customProperties.put("12", "This is modifiedValue 12");
Map<TaskCustomField, String> customProperties = new HashMap<>();
customProperties.put(CUSTOM_1, "This is modifiedValue 1");
customProperties.put(CUSTOM_5, "This is modifiedValue 5");
customProperties.put(CUSTOM_10, "This is modifiedValue 10");
customProperties.put(CUSTOM_12, "This is modifiedValue 12");
List<String> changedTasks = taskService.updateTasks(taskIds, customProperties);
assertThat(changedTasks).hasSize(3);
for (String taskId : changedTasks) {
Task task = taskService.getTask(taskId);
assertThat(task.getCustomAttribute("1")).isEqualTo("This is modifiedValue 1");
assertThat(task.getCustomAttribute("5")).isEqualTo("This is modifiedValue 5");
assertThat(task.getCustomAttribute("10")).isEqualTo("This is modifiedValue 10");
assertThat(task.getCustomAttribute("12")).isEqualTo("This is modifiedValue 12");
assertThat(task.getCustomAttribute("2")).isNull();
assertThat(task.getCustomAttribute(CUSTOM_1)).isEqualTo("This is modifiedValue 1");
assertThat(task.getCustomAttribute(CUSTOM_5)).isEqualTo("This is modifiedValue 5");
assertThat(task.getCustomAttribute(CUSTOM_10)).isEqualTo("This is modifiedValue 10");
assertThat(task.getCustomAttribute(CUSTOM_12)).isEqualTo("This is modifiedValue 12");
assertThat(task.getCustomAttribute(CUSTOM_2)).isNull();
}
}

View File

@ -56,7 +56,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3));
createSimpleCustomPropertyMap(3));
task.getAttachments().clear();
taskService.updateTask(task);
assertThat(task).isNotNull();
@ -291,7 +291,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"ABC45678901234567890123456789012345678901234567890"),
"ROHRPOST",
"2018-01-15",
createSimpleCustomProperties(4));
createSimpleCustomPropertyMap(4));
task.addAttachment(attachment2);
task = taskService.updateTask(task);
task = taskService.getTask(task.getId());
@ -304,12 +304,12 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
.areExactly(
1,
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"))
.areExactly(
1,
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"));
ClassificationSummary newClassificationSummary =
@ -320,7 +320,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
// modify existing attachment
for (Attachment att : task.getAttachments()) {
att.setClassificationSummary(newClassificationSummary);
if (att.getCustomAttributes().size() == 3) {
if (att.getCustomAttributeMap().size() == 3) {
att.setChannel("FAX");
}
}
@ -337,12 +337,12 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
.areExactly(
1,
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"))
.areExactly(
1,
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"));
}
@ -363,7 +363,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"ABC45678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(4));
createSimpleCustomPropertyMap(4));
task.addAttachment(attachment2);
task = taskService.updateTask(task);
task = taskService.getTask(task.getId());
@ -382,7 +382,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"ABC4567890123456789012345678901234567890DEF"),
"DHL",
"2018-01-15",
createSimpleCustomProperties(4));
createSimpleCustomPropertyMap(4));
// replace existing attachments by new via addAttachment call
task.getAttachments().clear();
@ -425,7 +425,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
newTask.addAttachment(
createAttachment(
"L1060", // prio 1, SL P1D
@ -437,7 +437,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"12345678901234567890123456789012345678901234567890"),
"E-MAIL",
"2018-01-15",
createSimpleCustomProperties(3)));
createSimpleCustomPropertyMap(3)));
Task createdTask = taskService.createTask(newTask);
assertThat(createdTask.getId()).isNotNull();
@ -483,7 +483,7 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
"E-MAIL",
"2018-01-15",
null);
attachment.getCustomAttributes().put("TEST_KEY", "TEST_VALUE");
attachment.getCustomAttributeMap().put("TEST_KEY", "TEST_VALUE");
task.addAttachment(attachment);
taskService.updateTask(task);
Task updatedTask = taskService.getTask("TKI:000000000000000000000000000000000000");
@ -494,6 +494,6 @@ class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
.orElse(null);
assertThat(updatedAttachment).isNotNull();
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.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.TaskImpl;
@ -61,7 +62,7 @@ class TaskRoutingAccTest extends AbstractAccTest {
newTask.setClassificationKey("L12010");
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setCustomAttribute("7", "noRouting");
newTask.setCustomAttribute(TaskCustomField.CUSTOM_7, "noRouting");
assertThatThrownBy(() -> taskService.createTask(newTask))
.isInstanceOf(InvalidArgumentException.class);
}
@ -75,7 +76,7 @@ class TaskRoutingAccTest extends AbstractAccTest {
newTask.setClassificationKey("L12010");
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setCustomAttribute("7", "multipleWorkbaskets");
newTask.setCustomAttribute(TaskCustomField.CUSTOM_7, "multipleWorkbaskets");
assertThatThrownBy(() -> taskService.createTask(newTask))
.isInstanceOf(InvalidArgumentException.class);
}
@ -88,7 +89,6 @@ class TaskRoutingAccTest extends AbstractAccTest {
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
TaskImpl createdTask = (TaskImpl) taskService.createTask(newTask);
return createdTask;
return (TaskImpl) taskService.createTask(newTask);
}
}

View File

@ -1,32 +1,21 @@
package acceptance.taskrouting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.spi.routing.api.TaskRoutingProvider;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.models.Task;
/** This is a sample implementation of TaskRouter. */
public class TestTaskRoutingProviderForDomainA implements TaskRoutingProvider {
private static final Logger LOGGER =
LoggerFactory.getLogger(TestTaskRoutingProviderForDomainA.class);
TaskanaEngine theEngine;
@Override
public void initialize(TaskanaEngine taskanaEngine) {
theEngine = taskanaEngine;
// no-op
}
@Override
public String determineWorkbasketId(Task task) {
String att7 = "";
try {
att7 = task.getCustomAttribute("7");
} catch (InvalidArgumentException ex) {
LOGGER.warn("caught exception ", ex);
}
String att7 = task.getCustomAttribute(TaskCustomField.CUSTOM_7);
if (att7 != null && att7.equals("multipleWorkbaskets")) {
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.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException;
@ -43,7 +44,7 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2");
wbai.setPermRead(true);
wbai.setPermission(WorkbasketPermission.READ, true);
workbasketService.createWorkbasketAccessItem(wbai);
int after = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
@ -109,58 +110,46 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
// missing key
ThrowingCallable call = () -> workbasketService.createWorkbasket(workbasket);
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket))
.isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket2 = workbasketService.newWorkbasket("key", "novatec");
workbasket2.setType(WorkbasketType.GROUP);
workbasket2.setOrgLevel1("company");
// missing name
call =
() -> {
workbasketService.createWorkbasket(workbasket2);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket2))
.isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket3 = workbasketService.newWorkbasket("key", "novatec");
workbasket3.setName("Megabasket");
workbasket3.setOrgLevel1("company");
// missing type
call = () -> workbasketService.createWorkbasket(workbasket3);
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket3))
.isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket4 = workbasketService.newWorkbasket("key", null);
workbasket4.setName("Megabasket");
workbasket4.setType(WorkbasketType.GROUP);
workbasket4.setOrgLevel1("company");
// missing domain
call =
() -> {
workbasketService.createWorkbasket(workbasket4);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket4))
.isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket5 = workbasketService.newWorkbasket("", "novatec");
workbasket5.setName("Megabasket");
workbasket5.setType(WorkbasketType.GROUP);
workbasket5.setOrgLevel1("company");
// empty key
call =
() -> {
workbasketService.createWorkbasket(workbasket5);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket5))
.isInstanceOf(InvalidWorkbasketException.class);
Workbasket workbasket6 = workbasketService.newWorkbasket("key", "novatec");
workbasket6.setName("");
workbasket6.setType(WorkbasketType.GROUP);
workbasket6.setOrgLevel1("company");
// empty name
call =
() -> {
workbasketService.createWorkbasket(workbasket);
};
assertThatThrownBy(call).isInstanceOf(InvalidWorkbasketException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(workbasket))
.isInstanceOf(InvalidWorkbasketException.class);
}
@WithAccessId(user = "businessadmin")
@ -178,11 +167,8 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
duplicateWorkbasketWithSmallX.setName("Personal Workbasket for UID X123456");
duplicateWorkbasketWithSmallX.setType(WorkbasketType.PERSONAL);
ThrowingCallable call =
() -> {
workbasketService.createWorkbasket(duplicateWorkbasketWithSmallX);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketAlreadyExistException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(duplicateWorkbasketWithSmallX))
.isInstanceOf(WorkbasketAlreadyExistException.class);
}
@WithAccessId(user = "businessadmin")
@ -201,18 +187,14 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
sameKeyAndDomain.setType(WorkbasketType.TOPIC);
sameKeyAndDomain.setName("new name");
ThrowingCallable call =
() -> {
workbasketService.createWorkbasket(sameKeyAndDomain);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketAlreadyExistException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasket(sameKeyAndDomain))
.isInstanceOf(WorkbasketAlreadyExistException.class);
}
@WithAccessId(user = "businessadmin")
@Test
void testWorkbasketAccessItemSetName() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
Workbasket workbasket = workbasketService.newWorkbasket("WBAIT1234", "DOMAIN_A");
workbasket.setName("MyNewBasket");
@ -221,7 +203,7 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-1-2");
wbai.setPermRead(true);
wbai.setPermission(WorkbasketPermission.READ, true);
wbai.setAccessName("Karl Napf");
workbasketService.createWorkbasketAccessItem(wbai);
@ -233,7 +215,10 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasketService.getWorkbasketAccessItems(createdWorkbasket.getId());
WorkbasketAccessItem item =
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")
@ -248,13 +233,10 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai =
workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user-3-2");
wbai.setPermRead(true);
wbai.setPermission(WorkbasketPermission.READ, true);
workbasketService.createWorkbasketAccessItem(wbai);
ThrowingCallable call =
() -> {
workbasketService.createWorkbasketAccessItem(wbai);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketAccessItemAlreadyExistException.class);
assertThatThrownBy(() -> workbasketService.createWorkbasketAccessItem(wbai))
.isInstanceOf(WorkbasketAccessItemAlreadyExistException.class);
}
}

View File

@ -3,13 +3,13 @@ package acceptance.workbasket;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
@ -25,13 +25,10 @@ class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000001", "user1");
accessItem.setPermAppend(true);
accessItem.setPermCustom11(true);
accessItem.setPermRead(true);
ThrowingCallable call =
() -> {
workbasketService.createWorkbasketAccessItem(accessItem);
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermission(WorkbasketPermission.CUSTOM_11, true);
accessItem.setPermission(WorkbasketPermission.READ, true);
assertThatThrownBy(() -> workbasketService.createWorkbasketAccessItem(accessItem))
.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.task.api.TaskService;
import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
@ -75,12 +76,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test
void testGetWorkbasketNotAuthorized() {
ThrowingCallable call =
() -> {
workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A");
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
assertThatThrownBy(() -> workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A"))
.isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "businessadmin")
@ -109,22 +106,14 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test
void testDeleteWorkbasketWithNullOrEmptyParam() {
// Test Null-Value
ThrowingCallable call =
() -> {
workbasketService.deleteWorkbasket(null);
};
assertThatThrownBy(call)
assertThatThrownBy(() -> workbasketService.deleteWorkbasket(null))
.describedAs(
"delete() should have thrown an InvalidArgumentException, "
+ "when the param ID is null.")
.isInstanceOf(InvalidArgumentException.class);
// Test EMPTY-Value
call =
() -> {
workbasketService.deleteWorkbasket("");
};
assertThatThrownBy(call)
assertThatThrownBy(() -> workbasketService.deleteWorkbasket(""))
.describedAs(
"delete() should have thrown an InvalidArgumentException, \"\n"
+ " + \"when the param ID is EMPTY-String.")
@ -134,11 +123,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "businessadmin")
@Test
void testDeleteWorkbasketButNotExisting() {
ThrowingCallable call =
() -> {
workbasketService.deleteWorkbasket("SOME NOT EXISTING ID");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
assertThatThrownBy(() -> workbasketService.deleteWorkbasket("SOME NOT EXISTING ID"))
.isInstanceOf(WorkbasketNotFoundException.class);
}
@WithAccessId(user = "user-1-2", groups = "businessadmin")
@ -146,11 +132,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
void testDeleteWorkbasketWhichIsUsed() throws Exception {
Workbasket wb =
workbasketService.getWorkbasket("user-1-2", "DOMAIN_A"); // all rights, DOMAIN_A with Tasks
ThrowingCallable call =
() -> {
workbasketService.deleteWorkbasket(wb.getId());
};
assertThatThrownBy(call).isInstanceOf(WorkbasketInUseException.class);
assertThatThrownBy(() -> workbasketService.deleteWorkbasket(wb.getId()))
.isInstanceOf(WorkbasketInUseException.class);
}
@WithAccessId(user = "businessadmin")
@ -160,14 +143,14 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
String wbId = wb.getId();
// create 2 access Items
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wbId, "TEAMLEAD-2");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem);
accessItem = workbasketService.newWorkbasketAccessItem(wbId, "elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem);
List<WorkbasketAccessItem> accessItemsBefore = workbasketService.getWorkbasketAccessItems(wbId);
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.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 java.util.List;
@ -24,17 +28,14 @@ import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ExtendWith(JaasExtension.class)
class GetWorkbasketAccTest extends AbstractAccTest {
GetWorkbasketAccTest() {
super();
}
private static final WorkbasketService WORKBASKET_SERVICE = taskanaEngine.getWorkbasketService();
@WithAccessId(user = "user-1-2")
@Test
void testGetWorkbasketById() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007");
WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000007");
assertThat(workbasket.getDomain()).isEqualTo("DOMAIN_A");
assertThat(workbasket.getDescription()).isEqualTo("PPK User 2 KSC 1");
@ -46,10 +47,10 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(workbasket.getOrgLevel2()).isEqualTo("abteilung");
assertThat(workbasket.getOrgLevel3()).isEqualTo("projekt");
assertThat(workbasket.getOrgLevel4()).isEqualTo("team");
assertThat(workbasket.getCustom1()).isEqualTo("custom1");
assertThat(workbasket.getCustom2()).isEqualTo("custom2");
assertThat(workbasket.getCustom3()).isEqualTo("custom3");
assertThat(workbasket.getCustom4()).isEqualTo("custom4");
assertThat(workbasket.getCustomAttribute(CUSTOM_1)).isEqualTo("custom1");
assertThat(workbasket.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(workbasket.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(workbasket.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
}
@WithAccessId(user = "admin")
@ -59,10 +60,8 @@ class GetWorkbasketAccTest extends AbstractAccTest {
void should_ReturnWorkbasketByKeyAndDomain_When_NoExplicitPermissionButUserHasAdministrativeRole()
throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket retrievedWorkbasket =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007");
WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000007");
assertThat(retrievedWorkbasket).isNotNull();
assertThat(retrievedWorkbasket.getOwner()).isEqualTo("Peter Maier");
@ -75,9 +74,7 @@ class GetWorkbasketAccTest extends AbstractAccTest {
void should_ReturnWorkbasketById_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket retrievedWorkbasket = workbasketService.getWorkbasket("USER-1-2", "DOMAIN_A");
Workbasket retrievedWorkbasket = WORKBASKET_SERVICE.getWorkbasket("USER-1-2", "DOMAIN_A");
assertThat(retrievedWorkbasket.getOwner()).isEqualTo("Peter Maier");
assertThat(retrievedWorkbasket).isNotNull();
@ -86,9 +83,8 @@ class GetWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "user-1-2")
@Test
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.getDescription()).isEqualTo("PPK User 2 KSC 1");
@ -99,18 +95,17 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(workbasket.getOrgLevel2()).isEqualTo("abteilung");
assertThat(workbasket.getOrgLevel3()).isEqualTo("projekt");
assertThat(workbasket.getOrgLevel4()).isEqualTo("team");
assertThat(workbasket.getCustom1()).isEqualTo("custom1");
assertThat(workbasket.getCustom2()).isEqualTo("custom2");
assertThat(workbasket.getCustom3()).isEqualTo("custom3");
assertThat(workbasket.getCustom4()).isEqualTo("custom4");
assertThat(workbasket.getCustomAttribute(CUSTOM_1)).isEqualTo("custom1");
assertThat(workbasket.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(workbasket.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(workbasket.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
}
@WithAccessId(user = "user-1-1", groups = GROUP_1_DN)
@Test
void testGetWorkbasketPermissions() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketPermission> permissions =
workbasketService.getPermissionsForWorkbasket("WBI:100000000000000000000000000000000007");
WORKBASKET_SERVICE.getPermissionsForWorkbasket("WBI:100000000000000000000000000000000007");
assertThat(permissions).hasSize(4);
assertThat(permissions.contains(WorkbasketPermission.READ)).isTrue();
@ -122,9 +117,8 @@ class GetWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "user-1-1")
@Test
void testGetWorkbasketPermissionsForInvalidWorkbasketId() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketPermission> permissions =
workbasketService.getPermissionsForWorkbasket("WBI:invalid");
WORKBASKET_SERVICE.getPermissionsForWorkbasket("WBI:invalid");
assertThat(permissions).isEmpty();
}
@ -132,10 +126,9 @@ class GetWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "user-1-2")
@Test
void testGetWorkbasketAsSummary() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketSummary workbasketSummary =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007").asSummary();
WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000007").asSummary();
assertThat(workbasketSummary.getDomain()).isEqualTo("DOMAIN_A");
assertThat(workbasketSummary.getDescription()).isEqualTo("PPK User 2 KSC 1");
@ -147,62 +140,43 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(workbasketSummary.getOrgLevel2()).isEqualTo("abteilung");
assertThat(workbasketSummary.getOrgLevel3()).isEqualTo("projekt");
assertThat(workbasketSummary.getOrgLevel4()).isEqualTo("team");
assertThat(workbasketSummary.getCustom1()).isEqualTo("custom1");
assertThat(workbasketSummary.getCustom2()).isEqualTo("custom2");
assertThat(workbasketSummary.getCustom3()).isEqualTo("custom3");
assertThat(workbasketSummary.getCustom4()).isEqualTo("custom4");
assertThat(workbasketSummary.getCustomAttribute(CUSTOM_1)).isEqualTo("custom1");
assertThat(workbasketSummary.getCustomAttribute(CUSTOM_2)).isEqualTo("custom2");
assertThat(workbasketSummary.getCustomAttribute(CUSTOM_3)).isEqualTo("custom3");
assertThat(workbasketSummary.getCustomAttribute(CUSTOM_4)).isEqualTo("custom4");
assertThat(workbasketSummary.isMarkedForDeletion()).isEqualTo(false);
}
@Test
void testThrowsExceptionIfIdIsInvalid() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.getWorkbasket("INVALID_ID");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("INVALID_ID"))
.isInstanceOf(WorkbasketNotFoundException.class);
}
@Test
void testThrowsExceptionIfKeyOrDomainIsInvalid() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.getWorkbasket("INVALID_KEY", "INVALID_DOMAIN");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("INVALID_KEY", "INVALID_DOMAIN"))
.isInstanceOf(WorkbasketNotFoundException.class);
}
@Test
void testGetByIdNotAuthorized() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000001");
};
() -> WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000001");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@Test
void testGetByKeyDomainNotAuthorized() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("GPK_KSC", "DOMAIN_A"))
.isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "user-1-1")
@Test
void testGetWorkbasketByIdNotExisting() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.getWorkbasket("NOT EXISTING ID");
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("NOT EXISTING ID"))
.isInstanceOf(WorkbasketNotFoundException.class);
}
}

View File

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

View File

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

View File

@ -36,7 +36,7 @@ class PojoTest {
@Test
void testsThatPojoClassesAreFound() {
assertThat(pojoClasses.stream().count() > 0).isTrue();
assertThat(pojoClasses).isNotEmpty();
}
@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;
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;
@ -13,14 +21,14 @@ class ClassificationModelsCloneTest {
Classification dummyClassificationForSummaryTest = new ClassificationImpl();
dummyClassificationForSummaryTest.setApplicationEntryPoint("dummyEntryPoint");
dummyClassificationForSummaryTest.setCategory("dummyCategory");
dummyClassificationForSummaryTest.setCustom1("dummyCustom1");
dummyClassificationForSummaryTest.setCustom2("dummyCustom2");
dummyClassificationForSummaryTest.setCustom3("dummyCustom3");
dummyClassificationForSummaryTest.setCustom4("dummyCustom4");
dummyClassificationForSummaryTest.setCustom5("dummyCustom5");
dummyClassificationForSummaryTest.setCustom6("dummyCustom6");
dummyClassificationForSummaryTest.setCustom7("dummyCustom7");
dummyClassificationForSummaryTest.setCustom8("dummyCustom8");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_1, "dummyCustom1");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_2, "dummyCustom2");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_3, "dummyCustom3");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_4, "dummyCustom4");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_5, "dummyCustom5");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_6, "dummyCustom6");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_7, "dummyCustom7");
dummyClassificationForSummaryTest.setCustomAttribute(CUSTOM_8, "dummyCustom8");
dummyClassificationForSummaryTest.setDescription("dummyDescription");
dummyClassificationForSummaryTest.setIsValidInDomain(true);
dummyClassificationForSummaryTest.setParentId("dummyParentId");
@ -46,14 +54,14 @@ class ClassificationModelsCloneTest {
dummyClassification.setId("dummyId");
dummyClassification.setApplicationEntryPoint("dummyEntryPoint");
dummyClassification.setCategory("dummyCategory");
dummyClassification.setCustom1("dummyCustom1");
dummyClassification.setCustom2("dummyCustom2");
dummyClassification.setCustom3("dummyCustom3");
dummyClassification.setCustom4("dummyCustom4");
dummyClassification.setCustom5("dummyCustom5");
dummyClassification.setCustom6("dummyCustom6");
dummyClassification.setCustom7("dummyCustom7");
dummyClassification.setCustom8("dummyCustom8");
dummyClassification.setCustomAttribute(CUSTOM_1, "dummyCustom1");
dummyClassification.setCustomAttribute(CUSTOM_2, "dummyCustom2");
dummyClassification.setCustomAttribute(CUSTOM_3, "dummyCustom3");
dummyClassification.setCustomAttribute(CUSTOM_4, "dummyCustom4");
dummyClassification.setCustomAttribute(CUSTOM_5, "dummyCustom5");
dummyClassification.setCustomAttribute(CUSTOM_6, "dummyCustom6");
dummyClassification.setCustomAttribute(CUSTOM_7, "dummyCustom7");
dummyClassification.setCustomAttribute(CUSTOM_8, "dummyCustom8");
dummyClassification.setDescription("dummyDescription");
dummyClassification.setIsValidInDomain(true);
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.header.TimeIntervalColumnHeader;
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;
/** Unit Test for CategoryBuilderImpl. */
@ -60,8 +60,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
@ -117,8 +117,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -179,8 +179,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
final Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
final Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -252,8 +252,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -271,7 +271,7 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
classificationIds,
excludedClassificationIds,
customAttributeFilter,
CustomField.CUSTOM_1))
TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult);
final List<String> actualResult =
@ -284,7 +284,7 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection();
verify(internalTaskanaEngineMock, times(2)).getEngine();
@ -307,7 +307,7 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
List<String> result =
cut.createClassificationCategoryReportBuilder()
.workbasketIdIn(Collections.singletonList("DieGibtsSicherNed"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
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.MonitorQueryItem;
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;
/** Unit Test for ClassificationReportBuilderImpl. */
@ -74,8 +74,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
@ -126,7 +126,7 @@ class ClassificationReportBuilderImplTest {
assertThat(actualResult).isNotNull();
assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue())
.isEqualTo(1);
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue());
assertThat(actualResult.getSumRow().getTotalValue()).isOne();
}
@Test
@ -138,8 +138,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -192,10 +192,10 @@ class ClassificationReportBuilderImplTest {
assertThat(actualResult).isNotNull();
assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue())
.isEqualTo(1);
assertThat(1)
.isEqualTo(actualResult.getRow("CLI:000000000000000000000000000000000001").getCells()[0]);
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue());
.isOne();
assertThat(actualResult.getRow("CLI:000000000000000000000000000000000001").getCells())
.isEqualTo(new int[] {1});
assertThat(actualResult.getSumRow().getTotalValue()).isOne();
}
@Test
@ -207,8 +207,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
@ -259,10 +259,10 @@ class ClassificationReportBuilderImplTest {
FoldableRow<DetailedMonitorQueryItem> line =
actualResult.getRow("CLI:000000000000000000000000000000000001");
assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(line.getTotalValue());
assertThat(line.getTotalValue()).isOne();
assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getTotalValue())
.isEqualTo(1);
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue());
.isOne();
assertThat(actualResult.getSumRow().getTotalValue()).isOne();
}
@Test
@ -274,8 +274,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -330,14 +330,14 @@ class ClassificationReportBuilderImplTest {
FoldableRow<DetailedMonitorQueryItem> line =
actualResult.getRow("CLI:000000000000000000000000000000000001");
assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(line.getTotalValue());
assertThat(line.getTotalValue()).isOne();
assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getTotalValue())
.isEqualTo(1);
assertThat(1).isEqualTo(line.getCells()[0]);
assertThat(1)
.isEqualTo(line.getFoldableRow("CLI:000000000000000000000000000000000006").getCells()[0]);
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue());
assertThat(1).isEqualTo(actualResult.getSumRow().getCells()[0]);
.isOne();
assertThat(line.getCells()).isEqualTo(new int[] {1});
assertThat(line.getFoldableRow("CLI:000000000000000000000000000000000006").getCells())
.isEqualTo(new int[] {1});
assertThat(actualResult.getSumRow().getTotalValue()).isOne();
assertThat(actualResult.getSumRow().getCells()).isEqualTo(new int[] {1});
}
@Test
@ -349,8 +349,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -424,8 +424,8 @@ class ClassificationReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -443,7 +443,7 @@ class ClassificationReportBuilderImplTest {
classificationIds,
excludedClassificationIds,
customAttributeFilter,
CustomField.CUSTOM_1))
TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult);
final List<String> actualResult =
@ -456,7 +456,7 @@ class ClassificationReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection();
verify(taskanaEngineMock).checkRoleMembership(any());
@ -478,7 +478,7 @@ class ClassificationReportBuilderImplTest {
List<String> result =
cut.createClassificationReportBuilder()
.workbasketIdIn(Collections.singletonList("DieGibtsGarantiertNed"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_10);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_10);
assertThat(result).isNotNull();
}
}

View File

@ -25,15 +25,15 @@ import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.SelectedItem;
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.item.MonitorQueryItem;
import pro.taskana.task.api.CustomField;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState;
/** Unit Test for CustomFieldValueReportBuilderImpl. */
@ExtendWith(MockitoExtension.class)
class CustomFieldValueReportBuilderImplTest {
class TaskCustomFieldValueReportBuilderImplTest {
@InjectMocks private MonitorServiceImpl cut;
@ -59,8 +59,8 @@ class CustomFieldValueReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
@ -68,7 +68,7 @@ class CustomFieldValueReportBuilderImplTest {
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
when(monitorMapperMock.getTaskCountOfCustomFieldValues(
CustomField.CUSTOM_1,
TaskCustomField.CUSTOM_1,
workbasketIds,
states,
categories,
@ -79,8 +79,8 @@ class CustomFieldValueReportBuilderImplTest {
customAttributeFilter))
.thenReturn(expectedResult);
final CustomFieldValueReport actualResult =
cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
final TaskCustomFieldValueReport actualResult =
cut.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds)
.stateIn(states)
.classificationCategoryIn(categories)
@ -105,8 +105,8 @@ class CustomFieldValueReportBuilderImplTest {
taskanaEngineConfigurationMock);
assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(actualResult.getRow("Geschaeftsstelle A").getTotalValue());
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue());
assertThat(actualResult.getRow("Geschaeftsstelle A").getTotalValue()).isOne();
assertThat(actualResult.getSumRow().getTotalValue()).isOne();
}
@Test
@ -118,8 +118,8 @@ class CustomFieldValueReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -130,7 +130,7 @@ class CustomFieldValueReportBuilderImplTest {
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
when(monitorMapperMock.getTaskCountOfCustomFieldValues(
CustomField.CUSTOM_1,
TaskCustomField.CUSTOM_1,
workbasketIds,
states,
categories,
@ -141,8 +141,8 @@ class CustomFieldValueReportBuilderImplTest {
customAttributeFilter))
.thenReturn(expectedResult);
final CustomFieldValueReport actualResult =
cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
final TaskCustomFieldValueReport actualResult =
cut.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds)
.stateIn(states)
.classificationCategoryIn(categories)
@ -168,9 +168,9 @@ class CustomFieldValueReportBuilderImplTest {
taskanaEngineConfigurationMock);
assertThat(actualResult).isNotNull();
assertThat(1).isEqualTo(actualResult.getRow("Geschaeftsstelle A").getTotalValue());
assertThat(1).isEqualTo(actualResult.getRow("Geschaeftsstelle A").getCells()[0]);
assertThat(1).isEqualTo(actualResult.getSumRow().getTotalValue());
assertThat(actualResult.getRow("Geschaeftsstelle A").getTotalValue()).isOne();
assertThat(actualResult.getRow("Geschaeftsstelle A").getCells()[0]).isOne();
assertThat(actualResult.getSumRow().getTotalValue()).isOne();
}
@Test
@ -182,8 +182,8 @@ class CustomFieldValueReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -201,11 +201,11 @@ class CustomFieldValueReportBuilderImplTest {
classificationIds,
excludedClassificationIds,
customAttributeFilter,
CustomField.CUSTOM_1))
TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult);
final List<String> actualResult =
cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
cut.createCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds)
.stateIn(states)
.classificationCategoryIn(categories)
@ -214,7 +214,7 @@ class CustomFieldValueReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection();
verify(taskanaEngineMock).checkRoleMembership(any());
@ -229,7 +229,6 @@ class CustomFieldValueReportBuilderImplTest {
monitorMapperMock,
taskanaEngineConfigurationMock);
assertThat(actualResult).isNotNull();
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.header.TimeIntervalColumnHeader;
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;
/** Unit Test for WorkbasketReportBuilderImpl. */
@ -62,8 +62,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<CombinedClassificationFilter> combinedClassificationFilter =
Collections.singletonList(
new CombinedClassificationFilter(
@ -126,8 +126,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<CombinedClassificationFilter> combinedClassificationFilter =
Collections.singletonList(
new CombinedClassificationFilter(
@ -195,8 +195,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -271,8 +271,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<TimeIntervalColumnHeader> columnHeaders =
Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
@ -290,7 +290,7 @@ class WorkbasketReportBuilderImplTest {
classificationIds,
excludedClassificationIds,
customAttributeFilter,
CustomField.CUSTOM_1))
TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult);
final List<String> actualResult =
@ -303,7 +303,7 @@ class WorkbasketReportBuilderImplTest {
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
verify(internalTaskanaEngineMock).openConnection();
verify(taskanaEngineMock).checkRoleMembership(any());
@ -324,7 +324,7 @@ class WorkbasketReportBuilderImplTest {
List<String> result =
cut.createWorkbasketReportBuilder()
.workbasketIdIn(Arrays.asList("GibtsSicherNed"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_14);
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_14);
assertThat(result).isNotNull();
}
@ -337,8 +337,8 @@ class WorkbasketReportBuilderImplTest {
final List<String> domains = Collections.singletonList("DOMAIN_A");
final List<String> classificationIds = Collections.singletonList("L10000");
final List<String> excludedClassificationIds = Collections.singletonList("L20000");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
Map<TaskCustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(TaskCustomField.CUSTOM_1, "Geschaeftsstelle A");
final List<CombinedClassificationFilter> combinedClassificationFilter =
Collections.singletonList(
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.util.IdGenerator;
import pro.taskana.sampledata.SampleDataGenerator;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.Workbasket;
@ -50,7 +52,6 @@ class TaskServiceImplIntAutocommitTest {
private static SampleDataGenerator sampleDataGenerator;
private static TaskanaEngineConfiguration taskanaEngineConfiguration;
private DataSource dataSource;
private TaskServiceImpl taskServiceImpl;
private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
@ -132,11 +133,8 @@ class TaskServiceImplIntAutocommitTest {
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
ThrowingCallable call =
() -> {
taskServiceImpl2.getTask(wb.getId());
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
assertThatThrownBy(() -> taskServiceImpl2.getTask(wb.getId()))
.isInstanceOf(TaskNotFoundException.class);
}
@Test
@ -165,7 +163,7 @@ class TaskServiceImplIntAutocommitTest {
.workbasketKeyDomainIn(
new KeyDomain("asd", "novatec"), new KeyDomain("asdasdasd", "DOMAIN_A"))
.ownerIn("test", "test2", "bla")
.customAttributeIn("16", "test")
.customAttributeIn(TaskCustomField.CUSTOM_16, "test")
.classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys")
@ -229,12 +227,8 @@ class TaskServiceImplIntAutocommitTest {
@Test
void shouldNotTransferAnyTask() {
ThrowingCallable call =
() -> {
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
assertThatThrownBy(() -> taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"))
.isInstanceOf(TaskNotFoundException.class);
}
@WithAccessId(user = "user-1-1", groups = "businessadmin")
@ -243,7 +237,7 @@ class TaskServiceImplIntAutocommitTest {
final String user = CurrentUserContext.getUserid();
// Set up Security for this Test
dataSource = TaskanaEngineTestConfiguration.getDataSource();
DataSource dataSource = TaskanaEngineTestConfiguration.getDataSource();
taskanaEngineConfiguration =
new TaskanaEngineConfiguration(
dataSource, false, true, TaskanaEngineTestConfiguration.getSchemaName());
@ -299,9 +293,7 @@ class TaskServiceImplIntAutocommitTest {
TaskImpl taskCreated = (TaskImpl) taskServiceImpl.createTask(task);
ThrowingCallable call =
() -> {
taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
};
() -> taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
assertThatThrownBy(call)
.describedAs(
"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);
call =
() -> {
taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId());
};
assertThatThrownBy(call)
assertThatThrownBy(() -> taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId()))
.describedAs(
"Transfer Task should be FAILED, because there are no TRANSFER-Rights on current WB.")
.isInstanceOf(NotAuthorizedException.class)
@ -376,10 +364,10 @@ class TaskServiceImplIntAutocommitTest {
throws Exception {
WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead);
accessItem.setPermAppend(permAppend);
accessItem.setPermTransfer(permTransfer);
accessItem.setPermission(WorkbasketPermission.OPEN, permOpen);
accessItem.setPermission(WorkbasketPermission.READ, permRead);
accessItem.setPermission(WorkbasketPermission.APPEND, permAppend);
accessItem.setPermission(WorkbasketPermission.TRANSFER, permTransfer);
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.util.IdGenerator;
import pro.taskana.sampledata.SampleDataGenerator;
import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.WorkbasketAccessItemAlreadyExistException;
@ -116,9 +118,9 @@ class TaskServiceImplIntExplicitTest {
taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem);
taskanaEngineImpl.getClassificationService().createClassification(classification);
@ -133,11 +135,8 @@ class TaskServiceImplIntExplicitTest {
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
ThrowingCallable call =
() -> {
taskServiceImpl2.getTask(workbasket.getId());
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
assertThatThrownBy(() -> taskServiceImpl2.getTask(workbasket.getId()))
.isInstanceOf(TaskNotFoundException.class);
connection.commit();
}
}
@ -152,9 +151,9 @@ class TaskServiceImplIntExplicitTest {
connection.commit();
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem);
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
@ -177,11 +176,8 @@ class TaskServiceImplIntExplicitTest {
Task test = this.generateDummyTask();
((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2");
ThrowingCallable call =
() -> {
taskServiceImpl.createTask(test);
};
assertThatThrownBy(call).isInstanceOf(WorkbasketNotFoundException.class);
assertThatThrownBy(() -> taskServiceImpl.createTask(test))
.isInstanceOf(WorkbasketNotFoundException.class);
}
}
@ -208,11 +204,8 @@ class TaskServiceImplIntExplicitTest {
((TaskImpl) task).setWorkbasketSummary(wb.asSummary());
task.setClassificationKey(classification.getKey());
ThrowingCallable call =
() -> {
taskServiceImpl.createTask(task);
};
assertThatThrownBy(call).isInstanceOf(ClassificationNotFoundException.class);
assertThatThrownBy(() -> taskServiceImpl.createTask(task))
.isInstanceOf(ClassificationNotFoundException.class);
}
}
@ -232,9 +225,9 @@ class TaskServiceImplIntExplicitTest {
workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "user-1-1");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
accessItem.setPermission(WorkbasketPermission.APPEND, true);
accessItem.setPermission(WorkbasketPermission.READ, true);
accessItem.setPermission(WorkbasketPermission.OPEN, true);
workbasketService.createWorkbasketAccessItem(accessItem);
Task task = taskServiceImpl.newTask(workbasket.getId());
@ -252,7 +245,7 @@ class TaskServiceImplIntExplicitTest {
.stateIn(TaskState.CLAIMED)
.workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A"))
.ownerIn("test", "test2", "bla")
.customAttributeLike("13", "test")
.customAttributeLike(TaskCustomField.CUSTOM_13, "test")
.classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys")
@ -287,11 +280,10 @@ class TaskServiceImplIntExplicitTest {
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true));
connection.commit();
ThrowingCallable call =
() -> {
workbasketService.createWorkbasketAccessItem(
createWorkbasketWithSecurity(
sourceWB, sourceWB.getOwner(), false, false, false, false));
};
() ->
workbasketService.createWorkbasketAccessItem(
createWorkbasketWithSecurity(
sourceWB, sourceWB.getOwner(), false, false, false, false));
assertThatThrownBy(call).isInstanceOf(WorkbasketAccessItemAlreadyExistException.class);
connection.rollback();
@ -345,11 +337,8 @@ class TaskServiceImplIntExplicitTest {
try (Connection connection = dataSource.getConnection()) {
taskanaEngineImpl.setConnection(connection);
ThrowingCallable call =
() -> {
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
};
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
assertThatThrownBy(() -> taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"))
.isInstanceOf(TaskNotFoundException.class);
}
}
@ -419,9 +408,7 @@ class TaskServiceImplIntExplicitTest {
// Check failing with missing APPEND
ThrowingCallable call =
() -> {
taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
};
() -> taskServiceImpl.transfer(taskCreated.getId(), wbNoAppendCreated.getId());
assertThatThrownBy(call)
.describedAs(
"Transfer Task should be FAILED, "
@ -439,11 +426,7 @@ class TaskServiceImplIntExplicitTest {
taskCreated.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
taskCreated.setExternalId(IdGenerator.generateWithPrefix("TST"));
TaskImpl taskCreated2 = (TaskImpl) taskServiceImpl.createTask(taskCreated);
call =
() -> {
taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId());
};
assertThatThrownBy(call)
assertThatThrownBy(() -> taskServiceImpl.transfer(taskCreated2.getId(), wbCreated.getId()))
.describedAs(
"Transfer Task should be FAILED, because there are no TRANSFER-Rights on current WB.")
.isInstanceOf(NotAuthorizedException.class)
@ -485,10 +468,10 @@ class TaskServiceImplIntExplicitTest {
boolean permTransfer) {
WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead);
accessItem.setPermAppend(permAppend);
accessItem.setPermTransfer(permTransfer);
accessItem.setPermission(WorkbasketPermission.OPEN, permOpen);
accessItem.setPermission(WorkbasketPermission.READ, permRead);
accessItem.setPermission(WorkbasketPermission.APPEND, permAppend);
accessItem.setPermission(WorkbasketPermission.TRANSFER, permTransfer);
return accessItem;
}
}

View File

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

View File

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

View File

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

View File

@ -1,9 +1,14 @@
package pro.taskana.workbasket.internal.models;
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 pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.models.Workbasket;
class WorkbasketModelsCloneTest {
@ -11,10 +16,10 @@ class WorkbasketModelsCloneTest {
@Test
void should_CopyWithoutId_When_WorkbasketSummaryClone() {
Workbasket dummyWorkbasketForSummaryTest = new WorkbasketImpl();
dummyWorkbasketForSummaryTest.setCustom1("dummyCustom1");
dummyWorkbasketForSummaryTest.setCustom2("dummyCustom2");
dummyWorkbasketForSummaryTest.setCustom3("dummyCustom3");
dummyWorkbasketForSummaryTest.setCustom4("dummyCustom4");
dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_1, "dummyCustom1");
dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_2, "dummyCustom2");
dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_3, "dummyCustom3");
dummyWorkbasketForSummaryTest.setCustomAttribute(CUSTOM_4, "dummyCustom4");
dummyWorkbasketForSummaryTest.setDescription("dummyDescription");
dummyWorkbasketForSummaryTest.setMarkedForDeletion(false);
dummyWorkbasketForSummaryTest.setName("dummyName");
@ -65,23 +70,23 @@ class WorkbasketModelsCloneTest {
WorkbasketAccessItemImpl dummyWorkbasketAccessItem = new WorkbasketAccessItemImpl();
dummyWorkbasketAccessItem.setId("dummyId");
dummyWorkbasketAccessItem.setAccessName("dummyAccessName");
dummyWorkbasketAccessItem.setPermAppend(false);
dummyWorkbasketAccessItem.setPermCustom1(false);
dummyWorkbasketAccessItem.setPermCustom2(false);
dummyWorkbasketAccessItem.setPermCustom3(false);
dummyWorkbasketAccessItem.setPermCustom4(false);
dummyWorkbasketAccessItem.setPermCustom5(false);
dummyWorkbasketAccessItem.setPermCustom6(false);
dummyWorkbasketAccessItem.setPermCustom7(false);
dummyWorkbasketAccessItem.setPermCustom8(false);
dummyWorkbasketAccessItem.setPermCustom9(false);
dummyWorkbasketAccessItem.setPermCustom10(false);
dummyWorkbasketAccessItem.setPermCustom11(false);
dummyWorkbasketAccessItem.setPermCustom12(false);
dummyWorkbasketAccessItem.setPermDistribute(false);
dummyWorkbasketAccessItem.setPermOpen(false);
dummyWorkbasketAccessItem.setPermRead(false);
dummyWorkbasketAccessItem.setPermTransfer(false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.OPEN, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.READ, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.APPEND, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.TRANSFER, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.DISTRIBUTE, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_1, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_2, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_3, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_4, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_5, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_6, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_7, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_8, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_9, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_10, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_11, false);
dummyWorkbasketAccessItem.setPermission(WorkbasketPermission.CUSTOM_12, false);
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.RestController;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationQuery;
import pro.taskana.classification.api.ClassificationService;
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 String LIKE = "%";
private static final String NAME = "name";
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 CATEGORY = "category";
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 ClassificationRepresentationModelAssembler modelAssembler;
@ -88,8 +82,8 @@ public class ClassificationController extends AbstractPagingController {
}
ClassificationQuery query = classificationService.createClassificationQuery();
query = applyFilterParams(query, params);
query = applySortingParams(query, params);
applyFilterParams(query, params);
applySortingParams(query, params);
PageMetadata pageMetadata = getPageMetadata(params, query);
List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata);
@ -188,8 +182,7 @@ public class ClassificationController extends AbstractPagingController {
return response;
}
private ClassificationQuery applySortingParams(
ClassificationQuery query, MultiValueMap<String, String> params)
private void applySortingParams(ClassificationQuery query, MultiValueMap<String, String> params)
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(query= {}, params= {})", query, params);
@ -219,11 +212,9 @@ public class ClassificationController extends AbstractPagingController {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applySortingParams(), returning {}", query);
}
return query;
}
private ClassificationQuery applyFilterParams(
ClassificationQuery query, MultiValueMap<String, String> params)
private void applyFilterParams(ClassificationQuery query, MultiValueMap<String, String> params)
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
@ -258,42 +249,21 @@ public class ClassificationController extends AbstractPagingController {
query.typeIn(names);
params.remove(TYPE);
}
if (params.containsKey(CUSTOM_1_LIKE)) {
query.customAttributeLike("1", LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE);
params.remove(CUSTOM_1_LIKE);
}
if (params.containsKey(CUSTOM_2_LIKE)) {
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);
for (ClassificationCustomField customField : ClassificationCustomField.values()) {
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;
}
query.customAttributeLike(customField, customValues);
}
}
if (LOGGER.isDebugEnabled()) {
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