use of pro.taskana.rest.resource.WorkbasketAccessItemResource in project taskana by Taskana.
the class WorkbasketDefinitionMapper method toResource.
/**
* maps the distro targets to their id to remove overhead.
*
* @param basket
* {@link Workbasket} which will be converted
* @return a {@link WorkbasketDefinition}, containing the {@code basket}, its distribution targets and its
* authorizations
* @throws NotAuthorizedException
* if the user is not authorized
* @throws WorkbasketNotFoundException
* if {@code basket} is an unknown workbasket
*/
public WorkbasketDefinition toResource(Workbasket basket) throws NotAuthorizedException, WorkbasketNotFoundException {
List<WorkbasketAccessItemResource> authorizations = new ArrayList<>();
for (WorkbasketAccessItem accessItem : workbasketService.getWorkbasketAccessItems(basket.getKey())) {
authorizations.add(workbasketAccessItemMapper.toResource(accessItem));
}
Set<String> distroTargets = workbasketService.getDistributionTargets(basket.getId()).stream().map(WorkbasketSummary::getId).collect(Collectors.toSet());
WorkbasketDefinition resource = new WorkbasketDefinition(workbasketMapper.toResource(basket), distroTargets, authorizations);
return addLinks(resource, basket);
}
Aggregations