1 package org.simantics.db.layer0.request;
3 import java.util.ArrayList;
4 import java.util.Collection;
6 import org.simantics.db.ReadGraph;
7 import org.simantics.db.Resource;
8 import org.simantics.db.common.request.ResourceRead2;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.layer0.adapter.Instances;
11 import org.simantics.user.UserResource;
13 public class PossibleRoles extends ResourceRead2<Collection<Resource>> {
15 public PossibleRoles(Resource model, Resource user) {
20 public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
22 UserResource USER = UserResource.getInstance(graph);
23 ArrayList<Resource> result = new ArrayList<Resource>();
24 Instances query = graph.adapt(USER.RoleAssignment, Instances.class);
25 for(Resource assignment : query.find(graph, resource)) {
26 if(graph.syncRequest(new IsUserAssigned(assignment, resource2))) {
27 result.addAll(graph.getObjects(assignment, USER.RoleAssignment_HasRole));
30 result.add(USER.DefaultRole);