1 package org.simantics.db.layer0.request;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.SessionModel;
6 import org.simantics.db.common.request.ResourceRead;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.operation.Layer0X;
9 import org.simantics.user.UserResource;
11 public class ActiveSessionRole extends ResourceRead<Resource> {
13 public ActiveSessionRole(Resource model) {
18 public Resource perform(ReadGraph graph) throws DatabaseException {
19 Layer0X L0X = Layer0X.getInstance(graph);
20 UserResource USER = UserResource.getInstance(graph);
21 Resource session = graph.getService(SessionModel.class).getResource();
22 for(Resource selection : graph.getObjects(session, L0X.Session_HasRoleSelection)) {
23 Resource model = graph.getPossibleObject(selection, USER.RoleSelection_HasModel);
24 if(model.equals(resource)) {
25 return graph.getPossibleObject(selection, USER.RoleSelection_HasRole);
28 return USER.DefaultRole;