Search in sources :

Example 1 with TimeIntervalColumnHeader

use of pro.taskana.impl.report.impl.TimeIntervalColumnHeader in project taskana by Taskana.

the class UpdateTaskAttachmentsAccTest method testPrioDurationOfTaskFromAttachmentsAtUpdate.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testPrioDurationOfTaskFromAttachmentsAtUpdate() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
    setUpMethod();
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    // prio 8, SL P7D
    newTask.setClassificationKey("L12010");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    newTask.addAttachment(createAttachment(// prio 99, SL P2000D
    "DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    newTask.addAttachment(createAttachment(// prio 1, SL P1D
    "L1060", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask.getId());
    assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    Task readTask = taskService.getTask(createdTask.getId());
    assertNotNull(readTask);
    assertThat(readTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    assertNotNull(readTask.getAttachments());
    assertEquals(2, readTask.getAttachments().size());
    assertNotNull(readTask.getAttachments().get(1).getCreated());
    assertNotNull(readTask.getAttachments().get(1).getModified());
    assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(1).getModified());
    // assertNotNull(readTask.getAttachments().get(0).getClassification());
    assertNotNull(readTask.getAttachments().get(0).getObjectReference());
    assertTrue(readTask.getPriority() == 99);
    DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
    long calendarDays = converter.convertWorkingDaysToDays(readTask.getPlanned(), 1);
    assertTrue(readTask.getDue().equals(readTask.getPlanned().plus(Duration.ofDays(calendarDays))));
}
Also used : DaysToWorkingDaysConverter(pro.taskana.impl.DaysToWorkingDaysConverter) Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 2 with TimeIntervalColumnHeader

use of pro.taskana.impl.report.impl.TimeIntervalColumnHeader in project taskana by Taskana.

the class UpdateClassificationAccTest method testUpdateClassificationPrioServiceLevel.

@WithAccessId(userName = "dummy", groupNames = { "admin" })
@Test
public void testUpdateClassificationPrioServiceLevel() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InterruptedException, TaskNotFoundException, InvalidArgumentException {
    String newEntryPoint = "updated EntryPoint";
    Instant before = Instant.now();
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    Classification classification = classificationService.getClassification("CLI:100000000000000000000000000000000003");
    Instant createdBefore = classification.getCreated();
    Instant modifiedBefore = classification.getModified();
    classification.setPriority(1000);
    classification.setServiceLevel("P15D");
    classificationService.updateClassification(classification);
    Thread.sleep(100);
    JobRunner runner = new JobRunner(taskanaEngine);
    runner.runJobs();
    // Get and check the new value
    Classification updatedClassification = classificationService.getClassification("CLI:100000000000000000000000000000000003");
    assertNotNull(updatedClassification);
    assertTrue(!modifiedBefore.isAfter(updatedClassification.getModified()));
    List<String> affectedTasks = new ArrayList<>(Arrays.asList("TKI:000000000000000000000000000000000000", "TKI:000000000000000000000000000000000003", "TKI:000000000000000000000000000000000004", "TKI:000000000000000000000000000000000005", "TKI:000000000000000000000000000000000006", "TKI:000000000000000000000000000000000007", "TKI:000000000000000000000000000000000008", "TKI:000000000000000000000000000000000009", "TKI:000000000000000000000000000000000010", "TKI:000000000000000000000000000000000011", "TKI:000000000000000000000000000000000012", "TKI:000000000000000000000000000000000013", "TKI:000000000000000000000000000000000014", "TKI:000000000000000000000000000000000015", "TKI:000000000000000000000000000000000016", "TKI:000000000000000000000000000000000017", "TKI:000000000000000000000000000000000018", "TKI:000000000000000000000000000000000019", "TKI:000000000000000000000000000000000020", "TKI:000000000000000000000000000000000021", "TKI:000000000000000000000000000000000022", "TKI:000000000000000000000000000000000023", "TKI:000000000000000000000000000000000024", "TKI:000000000000000000000000000000000025", "TKI:000000000000000000000000000000000026", "TKI:000000000000000000000000000000000027", "TKI:000000000000000000000000000000000028", "TKI:000000000000000000000000000000000029", "TKI:000000000000000000000000000000000030", "TKI:000000000000000000000000000000000031", "TKI:000000000000000000000000000000000032", "TKI:000000000000000000000000000000000033", "TKI:000000000000000000000000000000000034", "TKI:000000000000000000000000000000000035", "TKI:000000000000000000000000000000000053", "TKI:000000000000000000000000000000000054", "TKI:000000000000000000000000000000000055", "TKI:000000000000000000000000000000000100", "TKI:000000000000000000000000000000000101", "TKI:000000000000000000000000000000000102", "TKI:000000000000000000000000000000000103"));
    TaskService taskService = taskanaEngine.getTaskService();
    DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
    for (String taskId : affectedTasks) {
        Task task = taskService.getTask(taskId);
        assertTrue(task.getModified().isAfter(before));
        assertTrue(task.getPriority() == 1000);
        long calendarDays = converter.convertWorkingDaysToDays(task.getPlanned(), 15);
        if (!taskId.equals("TKI:000000000000000000000000000000000008") && !taskId.equals("TKI:000000000000000000000000000000000053")) {
            assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(calendarDays))));
        }
    }
}
Also used : DaysToWorkingDaysConverter(pro.taskana.impl.DaysToWorkingDaysConverter) JobRunner(pro.taskana.impl.JobRunner) Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) Classification(pro.taskana.Classification) ArrayList(java.util.ArrayList) ClassificationService(pro.taskana.ClassificationService) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 3 with TimeIntervalColumnHeader

use of pro.taskana.impl.report.impl.TimeIntervalColumnHeader in project taskana by Taskana.

the class ProvideCategoryReportAccTest method getShortListOfColumnHeaders.

private List<TimeIntervalColumnHeader> getShortListOfColumnHeaders() {
    List<TimeIntervalColumnHeader> columnHeaders = new ArrayList<>();
    columnHeaders.add(new TimeIntervalColumnHeader(Integer.MIN_VALUE, -6));
    columnHeaders.add(new TimeIntervalColumnHeader(-5, -1));
    columnHeaders.add(new TimeIntervalColumnHeader(0));
    columnHeaders.add(new TimeIntervalColumnHeader(1, 5));
    columnHeaders.add(new TimeIntervalColumnHeader(6, Integer.MAX_VALUE));
    return columnHeaders;
}
Also used : ArrayList(java.util.ArrayList) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader)

Example 4 with TimeIntervalColumnHeader

use of pro.taskana.impl.report.impl.TimeIntervalColumnHeader in project taskana by Taskana.

the class ProvideCategoryReportAccTest method reportToString.

private String reportToString(CategoryReport report, List<TimeIntervalColumnHeader> columnHeaders) {
    String formatColumWidth = "| %-7s ";
    String formatFirstColumn = "| %-36s  %-4s ";
    String formatFirstColumnFirstLine = "| %-29s %12s ";
    String formatFirstColumnSumLine = "| %-36s  %-5s";
    int reportWidth = columnHeaders == null ? 46 : columnHeaders.size() * 10 + 46;
    StringBuilder builder = new StringBuilder();
    builder.append("\n");
    for (int i = 0; i < reportWidth; i++) {
        builder.append("-");
    }
    builder.append("\n");
    builder.append(String.format(formatFirstColumnFirstLine, "Categories", "Total"));
    if (columnHeaders != null) {
        for (TimeIntervalColumnHeader def : columnHeaders) {
            if (def.getLowerAgeLimit() == Integer.MIN_VALUE) {
                builder.append(String.format(formatColumWidth, "< " + def.getUpperAgeLimit()));
            } else if (def.getUpperAgeLimit() == Integer.MAX_VALUE) {
                builder.append(String.format(formatColumWidth, "> " + def.getLowerAgeLimit()));
            } else if (def.getLowerAgeLimit() == def.getUpperAgeLimit()) {
                if (def.getLowerAgeLimit() == 0) {
                    builder.append(String.format(formatColumWidth, "today"));
                } else {
                    builder.append(String.format(formatColumWidth, def.getLowerAgeLimit()));
                }
            } else {
                builder.append(String.format(formatColumWidth, def.getLowerAgeLimit() + ".." + def.getUpperAgeLimit()));
            }
        }
    }
    builder.append("|\n");
    for (int i = 0; i < reportWidth; i++) {
        builder.append("-");
    }
    builder.append("\n");
    for (String rl : report.rowTitles()) {
        builder.append(String.format(formatFirstColumn, rl, report.getRow(rl).getTotalValue()));
        if (columnHeaders != null) {
            for (int cell : report.getRow(rl).getCells()) {
                builder.append(String.format(formatColumWidth, cell));
            }
        }
        builder.append("|\n");
        for (int i = 0; i < reportWidth; i++) {
            builder.append("-");
        }
        builder.append("\n");
    }
    builder.append(String.format(formatFirstColumnSumLine, "Total", report.getSumRow().getTotalValue()));
    for (int cell : report.getSumRow().getCells()) {
        builder.append(String.format(formatColumWidth, cell));
    }
    builder.append("|\n");
    for (int i = 0; i < reportWidth; i++) {
        builder.append("-");
    }
    builder.append("\n");
    return builder.toString();
}
Also used : TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader)

Example 5 with TimeIntervalColumnHeader

use of pro.taskana.impl.report.impl.TimeIntervalColumnHeader in project taskana by Taskana.

the class ProvideCategoryReportAccTest method testGetCategoryReportWithReportLineItemDefinitions.

@Test
public void testGetCategoryReportWithReportLineItemDefinitions() throws InvalidArgumentException {
    TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
    List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
    CategoryReport report = taskMonitorService.getCategoryReport(null, null, null, null, null, null, columnHeaders);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(reportToString(report, columnHeaders));
    }
    int sumLineCount = IntStream.of(report.getSumRow().getCells()).sum();
    assertNotNull(report);
    assertEquals(3, report.rowSize());
    assertEquals(33, report.getRow("EXTERN").getTotalValue());
    assertEquals(7, report.getRow("AUTOMATIC").getTotalValue());
    assertEquals(10, report.getRow("MANUAL").getTotalValue());
    int[] sumRow = report.getSumRow().getCells();
    assertArrayEquals(new int[] { 10, 9, 11, 0, 4, 0, 7, 4, 5 }, sumRow);
    assertEquals(50, report.getSumRow().getTotalValue());
    assertEquals(50, sumLineCount);
}
Also used : TaskMonitorService(pro.taskana.TaskMonitorService) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) CategoryReport(pro.taskana.impl.report.impl.CategoryReport) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Aggregations

TimeIntervalColumnHeader (pro.taskana.impl.report.impl.TimeIntervalColumnHeader)75 Test (org.junit.Test)57 TaskMonitorService (pro.taskana.TaskMonitorService)46 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)46 ArrayList (java.util.ArrayList)25 CustomField (pro.taskana.CustomField)19 DetailedMonitorQueryItem (pro.taskana.impl.report.impl.DetailedMonitorQueryItem)13 TaskState (pro.taskana.TaskState)12 DetailedClassificationReport (pro.taskana.impl.report.impl.DetailedClassificationReport)10 CategoryReport (pro.taskana.impl.report.impl.CategoryReport)9 ClassificationReport (pro.taskana.impl.report.impl.ClassificationReport)9 CustomFieldValueReport (pro.taskana.impl.report.impl.CustomFieldValueReport)9 WorkbasketLevelReport (pro.taskana.impl.report.impl.WorkbasketLevelReport)9 DetailedReportRow (pro.taskana.impl.report.impl.DetailedReportRow)8 SelectedItem (pro.taskana.impl.SelectedItem)6 AbstractAccTest (acceptance.AbstractAccTest)4 DaysToWorkingDaysConverter (pro.taskana.impl.DaysToWorkingDaysConverter)4 MonitorQueryItem (pro.taskana.impl.report.impl.MonitorQueryItem)4 WithAccessId (pro.taskana.security.WithAccessId)4 Task (pro.taskana.Task)3