Search in sources :

Example 51 with Classification

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

the class CreateClassificationAccTest method testCreateClassificationWithInvalidParent.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test(expected = ClassificationNotFoundException.class)
public void testCreateClassificationWithInvalidParent() throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
    Classification classification = classificationService.newClassification("Key5", "", "TASK");
    classification.setParentId("ID WHICH CANT BE FOUND");
    classification = classificationService.createClassification(classification);
}
Also used : Classification(pro.taskana.Classification) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 52 with Classification

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

the class GetClassificationAccTest method testGetOneClassificationById.

@Test
public void testGetOneClassificationById() throws ClassificationNotFoundException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    Classification classification = classificationService.getClassification("CLI:100000000000000000000000000000000011");
    Assert.assertNotNull(classification);
}
Also used : Classification(pro.taskana.Classification) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 53 with Classification

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

the class TaskServiceImpl method addWorkbasketSummariesToTaskSummaries.

private void addWorkbasketSummariesToTaskSummaries(List<TaskSummaryImpl> taskSummaries) throws NotAuthorizedException {
    LOGGER.debug("entry to addWorkbasketSummariesToTaskSummaries()");
    if (taskSummaries == null || taskSummaries.isEmpty()) {
        return;
    }
    // calculate parameters for workbasket query: workbasket keys
    Set<String> workbasketIdSet = taskSummaries.stream().map(t -> t.getWorkbasketSummary().getId()).collect(Collectors.toSet());
    String[] workbasketIdArray = workbasketIdSet.toArray(new String[0]);
    // perform workbasket query
    LOGGER.debug("addWorkbasketSummariesToTaskSummaries() about to query workbaskets");
    WorkbasketQueryImpl query = (WorkbasketQueryImpl) workbasketService.createWorkbasketQuery();
    query.setUsedToAugmentTasks(true);
    List<WorkbasketSummary> workbaskets = query.idIn(workbasketIdArray).list();
    // assign query results to appropriate tasks.
    Iterator<TaskSummaryImpl> taskIterator = taskSummaries.iterator();
    while (taskIterator.hasNext()) {
        TaskSummaryImpl task = taskIterator.next();
        String workbasketId = task.getWorkbasketSummaryImpl().getId();
        // find the appropriate workbasket from the query result
        WorkbasketSummary aWorkbasket = workbaskets.stream().filter(x -> workbasketId != null && workbasketId.equals(x.getId())).findFirst().orElse(null);
        if (aWorkbasket == null) {
            LOGGER.warn("Could not find a Workbasket for task {}.", task.getTaskId());
            taskIterator.remove();
            continue;
        }
        // set the classification on the task object
        task.setWorkbasketSummary(aWorkbasket);
    }
    LOGGER.debug("exit from addWorkbasketSummariesToTaskSummaries()");
}
Also used : Arrays(java.util.Arrays) PersistenceException(org.apache.ibatis.exceptions.PersistenceException) IdGenerator(pro.taskana.impl.util.IdGenerator) LoggerFactory(org.slf4j.LoggerFactory) WorkbasketService(pro.taskana.WorkbasketService) ArrayList(java.util.ArrayList) CurrentUserContext(pro.taskana.security.CurrentUserContext) HashSet(java.util.HashSet) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) SystemException(pro.taskana.exceptions.SystemException) CustomPropertySelector(pro.taskana.mappings.CustomPropertySelector) Task(pro.taskana.Task) InvalidStateException(pro.taskana.exceptions.InvalidStateException) Duration(java.time.Duration) Map(java.util.Map) TaskState(pro.taskana.TaskState) WorkbasketPermission(pro.taskana.WorkbasketPermission) WorkbasketSummary(pro.taskana.WorkbasketSummary) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) ClassificationSummary(pro.taskana.ClassificationSummary) TaskNotFoundException(pro.taskana.exceptions.TaskNotFoundException) TaskanaEngine(pro.taskana.TaskanaEngine) Attachment(pro.taskana.Attachment) TaskAlreadyExistException(pro.taskana.exceptions.TaskAlreadyExistException) TaskSummary(pro.taskana.TaskSummary) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) ConcurrencyException(pro.taskana.exceptions.ConcurrencyException) Logger(org.slf4j.Logger) InvalidOwnerException(pro.taskana.exceptions.InvalidOwnerException) Iterator(java.util.Iterator) Set(java.util.Set) InvalidWorkbasketException(pro.taskana.exceptions.InvalidWorkbasketException) AttachmentMapper(pro.taskana.mappings.AttachmentMapper) Classification(pro.taskana.Classification) LoggerUtils(pro.taskana.impl.util.LoggerUtils) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) AttachmentPersistenceException(pro.taskana.exceptions.AttachmentPersistenceException) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskMapper(pro.taskana.mappings.TaskMapper) List(java.util.List) Workbasket(pro.taskana.Workbasket) TaskanaRole(pro.taskana.TaskanaRole) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) TaskanaException(pro.taskana.exceptions.TaskanaException) TaskQuery(pro.taskana.TaskQuery) Collections(java.util.Collections) WorkbasketSummary(pro.taskana.WorkbasketSummary)

Example 54 with Classification

use of pro.taskana.Classification 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)

Example 55 with Classification

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

the class TaskServiceImpl method augmentAttachmentsByClassification.

private List<Attachment> augmentAttachmentsByClassification(List<AttachmentImpl> attachmentImpls, BulkOperationResults<String, Exception> bulkLog) {
    List<Attachment> result = new ArrayList<>();
    if (attachmentImpls == null || attachmentImpls.isEmpty()) {
        return result;
    }
    Set<String> classificationIds = attachmentImpls.stream().map(t -> t.getClassificationSummary().getId()).collect(Collectors.toSet());
    List<ClassificationSummary> classifications = classificationService.createClassificationQuery().idIn(classificationIds.toArray(new String[0])).list();
    for (AttachmentImpl att : attachmentImpls) {
        ClassificationSummary classificationSummary = classifications.stream().filter(cl -> cl.getId().equals(att.getClassificationSummary().getId())).findFirst().orElse(null);
        if (classificationSummary == null) {
            String id = att.getClassificationSummary().getId();
            bulkLog.addError(att.getClassificationSummary().getId(), new ClassificationNotFoundException(id, "When processing task updates due to change of classification, the classification with id " + id + " was not found."));
        } else {
            att.setClassificationSummary(classificationSummary);
            result.add(att);
        }
    }
    return result;
}
Also used : Arrays(java.util.Arrays) PersistenceException(org.apache.ibatis.exceptions.PersistenceException) IdGenerator(pro.taskana.impl.util.IdGenerator) LoggerFactory(org.slf4j.LoggerFactory) WorkbasketService(pro.taskana.WorkbasketService) ArrayList(java.util.ArrayList) CurrentUserContext(pro.taskana.security.CurrentUserContext) HashSet(java.util.HashSet) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) SystemException(pro.taskana.exceptions.SystemException) CustomPropertySelector(pro.taskana.mappings.CustomPropertySelector) Task(pro.taskana.Task) InvalidStateException(pro.taskana.exceptions.InvalidStateException) Duration(java.time.Duration) Map(java.util.Map) TaskState(pro.taskana.TaskState) WorkbasketPermission(pro.taskana.WorkbasketPermission) WorkbasketSummary(pro.taskana.WorkbasketSummary) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) ClassificationSummary(pro.taskana.ClassificationSummary) TaskNotFoundException(pro.taskana.exceptions.TaskNotFoundException) TaskanaEngine(pro.taskana.TaskanaEngine) Attachment(pro.taskana.Attachment) TaskAlreadyExistException(pro.taskana.exceptions.TaskAlreadyExistException) TaskSummary(pro.taskana.TaskSummary) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) ConcurrencyException(pro.taskana.exceptions.ConcurrencyException) Logger(org.slf4j.Logger) InvalidOwnerException(pro.taskana.exceptions.InvalidOwnerException) Iterator(java.util.Iterator) Set(java.util.Set) InvalidWorkbasketException(pro.taskana.exceptions.InvalidWorkbasketException) AttachmentMapper(pro.taskana.mappings.AttachmentMapper) Classification(pro.taskana.Classification) LoggerUtils(pro.taskana.impl.util.LoggerUtils) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) AttachmentPersistenceException(pro.taskana.exceptions.AttachmentPersistenceException) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskMapper(pro.taskana.mappings.TaskMapper) List(java.util.List) Workbasket(pro.taskana.Workbasket) TaskanaRole(pro.taskana.TaskanaRole) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) TaskanaException(pro.taskana.exceptions.TaskanaException) TaskQuery(pro.taskana.TaskQuery) Collections(java.util.Collections) ClassificationSummary(pro.taskana.ClassificationSummary) ArrayList(java.util.ArrayList) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) Attachment(pro.taskana.Attachment)

Aggregations

Classification (pro.taskana.Classification)102 Test (org.junit.Test)88 Task (pro.taskana.Task)32 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)29 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)28 AbstractAccTest (acceptance.AbstractAccTest)23 WithAccessId (pro.taskana.security.WithAccessId)21 ClassificationSummary (pro.taskana.ClassificationSummary)20 Workbasket (pro.taskana.Workbasket)18 Connection (java.sql.Connection)14 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)14 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)13 TaskAlreadyExistException (pro.taskana.exceptions.TaskAlreadyExistException)11 ClassificationService (pro.taskana.ClassificationService)10 AttachmentPersistenceException (pro.taskana.exceptions.AttachmentPersistenceException)10 ConcurrencyException (pro.taskana.exceptions.ConcurrencyException)10 InvalidOwnerException (pro.taskana.exceptions.InvalidOwnerException)10 InvalidStateException (pro.taskana.exceptions.InvalidStateException)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)10 SystemException (pro.taskana.exceptions.SystemException)10