1 package org.simantics.db.layer0.request;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.common.request.ResourceRead;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.layer0.variable.StandardGraphChildVariable;
8 import org.simantics.db.layer0.variable.Variable;
9 import org.simantics.layer0.Layer0;
11 public class ResourceToPossibleVariable extends ResourceRead<Variable> {
13 public ResourceToPossibleVariable(Resource resource) {
18 public Variable perform(ReadGraph graph) throws DatabaseException {
20 Layer0 L0 = Layer0.getInstance(graph);
21 Resource parent = graph.getPossibleObject(resource, L0.PartOf);
23 if(graph.getRootLibrary().equals(resource)) return new StandardGraphChildVariable(null, null, graph.getRootLibrary());
26 Variable parentVariable = graph.syncRequest(new ResourceToPossibleVariable(parent));
27 if(parentVariable == null) return null;
28 return parentVariable.browsePossible(graph, resource);