Search in sources :

Example 21 with ClassificationSummary

use of pro.taskana.ClassificationSummary in project taskana by Taskana.

the class GetClassificationAccTest method testFindAllClassifications.

@Test
public void testFindAllClassifications() {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery().list();
    Assert.assertNotNull(classificationSummaryList);
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 22 with ClassificationSummary

use of pro.taskana.ClassificationSummary in project taskana by Taskana.

the class QueryClassificationWithPaginationAccTest method testListOffsetAndLimitOutOfBounds.

@Test
public void testListOffsetAndLimitOutOfBounds() throws NotAuthorizedException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    // both will be 0, working
    List<ClassificationSummary> results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list(-1, -3);
    assertThat(results.size(), equalTo(0));
    // limit will be 0
    results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list(1, -3);
    assertThat(results.size(), equalTo(0));
    // offset will be 0
    results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list(-1, 3);
    assertThat(results.size(), equalTo(3));
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 23 with ClassificationSummary

use of pro.taskana.ClassificationSummary in project taskana by Taskana.

the class QueryClassificationWithPaginationAccTest method testGetFirstPageOfClassificationQueryWithOffset.

@Test
public void testGetFirstPageOfClassificationQueryWithOffset() throws NotAuthorizedException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    List<ClassificationSummary> results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list(0, 5);
    assertThat(results.size(), equalTo(5));
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 24 with ClassificationSummary

use of pro.taskana.ClassificationSummary in project taskana by Taskana.

the class TaskServiceImpl method handleAttachments.

private PrioDurationHolder handleAttachments(TaskImpl task) throws InvalidArgumentException {
    List<Attachment> attachments = task.getAttachments();
    if (attachments == null || attachments.isEmpty()) {
        return new PrioDurationHolder(null, Integer.MIN_VALUE);
    }
    Duration minDuration = MAX_DURATION;
    int maxPrio = Integer.MIN_VALUE;
    Iterator<Attachment> i = attachments.iterator();
    while (i.hasNext()) {
        Attachment attachment = i.next();
        if (attachment == null) {
            i.remove();
        } else {
            ObjectReference objRef = attachment.getObjectReference();
            validateObjectReference(objRef, "ObjectReference", "Attachment");
            if (attachment.getClassificationSummary() == null) {
                throw new InvalidArgumentException("Classification of attachment " + attachment + " must not be null");
            } else {
                ClassificationSummary classificationSummary = attachment.getClassificationSummary();
                if (classificationSummary != null) {
                    PrioDurationHolder newPrioDuraton = getNewPrioDuration(maxPrio, minDuration, classificationSummary.getPriority(), classificationSummary.getServiceLevel());
                    maxPrio = newPrioDuraton.getPrio();
                    minDuration = newPrioDuraton.getDuration();
                }
            }
        }
    }
    if (minDuration != null && MAX_DURATION.equals(minDuration)) {
        minDuration = null;
    }
    return new PrioDurationHolder(minDuration, maxPrio);
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) ClassificationSummary(pro.taskana.ClassificationSummary) Attachment(pro.taskana.Attachment) Duration(java.time.Duration)

Example 25 with ClassificationSummary

use of pro.taskana.ClassificationSummary in project taskana by Taskana.

the class TaskServiceImpl method updateClassificationRelatedProperties.

private void updateClassificationRelatedProperties(TaskImpl oldTaskImpl, TaskImpl newTaskImpl, PrioDurationHolder prioDurationFromAttachments) throws NotAuthorizedException, ClassificationNotFoundException {
    // insert Classification specifications if Classification is given.
    ClassificationSummary oldClassificationSummary = oldTaskImpl.getClassificationSummary();
    ClassificationSummary newClassificationSummary = newTaskImpl.getClassificationSummary();
    if (newClassificationSummary == null) {
        newClassificationSummary = oldClassificationSummary;
    }
    if (newClassificationSummary == null) {
        // newClassification is null -> take prio and duration from attachments
        if (prioDurationFromAttachments.getDuration() != null) {
            long days = converter.convertWorkingDaysToDays(newTaskImpl.getPlanned(), prioDurationFromAttachments.getDuration().toDays());
            Instant due = newTaskImpl.getPlanned().plus(Duration.ofDays(days));
            newTaskImpl.setDue(due);
        }
        if (prioDurationFromAttachments.getPrio() > Integer.MIN_VALUE) {
            newTaskImpl.setPriority(prioDurationFromAttachments.getPrio());
        }
    } else {
        Classification newClassification = null;
        if (!oldClassificationSummary.getKey().equals(newClassificationSummary.getKey())) {
            newClassification = this.classificationService.getClassification(newClassificationSummary.getKey(), newTaskImpl.getWorkbasketSummary().getDomain());
            newClassificationSummary = newClassification.asSummary();
            newTaskImpl.setClassificationSummary(newClassificationSummary);
        }
        if (newClassificationSummary.getServiceLevel() != null) {
            Duration durationFromClassification = Duration.parse(newClassificationSummary.getServiceLevel());
            Duration minDuration = prioDurationFromAttachments.getDuration();
            if (minDuration != null) {
                if (minDuration.compareTo(durationFromClassification) > 0) {
                    minDuration = durationFromClassification;
                }
            } else {
                minDuration = durationFromClassification;
            }
            long days = converter.convertWorkingDaysToDays(newTaskImpl.getPlanned(), minDuration.toDays());
            Instant due = newTaskImpl.getPlanned().plus(Duration.ofDays(days));
            newTaskImpl.setDue(due);
        }
        if (newTaskImpl.getName() == null) {
            newTaskImpl.setName(newClassificationSummary.getName());
        }
        if (newTaskImpl.getDescription() == null && newClassification != null) {
            newTaskImpl.setDescription(newClassification.getDescription());
        }
        int newPriority = Math.max(newClassificationSummary.getPriority(), prioDurationFromAttachments.getPrio());
        newTaskImpl.setPriority(newPriority);
    }
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) Instant(java.time.Instant) Classification(pro.taskana.Classification) Duration(java.time.Duration)

Aggregations

ClassificationSummary (pro.taskana.ClassificationSummary)51 Test (org.junit.Test)38 AbstractAccTest (acceptance.AbstractAccTest)21 Classification (pro.taskana.Classification)20 ClassificationService (pro.taskana.ClassificationService)20 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)14 Connection (java.sql.Connection)7 Attachment (pro.taskana.Attachment)7 Duration (java.time.Duration)5 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)5 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Task (pro.taskana.Task)4 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)4 SystemException (pro.taskana.exceptions.SystemException)4 WithAccessId (pro.taskana.security.WithAccessId)4 PersistenceException (org.apache.ibatis.exceptions.PersistenceException)3 SQLException (java.sql.SQLException)2