use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class WorkbasketServiceImpl method getDistributionSources.
@Override
public List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain) throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("entry to getDistributionSources(workbasketKey = {}, domain = {})", workbasketKey, domain);
List<WorkbasketSummary> result = new ArrayList<>();
try {
taskanaEngine.openConnection();
// check that source workbasket exists
Workbasket workbasket = getWorkbasket(workbasketKey, domain);
if (!taskanaEngine.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN)) {
checkAuthorization(workbasket.getId(), WorkbasketPermission.READ);
}
List<WorkbasketSummaryImpl> distributionSources = workbasketMapper.findDistributionSources(workbasket.getId());
result.addAll(distributionSources);
return result;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result.size();
LOGGER.debug("exit from getDistributionSources(workbasketId). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
}
}
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class WorkbasketQueryImpl method single.
@Override
public WorkbasketSummary single() {
LOGGER.debug("entry to single(), this = {}", this);
WorkbasketSummary workbasket = null;
try {
taskanaEngine.openConnection();
handleCallerRolesAndAccessIds();
workbasket = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
return workbasket;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", workbasket);
}
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class WorkbasketController method getWorkbaskets.
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<WorkbasketSummaryResource>> getWorkbaskets(@RequestParam(value = "sortBy", defaultValue = "name", required = false) String sortBy, @RequestParam(value = "order", defaultValue = "asc", required = false) String order, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "nameLike", required = false) String nameLike, @RequestParam(value = "key", required = false) String key, @RequestParam(value = "keyLike", required = false) String keyLike, @RequestParam(value = "descLike", required = false) String descLike, @RequestParam(value = "owner", required = false) String owner, @RequestParam(value = "ownerLike", required = false) String ownerLike, @RequestParam(value = "type", required = false) String type, @RequestParam(value = "requiredPermission", required = false) String requiredPermission, @RequestParam(value = "page", required = false) String page, @RequestParam(value = "pagesize", required = false) String pageSize) throws InvalidArgumentException {
WorkbasketQuery query = workbasketService.createWorkbasketQuery();
addSortingToQuery(query, sortBy, order);
addAttributeFilter(query, name, nameLike, key, keyLike, descLike, owner, ownerLike, type);
addAuthorizationFilter(query, requiredPermission);
PageMetadata pageMetadata = null;
List<WorkbasketSummary> workbasketSummaries = null;
if (page != null && pageSize != null) {
// paging
long totalElements = query.count();
pageMetadata = initPageMetadata(pageSize, page, totalElements);
workbasketSummaries = query.listPage((int) pageMetadata.getNumber(), (int) pageMetadata.getSize());
} else if (page == null && pageSize == null) {
// not paging
workbasketSummaries = query.list();
} else {
throw new InvalidArgumentException("Paging information is incomplete.");
}
WorkbasketSummaryResourcesAssembler assembler = new WorkbasketSummaryResourcesAssembler();
PagedResources<WorkbasketSummaryResource> pagedResources = assembler.toResources(workbasketSummaries, pageMetadata);
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class WorkbasketDefinitionController method exportWorkbaskets.
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<List<WorkbasketDefinition>> exportWorkbaskets(@RequestParam(required = false) String domain) {
try {
WorkbasketQuery workbasketQuery = workbasketService.createWorkbasketQuery();
List<WorkbasketSummary> workbasketSummaryList = domain != null ? workbasketQuery.domainIn(domain).list() : workbasketQuery.list();
List<WorkbasketDefinition> basketExports = new ArrayList<>();
for (WorkbasketSummary summary : workbasketSummaryList) {
Workbasket workbasket = workbasketService.getWorkbasket(summary.getId());
basketExports.add(workbasketDefinitionMapper.toResource(workbasket));
}
return new ResponseEntity<>(basketExports, HttpStatus.OK);
} catch (WorkbasketNotFoundException e) {
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} catch (NotAuthorizedException e) {
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}
}
use of pro.taskana.WorkbasketSummary in project taskana by Taskana.
the class WorkbasketServiceImplIntExplicitTest method testUpdateWorkbasket.
@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testUpdateWorkbasket() throws Exception {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService();
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(workbasket3.getId(), 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());
connection.commit();
}
Aggregations