use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method testWithPrimaryObjectRef.
@Test
public void testWithPrimaryObjectRef() throws FileNotFoundException, SQLException, TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
wb.setName("workbasket");
wb.setType(WorkbasketType.GROUP);
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngine.getClassificationService().createClassification(classification);
Task task = taskServiceImpl.newTask(wb.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
ObjectReference objRef = new ObjectReference();
objRef.setCompany("novatec");
objRef.setSystem("linux");
objRef.setSystemInstance("inst1");
objRef.setType("fast");
objRef.setValue("4711");
task.setPrimaryObjRef(objRef);
task = taskServiceImpl.createTask(task);
Task task2 = taskServiceImpl.getTask(task.getId());
// skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
Assert.assertNotNull(task2);
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method testStartTransactionFail.
@Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket wb = workbasketService.newWorkbasket("wb1k1", "DOMAIN_A");
wb.setName("sdf");
wb.setType(WorkbasketType.GROUP);
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classification = taskanaEngine.getClassificationService().createClassification(classification);
classification = taskanaEngine.getClassificationService().getClassification(classification.getKey(), classification.getDomain());
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getKey(), "DOMAIN_A");
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
taskServiceImpl.createTask(task);
taskServiceImpl.getTask(task.getId());
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
taskServiceImpl2.getTask(wb.getId());
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class WorkbasketServiceImplIntAutocommitTest method testUpdateWorkbasket.
@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testUpdateWorkbasket() throws Exception {
String id0 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "DOMAIN_A", "Superbasket", WorkbasketType.GROUP);
workbasket0 = workBasketService.createWorkbasket(workbasket0);
createWorkbasketWithSecurity(workbasket0, "Elena", true, true, false, false);
String id1 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "DOMAIN_A", "Megabasket", WorkbasketType.GROUP);
workbasket1 = workBasketService.createWorkbasket(workbasket1);
createWorkbasketWithSecurity(workbasket1, "Elena", true, true, false, false);
String id2 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "DOMAIN_A", "Hyperbasket", WorkbasketType.GROUP);
workbasket2 = workBasketService.createWorkbasket(workbasket2);
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
String id3 = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "DOMAIN_A", "hm ... irgend ein basket", WorkbasketType.GROUP);
workbasket3 = workBasketService.createWorkbasket(workbasket3);
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId()));
Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets);
Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId());
List<WorkbasketSummary> distributionTargets = workBasketService.getDistributionTargets(foundBasket.getId());
Assert.assertEquals(1, distributionTargets.size());
Assert.assertEquals(id3, distributionTargets.get(0).getId());
Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(), workBasketService.getWorkbasket(id2).getModified());
Assert.assertEquals(workBasketService.getWorkbasket(id1).getCreated(), workBasketService.getWorkbasket(id1).getModified());
Assert.assertEquals(workBasketService.getWorkbasket(id3).getCreated(), workBasketService.getWorkbasket(id3).getModified());
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class WorkbasketController method createWorkbasket.
@PostMapping
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketResource> createWorkbasket(@RequestBody WorkbasketResource workbasketResource) throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, WorkbasketNotFoundException, DomainNotFoundException {
Workbasket workbasket = workbasketMapper.toModel(workbasketResource);
workbasket = workbasketService.createWorkbasket(workbasket);
return new ResponseEntity<>(workbasketMapper.toResource(workbasket), HttpStatus.CREATED);
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class TaskServiceImpl method transferTasks.
@Override
public BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId, List<String> taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
try {
taskanaEngine.openConnection();
LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds);
// Check pre-conditions with trowing Exceptions
if (destinationWorkbasketId == null || taskIds == null) {
throw new InvalidArgumentException("DestinationWorkbasketId or TaskIds canĀ“t be used as NULL-Parameter.");
}
Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketId);
return transferTasks(taskIds, destinationWorkbasket);
} finally {
LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketId, taskIds);
taskanaEngine.returnConnection();
}
}
Aggregations