package org.simantics.modeling; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.procedure.adapter.TransientCacheListener; import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.StandardGraphChildVariable; import org.simantics.db.layer0.variable.StandardGraphPropertyVariable; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.VariableBuilder; import org.simantics.db.layer0.variable.VariableNode; public class ImmutableComponentVariableBuilder implements VariableBuilder { @Override public Variable buildChild(ReadGraph graph, Variable parent, VariableNode node, Resource child) throws DatabaseException { boolean isImmutable = graph.isImmutable(child); Resource possibleIndexRoot = graph.syncRequest(new PossibleIndexRoot(child)); if(possibleIndexRoot != null) { // String puri = graph.getURI(possibleIndexRoot); // if(puri.contains("ModelBroker")) // isImmutable = true; // if(NameUtils.getSafeName(graph, child).equals("Project")) // isImmutable = false; } if(isImmutable) { // System.err.println("ImmutableComponentVariableContentRequest " + parent.getURI(graph) + " " + NameUtils.getSafeName(graph, child)); ImmutableComponentVariableContent content = graph.syncRequest(new ImmutableComponentVariableContentRequest(child), TransientCacheListener.instance()); return new ImmutableComponentVariable(parent, content); } else { return new StandardGraphChildVariable(parent, node, child); } } @Override public Variable buildProperty(ReadGraph graph, Variable parent, VariableNode node, Resource subject, Resource predicate) throws DatabaseException { return new StandardGraphPropertyVariable(graph, parent, node, subject, predicate); } }