Search in sources :

Example 16 with TaskState

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);
}
Also used : CustomField(pro.taskana.CustomField) ArrayList(java.util.ArrayList) DetailedClassificationReport(pro.taskana.impl.report.impl.DetailedClassificationReport) DetailedMonitorQueryItem(pro.taskana.impl.report.impl.DetailedMonitorQueryItem) DetailedReportRow(pro.taskana.impl.report.impl.DetailedReportRow) TaskState(pro.taskana.TaskState) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) Test(org.junit.Test)

Example 17 with TaskState

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();
}
Also used : TaskService(pro.taskana.TaskService) Arrays(java.util.Arrays) List(java.util.List) Component(org.springframework.stereotype.Component) TaskSummary(pro.taskana.TaskSummary) TaskState(pro.taskana.TaskState) Autowired(org.springframework.beans.factory.annotation.Autowired) MultiValueMap(org.springframework.util.MultiValueMap) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) TaskQuery(pro.taskana.TaskQuery) ArrayList(java.util.ArrayList) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskQuery(pro.taskana.TaskQuery) TaskState(pro.taskana.TaskState)

Example 18 with TaskState

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;
}
Also used : Instant(java.time.Instant) InvalidOwnerException(pro.taskana.exceptions.InvalidOwnerException) InvalidStateException(pro.taskana.exceptions.InvalidStateException) TaskState(pro.taskana.TaskState)

Example 19 with TaskState

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);
}
Also used : TaskMonitorService(pro.taskana.TaskMonitorService) CustomFieldValueReport(pro.taskana.impl.report.impl.CustomFieldValueReport) CustomField(pro.taskana.CustomField) TaskState(pro.taskana.TaskState) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 20 with TaskState

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);
}
Also used : WorkbasketLevelReport(pro.taskana.impl.report.impl.WorkbasketLevelReport) TaskMonitorService(pro.taskana.TaskMonitorService) TaskState(pro.taskana.TaskState) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Aggregations

TaskState (pro.taskana.TaskState)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)12 CustomField (pro.taskana.CustomField)12 TimeIntervalColumnHeader (pro.taskana.impl.report.impl.TimeIntervalColumnHeader)12 DetailedMonitorQueryItem (pro.taskana.impl.report.impl.DetailedMonitorQueryItem)11 MonitorQueryItem (pro.taskana.impl.report.impl.MonitorQueryItem)8 TaskMonitorService (pro.taskana.TaskMonitorService)6 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)6 DetailedClassificationReport (pro.taskana.impl.report.impl.DetailedClassificationReport)5 CategoryReport (pro.taskana.impl.report.impl.CategoryReport)3 ClassificationReport (pro.taskana.impl.report.impl.ClassificationReport)3 CustomFieldValueReport (pro.taskana.impl.report.impl.CustomFieldValueReport)3 DetailedReportRow (pro.taskana.impl.report.impl.DetailedReportRow)3 WorkbasketLevelReport (pro.taskana.impl.report.impl.WorkbasketLevelReport)3 Instant (java.time.Instant)2 InvalidOwnerException (pro.taskana.exceptions.InvalidOwnerException)2 InvalidStateException (pro.taskana.exceptions.InvalidStateException)2 Arrays (java.util.Arrays)1 List (java.util.List)1