use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class TaskServiceImpl method handleAttachmentsOnClassificationUpdate.
private PrioDurationHolder handleAttachmentsOnClassificationUpdate(Task task) {
Duration minDuration = MAX_DURATION;
int maxPrio = Integer.MIN_VALUE;
// Iterator for removing invalid current values directly. OldAttachments can be ignored.
Iterator<Attachment> i = task.getAttachments().iterator();
while (i.hasNext()) {
Attachment attachment = i.next();
if (attachment != null) {
ClassificationSummary classification = attachment.getClassificationSummary();
if (classification != null) {
PrioDurationHolder newPrioDuration = getNewPrioDuration(maxPrio, minDuration, classification.getPriority(), classification.getServiceLevel());
maxPrio = newPrioDuration.getPrio();
minDuration = newPrioDuration.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 addClassificationSummariesToAttachmentSummaries.
private void addClassificationSummariesToAttachmentSummaries(List<AttachmentSummaryImpl> attachmentSummaries, List<TaskSummaryImpl> taskSummaries, List<ClassificationSummary> classifications) {
// prereq: in each attachmentSummary, the classificationSummary.key property is set.
if (attachmentSummaries == null || attachmentSummaries.isEmpty() || taskSummaries == null || taskSummaries.isEmpty()) {
return;
}
// iterate over all attachment summaries an add the appropriate classification summary to each
for (AttachmentSummaryImpl att : attachmentSummaries) {
String classificationId = att.getClassificationSummary().getId();
ClassificationSummary aClassification = classifications.stream().filter(x -> classificationId != null && classificationId.equals(x.getId())).findFirst().orElse(null);
if (aClassification == null) {
LOGGER.error("Could not find a Classification for attachment {}.", att);
throw new SystemException("Could not find a Classification for attachment " + att);
}
att.setClassificationSummary(aClassification);
}
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class TaskServiceImpl method addClassificationSummariesToTaskSummaries.
private void addClassificationSummariesToTaskSummaries(List<TaskSummaryImpl> tasks, List<ClassificationSummary> classifications) {
if (tasks == null || tasks.isEmpty()) {
return;
}
// assign query results to appropriate tasks.
for (TaskSummaryImpl task : tasks) {
String classificationId = task.getClassificationSummary().getId();
ClassificationSummary aClassification = classifications.stream().filter(c -> c.getId().equals(classificationId)).findFirst().orElse(null);
if (aClassification == null) {
LOGGER.error("Didnt find a Classification for task ");
throw new SystemException("Did not find a Classification for task (Id=" + task.getTaskId() + ",classification=" + task.getClassificationSummary().getId() + ")");
}
// set the classification on the task object
task.setClassificationSummary(aClassification);
}
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class TaskServiceImpl method addClassificationSummariesToAttachments.
private List<Attachment> addClassificationSummariesToAttachments(TaskImpl task, List<AttachmentImpl> attachmentImpls, List<ClassificationSummary> classifications) {
if (attachmentImpls == null || attachmentImpls.isEmpty()) {
return new ArrayList<>();
}
List<Attachment> result = new ArrayList<>();
for (AttachmentImpl att : attachmentImpls) {
// find the associated task to use the correct domain
ClassificationSummary aClassification = classifications.stream().filter(c -> c != null & c.getId().equals(att.getClassificationSummary().getId())).findFirst().orElse(null);
if (aClassification == null) {
LOGGER.error("Could not find a Classification for attachment {}.", att);
throw new SystemException("Could not find a Classification for attachment " + att);
}
att.setClassificationSummary(aClassification);
result.add(att);
}
return result;
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationQueryImpl method list.
@Override
public List<ClassificationSummary> list(int offset, int limit) {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<ClassificationSummary> result = null;
try {
taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit);
result = taskanaEngine.getSqlSession().selectList(LINK_TO_SUMMARYMAPPER, this, rowBounds);
return result;
} catch (Exception e) {
if (e instanceof PersistenceException) {
if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex = new TaskanaRuntimeException("The offset beginning was set over the amount of result-rows.", e.getCause());
ex.setStackTrace(e.getStackTrace());
throw ex;
}
}
throw e;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
}
}
}
Aggregations