use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskMonitorServiceImplTest method testGetDetailedClassificationReportWithReportLineItemDefinitions.
@Test
public void testGetDetailedClassificationReportWithReportLineItemDefinitions() throws InvalidArgumentException {
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
List<String> categories = Collections.singletonList("EXTERN");
List<String> domains = Collections.singletonList("DOMAIN_A");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
detailedMonitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
detailedMonitorQueryItem.setAttachmentKey("CLI:000000000000000000000000000000000006");
detailedMonitorQueryItem.setAgeInDays(0);
detailedMonitorQueryItem.setNumberOfTasks(1);
expectedResult.add(detailedMonitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfDetailedClassifications(workbasketIds, states, categories, domains, customField, customFieldValues);
DetailedClassificationReport actualResult = cut.getDetailedClassificationReport(workbasketIds, states, categories, domains, customField, customFieldValues, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfDetailedClassifications(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
DetailedReportRow line = actualResult.getRow("CLI:000000000000000000000000000000000001");
assertNotNull(actualResult);
assertEquals(line.getTotalValue(), 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getTotalValue(), 1);
assertEquals(line.getCells()[0], 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getCells()[0], 1);
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskFilter method inspectParams.
public List<TaskSummary> inspectParams(MultiValueMap<String, String> params) throws NotAuthorizedException, InvalidArgumentException {
TaskQuery taskQuery = taskService.createTaskQuery();
// apply filters
if (params.containsKey(NAME)) {
String[] names = extractCommaSeperatedFields(params.get(NAME));
taskQuery.nameIn(names);
}
if (params.containsKey(DESCRIPTION)) {
taskQuery.descriptionLike(params.get(DESCRIPTION).get(0));
}
if (params.containsKey(PRIORITY)) {
String[] prioritesInString = extractCommaSeperatedFields(params.get(PRIORITY));
int[] priorites = extractPriorities(prioritesInString);
taskQuery.priorityIn(priorites);
}
if (params.containsKey(STATE)) {
TaskState[] states = extractStates(params);
taskQuery.stateIn(states);
}
if (params.containsKey(CLASSIFICATION_KEY)) {
String[] classificationKeys = extractCommaSeperatedFields(params.get(CLASSIFICATION_KEY));
taskQuery.classificationKeyIn(classificationKeys);
}
if (params.containsKey(WORKBASKET_ID)) {
String[] workbaskets = extractCommaSeperatedFields(params.get(WORKBASKET_ID));
taskQuery.workbasketIdIn(workbaskets);
}
if (params.containsKey(OWNER)) {
String[] owners = extractCommaSeperatedFields(params.get(OWNER));
taskQuery.ownerIn(owners);
}
// objectReference
if (params.keySet().stream().filter(s -> s.startsWith(POR)).toArray().length > 0) {
if (params.containsKey(POR_COMPANY)) {
String[] companies = extractCommaSeperatedFields(params.get(POR_COMPANY));
taskQuery.primaryObjectReferenceCompanyIn(companies);
}
if (params.containsKey(POR_SYSTEM)) {
String[] systems = extractCommaSeperatedFields(params.get(POR_SYSTEM));
taskQuery.primaryObjectReferenceSystemIn(systems);
}
if (params.containsKey(POR_SYSTEM_INSTANCE)) {
String[] systemInstances = extractCommaSeperatedFields(params.get(POR_SYSTEM_INSTANCE));
taskQuery.primaryObjectReferenceSystemInstanceIn(systemInstances);
}
if (params.containsKey(POR_TYPE)) {
String[] types = extractCommaSeperatedFields(params.get(POR_TYPE));
taskQuery.primaryObjectReferenceTypeIn(types);
}
if (params.containsKey(POR_VALUE)) {
String[] values = extractCommaSeperatedFields(params.get(POR_VALUE));
taskQuery.primaryObjectReferenceValueIn(values);
}
}
if (params.containsKey(IS_READ)) {
taskQuery.readEquals(Boolean.getBoolean(params.get(IS_READ).get(0)));
}
if (params.containsKey(IS_TRANSFERRED)) {
taskQuery.transferredEquals(Boolean.getBoolean(params.get(IS_TRANSFERRED).get(0)));
}
return taskQuery.list();
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskServiceImpl method claim.
@Override
public Task claim(String taskId, boolean forceClaim) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug("entry to claim(id = {}, forceClaim = {}, userId = {})", taskId, forceClaim, userId);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
LOGGER.warn("Method claim() found that task {} is already completed. Throwing InvalidStateException", taskId);
throw new InvalidStateException("Task is already completed");
}
if (state == TaskState.CLAIMED && !forceClaim && !task.getOwner().equals(userId)) {
LOGGER.warn("Method claim() found that task {} is claimed by {} and forceClaim is false. Throwing InvalidOwnerException", taskId, task.getOwner());
throw new InvalidOwnerException("You´re not the owner of this task and it is already claimed by other user " + task.getOwner());
}
Instant now = Instant.now();
task.setOwner(userId);
task.setModified(now);
task.setClaimed(now);
task.setRead(true);
task.setState(TaskState.CLAIMED);
taskMapper.update(task);
LOGGER.debug("Method claim() claimed task '{}' for user '{}'.", taskId, userId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from claim()");
}
return task;
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class ProvideCustomFieldValueReportAccTest method testEachItemOfCustomFieldValueReportWithStateFilter.
@Test
public void testEachItemOfCustomFieldValueReportWithStateFilter() throws InvalidArgumentException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TaskState> states = Collections.singletonList(TaskState.READY);
CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, states, null, null, customField, null, columnHeaders);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders));
}
assertNotNull(report);
assertEquals(3, report.rowSize());
int[] row1 = report.getRow("Geschaeftsstelle A").getCells();
assertArrayEquals(new int[] { 11, 4, 3, 4, 0 }, row1);
int[] row2 = report.getRow("Geschaeftsstelle B").getCells();
assertArrayEquals(new int[] { 5, 3, 0, 2, 0 }, row2);
int[] row3 = report.getRow("Geschaeftsstelle C").getCells();
assertArrayEquals(new int[] { 3, 4, 1, 1, 0 }, row3);
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class ProvideWorkbasketLevelReportAccTest method testEachItemOfWorkbasketLevelReportWithStateFilter.
@Test
public void testEachItemOfWorkbasketLevelReportWithStateFilter() throws InvalidArgumentException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TaskState> states = Collections.singletonList(TaskState.READY);
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, states, null, null, null, null, columnHeaders);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders));
}
assertNotNull(report);
assertEquals(3, report.rowSize());
int[] row1 = report.getRow("USER_1_1").getCells();
assertArrayEquals(new int[] { 13, 3, 1, 1, 0 }, row1);
int[] row2 = report.getRow("USER_1_2").getCells();
assertArrayEquals(new int[] { 4, 6, 3, 6, 0 }, row2);
int[] row3 = report.getRow("USER_1_3").getCells();
assertArrayEquals(new int[] { 2, 2, 0, 0, 0 }, row3);
}
Aggregations