Search in sources :

Example 31 with WorkbasketAccessItem

use of pro.taskana.WorkbasketAccessItem 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);
}
Also used : WorkbasketDefinition(pro.taskana.rest.resource.WorkbasketDefinition) WorkbasketAccessItemResource(pro.taskana.rest.resource.WorkbasketAccessItemResource) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) ArrayList(java.util.ArrayList)

Aggregations

WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)31 Test (org.junit.Test)18 WithAccessId (pro.taskana.security.WithAccessId)16 AbstractAccTest (acceptance.AbstractAccTest)11 WorkbasketService (pro.taskana.WorkbasketService)11 ArrayList (java.util.ArrayList)6 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)6 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)5 WorkbasketAccessItemResource (pro.taskana.rest.resource.WorkbasketAccessItemResource)5 Task (pro.taskana.Task)4 Connection (java.sql.Connection)3 KeyDomain (pro.taskana.KeyDomain)3 TaskService (pro.taskana.TaskService)3 TaskSummary (pro.taskana.TaskSummary)3 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)3 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)3 NotAuthorizedToQueryWorkbasketException (pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException)3 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)3 WorkbasketAccessItemImpl (pro.taskana.impl.WorkbasketAccessItemImpl)3 SQLException (java.sql.SQLException)2