Search in sources :

Example 1 with JobRunner

use of pro.taskana.impl.JobRunner 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 2 with JobRunner

use of pro.taskana.impl.JobRunner in project taskana by Taskana.

the class JobScheduler method triggerJobs.

@Scheduled(fixedRate = 60000)
@Transactional(rollbackFor = Exception.class)
public void triggerJobs() {
    JobRunner runner = new JobRunner(taskanaEngine);
    LOGGER.info("Running Jobs");
    BulkOperationResults<String, Exception> result = runner.runJobs();
    Map<String, Exception> errors = result.getErrorMap();
    LOGGER.info("Job run completed. Result = {} ", LoggerUtils.mapToString(errors));
}
Also used : JobRunner(pro.taskana.impl.JobRunner) Scheduled(org.springframework.scheduling.annotation.Scheduled) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

JobRunner (pro.taskana.impl.JobRunner)2 AbstractAccTest (acceptance.AbstractAccTest)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Classification (pro.taskana.Classification)1 ClassificationService (pro.taskana.ClassificationService)1 Task (pro.taskana.Task)1 TaskService (pro.taskana.TaskService)1 DaysToWorkingDaysConverter (pro.taskana.impl.DaysToWorkingDaysConverter)1 TimeIntervalColumnHeader (pro.taskana.impl.report.impl.TimeIntervalColumnHeader)1 WithAccessId (pro.taskana.security.WithAccessId)1