1 package org.simantics.modeling;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
6 import org.simantics.db.common.request.PossibleIndexRoot;
7 import org.simantics.db.common.utils.NameUtils;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.variable.StandardGraphChildVariable;
10 import org.simantics.db.layer0.variable.StandardGraphPropertyVariable;
11 import org.simantics.db.layer0.variable.Variable;
12 import org.simantics.db.layer0.variable.VariableBuilder;
13 import org.simantics.db.layer0.variable.VariableNode;
15 public class ImmutableComponentVariableBuilder<Node> implements VariableBuilder<Node> {
18 public Variable buildChild(ReadGraph graph, Variable parent, VariableNode<Node> node, Resource child) throws DatabaseException {
19 boolean isImmutable = graph.isImmutable(child);
20 Resource possibleIndexRoot = graph.syncRequest(new PossibleIndexRoot(child));
21 if(possibleIndexRoot != null) {
22 // String puri = graph.getURI(possibleIndexRoot);
23 // if(puri.contains("ModelBroker"))
24 // isImmutable = true;
25 // if(NameUtils.getSafeName(graph, child).equals("Project"))
26 // isImmutable = false;
29 // System.err.println("ImmutableComponentVariableContentRequest " + parent.getURI(graph) + " " + NameUtils.getSafeName(graph, child));
30 ImmutableComponentVariableContent content = graph.syncRequest(new ImmutableComponentVariableContentRequest(child), TransientCacheListener.instance());
31 return new ImmutableComponentVariable(parent, content);
33 return new StandardGraphChildVariable(parent, node, child);
38 public Variable buildProperty(ReadGraph graph, Variable parent, VariableNode<Node> node, Resource subject, Resource predicate) throws DatabaseException {
39 return new StandardGraphPropertyVariable(graph, parent, node, subject, predicate);