use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationServiceImplIntExplicitTest method testFindWithClassificationMapperPriorityTypeAndParent.
@Test
public void testFindWithClassificationMapperPriorityTypeAndParent() throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Classification classification = this.createNewClassificationWithUniqueKey("", "TASK");
classification.setPriority(Integer.decode("5"));
classificationService.createClassification(classification);
Classification classification1 = this.createNewClassificationWithUniqueKey("", "TASK");
classification1.setPriority(Integer.decode("3"));
classification1.setParentId(classification.getId());
classificationService.createClassification(classification1);
Classification classification2 = this.createNewClassificationWithUniqueKey("", "DOCUMENT");
classification2.setPriority(Integer.decode("5"));
classification2.setParentId(classification.getId());
classificationService.createClassification(classification2);
Classification classification3 = this.createNewClassificationWithUniqueKey("", "TASK");
classification3.setPriority(Integer.decode("5"));
classification3.setParentId(classification1.getId());
classificationService.createClassification(classification3);
List<ClassificationSummary> list = classificationService.createClassificationQuery().parentIdIn(classification.getId()).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().typeIn("TASK").priorityIn(Integer.decode("5")).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().priorityIn(Integer.decode("5")).typeIn("TASK").parentIdIn(classification1.getId()).list();
Assert.assertEquals(1, list.size());
connection.commit();
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationServiceImplIntExplicitTest method testDefaultSettingsWithClassificationQuery.
@Test
public void testDefaultSettingsWithClassificationQuery() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
classification = classificationService.createClassification(classification);
Classification classification1 = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
classification1 = classificationService.createClassification(classification1);
classification1.setParentId(classification.getId());
classification1 = classificationService.updateClassification(classification1);
List<ClassificationSummary> list = classificationService.createClassificationQuery().parentIdIn("").list();
Assert.assertEquals(3, list.size());
list = classificationService.createClassificationQuery().list();
Assert.assertEquals(4, list.size());
connection.commit();
list = classificationService.createClassificationQuery().validInDomainEquals(true).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().createdWithin(today()).list();
Assert.assertEquals(4, list.size());
list = classificationService.createClassificationQuery().domainIn("DOMAIN_C").validInDomainEquals(false).list();
Assert.assertEquals(0, list.size());
list = classificationService.createClassificationQuery().keyIn(classification1.getKey()).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().parentIdIn(classification.getId()).list();
Assert.assertEquals(1, list.size());
assertThat(list.get(0).getKey(), equalTo(classification1.getKey()));
connection.commit();
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationServiceImplIntAutoCommitTest method testFindWithClassificationMapperCustomAndCategory.
@Test
public void testFindWithClassificationMapperCustomAndCategory() throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification1.setDescription("DESC1");
classification1.setCategory("EXTERNAL");
classificationService.createClassification(classification1);
Classification classification2 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification2.setDescription("DESC1");
classification2.setCustom1("custom1");
classification2.setCategory("EXTERNAL");
classificationService.createClassification(classification2);
Classification classification3 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification3.setCustom1("custom2");
classification3.setCustom2("custom1");
classification3.setCategory("MANUAL");
classificationService.createClassification(classification3);
Classification classification4 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification4.setDescription("description2");
classification4.setCustom8("custom2");
classification4.setCategory("EXTERNAL");
classificationService.createClassification(classification4);
List<ClassificationSummary> list = classificationService.createClassificationQuery().descriptionLike("DESC1").custom1In("custom1").list();
Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().custom1In("custom2").list();
Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().descriptionLike("DESC1").categoryIn("EXTERNAL").list();
Assert.assertEquals(2, list.size());
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationDefinitionController method getClassifications.
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<List<ClassificationResource>> getClassifications(@RequestParam(required = false) String domain) throws ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, ConcurrencyException, DomainNotFoundException, InvalidArgumentException {
ClassificationQuery query = classificationService.createClassificationQuery();
List<ClassificationSummary> summaries = domain != null ? query.domainIn(domain).list() : query.list();
List<ClassificationResource> export = new ArrayList<>();
for (ClassificationSummary summary : summaries) {
Classification classification = classificationService.getClassification(summary.getKey(), summary.getDomain());
export.add(classificationMapper.toResource(classification));
}
return new ResponseEntity<>(export, HttpStatus.OK);
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class TaskServiceImpl method getTask.
@Override
public Task getTask(String id) throws TaskNotFoundException, NotAuthorizedException {
LOGGER.debug("entry to getTaskById(id = {})", id);
TaskImpl resultTask = null;
try {
taskanaEngine.openConnection();
resultTask = taskMapper.findById(id);
if (resultTask != null) {
WorkbasketQueryImpl query = (WorkbasketQueryImpl) workbasketService.createWorkbasketQuery();
query.setUsedToAugmentTasks(true);
String workbasketId = resultTask.getWorkbasketSummary().getId();
List<WorkbasketSummary> workbaskets = query.idIn(workbasketId).list();
if (workbaskets.isEmpty()) {
String currentUser = CurrentUserContext.getUserid();
LOGGER.error("The current user {} has no read permission for workbasket {}.", currentUser, workbasketId);
throw new NotAuthorizedException("The current user " + currentUser + " has no read permission for workbasket " + workbasketId);
} else {
resultTask.setWorkbasketSummary(workbaskets.get(0));
}
List<AttachmentImpl> attachmentImpls = attachmentMapper.findAttachmentsByTaskId(resultTask.getId());
if (attachmentImpls == null) {
attachmentImpls = new ArrayList<>();
}
List<ClassificationSummary> classifications;
try {
classifications = findClassificationForTaskImplAndAttachments(resultTask, attachmentImpls);
} catch (NotAuthorizedException e1) {
LOGGER.error("ClassificationQuery unexpectedly returned NotauthorizedException. Throwing SystemException ");
throw new SystemException("ClassificationQuery unexpectedly returned NotauthorizedException.");
}
List<Attachment> attachments = addClassificationSummariesToAttachments(resultTask, attachmentImpls, classifications);
resultTask.setAttachments(attachments);
String classificationId = resultTask.getClassificationSummary().getId();
ClassificationSummary classification = classifications.stream().filter(c -> c.getId().equals(classificationId)).findFirst().orElse(null);
if (classification == null) {
LOGGER.error("Could not find a Classification for task {} ", resultTask);
throw new SystemException("Could not find a Classification for task " + resultTask.getId());
}
resultTask.setClassificationSummary(classification);
return resultTask;
} else {
LOGGER.warn("Method getTaskById() didn't find task with id {}. Throwing TaskNotFoundException", id);
throw new TaskNotFoundException(id, "Task with id " + id + " was not found");
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from getTaskById(). Returning result {} ", resultTask);
}
}
Aggregations