X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fscl%2FGraphEntityType.java;h=d59ea605cb2f3f40e7f0e5ae6077b65063ae05de;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=cd7a6d163caf3c2263302c54ad438d8d2957b451;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphEntityType.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphEntityType.java index cd7a6d163..d59ea605c 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphEntityType.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphEntityType.java @@ -1,84 +1,84 @@ -package org.simantics.modeling.scl; - -import static org.simantics.scl.compiler.elaboration.expressions.Expressions.externalConstant; -import gnu.trove.map.hash.THashMap; - -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.scl.compiler.common.names.Name; -import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; -import org.simantics.scl.compiler.elaboration.expressions.EApply; -import org.simantics.scl.compiler.elaboration.expressions.EConstant; -import org.simantics.scl.compiler.elaboration.expressions.EVariable; -import org.simantics.scl.compiler.elaboration.expressions.Expression; -import org.simantics.scl.compiler.elaboration.expressions.Variable; -import org.simantics.scl.compiler.elaboration.java.CheckRelation; -import org.simantics.scl.compiler.elaboration.query.QAtom; -import org.simantics.scl.compiler.elaboration.query.QConjunction; -import org.simantics.scl.compiler.elaboration.query.Query; -import org.simantics.scl.compiler.elaboration.relations.SCLEntityType; -import org.simantics.scl.compiler.elaboration.relations.SCLRelation; -import org.simantics.scl.compiler.types.Types; - -public class GraphEntityType implements SCLEntityType { - - Resource type; - THashMap attributeMap = new THashMap(); - - public GraphEntityType(ReadGraph graph, Resource type) throws DatabaseException { - this.type = type; - Layer0 L0 = Layer0.getInstance(graph); - for(Resource stype : graph.getSupertypes(type)) - addSupertype(graph, L0, stype); - addSupertype(graph, L0, type); - addRelation(graph, L0, L0.PartOf); - } - - private void addSupertype(ReadGraph graph, Layer0 L0, Resource type) throws DatabaseException { - for(Resource relation : graph.getObjects(type, L0.DomainOf)) - addRelation(graph, L0, relation); - } - - private void addRelation(ReadGraph graph, Layer0 L0, Resource relation) throws DatabaseException { - String relationName = (String)graph.getRelatedValue(relation, L0.HasName, Bindings.STRING); - attributeMap.put(relationName, new GraphAttribute(OntologyModule.createRelation(graph, relation))); - } - - private static final Name DB_isInstanceOf = Name.create("Simantics/DB", "isInstanceOf"); - - @Override - public Query generateQuery(TranslationContext context, Variable base, - AttributeBinding[] attributeBindings) { - Query[] queries = new Query[attributeBindings.length+1]; - for(int i=0;i attributeMap = new THashMap(); + + public GraphEntityType(ReadGraph graph, Resource type) throws DatabaseException { + this.type = type; + Layer0 L0 = Layer0.getInstance(graph); + for(Resource stype : graph.getSupertypes(type)) + addSupertype(graph, L0, stype); + addSupertype(graph, L0, type); + addRelation(graph, L0, L0.PartOf); + } + + private void addSupertype(ReadGraph graph, Layer0 L0, Resource type) throws DatabaseException { + for(Resource relation : graph.getObjects(type, L0.DomainOf)) + addRelation(graph, L0, relation); + } + + private void addRelation(ReadGraph graph, Layer0 L0, Resource relation) throws DatabaseException { + String relationName = (String)graph.getRelatedValue(relation, L0.HasName, Bindings.STRING); + attributeMap.put(relationName, new GraphAttribute(OntologyModule.createRelation(graph, relation))); + } + + private static final Name DB_isInstanceOf = Name.create("Simantics/DB", "isInstanceOf"); + + @Override + public Query generateQuery(TranslationContext context, Variable base, + AttributeBinding[] attributeBindings) { + Query[] queries = new Query[attributeBindings.length+1]; + for(int i=0;i