]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
For PSaaS private/balas6
authorAntti Villberg <antti.villberg@semantum.fi>
Tue, 13 Nov 2018 05:53:59 +0000 (07:53 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Tue, 13 Nov 2018 05:53:59 +0000 (07:53 +0200)
Change-Id: Ia17882d6622fc7e280049dc2d4dee1c378ad386a

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ProxyVariableSupport.java [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ProxyVariables.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphChildVariable.java
bundles/org.simantics.document.base.ontology/graph/Components.pgraph
bundles/org.simantics.document.base.ontology/graph/Properties.pgraph
bundles/org.simantics.document.server/scl/Document/All.scl
bundles/org.simantics.document.server/src/org/simantics/document/server/DocumentProperties.java [new file with mode: 0644]
bundles/org.simantics.document.server/src/org/simantics/document/server/DocumentServerUtils.java
bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java
bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequest.java
bundles/org.simantics.structural2/src/org/simantics/structural2/queries/StructuralChildMapOfResource.java [new file with mode: 0644]

diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ProxyVariableSupport.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ProxyVariableSupport.java
new file mode 100644 (file)
index 0000000..9ae52c6
--- /dev/null
@@ -0,0 +1,10 @@
+package org.simantics.db.layer0.variable;
+
+import org.simantics.db.ReadGraph;
+
+public interface ProxyVariableSupport {
+
+    Variable attachTo(ReadGraph graph, Variable parent);
+    Variable attachToRenamed(ReadGraph graph, Variable parent, String name);
+    
+}
index db552650b09c7098074bfd069b954a9b5d80ca15..d288802e040a562ee4618a42e2d60a71ec0e9a13 100644 (file)
@@ -5,6 +5,22 @@ import org.simantics.db.exception.DatabaseException;
 
 public class ProxyVariables {
        
+    public static Variable tryToOwn(ReadGraph graph, Variable parent, Variable variable) {
+        if(variable instanceof ProxyVariableSupport) {
+            ProxyVariableSupport pvs = (ProxyVariableSupport)variable;
+            return pvs.attachTo(graph, parent);
+        }
+        return null;
+    }
+
+    public static Variable tryToOwnRenamed(ReadGraph graph, Variable parent, Variable variable, String name) {
+        if(variable instanceof ProxyVariableSupport) {
+            ProxyVariableSupport pvs = (ProxyVariableSupport)variable;
+            return pvs.attachToRenamed(graph, parent, name);
+        }
+        return null;
+    }
+
        public static Variable inputVariable(ReadGraph graph, Variable context) throws DatabaseException {
        Variable session = graph.syncRequest(new ProxySessionRequest(context));
        if(session == null) return null;
index b784754bfa69ce8187999cb78af598506552c45d..5ab9d50283cb0801a456a3ada386c366be7052f8 100644 (file)
@@ -24,7 +24,7 @@ import org.simantics.db.layer0.variable.Variables.Role;
 import org.simantics.layer0.Layer0;
 import org.simantics.simulator.variable.exceptions.NodeManagerException;
 
-public class StandardGraphChildVariable extends AbstractChildVariable {
+public class StandardGraphChildVariable extends AbstractChildVariable implements ProxyVariableSupport {
 
        /*
         * Extension points
@@ -335,5 +335,20 @@ public class StandardGraphChildVariable extends AbstractChildVariable {
     public Resource getPossiblePredicateResource(ReadGraph graph) throws DatabaseException {
        return null;
     }
+
+    @Override
+    public Variable attachTo(ReadGraph graph, Variable parent) {
+        return new StandardGraphChildVariable(parent, node, resource);
+    }
+    
+    @Override
+    public Variable attachToRenamed(ReadGraph graph, Variable parent, String name) {
+        return new StandardGraphChildVariable(parent, node, resource) {
+            @Override
+            public String getName(ReadGraph graph) throws DatabaseException {
+                return name;
+            }
+        };
+    }
        
 }
index 099755380dc64c4ff874d8d1fe637ef97bc954f6..65a75d288777bc3556ef802cfa1d0219828aba9f 100644 (file)
@@ -67,9 +67,7 @@ COMPONENTS.Component <T STR.Component
     @sclAttribute PROPERTIES.commands "commandList self" "[Command]"
 
 COMPONENTS.PrimitiveComponent <T COMPONENTS.Component
-    @L0.assert PROPERTIES.primitiveProperties
-      _ : L0.Value
-        L0.domainProperties FUNCTIONS.primitiveProperties
+    @L0.sclAssertion PROPERTIES.primitiveProperties "primitiveProperties" "DocumentProperties"
 
 COMPONENTS.ParentlessComponent <T COMPONENTS.PrimitiveComponent /* Component without a parent, e.g. Root, DialogBox */
 
@@ -88,7 +86,7 @@ COMPONENTS.Event <T COMPONENTS.ParentlessComponent
  
 COMPONENTS.CommandEvent <T COMPONENTS.Event
    @connectionPoint RELATIONS.data1
-   @sclAttribute PROPERTIES.dataDefinitions "dataDefinitions self" "[DataDefinition]"
+   @sclAttribute PROPERTIES.dataDefinitions "computeDataDefinitions self" "[DataDefinition]"
    @sclAttribute PROPERTIES.SCLFunction "emptyOnClick ()" "String"
 
 DOC.commandEvent : L0.Template
index d502e3d2f2e860ed22dbdc56340c9e44954a643d..e1c71fe976a62df8b76c3a213c51418a8dbabd34 100644 (file)
@@ -52,7 +52,7 @@ PROPERTIES.model <R L0.HasProperty : L0.FunctionalRelation
     ==> "Variable"
 
 PROPERTIES.primitiveProperties <R L0.HasProperty : L0.FunctionalRelation
-    ==> "String"
+    ==> "DocumentProperties"
 
 PROPERTIES.exists
     @defAttribute L0.Value
index 4db639f5bf2696a389669d527bae19b035978064..6eaf328a32d64cd67ba13e64ded08f915cc31a02 100644 (file)
@@ -2,6 +2,9 @@ import "Simantics/DB"
 import "Simantics/Variables"
 import "JavaBuiltin" as Java
 
+importJava "org.simantics.document.server.DocumentProperties" where
+    data DocumentProperties
+
 importJava "org.simantics.document.server.io.IConsole" where
     data IConsole
     addMessage :: IConsole -> String -> <Proc> ()
@@ -110,6 +113,9 @@ importJava "org.simantics.document.server.Functions" where
 
     dataDefinitions :: Variable -> <ReadGraph> [DataDefinition]
 
+    @JavaName "dataDefinitions"
+    computeDataDefinitions :: Variable -> <ReadGraph> [DataDefinition]
+
     emptyOnClick :: () -> <ReadGraph> AbstractEventHandler
     
     writeEventHandler :: Variable -> (Variable -> (String -> Maybe String) -> <WriteGraph> String) -> <ReadGraph> AbstractEventHandler
@@ -138,6 +144,8 @@ importJava "org.simantics.document.server.Functions" where
     stateVariable :: Variable -> <ReadGraph> Variable
     
     compileDocumentSCLValueExpression :: Variable -> <ReadGraph> String
+
+    primitiveProperties :: <Proc> DocumentProperties
     
 propertyValueCached :: Serializable a => Typeable a => Variable -> String -> <ReadGraph> a
 propertyValueCached var prop = propertyValueCached_ var prop binding
diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/DocumentProperties.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/DocumentProperties.java
new file mode 100644 (file)
index 0000000..2951b93
--- /dev/null
@@ -0,0 +1,14 @@
+package org.simantics.document.server;
+
+import java.util.Collection;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+
+public interface DocumentProperties {
+       
+       Collection<String> getKeys(ReadGraph graph, Variable context) throws DatabaseException;
+       Object getValue(ReadGraph graph, Variable context, String key) throws DatabaseException;
+       
+}
index 5e1f5cc30e798aff45343b8f8c5f4483b6d8a9cc..d059bd7b4db289839fae135a38fdb8797a823c66 100644 (file)
@@ -19,359 +19,353 @@ import org.simantics.db.layer0.variable.ProxyChildVariable;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.document.base.ontology.DocumentationResource;
-import org.simantics.document.server.Functions.RootVariable;
 import org.simantics.document.server.request.NodeRequest;
 import org.simantics.document.server.request.NodeRequestUtils;
 import org.simantics.structural2.variables.Connection;
 import org.simantics.structural2.variables.VariableConnectionPointDescriptor;
-import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.strings.AlphanumComparator;
 
 public class DocumentServerUtils {
 
     public static Collection<Variable> getChildren(ReadGraph graph, Variable variable) throws DatabaseException {
 
-       DocumentationResource DOC = DocumentationResource.getInstance(graph);
-       
-               ArrayList<Variable> result = new ArrayList<Variable>();
-               for(Variable property : variable.getProperties(graph)) {
-                       Collection<String> classifications = property.getPossiblePropertyValue(graph, Variables.CLASSIFICATIONS);
-                       if(classifications != null) {
-                               if(classifications.contains(DocumentationResource.URIs.Document_ChildRelation)) {
-                                       Connection conn = property.getValue(graph);
-                                       Variable childConnectionPoint = DocumentServerUtils.getPossibleOtherConnectionPoint(graph, property, conn);
-                                       if(childConnectionPoint != null) {
-                                               result.add(childConnectionPoint.getParent(graph));
-                                       }
-                               } else if (DOC.Relations_partN.equals(property.getPossiblePredicateResource(graph))) {
-                                       Connection conn = property.getValue(graph);
-                                       for (Variable childConnectionPoint : DocumentServerUtils.getOtherConnectionPoints(graph, property, conn)) {
-                                               result.add(childConnectionPoint.getParent(graph));
-                                       }
-                               }
-                       }
-               }
-               return result;
-
-       }
+        DocumentationResource DOC = DocumentationResource.getInstance(graph);
+        
+        ArrayList<Variable> result = new ArrayList<Variable>();
+        for(Variable property : variable.getProperties(graph)) {
+            Collection<String> classifications = property.getPossiblePropertyValue(graph, Variables.CLASSIFICATIONS);
+            if(classifications != null) {
+                if(classifications.contains(DocumentationResource.URIs.Document_ChildRelation)) {
+                    Connection conn = property.getValue(graph);
+                    Variable childConnectionPoint = DocumentServerUtils.getPossibleOtherConnectionPoint(graph, property, conn);
+                    if(childConnectionPoint != null) {
+                        result.add(childConnectionPoint.getParent(graph));
+                    }
+                } else if (DOC.Relations_partN.equals(property.getPossiblePredicateResource(graph))) {
+                    Connection conn = property.getValue(graph);
+                    for (Variable childConnectionPoint : DocumentServerUtils.getOtherConnectionPoints(graph, property, conn)) {
+                        result.add(childConnectionPoint.getParent(graph));
+                    }
+                }
+            }
+        }
+        return result;
+
+    }
     
-       public static String findManualOrdinal(ReadGraph graph, Variable v) throws DatabaseException {
-               DocumentationResource DOC = DocumentationResource.getInstance(graph);
-               Integer j = null;
-               while (j == null && v != null) {
-                       j = v.getPossiblePropertyValue(graph, DOC.Components_Component_manualOrdinal);
-                       v = v.getParent(graph);
-               }
-               if (j != null) {
-                       return Integer.toString(j);
-               } else {
-                       return null;
-               }
-       }
+    public static String findManualOrdinal(ReadGraph graph, Variable v) throws DatabaseException {
+        DocumentationResource DOC = DocumentationResource.getInstance(graph);
+        Integer j = null;
+        while (j == null && v != null) {
+            j = v.getPossiblePropertyValue(graph, DOC.Components_Component_manualOrdinal);
+            v = v.getParent(graph);
+        }
+        if (j != null) {
+            return Integer.toString(j);
+        } else {
+            return null;
+        }
+    }
     
     public static Collection<Variable> getChildrenInOrdinalOrder(ReadGraph graph, Variable variable) throws DatabaseException {
-       DocumentationResource DOC = DocumentationResource.getInstance(graph);
-       
-               SortedMap<String, Variable> childMap = new TreeMap<String, Variable>(AlphanumComparator.COMPARATOR);
-               
-               for(Variable property : variable.getProperties(graph, DocumentationResource.URIs.Document_ChildRelation)) {
-                       Resource cp = property.getPossiblePredicateResource(graph);
-                       String i = graph.getRelatedValue(cp, DOC.Document_ChildRelation_ordinal, Bindings.STRING);
-                       Connection conn = property.getValue(graph);
-                       Variable childConnectionPoint = DocumentServerUtils.getPossibleOtherConnectionPoint(graph, property, conn);
-                       if(childConnectionPoint != null) {
-                               childMap.put(i, childConnectionPoint.getParent(graph));
-                       }
-               }
-               
-               Variable property = variable.getPossibleProperty(graph, "partN");
-               if(property != null) {
-                       Connection conn = property.getValue(graph);
-                       for (Variable childConnectionPoint : DocumentServerUtils.getOtherConnectionPoints(graph, property, conn)) {
-                               Variable child = childConnectionPoint.getParent(graph);
-                               String i = findManualOrdinal(graph, child);
-                               if (i == null) {
-                                       i = "0";
-                               }
-                               childMap.put(i, child);
-                       }
-               }
-
-               return childMap.values();
-
-       }    
-
-       public static Collection<Variable> collectNodes(ReadGraph graph, Variable variable, Collection<Variable> nodes) throws DatabaseException {
-
-               DocumentationResource DOC = DocumentationResource.getInstance(graph);
-
-               Resource type = variable.getPossibleType(graph);
-               if(type == null) return nodes;
-               
-               if(!graph.isInheritedFrom(type, DOC.Components_Component)) return nodes;
-
-               Boolean enabled = variable.getPossiblePropertyValue(graph, DOC.Properties_exists, Bindings.BOOLEAN);
-               if(enabled != null && !enabled) return nodes;
-
-               if(graph.isInheritedFrom(type, DOC.Components_PrimitiveComponent)) {
-                       nodes.add(variable);
-               } else {
-                       for(Variable child : variable.getChildren(graph)) {
-                               collectNodes(graph, child, nodes);
-                       }
-               }
-
-               return nodes;
-
-       }
-
-       public static Variable getPossibleOtherConnectionPoint(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
-
-               Collection<VariableConnectionPointDescriptor> descs = conn.getConnectionPointDescriptors(graph, null);
-               if(descs.size() != 2) return null;
-
-               for(VariableConnectionPointDescriptor desc : descs) {
-                       if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
-                       return desc.getVariable(graph);
-               }
-               
-               return null;
-
-       }
-
-       public static Variable getPossibleChildConnectionPoint(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
-
-               Collection<VariableConnectionPointDescriptor> descs = conn.getConnectionPointDescriptors(graph, null);
-               if(descs.size() != 2) return null;
-
-       DocumentationResource DOC = DocumentationResource.getInstance(graph);
-               
-               for(VariableConnectionPointDescriptor desc : descs) {
-                       Resource res = desc.getConnectionPointResource(graph);
-                       if(graph.isInstanceOf(res, DOC.Relations_parentRelation)) continue;
-                       //if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
-                       return desc.getVariable(graph);
-               }
-               
-               return null;
-
-       }
-       
-       public static Collection<Variable> getOtherConnectionPoints(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
-
-               ArrayList<Variable> connectionPoints = new ArrayList<Variable>();
-               
-               Collection<VariableConnectionPointDescriptor> descs = conn.getConnectionPointDescriptors(graph, null);
-
-               for(VariableConnectionPointDescriptor desc : descs) {
-                       if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
-                       connectionPoints.add(desc.getVariable(graph));
-               }
-               
-               return connectionPoints;
-
-       }
-
-       public static Variable getPossibleCommandTriggerConnectionPoint(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
-
-               Collection<Variable> cpts = conn.getConnectionPoints(graph, null);
-
-               Variable result = null;
-               
-               for(Variable cpt : cpts) {
-                       Set<String> classifications = cpt.getClassifications(graph);
-                       if(classifications.contains(DocumentationResource.URIs.Relations_commandExecutorRelation)) {
-                               if(result != null) throw new DatabaseException("Multiple executor connection points in command connection");
-                               result = cpt;
-                       }
-               }
-               
-               return result;
-
-       }
-
-       public static Collection<Variable> getPossibleOtherConnectionPoints(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
-
-           Collection<Variable> cpts = conn.getConnectionPoints(graph, null);
-           if(cpts.size() < 2) 
-               return Collections.emptyList();
-
-           ArrayList<Variable> result = new ArrayList<Variable>();
-           for(Variable cpt : cpts) {
-               if(!cpt.equals(connectionPoint)) 
-                   result.add(cpt);
-           }
-           return result;
-       }
-
-       public static String getId(ReadGraph graph, Variable node) throws DatabaseException {
-
-               if(node == null) return "root";
-               else {
-                       String uri = node.getURI(graph); 
-                       int l = uri.lastIndexOf(ProxyChildVariable.CONTEXT_END);
-                       return uri.substring(l+4);
-               }
-
-       }
-
-       public static Object getValue(ReadGraph graph, Variable attrib) throws DatabaseException {
-               return graph.syncRequest(new DocumentValue(attrib));
-       }
-
-       public static Variable getParentConnectionPoint(ReadGraph graph, Variable component) throws DatabaseException {
-
-               Variable connectionPoint = component.getPossibleProperty(graph, "parent");
-               if(connectionPoint == null) {
-                       DocumentationResource DOC = DocumentationResource.getInstance(graph);
-                       Collection<Variable> cps = component.getProperties(graph, DOC.Relations_parentRelation);
-                       if(cps.size() == 1) {
-                               connectionPoint = cps.iterator().next();
-                       } else {
-                               return null;
-                       }
-               }
-               
-               Connection conn = connectionPoint.getValue(graph);
-               Variable otherCp = DocumentServerUtils.getPossibleOtherConnectionPoint(graph, connectionPoint, conn);
-               if (otherCp != null) {
-                       return otherCp;
-               } else {
-                       Variable parentCp = graph.sync(new UnaryRead<Connection, Variable>(conn) {
-                   @Override
-                   public Variable perform(ReadGraph graph) throws DatabaseException {
-                       DocumentationResource DOC = DocumentationResource.getInstance(graph);
-                       Collection<VariableConnectionPointDescriptor> descs = parameter.getConnectionPointDescriptors(graph, null);
-
-                               for(VariableConnectionPointDescriptor desc : descs) {
-                                       if (DOC.Relations_partN.equals(desc.getConnectionPointResource(graph))) {
-                                               return desc.getVariable(graph);
-                                       }
-                               }
-                               return null;
-                   }
-               });
-                       if (parentCp != null) {
-                               return parentCp;
-                       }
-               }
-               return null;
-
-       }
-       
-       /* Children */
-       public static Collection<Variable> getChildConnections(ReadGraph graph, Variable variable) throws DatabaseException {
-               return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_ChildRelation);
-       }
-
-       /* Command sequence */
-       public static Collection<Variable> getTriggerCommands(ReadGraph graph, Variable variable) throws DatabaseException {
-               ArrayList<Variable> result = new ArrayList<Variable>();
-               DocumentationResource DOC = DocumentationResource.getInstance(graph);
-               for(Variable var : variable.getProperties(graph, DOC.Document_CommandRelation)) {
+        DocumentationResource DOC = DocumentationResource.getInstance(graph);
+        
+        SortedMap<String, Variable> childMap = new TreeMap<String, Variable>(AlphanumComparator.COMPARATOR);
+        
+        for(Variable property : variable.getProperties(graph, DocumentationResource.URIs.Document_ChildRelation)) {
+            Resource cp = property.getPossiblePredicateResource(graph);
+            String i = graph.getRelatedValue(cp, DOC.Document_ChildRelation_ordinal, Bindings.STRING);
+            Connection conn = property.getValue(graph);
+            Variable childConnectionPoint = DocumentServerUtils.getPossibleOtherConnectionPoint(graph, property, conn);
+            if(childConnectionPoint != null) {
+                childMap.put(i, childConnectionPoint.getParent(graph));
+            }
+        }
+        
+        Variable property = variable.getPossibleProperty(graph, "partN");
+        if(property != null) {
+            Connection conn = property.getValue(graph);
+            for (Variable childConnectionPoint : DocumentServerUtils.getOtherConnectionPoints(graph, property, conn)) {
+                Variable child = childConnectionPoint.getParent(graph);
+                String i = findManualOrdinal(graph, child);
+                if (i == null) {
+                    i = "0";
+                }
+                childMap.put(i, child);
+            }
+        }
+
+        return childMap.values();
+
+    }    
+
+    public static Collection<Variable> collectNodes(ReadGraph graph, Variable variable, Collection<Variable> nodes) throws DatabaseException {
+
+        DocumentationResource DOC = DocumentationResource.getInstance(graph);
+
+        Resource type = variable.getPossibleType(graph);
+        if(type == null) return nodes;
+        
+        if(!graph.isInheritedFrom(type, DOC.Components_Component)) return nodes;
+
+        Boolean enabled = variable.getPossiblePropertyValue(graph, DOC.Properties_exists, Bindings.BOOLEAN);
+        if(enabled != null && !enabled) return nodes;
+
+        if(graph.isInheritedFrom(type, DOC.Components_PrimitiveComponent)) {
+            nodes.add(variable);
+        } else {
+            for(Variable child : variable.getChildren(graph)) {
+                collectNodes(graph, child, nodes);
+            }
+        }
+
+        return nodes;
+
+    }
+
+    public static Variable getPossibleOtherConnectionPoint(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
+
+        Collection<VariableConnectionPointDescriptor> descs = conn.getConnection2().getConnectionPointDescriptors(graph, connectionPoint.getParent(graph), null);
+        if(descs.size() != 2) return null;
+
+        for(VariableConnectionPointDescriptor desc : descs) {
+            if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
+            return desc.getVariable(graph);
+        }
+        
+        return null;
+
+    }
+
+    public static Variable getPossibleChildConnectionPoint(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
+
+        Collection<VariableConnectionPointDescriptor> descs = conn.getConnection2().getConnectionPointDescriptors(graph, connectionPoint.getParent(graph), null);
+        if(descs.size() != 2) return null;
+
+        DocumentationResource DOC = DocumentationResource.getInstance(graph);
+        
+        for(VariableConnectionPointDescriptor desc : descs) {
+            Resource res = desc.getConnectionPointResource(graph);
+            if(graph.isInstanceOf(res, DOC.Relations_parentRelation)) continue;
+            //if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
+            return desc.getVariable(graph);
+        }
+        
+        return null;
+
+    }
+    
+    public static Collection<Variable> getOtherConnectionPoints(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
+
+        ArrayList<Variable> connectionPoints = new ArrayList<Variable>();
+        
+        Collection<VariableConnectionPointDescriptor> descs = conn.getConnectionPointDescriptors(graph, null);
+
+        for(VariableConnectionPointDescriptor desc : descs) {
+            if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
+            connectionPoints.add(desc.getVariable(graph));
+        }
+        
+        return connectionPoints;
+
+    }
+
+    public static Variable getPossibleCommandTriggerConnectionPoint(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
+
+        Collection<Variable> cpts = conn.getConnection2().getConnectionPoints(graph, connectionPoint.getParent(graph), null);
+
+        Variable result = null;
+        
+        for(Variable cpt : cpts) {
+            Set<String> classifications = cpt.getClassifications(graph);
+            if(classifications.contains(DocumentationResource.URIs.Relations_commandExecutorRelation)) {
+                if(result != null) throw new DatabaseException("Multiple executor connection points in command connection");
+                result = cpt;
+            }
+        }
+        
+        return result;
+
+    }
+
+    public static Collection<Variable> getPossibleOtherConnectionPoints(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
+
+        Collection<Variable> cpts = conn.getConnection2().getConnectionPoints(graph, connectionPoint.getParent(graph), null);
+        if(cpts.size() < 2) 
+            return Collections.emptyList();
+
+        ArrayList<Variable> result = new ArrayList<Variable>();
+        for(Variable cpt : cpts) {
+            if(!cpt.equals(connectionPoint)) 
+                result.add(cpt);
+        }
+        return result;
+    }
+
+    public static String getId(ReadGraph graph, Variable node) throws DatabaseException {
+
+        if(node == null) return "root";
+        else {
+            String name = node.getName(graph);
+            if(ProxyChildVariable.CONTEXT_END.equals(name)) return "";
+            else {
+                String parentId = getId(graph, node.getParent(graph));
+                if(parentId.isEmpty()) return name;
+                else return parentId + "/" + name; 
+            }
+            
+        }
+
+    }
+
+    public static Object getValue(ReadGraph graph, Variable attrib) throws DatabaseException {
+        return graph.syncRequest(new DocumentValue(attrib));
+    }
+
+    public static Variable getParentConnectionPoint(ReadGraph graph, Variable component) throws DatabaseException {
+
+        Variable connectionPoint = component.getPossibleProperty(graph, "parent");
+        if(connectionPoint == null) {
+            DocumentationResource DOC = DocumentationResource.getInstance(graph);
+            Collection<Variable> cps = component.getProperties(graph, DOC.Relations_parentRelation);
+            if(cps.size() == 1) {
+                connectionPoint = cps.iterator().next();
+            } else {
+                return null;
+            }
+        }
+        
+        Connection conn = connectionPoint.getValue(graph);
+        Variable otherCp = DocumentServerUtils.getPossibleOtherConnectionPoint(graph, connectionPoint, conn);
+        if (otherCp != null) {
+            return otherCp;
+        } else {
+            Variable parentCp = graph.sync(new UnaryRead<Connection, Variable>(conn) {
+                @Override
+                public Variable perform(ReadGraph graph) throws DatabaseException {
+                    DocumentationResource DOC = DocumentationResource.getInstance(graph);
+                    Collection<VariableConnectionPointDescriptor> descs = parameter.getConnectionPointDescriptors(graph, null);
+
+                    for(VariableConnectionPointDescriptor desc : descs) {
+                        if (DOC.Relations_partN.equals(desc.getConnectionPointResource(graph))) {
+                            return desc.getVariable(graph);
+                        }
+                    }
+                    return null;
+                }
+            });
+            if (parentCp != null) {
+                return parentCp;
+            }
+        }
+        return null;
+
+    }
+    
+    /* Children */
+    public static Collection<Variable> getChildConnections(ReadGraph graph, Variable variable) throws DatabaseException {
+        return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_ChildRelation);
+    }
+
+    /* Command sequence */
+    public static Collection<Variable> getTriggerCommands(ReadGraph graph, Variable variable) throws DatabaseException {
+        ArrayList<Variable> result = new ArrayList<Variable>();
+        DocumentationResource DOC = DocumentationResource.getInstance(graph);
+        for(Variable var : variable.getProperties(graph, DOC.Document_CommandRelation)) {
             if(DOC.Relations_broadcasted.equals(var.getPredicateResource(graph))) continue;
             result.add(var);
-               }
-               return result;
-       }
-
-       public static Collection<Variable> getCommands(ReadGraph graph, Variable variable) throws DatabaseException {
-               return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_CommandRelation);
-       }
-
-       /* Data definition */
-       public static Collection<Variable> getDataDefinitions(ReadGraph graph, Variable variable) throws DatabaseException {
-               return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_DataDefinitionRelation);
-       }
-
-       /* Data relation */
-       public static Collection<Variable> getDataRelations(ReadGraph graph, Variable variable) throws DatabaseException {
-               return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_DataRelation);
-       }
-
-       /* Attributes */
-       public static Collection<Variable> getAttributes(ReadGraph graph, DocumentationResource DOC, Variable variable) throws DatabaseException {
-               return variable.getProperties(graph, DOC.Document_AttributeRelation);
-       }
-       
-       public static class AttributesRequest extends VariableRead<Pair<JSONObject, Collection<Variable>>> {
-
-               public AttributesRequest(Variable variable) {
-                       super(variable);
-               }
-
-               @Override
-               public Pair<JSONObject,Collection<Variable>> perform(ReadGraph graph) throws DatabaseException {
-               ArrayList<Variable> statics = new ArrayList<Variable>();
-               DocumentationResource DOC = DocumentationResource.getInstance(graph);
-               
-               Variable primitives = variable.getProperty(graph, DOC.Properties_primitiveProperties);
-               for(Variable property : primitives.getProperties(graph)) {
-                       statics.add(property);
-                       // NO SUPPORT FOR DYNAMICS AT THIS STAGE
-               }
-               
-               JSONObject staticContent = computeStatic(graph, variable, statics);
-               
-               return new Pair<JSONObject, Collection<Variable>>(staticContent, Collections.emptyList());
-               
-               }
-               
-               JSONObject computeStatic(ReadGraph graph, Variable variable, ArrayList<Variable> statics) throws DatabaseException {
-                       
-                       JSONObject base = graph.syncRequest(new org.simantics.document.server.request.DefaultFields(variable));
-                       JSONObject object = base.clone();
-                       
-                       for(Variable attrib : statics) {
-                               String name = attrib.getName(graph);
-                               try {
-                                       if (name.equals(NodeRequest.PROPERTY_VALUE_EXCEPTIONS)) {
-                                       @SuppressWarnings("unchecked")
-                                               Map<String, Exception> exceptions = (Map<String, Exception>)DocumentServerUtils.getValue(graph, attrib);
-                                       
-                                       List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
-                                           if(errorList == null)
-                                               errorList = new ArrayList<String>();
-                                           
-                                   for (Map.Entry<String, Exception> entry : exceptions.entrySet()) {
-                                       String errorMessage = NodeRequestUtils.formatErrorMessage(entry.getKey(), entry.getValue());
-                                       errorList.add(errorMessage);
-                                   }
-                                       object.addJSONField(NodeRequest.ERRORS, errorList);
-                                       
-                                   } else {
-                                               Object value = DocumentServerUtils.getValue(graph, attrib);
-                                           object.addJSONField(name, value);
-                                   }
-                               } catch (Throwable t) {
-                                   List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
-                                   if(errorList == null)
-                                       errorList = new ArrayList<String>();
-                                   
-                           String errorMessage = NodeRequestUtils.formatErrorMessage(name, t);
-                           
-                                   errorList.add(errorMessage);
-                                   object.addJSONField(NodeRequest.ERRORS, errorList);
-                               }
-
-                       }
-
-                       return object;
-                       
-               }
-               
-       }
-
-       public static Collection<Variable> getDynamicAttributes(ReadGraph graph, final DocumentationResource DOC, Variable variable) throws DatabaseException {
-       Pair<JSONObject, Collection<Variable>> attribs = graph.syncRequest(new AttributesRequest(variable));
-       return attribs.second;
-       }
-       
-       public static Variable getPossibleDocumentRootVariable(ReadGraph graph, Variable documentPart) throws DatabaseException {
-               if(documentPart instanceof RootVariable) return documentPart;
-               Variable parent = documentPart.getParent(graph);
-               if(parent == null) return null;
-               return getPossibleDocumentRootVariable(graph, parent);
-       }
+        }
+        return result;
+    }
+
+    public static Collection<Variable> getCommands(ReadGraph graph, Variable variable) throws DatabaseException {
+        return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_CommandRelation);
+    }
+
+    /* Data definition */
+    public static Collection<Variable> getDataDefinitions(ReadGraph graph, Variable variable) throws DatabaseException {
+        return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_DataDefinitionRelation);
+    }
+
+    /* Data relation */
+    public static Collection<Variable> getDataRelations(ReadGraph graph, Variable variable) throws DatabaseException {
+        return variable.getProperties(graph, DocumentationResource.getInstance(graph).Document_DataRelation);
+    }
+
+    /* Attributes */
+    public static Collection<Variable> getAttributes(ReadGraph graph, DocumentationResource DOC, Variable variable) throws DatabaseException {
+        return variable.getProperties(graph, DOC.Document_AttributeRelation);
+    }
+    
+    public static class AttributesRequest extends VariableRead<JSONObject> {
+
+        public AttributesRequest(Variable variable) {
+            super(variable);
+        }
+
+        @Override
+        public JSONObject perform(ReadGraph graph) throws DatabaseException {
+
+            DocumentationResource DOC = DocumentationResource.getInstance(graph);
+            
+            DocumentProperties properties = variable.getPropertyValue(graph, DOC.Properties_primitiveProperties); 
+            
+            return computeStatic(graph, variable, properties);
+            
+        }
+        
+        JSONObject computeStatic(ReadGraph graph, Variable variable, DocumentProperties statics) throws DatabaseException {
+            
+            JSONObject base = graph.syncRequest(new org.simantics.document.server.request.DefaultFields(variable));
+            JSONObject object = base.clone();
+            
+            for(String name : statics.getKeys(graph, variable)) {
+                try {
+                    if (name.equals(NodeRequest.PROPERTY_VALUE_EXCEPTIONS)) {
+                        @SuppressWarnings("unchecked")
+                        Map<String, Exception> exceptions = (Map<String, Exception>)statics.getValue(graph, variable, name);//(Map<String, Exception>)DocumentServerUtils.getValue(graph, attrib);
+                        
+                        List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
+                        if(errorList == null)
+                            errorList = new ArrayList<String>();
+                        
+                        for (Map.Entry<String, Exception> entry : exceptions.entrySet()) {
+                            String errorMessage = NodeRequestUtils.formatErrorMessage(entry.getKey(), entry.getValue());
+                            errorList.add(errorMessage);
+                        }
+                        object.addJSONField(NodeRequest.ERRORS, errorList);
+                        
+                    } else {
+                        object.addJSONField(name, statics.getValue(graph, variable, name));
+                    }
+                } catch (Throwable t) {
+                    List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
+                    if(errorList == null)
+                        errorList = new ArrayList<String>();
+                    
+                    String errorMessage = NodeRequestUtils.formatErrorMessage(name, t);
+                    
+                    errorList.add(errorMessage);
+                    object.addJSONField(NodeRequest.ERRORS, errorList);
+                }
+
+            }
+
+            return object;
+            
+        }
+        
+    }
+
+    public static Collection<Variable> getDynamicAttributes(ReadGraph graph, final DocumentationResource DOC, Variable variable) throws DatabaseException {
+        return Collections.emptyList();
+    }
+    
+    public static Variable getPossibleDocumentRootVariable(ReadGraph graph, Variable documentPart) throws DatabaseException {
+        if(ProxyChildVariable.CONTEXT_END.equals(documentPart.getName(graph))) return documentPart;
+        Variable parent = documentPart.getParent(graph);
+        if(parent == null) return null;
+        return getPossibleDocumentRootVariable(graph, parent);
+    }
 
 }
index aabe7b29ffd04dbcdff684dc899f11f2bde8c19f..4e46fdb14cba4c0960550b38afc1e92a0a8a306b 100644 (file)
@@ -15,7 +15,6 @@ import org.simantics.databoard.Bindings;
 import org.simantics.databoard.Datatypes;
 import org.simantics.databoard.binding.Binding;
 import org.simantics.databoard.type.Datatype;
-import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.DirectStatements;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.RequestProcessor;
@@ -25,7 +24,7 @@ import org.simantics.db.Statement;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.primitiverequest.Adapter;
 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
-import org.simantics.db.common.request.UnaryRead;
+import org.simantics.db.common.request.BinaryRead;
 import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.common.request.WriteResultRequest;
 import org.simantics.db.common.utils.Logger;
@@ -42,15 +41,14 @@ import org.simantics.db.layer0.scl.SCLDatabaseException;
 import org.simantics.db.layer0.variable.ConstantPropertyVariable;
 import org.simantics.db.layer0.variable.ProxyChildVariable;
 import org.simantics.db.layer0.variable.ProxySessionRequest;
+import org.simantics.db.layer0.variable.ProxyVariableSupport;
 import org.simantics.db.layer0.variable.ProxyVariables;
 import org.simantics.db.layer0.variable.StandardAssertedGraphPropertyVariable;
-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.VariableMap;
 import org.simantics.db.layer0.variable.VariableMapImpl;
 import org.simantics.db.layer0.variable.Variables;
-import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.db.service.DirectQuerySupport;
 import org.simantics.document.base.ontology.DocumentationResource;
 import org.simantics.document.server.bean.Command;
@@ -107,21 +105,6 @@ public class Functions {
 
     private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Functions.class);
     
-    private static class PrimitivePropertyStatementsProcedure implements AsyncProcedure<DirectStatements> {
-
-        public DirectStatements result;
-
-        @Override
-        public void execute(AsyncReadGraph graph, DirectStatements result) {
-            this.result = result;
-        }
-
-        @Override
-        public void exception(AsyncReadGraph graph, Throwable throwable) {
-        }
-
-    }
-
     @SCLValue(type = "VariableMap")
     public static VariableMap primitiveProperties = new VariableMapImpl() {
        private void storePropertyValueAndExceptions(ReadGraph graph, Variable parent, String name, Variable property, Map<String, Variable> map) {
@@ -229,11 +212,39 @@ public class Functions {
 
     };
 
+    static class StandardDocumentProperties implements DocumentProperties {
+
+        @Override
+        public Collection<String> getKeys(ReadGraph graph, Variable context) throws DatabaseException {
+            
+            DocumentationResource DOC = DocumentationResource.getInstance(graph);
+            StandardGraphPropertyVariable asd = new StandardGraphPropertyVariable(graph, context, DOC.Properties_primitiveProperties);
+            Map<String, Variable> ps = primitiveProperties.getVariables(graph, asd, null);
+            return ps.keySet();
+            
+        }
+
+        @Override
+        public Object getValue(ReadGraph graph, Variable context, String key) throws DatabaseException {
+            
+            DocumentationResource DOC = DocumentationResource.getInstance(graph);
+            StandardGraphPropertyVariable asd = new StandardGraphPropertyVariable(graph, context, DOC.Properties_primitiveProperties);
+            Map<String, Variable> ps = primitiveProperties.getVariables(graph, asd, null);
+            return ps.get(key).getValue(graph);
+            
+        }
+        
+    }
+    
+    public static DocumentProperties primitiveProperties() throws DatabaseException {
+        return new StandardDocumentProperties();
+    }
+    
     @SCLValue(type = "VariableMap")
     public static VariableMap inputSpaceChildren = new VariableMapImpl() {
 
         private Variable getProxy(ReadGraph graph, Variable context) throws DatabaseException {
-            Variable root = Variables.getRootVariable(graph);
+            Variable root = Variables.getVariable(graph, graph.getRootLibrary());   
             return new DocumentProxyChildVariable(context, context, root, ProxyChildVariable.CONTEXT_BEGIN);
         }
 
@@ -257,7 +268,7 @@ public class Functions {
 
     };
 
-    static class DocumentProxyChildVariable extends ProxyChildVariable {
+    static class DocumentProxyChildVariable extends ProxyChildVariable implements ProxyVariableSupport {
 
         public DocumentProxyChildVariable(Variable base, Variable parent, Variable other, String name) {
             super(base, parent, other, name);
@@ -275,7 +286,7 @@ public class Functions {
                        // The context is also a proxy - let it do the job
                     return super.getPossibleChild(graph, name);
                } else {
-                       return new RootVariable(this, base.getRepresents(graph));
+                   return ProxyVariables.tryToOwnRenamed(graph, this, base, CONTEXT_END);
                }
                }
 
@@ -283,33 +294,17 @@ public class Functions {
 
         }
 
-        public Collection<Variable> getChildren(ReadGraph graph) throws DatabaseException {
-
-            Collection<Variable> result = super.getChildren(graph);
-            if(!(base instanceof ProxyChildVariable)) {
-               result.add(new RootVariable(this, base.getRepresents(graph)));
-            }
-            return result;
-
-        }
-
-    }
-
-    static class RootVariable extends StandardGraphChildVariable {
-
-        public RootVariable(DocumentProxyChildVariable parent, Resource resource) {
-            super(parent, null, resource);
-        }
-
         @Override
-        public String getName(ReadGraph graph) throws DatabaseException {
-            return ProxyChildVariable.CONTEXT_END;
+        public Variable attachTo(ReadGraph graph, Variable parent) {
+            return attachToRenamed(graph, parent, name);
         }
-
-        @SuppressWarnings("deprecation")
+        
         @Override
-        public Variable getNameVariable(ReadGraph graph) throws DatabaseException {
-            return new ConstantPropertyVariable(this, Variables.NAME, ProxyChildVariable.CONTEXT_END, Bindings.STRING);
+        public Variable attachToRenamed(ReadGraph graph, Variable parent, String name) {
+            if(this.parent.equals(base))
+                return new DocumentProxyChildVariable(parent, parent, other, name);
+            else
+                return new DocumentProxyChildVariable(base, parent, other, name);
         }
 
     }
@@ -1252,11 +1247,11 @@ public class Functions {
                                                return true;
                                        }
                                } else {
-                                       Variable parentCp = graph.sync(new UnaryRead<Connection, Variable>(conn) {
+                                       Variable parentCp = graph.sync(new BinaryRead<Variable, Connection, Variable>(widget, conn) {
                                    @Override
                                    public Variable perform(ReadGraph graph) throws DatabaseException {
                                        DocumentationResource DOC = DocumentationResource.getInstance(graph);
-                                       Collection<VariableConnectionPointDescriptor> descs = parameter.getConnectionPointDescriptors(graph, null);
+                                       Collection<VariableConnectionPointDescriptor> descs = parameter2.getConnection2().getConnectionPointDescriptors(graph, parameter, null);
 
                                                for(VariableConnectionPointDescriptor desc : descs) {
                                                        if (DOC.Relations_partN.equals(desc.getConnectionPointResource(graph))) {
index d9418db9947d482fecd4daf547d85359363bea5c..9367a151d6879d663698b44b4e0883528d468074 100644 (file)
@@ -1,67 +1,28 @@
 package org.simantics.document.server.request;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
 import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.VariableRead;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.document.server.DocumentServerUtils.AttributesRequest;
 import org.simantics.document.server.JSONObject;
-import org.simantics.utils.datastructures.Pair;
 
 public class NodeRequest extends VariableRead<JSONObject> {
 
     public static final String ERRORS = "Errors";
     public static final String PROPERTY_VALUE_EXCEPTIONS = "_PropertyValueExceptions";
-    
-       public NodeRequest(Variable node) {
-               super(node);
-       }
-
-       @SuppressWarnings("unchecked")
-    @Override
-       public JSONObject perform(ReadGraph graph) throws DatabaseException {
-
-               long s = System.nanoTime();
-
-               Pair<JSONObject, Collection<Variable>> attribs = graph.syncRequest(new AttributesRequest(variable));
-
-           JSONObject staticContent = attribs.first;
-           if(attribs.second.isEmpty()) {
-
-               if(DocumentRequest.PROFILE) {
-                       long dura = System.nanoTime()-s;
-                   if(dura > DocumentRequest.PROFILE_THRESHOLD_NODEREQUEST * 1e3) {
-                       System.err.println("NodeRequest " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph));
-                   }
-               }
-
-               return staticContent;
-           }
 
-           Map<String,Object> dynamicContent = graph.syncRequest(new NodeRequestDynamic(variable));
-           if(dynamicContent.isEmpty()) {
-               return staticContent;
-           }
-
-        JSONObject result = staticContent.clone();
-        result.add(dynamicContent);
+    public NodeRequest(Variable node) {
+        super(node);
+    }
 
-        if(dynamicContent.containsKey(ERRORS) || staticContent.getJSONField(ERRORS) != null) {
-            ArrayList<String> errorList = new ArrayList<>();
+    @SuppressWarnings("unchecked")
+    @Override
+    public JSONObject perform(ReadGraph graph) throws DatabaseException {
 
-            if(dynamicContent.containsKey(ERRORS))
-                errorList.addAll((List<String>)dynamicContent.get(ERRORS));
+        long s = System.nanoTime();
 
-            if(staticContent.getJSONField(ERRORS) != null)
-                errorList.addAll((List<String>)staticContent.getJSONField(ERRORS));
-
-            result.addJSONField(ERRORS, errorList);
-        }
+        JSONObject staticContent = graph.syncRequest(new AttributesRequest(variable));
 
         if(DocumentRequest.PROFILE) {
             long dura = System.nanoTime()-s;
@@ -69,8 +30,9 @@ public class NodeRequest extends VariableRead<JSONObject> {
                 System.err.println("NodeRequest " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph));
             }
         }
-        
-        return result;
+
+
+        return staticContent;
 
     }
 
diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/StructuralChildMapOfResource.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/StructuralChildMapOfResource.java
new file mode 100644 (file)
index 0000000..4243c1d
--- /dev/null
@@ -0,0 +1,34 @@
+package org.simantics.structural2.queries;
+
+import java.util.Map;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.common.uri.UnescapedChildMapOfResource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.structural.stubs.StructuralResource2;
+
+public class StructuralChildMapOfResource extends ResourceRead<Map<String, Resource>> {
+
+    public StructuralChildMapOfResource(Resource resource) {
+        super(resource);
+    }
+
+    @Override
+    public Map<String, Resource> perform(ReadGraph graph) throws DatabaseException {
+        StructuralResource2 STR = StructuralResource2.getInstance(graph);
+        Resource type = graph.getPossibleType(resource, STR.Component);
+        if(type != null) {
+            Resource definition = graph.getPossibleObject(type, STR.IsDefinedBy);
+            if(definition != null) {
+                Map<String, Resource> map = graph.syncRequest(new UnescapedChildMapOfResource(definition));
+                if (!map.isEmpty())
+                    return map;
+            } 
+        }
+        Map<String, Resource> directChildren = graph.syncRequest(new UnescapedChildMapOfResource(resource));
+        return directChildren;
+    }
+
+}
\ No newline at end of file