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