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);
}
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);
}
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()");
}
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);
}
}
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;
}
Aggregations