]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Support pending values in NodeManager 94/4094/2
authorAntti Villberg <antti.villberg@semantum.fi>
Sun, 5 Apr 2020 13:43:55 +0000 (16:43 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Sun, 5 Apr 2020 13:52:46 +0000 (16:52 +0300)
gitlab #511

Change-Id: I75b309dffe494d552c442c65e672cc62c3c334ad

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/function/All.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/NodeValueRequest.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java
bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardNodeManager.java
bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/NodeManager.java

index f52148c2a6b2306d9c8d4b6c0ce9e31cb5e89efe..671810d8e40853938414353d82fdc7440ccb37bd 100644 (file)
@@ -36,7 +36,6 @@ import org.simantics.db.common.uri.UnescapedChildMapOfResource;
 import org.simantics.db.common.utils.CommonDBUtils;
 import org.simantics.db.common.utils.Functions;
 import org.simantics.db.common.utils.ListUtils;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.common.utils.NearestOwnerFinder;
 import org.simantics.db.common.validation.L0Validations;
@@ -92,15 +91,19 @@ import org.simantics.simulator.variable.exceptions.NodeManagerException;
 import org.simantics.utils.Development;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.strings.StringInputValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.set.hash.THashSet;
 
 public class All {
 
-       public static Object standardGetValue1(ReadGraph graph, Variable context) throws DatabaseException {
+    private static final Logger LOGGER = LoggerFactory.getLogger(All.class);
 
-               StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+    public static Object standardGetValue1(ReadGraph graph, Variable context) throws DatabaseException {
+
+        StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
 
         // First from node
         if(variable.node != null) {
@@ -108,59 +111,61 @@ public class All {
             if(Variables.PENDING_NODE_VALUE == value) throw new PendingVariableException("");
             return value.getValue();
         }
-               
-               try {
+
+        try {
 
             if(variable.property.hasEnumerationRange) {
-                       Resource object = variable.getRepresents(graph);
-                               if(graph.sync(new IsEnumeratedValue(object))) {
-                           Layer0 L0 = Layer0.getInstance(graph);
-                                       if(graph.isInstanceOf(object, L0.Literal)) {
-                                               return graph.getValue(object);
-                                       } else {
-                                               String label = graph.getPossibleRelatedValue2(variable.getRepresents(graph), L0.HasLabel, Bindings.STRING);
-                                               if(label == null) label = graph.getPossibleRelatedValue(variable.getRepresents(graph), L0.HasName, Bindings.STRING);
-                                               if(label == null) label = "<no label>";
-                                               return label;
-                                       }
-                               }
+                Resource object = variable.getRepresents(graph);
+                if(graph.sync(new IsEnumeratedValue(object))) {
+                    Layer0 L0 = Layer0.getInstance(graph);
+                    if(graph.isInstanceOf(object, L0.Literal)) {
+                        return graph.getValue(object);
+                    } else {
+                        String label = graph.getPossibleRelatedValue2(variable.getRepresents(graph), L0.HasLabel, Bindings.STRING);
+                        if(label == null) label = graph.getPossibleRelatedValue(variable.getRepresents(graph), L0.HasName, Bindings.STRING);
+                        if(label == null) label = "<no label>";
+                        return label;
+                    }
+                }
             }
-                       
+
             if (variable.isAsserted()) {
-                               if (variable.parentResource != null) {
-                                       Map<String, Pair<PropertyInfo, Resource>> assertions = graph.syncRequest(
-                                                       new UnescapedAssertedPropertyMapOfResource(variable.parentResource),
-                                                       TransientCacheAsyncListener.instance());
-
-                                       // NOTE: This optimization assumes the property
-                                       // variable's representation is the asserted object.
-                                       Resource object = variable.getPossibleRepresents(graph);
-                                       if (object != null) {
-                                               return graph.getValue2(object, variable);
-                                       } else {
-                                               for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
-                                                       if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
-                                                               return graph.getValue2(assertion.second, variable);
-                                                       }
-                                               }
-                                       }
-                               }
+                if (variable.parentResource != null) {
+                    Map<String, Pair<PropertyInfo, Resource>> assertions = graph.syncRequest(
+                            new UnescapedAssertedPropertyMapOfResource(variable.parentResource),
+                            TransientCacheAsyncListener.instance());
+
+                    // NOTE: This optimization assumes the property
+                    // variable's representation is the asserted object.
+                    Resource object = variable.getPossibleRepresents(graph);
+                    if (object != null) {
+                        return graph.getValue2(object, variable);
+                    } else {
+                        for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
+                            if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
+                                return graph.getValue2(assertion.second, variable);
+                            }
+                        }
+                    }
+                }
             }
-                
-                       return graph.getValue2(variable.getRepresents(graph), variable);
-                       
-               } catch (NoSingleResultException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               } catch (DoesNotContainValueException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               } catch (DatabaseException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               }
-
-       }
-       
-       public static Object standardGetValue2(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {           
-               StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+
+            return graph.getValue2(variable.getRepresents(graph), variable);
+
+        } catch (PendingVariableException e) {
+            throw e;
+        } catch (NoSingleResultException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        } catch (DoesNotContainValueException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        } catch (DatabaseException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        }
+
+    }
+
+    public static Object standardGetValue2(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {              
+        StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
 
         // First from node
         if(variable.node != null) {
@@ -173,61 +178,61 @@ public class All {
                 throw new AdaptionException("Could not get value for " + context.getURI(graph), e);
             }
         }
-               
-       try {
-                       
-               if(variable.property.hasEnumerationRange) {
-               Resource object = variable.getRepresents(graph);
-               if(graph.sync(new IsEnumeratedValue(object))) {
-                       Layer0 L0 = Layer0.getInstance(graph);
-                       if(graph.isInstanceOf(object, L0.Literal)) {
-                               return graph.getValue(object, binding);
-                       } else {
-                               return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);
-                       }
-               }
+
+        try {
+
+            if(variable.property.hasEnumerationRange) {
+                Resource object = variable.getRepresents(graph);
+                if(graph.sync(new IsEnumeratedValue(object))) {
+                    Layer0 L0 = Layer0.getInstance(graph);
+                    if(graph.isInstanceOf(object, L0.Literal)) {
+                        return graph.getValue(object, binding);
+                    } else {
+                        return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);
+                    }
+                }
             }
-                       
-               if (variable.isAsserted()) {
-                       if (variable.parentResource != null) {
-                                       Map<String, Pair<PropertyInfo, Resource>> assertions = graph.syncRequest(
-                                                       new UnescapedAssertedPropertyMapOfResource(variable.parentResource),
-                                                       TransientCacheAsyncListener.instance());
-
-                                       // NOTE: This optimization assumes the property
-                                       // variable's representation is the asserted object.
-                                       Resource object = variable.getPossibleRepresents(graph);
-                                       if (object != null) {
-                                               return graph.getValue2(object, variable, binding);
-                                       } else {
-                                               for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
-                                                       if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
-                                                               return graph.getValue2(assertion.second, variable, binding);
-                                                       }
-                                               }
-                                       }
-                       }
-               }
-                       
-                       return graph.getValue2(variable.getRepresents(graph), context, binding);
-                       
-               } catch (NoSingleResultException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph));
-               } catch (DoesNotContainValueException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph));
-               } catch (DatabaseException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               }
-
-       }
-
-       public static void standardSetValue2(WriteGraph graph, Variable context, final Object value) throws DatabaseException {
-               
-           if(context instanceof StandardGraphPropertyVariable) {
-
-               final StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context; 
-               
-               // First from node
+
+            if (variable.isAsserted()) {
+                if (variable.parentResource != null) {
+                    Map<String, Pair<PropertyInfo, Resource>> assertions = graph.syncRequest(
+                            new UnescapedAssertedPropertyMapOfResource(variable.parentResource),
+                            TransientCacheAsyncListener.instance());
+
+                    // NOTE: This optimization assumes the property
+                    // variable's representation is the asserted object.
+                    Resource object = variable.getPossibleRepresents(graph);
+                    if (object != null) {
+                        return graph.getValue2(object, variable, binding);
+                    } else {
+                        for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
+                            if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
+                                return graph.getValue2(assertion.second, variable, binding);
+                            }
+                        }
+                    }
+                }
+            }
+
+            return graph.getValue2(variable.getRepresents(graph), context, binding);
+
+        } catch (NoSingleResultException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph));
+        } catch (DoesNotContainValueException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph));
+        } catch (DatabaseException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        }
+
+    }
+
+    public static void standardSetValue2(WriteGraph graph, Variable context, final Object value) throws DatabaseException {
+
+        if(context instanceof StandardGraphPropertyVariable) {
+
+            final StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context; 
+
+            // First from node
             if(variable.node != null) {
 
                 final Binding binding = Layer0Utils.getDefaultBinding(graph, variable);
@@ -243,8 +248,8 @@ public class All {
                             } catch (NodeManagerException e) {
                                 throw new RuntimeException(e);
                             } catch (BindingException e) {
-                                   throw new RuntimeException(e);
-                               }
+                                throw new RuntimeException(e);
+                            }
                         }
                     });
                 } catch(RuntimeException e) {
@@ -262,31 +267,31 @@ public class All {
 
                 return;
             }
-               
-           }
-           
-               Function4<WriteGraph, Variable, Object, Object, String> modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);
-               if(modifier == null) modifier = VariableUtils.defaultInputModifier; 
-               try {
-                       modifier.apply(graph, context, value, Bindings.getBinding(value.getClass()));
-               } catch (BindingConstructionException e) {
-                       throw new org.simantics.db.exception.BindingException("",e);
-               }
 
-       }
+        }
+
+        Function4<WriteGraph, Variable, Object, Object, String> modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);
+        if(modifier == null) modifier = VariableUtils.defaultInputModifier; 
+        try {
+            modifier.apply(graph, context, value, Bindings.getBinding(value.getClass()));
+        } catch (BindingConstructionException e) {
+            throw new org.simantics.db.exception.BindingException("",e);
+        }
+
+    }
 
-       public static void standardSetValue3(final WriteGraph graph, Variable context, final Object value, final Binding binding) throws DatabaseException {
+    public static void standardSetValue3(final WriteGraph graph, Variable context, final Object value, final Binding binding) throws DatabaseException {
 
         // First from node
         if(context instanceof StandardGraphPropertyVariable) {
 
             final StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context; 
-            
+
             // First from node
             if(variable.node != null) {
-                
+
                 try {
-                    
+
                     variable.node.support.manager.getRealm().syncExec(new Runnable() {
 
                         @Override
@@ -297,42 +302,42 @@ public class All {
                                 ExternalSetValue ext = new ExternalSetValue(variable.node.support.manager, variable.node.node, oldValue, value, binding);
                                 graph.getService(UndoRedoSupport.class).addExternalOperation(graph, ext);
                             } catch (NodeManagerException | BindingException e) {
-                                Logger.defaultLogError(e);
+                                LOGGER.error("Error setting value", e);
                             }
                         }
 
-                        
+
                     });
-                    
+
                     return;
-                    
+
                 } catch (InterruptedException e) {
                     throw new DatabaseException(e);
                 }
-                
+
             }
-            
+
         }
-           
-               Function4<WriteGraph, Variable, Object, Object, String> modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);
-               if(modifier == null) modifier = VariableUtils.defaultInputModifier; 
-               modifier.apply(graph, context, value, binding);
-
-       }
-
-       public static Datatype getDatatypeFromValue(ReadGraph graph, Variable context) throws DatabaseException {
-               if (context instanceof AbstractVariable) {
-                       Binding defaultBinding = ((AbstractVariable)context).getPossibleDefaultBinding(graph);
-                       if (defaultBinding != null)
-                               return defaultBinding.type();
-               }
-                       
-       Variant value = context.getVariantValue(graph);
-       if (value.getBinding() == null)
-               throw new DatabaseException("No value binding for " + context.getURI(graph));
-       
-       return value.getBinding().type();
-       }
+
+        Function4<WriteGraph, Variable, Object, Object, String> modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);
+        if(modifier == null) modifier = VariableUtils.defaultInputModifier; 
+        modifier.apply(graph, context, value, binding);
+
+    }
+
+    public static Datatype getDatatypeFromValue(ReadGraph graph, Variable context) throws DatabaseException {
+        if (context instanceof AbstractVariable) {
+            Binding defaultBinding = ((AbstractVariable)context).getPossibleDefaultBinding(graph);
+            if (defaultBinding != null)
+                return defaultBinding.type();
+        }
+
+        Variant value = context.getVariantValue(graph);
+        if (value.getBinding() == null)
+            throw new DatabaseException("No value binding for " + context.getURI(graph));
+
+        return value.getBinding().type();
+    }
 
     @SuppressWarnings("rawtypes")
     private static class DatatypeGetter implements VariableNodeReadRunnable {
@@ -360,25 +365,25 @@ public class All {
     }
 
     public static Datatype standardGetDatatype(ReadGraph graph, Variable context) throws DatabaseException {
-       if (context instanceof AbstractVariable) {
-               final AbstractVariable variable = (AbstractVariable)context;
-               if (variable.node != null) {
-                       try {
-                               DatatypeGetter request = new DatatypeGetter(variable.node);
-                               
-                                       variable.node.support.manager.getRealm().syncExec(request);
-                                       
-                                       if (request.exception != null)
-                                               throw new DatabaseException(request.exception);
-                                       
-                                       return request.type;
-                               } catch (InterruptedException e) {
-                               }
-               }
-       }
-       
-       return getDatatypeFromValue(graph, context);
-       }
+        if (context instanceof AbstractVariable) {
+            final AbstractVariable variable = (AbstractVariable)context;
+            if (variable.node != null) {
+                try {
+                    DatatypeGetter request = new DatatypeGetter(variable.node);
+
+                    variable.node.support.manager.getRealm().syncExec(request);
+
+                    if (request.exception != null)
+                        throw new DatabaseException(request.exception);
+
+                    return request.type;
+                } catch (InterruptedException e) {
+                }
+            }
+        }
+
+        return getDatatypeFromValue(graph, context);
+    }
 
 //     @SCLValue(type = "ValueAccessor")
 //     public static ValueAccessor standardValueAccessor = new ValueAccessor() {
@@ -409,54 +414,54 @@ public class All {
 //             }
 //             
 //     };
-       
-       @SCLValue(type = "ValueAccessor")
-       public static ValueAccessor standardValueAccessor = new ValueAccessor() {
-
-               @Override
-               public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {
-                       ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
-                       if(accessor != null) return accessor.getValue(graph, context);
-                       else 
-                               return standardGetValue1(graph, context);
-               }
-
-               @Override
-               public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {
-                       ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
-                       if(accessor != null) return accessor.getValue(graph, context, binding);
-                       else 
-                               return standardGetValue2(graph, context, binding);
-               }
-
-               @Override
-               public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {
-                       ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
-                       if(accessor != null) accessor.setValue(graph, context, value);
-                       else 
-                               standardSetValue2(graph, context, value);
-               }
-
-               @Override
-               public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {
-                       ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
-                       if(accessor != null) accessor.setValue(graph, context, value, binding);
-                       else 
-                               standardSetValue3(graph, context, value, binding);
-               }
-
-               @Override
-               public Datatype getDatatype(ReadGraph graph, Variable context)
-                               throws DatabaseException {
-                       ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
-                       if(accessor != null) return accessor.getDatatype(graph, context);
-                       else 
-                               return standardGetDatatype(graph, context);
-               }
-               
-       };
-
-       public static Variable getStandardChildDomainPropertyVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+
+    @SCLValue(type = "ValueAccessor")
+    public static ValueAccessor standardValueAccessor = new ValueAccessor() {
+
+        @Override
+        public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {
+            ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
+            if(accessor != null) return accessor.getValue(graph, context);
+            else 
+                return standardGetValue1(graph, context);
+        }
+
+        @Override
+        public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {
+            ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
+            if(accessor != null) return accessor.getValue(graph, context, binding);
+            else 
+                return standardGetValue2(graph, context, binding);
+        }
+
+        @Override
+        public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {
+            ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
+            if(accessor != null) accessor.setValue(graph, context, value);
+            else 
+                standardSetValue2(graph, context, value);
+        }
+
+        @Override
+        public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {
+            ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
+            if(accessor != null) accessor.setValue(graph, context, value, binding);
+            else 
+                standardSetValue3(graph, context, value, binding);
+        }
+
+        @Override
+        public Datatype getDatatype(ReadGraph graph, Variable context)
+                throws DatabaseException {
+            ValueAccessor accessor = getPossibleValueValueAccessor(graph, context);
+            if(accessor != null) return accessor.getDatatype(graph, context);
+            else 
+                return standardGetDatatype(graph, context);
+        }
+
+    };
+
+    public static Variable getStandardChildDomainPropertyVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
         StandardGraphChildVariable variable = (StandardGraphChildVariable)context;
         PropertyInfo graphProperty = getPossiblePropertyInfoFromContext(graph, variable, variable.resource, name);
         return getStandardChildDomainPropertyVariable(graph, context, graphProperty, name);
@@ -471,7 +476,7 @@ public class All {
         return null;
     }
 
-       public static Variable getStandardChildDomainPropertyVariable(ReadGraph graph, Variable context, PropertyInfo graphProperty, String name) throws DatabaseException {
+    public static Variable getStandardChildDomainPropertyVariable(ReadGraph graph, Variable context, PropertyInfo graphProperty, String name) throws DatabaseException {
         StandardGraphChildVariable variable = (StandardGraphChildVariable)context;
         Object propertyNode = getPossibleNodeProperty(graph, variable, name, true);
         if(graphProperty != null && graphProperty.builder != null)
@@ -511,41 +516,41 @@ public class All {
     }
 
     public static Map<String, Variable> getStandardChildDomainPropertyVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-       // Get properties with null identification
+        // Get properties with null identification
         return getStandardChildDomainPropertyVariables(graph, context, null, map);
     }
 
     public static Map<String, Variable> getStandardChildDomainPropertyVariables(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
-       
+
         StandardGraphChildVariable variable = (StandardGraphChildVariable)context;
-        
+
         Collection<Object> nodeProperties = getPossibleNodeProperties(graph, variable);
         if(!nodeProperties.isEmpty()) {
 
             // Get variables for properties read from the graph
             Map<String,PropertyInfo> graphProperties = collectPropertyInfosFromContext(graph, variable, variable.resource);
-            
+
             Set<String> used = new THashSet<String>(nodeProperties.size());
-            
+
             map = ensureVariableMap(map, graphProperties.size() + nodeProperties.size());
-            
+
             // Process NodeManager property nodes
             for(Object nodeProperty : nodeProperties) {
-               String name = getNodeName(variable, nodeProperty);
+                String name = getNodeName(variable, nodeProperty);
                 used.add(name);
-                
+
                 PropertyInfo graphProperty = graphProperties.get(name); 
                 if(graphProperty != null && graphProperty.builder != null) {
                     if (classification != null && !graphProperty.hasClassification(classification)) continue;
-                    
+
                     // Combine with identically named graph property
                     map.put(name, buildPropertyVariable(graph, variable, variable.resource, graphProperty, nodeProperty));
                     continue;
                 }
-                
+
                 map.put(name, createStandardGraphPropertyVariable(graph, variable, nodeProperty));
             }
-            
+
             // Process graph properties
             for(PropertyInfo info : graphProperties.values()) {
                 String name = info.name;
@@ -556,249 +561,249 @@ public class All {
                 }
             }
             return map;
-               
+
         } else {
 
-               if(variable.resource == null) return map;
+            if(variable.resource == null) return map;
+
+            // Only graph properties
+            Collection<Resource> predicates = graph.getPredicates(variable.resource);
+            if(predicates.isEmpty()) return map;
+
+            map = ensureVariableMap(map, predicates.size());
 
-               // Only graph properties
-               Collection<Resource> predicates = graph.getPredicates(variable.resource);
-               if(predicates.isEmpty()) return map;
-               
-               map = ensureVariableMap(map, predicates.size());
-               
             // Process graph properties
             for(Resource predicate : predicates) {
-               
-                       PropertyInfo info = //graph.isImmutable(predicate) ?
-                                       graph.syncRequest(new PropertyInfoRequest(predicate), TransientCacheAsyncListener.<PropertyInfo>instance());// :
-                                               //graph.syncRequest(new PropertyInfoRequest(predicate));
 
-                       if(!info.isHasProperty) continue;
-                                       
+                PropertyInfo info = //graph.isImmutable(predicate) ?
+                        graph.syncRequest(new PropertyInfoRequest(predicate), TransientCacheAsyncListener.<PropertyInfo>instance());// :
+                //graph.syncRequest(new PropertyInfoRequest(predicate));
+
+                if(!info.isHasProperty) continue;
+
                 if (classification != null && !info.hasClassification(classification)) continue;
                 if (info.builder != null) {
                     map.put(info.name, buildPropertyVariable(graph, variable, variable.resource, info, null));
                 }
-                
+
             }
-            
+
             return map;
-               
+
         }
-        
-     }
-       
+
+    }
+
     @SCLValue(type = "VariableMap")
-       public static VariableMap standardChildDomainProperties = new VariableMapImpl() {
-       
-               @Override
-               public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-               return getStandardChildDomainPropertyVariable(graph, context, name);
-               }
-
-               @Override
-               public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-                   return getStandardChildDomainPropertyVariables(graph, context, map);
-               }
-               
-       };
-       
+    public static VariableMap standardChildDomainProperties = new VariableMapImpl() {
+
+        @Override
+        public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+            return getStandardChildDomainPropertyVariable(graph, context, name);
+        }
+
+        @Override
+        public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+            return getStandardChildDomainPropertyVariables(graph, context, map);
+        }
+
+    };
+
     @SCLValue(type = "VariableMap")
-       public static VariableMap methodsPropertyDomainProperties = new VariableMapImpl() {
-       
-               @Override
-               public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-                       Variable parent = context.getParent(graph);
-                       Resource container = parent.getPossibleRepresents(graph);
-                       if(container == null)
-                               return null;
-                       Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
-                       Resource predicate = methods.get(name);
-                       if(predicate != null) {
-                               Layer0 L0 = Layer0.getInstance(graph);
-                               PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
-                               Resource value = graph.getSingleObject(container, predicate);
-                               return new StandardGraphPropertyVariable(context, null, container, info, value);
-                       }
-                       return null;
-               }
-
-               @Override
-               public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-                       Variable parent = context.getParent(graph);
-                       Resource container = parent.getPossibleRepresents(graph);
-                       if(container == null)
-                               return Collections.emptyMap();
-                       Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
-                       for(Map.Entry<String, Resource> entry : methods.entrySet()) {
-                               String name = entry.getKey();
-                               Resource predicate = entry.getValue();
-                               Layer0 L0 = Layer0.getInstance(graph);
-                               PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
-                               Resource value = graph.getSingleObject(container, predicate);
-                               if(map == null) map = new HashMap<>();
-                               map.put(name, new StandardGraphPropertyVariable(context, null, container, info, value));
-                       }
-                       return map;
-               }
-               
-       };
-
-       public static Variable getStandardPropertyDomainPropertyVariableFromValue(ReadGraph graph, Variable context, String name) throws DatabaseException {
-
-               if(context instanceof StandardGraphPropertyVariable) {
-               StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
-               Resource literal = variable.getPossibleRepresents(graph);
-               Object propertyNode = getPossibleNodeProperty(graph, variable, name, false);
-
-               if(literal != null) {
-                       Variable result = getPossiblePropertyFromContext(graph, variable, literal, name, propertyNode);
-                       if(result != null) return result;
-               }
-               
-               Variable result = getPossibleSubliteralPropertyFromContext(graph, variable, name);
-               if(result != null) return result;
-               result = getPossiblePropertyFromContext(graph, variable, variable.property.predicate, name, propertyNode);
-               if (result != null) return result;
-               
-               // Get possible property from NodeManager
-               if (propertyNode != null)
-                       return createStandardGraphPropertyVariable(graph, variable, propertyNode);
-               return null;
-               } else if (context instanceof StandardGraphChildVariable) {
-                       return standardChildDomainProperties.getVariable(graph, context, name);
-               } else {
-                       throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
-               }                       
-               
-       }
-       
-       public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-
-               if(context instanceof StandardGraphPropertyVariable) {
-                       StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
-                       map = collectPropertiesFromContext(graph, variable, variable.property.predicate, map);
-                       if (variable.parentResource != null) {
-                               Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
-                               if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, map);
-                               map=collectSubliteralProperties(graph, variable, map);
-                       }
-
-                       // Get properties from VariableNode
-                       map = getStandardNodePropertyVariables(graph, context, map);
-                       return map;
-               } else if (context instanceof StandardGraphChildVariable) {
-                       return standardChildDomainProperties.getVariables(graph, context, map);
-               } else {
-                       throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
-               }
-               
-       }
-       
-       public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
-
-               if(context instanceof StandardGraphPropertyVariable) {
-                       StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
-                       map = collectPropertiesFromContext(graph, variable, variable.property.predicate, classification, map);
-                       if (variable.parentResource != null) {
-                               Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
-                               if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, classification, map);
-                       }
-                       
-                       // Get properties from VariableNode
-                       map = getStandardNodePropertyVariables(graph, context, map);
-                       return map;
-               } else if (context instanceof StandardGraphChildVariable) {
-                       return standardChildDomainProperties.getVariables(graph, context, map);
-               } else {
-                       throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
-               }       
-               
-       }       
-       
+    public static VariableMap methodsPropertyDomainProperties = new VariableMapImpl() {
+
+        @Override
+        public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+            Variable parent = context.getParent(graph);
+            Resource container = parent.getPossibleRepresents(graph);
+            if(container == null)
+                return null;
+            Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
+            Resource predicate = methods.get(name);
+            if(predicate != null) {
+                Layer0 L0 = Layer0.getInstance(graph);
+                PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
+                Resource value = graph.getSingleObject(container, predicate);
+                return new StandardGraphPropertyVariable(context, null, container, info, value);
+            }
+            return null;
+        }
+
+        @Override
+        public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+            Variable parent = context.getParent(graph);
+            Resource container = parent.getPossibleRepresents(graph);
+            if(container == null)
+                return Collections.emptyMap();
+            Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
+            for(Map.Entry<String, Resource> entry : methods.entrySet()) {
+                String name = entry.getKey();
+                Resource predicate = entry.getValue();
+                Layer0 L0 = Layer0.getInstance(graph);
+                PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
+                Resource value = graph.getSingleObject(container, predicate);
+                if(map == null) map = new HashMap<>();
+                map.put(name, new StandardGraphPropertyVariable(context, null, container, info, value));
+            }
+            return map;
+        }
+
+    };
+
+    public static Variable getStandardPropertyDomainPropertyVariableFromValue(ReadGraph graph, Variable context, String name) throws DatabaseException {
+
+        if(context instanceof StandardGraphPropertyVariable) {
+            StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+            Resource literal = variable.getPossibleRepresents(graph);
+            Object propertyNode = getPossibleNodeProperty(graph, variable, name, false);
+
+            if(literal != null) {
+                Variable result = getPossiblePropertyFromContext(graph, variable, literal, name, propertyNode);
+                if(result != null) return result;
+            }
+
+            Variable result = getPossibleSubliteralPropertyFromContext(graph, variable, name);
+            if(result != null) return result;
+            result = getPossiblePropertyFromContext(graph, variable, variable.property.predicate, name, propertyNode);
+            if (result != null) return result;
+
+            // Get possible property from NodeManager
+            if (propertyNode != null)
+                return createStandardGraphPropertyVariable(graph, variable, propertyNode);
+            return null;
+        } else if (context instanceof StandardGraphChildVariable) {
+            return standardChildDomainProperties.getVariable(graph, context, name);
+        } else {
+            throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+        }                      
+
+    }
+
+    public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+
+        if(context instanceof StandardGraphPropertyVariable) {
+            StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+            map = collectPropertiesFromContext(graph, variable, variable.property.predicate, map);
+            if (variable.parentResource != null) {
+                Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
+                if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, map);
+                map=collectSubliteralProperties(graph, variable, map);
+            }
+
+            // Get properties from VariableNode
+            map = getStandardNodePropertyVariables(graph, context, map);
+            return map;
+        } else if (context instanceof StandardGraphChildVariable) {
+            return standardChildDomainProperties.getVariables(graph, context, map);
+        } else {
+            throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+        }
+
+    }
+
+    public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
+
+        if(context instanceof StandardGraphPropertyVariable) {
+            StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+            map = collectPropertiesFromContext(graph, variable, variable.property.predicate, classification, map);
+            if (variable.parentResource != null) {
+                Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
+                if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, classification, map);
+            }
+
+            // Get properties from VariableNode
+            map = getStandardNodePropertyVariables(graph, context, map);
+            return map;
+        } else if (context instanceof StandardGraphChildVariable) {
+            return standardChildDomainProperties.getVariables(graph, context, map);
+        } else {
+            throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+        }      
+
+    }  
+
     @SCLValue(type = "VariableMap")
-       public static VariableMap standardPropertyDomainProperties = new VariableMapImpl() {
-
-       VariableMap getValueVariableMap(ReadGraph graph, Variable context) throws DatabaseException {
-               Resource represents = context.getPossibleRepresents(graph);
-               if(represents == null) return null;
-               
-               VariableMap map = graph.isImmutable(represents) ?
-                               graph.syncRequest(new PropertyVariableMapRequest(represents), TransientCacheListener.<VariableMap>instance()) :
-                                       (VariableMap)graph.getPossibleRelatedValue2(represents, Layer0.getInstance(graph).domainProperties, represents);
-               
-               if(map == standardPropertyDomainProperties) return null;
-               else return map;
-               
-       }
-       
-               @Override
-               public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-                       VariableMap valueMap = getValueVariableMap(graph, context);
-                       if(valueMap != null) return valueMap.getVariable(graph, context, name);
-                       return getStandardPropertyDomainPropertyVariableFromValue(graph, context, name);
-               }
-
-               @Override
-               public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-                       VariableMap valueMap = getValueVariableMap(graph, context);
-                       if(valueMap != null) return valueMap.getVariables(graph, context, map);
-                       else return getStandardPropertyDomainPropertyVariablesFromValue(graph, context, map);
-               }
-               
-               @Override
-               public Map<String, Variable> getVariables(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
-                       VariableMap valueMap = getValueVariableMap(graph, context);
-                       if(valueMap != null) return valueMap.getVariables(graph, context, classification, map);
-                       else return getStandardPropertyDomainPropertyVariablesFromValue(graph, context, classification, map);
-               }
-               
-       };
+    public static VariableMap standardPropertyDomainProperties = new VariableMapImpl() {
+
+        VariableMap getValueVariableMap(ReadGraph graph, Variable context) throws DatabaseException {
+            Resource represents = context.getPossibleRepresents(graph);
+            if(represents == null) return null;
+
+            VariableMap map = graph.isImmutable(represents) ?
+                    graph.syncRequest(new PropertyVariableMapRequest(represents), TransientCacheListener.<VariableMap>instance()) :
+                        (VariableMap)graph.getPossibleRelatedValue2(represents, Layer0.getInstance(graph).domainProperties, represents);
+
+                    if(map == standardPropertyDomainProperties) return null;
+                    else return map;
+
+        }
+
+        @Override
+        public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+            VariableMap valueMap = getValueVariableMap(graph, context);
+            if(valueMap != null) return valueMap.getVariable(graph, context, name);
+            return getStandardPropertyDomainPropertyVariableFromValue(graph, context, name);
+        }
+
+        @Override
+        public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+            VariableMap valueMap = getValueVariableMap(graph, context);
+            if(valueMap != null) return valueMap.getVariables(graph, context, map);
+            else return getStandardPropertyDomainPropertyVariablesFromValue(graph, context, map);
+        }
+
+        @Override
+        public Map<String, Variable> getVariables(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
+            VariableMap valueMap = getValueVariableMap(graph, context);
+            if(valueMap != null) return valueMap.getVariables(graph, context, classification, map);
+            else return getStandardPropertyDomainPropertyVariablesFromValue(graph, context, classification, map);
+        }
+
+    };
 
     public static Resource getPossibleGraphChild(ReadGraph graph, Variable variable, String name) throws DatabaseException {
-       Resource resource = variable.getPossibleRepresents(graph);
+        Resource resource = variable.getPossibleRepresents(graph);
         if(resource == null) return null;
         Map<String, Resource> graphChildren = graph.syncRequest(new UnescapedChildMapOfResource(resource));
         return graphChildren.get(name);
     }
 
     public static Map<String,Resource> getPossibleGraphChildren(ReadGraph graph, Variable variable) throws DatabaseException {
-       Resource resource = variable.getPossibleRepresents(graph);
+        Resource resource = variable.getPossibleRepresents(graph);
         if(resource == null) return Collections.emptyMap();
         return graph.syncRequest(new UnescapedChildMapOfResource(resource));
     }
 
     public static Object getPossibleNodeChild(ReadGraph graph, Variable variable, String name) throws DatabaseException {
-       if (!(variable instanceof AbstractVariable)) return null;
-       VariableNode<?> node = ((AbstractVariable)variable).node;
+        if (!(variable instanceof AbstractVariable)) return null;
+        VariableNode<?> node = ((AbstractVariable)variable).node;
         if(node == null) return null;
         NodeStructure structure = Variables.requestNodeStructure(graph, node);
         if(Variables.PENDING_NODE_STRUCTURE == structure) throw new PendingVariableException("");
         return structure.children.get(name);
-       }
-       
+    }
+
     public static Collection<Object> getPossibleNodeChildren(ReadGraph graph, Variable variable) throws DatabaseException {
-       if (!(variable instanceof AbstractVariable)) return null;
-       VariableNode<?> node = ((AbstractVariable)variable).node;
+        if (!(variable instanceof AbstractVariable)) return null;
+        VariableNode<?> node = ((AbstractVariable)variable).node;
         if(node == null) return Collections.emptyList();
         NodeStructure structure = Variables.requestNodeStructure(graph, node);
         if(Variables.PENDING_NODE_STRUCTURE == structure) throw new PendingVariableException("");
         return structure.children.values();
     }
-    
+
     public static Object getPossibleNodeProperty(ReadGraph graph, Variable variable, String name, boolean throwPending) throws DatabaseException {
-       if (!(variable instanceof AbstractVariable)) return null;
-       VariableNode<?> node = ((AbstractVariable)variable).node;
+        if (!(variable instanceof AbstractVariable)) return null;
+        VariableNode<?> node = ((AbstractVariable)variable).node;
         if(node == null) return null;
         NodeStructure structure = Variables.requestNodeStructure(graph, node);
         if(throwPending && Variables.PENDING_NODE_STRUCTURE == structure) throw new PendingVariableException("");
         return structure.properties.get(name);
     }
-    
+
     public static Collection<Object> getPossibleNodeProperties(ReadGraph graph, Variable variable) throws DatabaseException {
-       if (!(variable instanceof AbstractVariable)) return null;
-       VariableNode<?> node = ((AbstractVariable)variable).node;
+        if (!(variable instanceof AbstractVariable)) return null;
+        VariableNode<?> node = ((AbstractVariable)variable).node;
         if(node == null) return Collections.emptyList();
         NodeStructure structure = Variables.requestNodeStructure(graph, node);
         if(Variables.PENDING_NODE_STRUCTURE == structure) throw new PendingVariableException("");
@@ -813,24 +818,24 @@ public class All {
 
     @Deprecated
     public static Variable getStandardChildDomainChildVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-       return StandardChildDomainChildren.getStandardChildDomainChildVariable(graph, context, name);
+        return StandardChildDomainChildren.getStandardChildDomainChildVariable(graph, context, name);
     }
 
     @Deprecated
     public static Variable getStandardChildDomainChildVariable(ReadGraph graph, Variable context, Resource graphChild, String name) throws DatabaseException {
-       return StandardChildDomainChildren.getStandardChildDomainChildVariable(graph, context, graphChild, name);
+        return StandardChildDomainChildren.getStandardChildDomainChildVariable(graph, context, graphChild, name);
     }
-       
+
     @Deprecated
     public static Map<String, Variable> getStandardChildDomainChildVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-       return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, map);
+        return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, map);
     }
 
     @Deprecated
     public static Map<String, Variable> getStandardChildDomainChildVariables(ReadGraph graph, Variable context, Map<String,Resource> graphChildren, Map<String, Variable> map) throws DatabaseException {
-       return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, graphChildren, map);
+        return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, graphChildren, map);
     }
-    
+
     /**
      * Get a map of child Variables from a node manager-based Variable, combined with the existing variables in #map.
      * @param graph  The read graph.
@@ -840,18 +845,18 @@ public class All {
      * @throws DatabaseException
      */
     public static Map<String, Variable> getStandardNodeChildVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-       AbstractVariable variable = (AbstractVariable)context;
-       if (variable.node == null) return map;
-        
+        AbstractVariable variable = (AbstractVariable)context;
+        if (variable.node == null) return map;
+
         Collection<Object> nodeChildren = getPossibleNodeChildren(graph, variable);
         if (nodeChildren.isEmpty()) return map;
-        
+
         map = ensureVariableMap(map, nodeChildren.size());
 
         for(Object nodeChild : nodeChildren) {
             String name = getNodeName(variable, nodeChild);
             if (!map.containsKey(name))
-               map.put(name, createStandardGraphChildVariable(variable, nodeChild));
+                map.put(name, createStandardGraphChildVariable(variable, nodeChild));
         }
 
         return map;
@@ -866,371 +871,371 @@ public class All {
      * @throws DatabaseException
      */
     public static Map<String, Variable> getStandardNodePropertyVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-       AbstractVariable variable = (AbstractVariable)context;
-       if (variable.node == null) return map;
-        
+        AbstractVariable variable = (AbstractVariable)context;
+        if (variable.node == null) return map;
+
         Collection<Object> nodeProperties = getPossibleNodeProperties(graph, variable);
         if (nodeProperties.isEmpty()) return map;
-        
+
         map = ensureVariableMap(map, nodeProperties.size());
 
         for(Object nodeProperty : nodeProperties) {
             String name = getNodeName(variable, nodeProperty);
             if (!map.containsKey(name)) {
-               map.put(name, createStandardGraphPropertyVariable(graph, variable, nodeProperty));
+                map.put(name, createStandardGraphPropertyVariable(graph, variable, nodeProperty));
             }
         }
 
         return map;
     }    
 
-       @SCLValue(type = "VariableMap")
-       public static VariableMap standardChildDomainChildren = new VariableMapImpl() {
+    @SCLValue(type = "VariableMap")
+    public static VariableMap standardChildDomainChildren = new VariableMapImpl() {
 
-               @Override
-               public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-                       return StandardChildDomainChildren.getStandardChildDomainChildVariable(graph, context, name);
-               }
+        @Override
+        public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+            return StandardChildDomainChildren.getStandardChildDomainChildVariable(graph, context, name);
+        }
+
+        @Override
+        public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+            return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, map);
+        }
 
-               @Override
-               public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-                   return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, map);
-               }
-               
-       };
+    };
 
     @SCLValue(type = "VariableMap")
-       public static VariableMap standardPropertyDomainChildren = new VariableMapImpl() {
-
-       /**
-        * Get a possible non-standard VariableMap defined in the graph.
-        * @param graph  The graph
-        * @param context  The context node
-        * @return  A non-standard VariableMap instance for the context node,
-        *          or null, if not defined or defined as this instance.
-        * @throws DatabaseException
-        */
-       VariableMap getValueVariableMap(ReadGraph graph, Variable context) throws DatabaseException {
-               Resource represents = context.getPossibleRepresents(graph);
-               if(represents == null) return null;
-                       VariableMap map = graph.syncRequest(new ChildVariableMapRequest(represents));
-               if(map == standardPropertyDomainChildren) return null;
-               else return map;
-       }
-       
-               @Override
-               public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-                       // Delegate call to a non-standard variable map?
-                       VariableMap valueMap = getValueVariableMap(graph, context);
-                       if(valueMap != null) return valueMap.getVariable(graph, context, name);
-                       
-                       if(context instanceof StandardGraphPropertyVariable) {
-                               StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
-                               Datatype dt = variable.getDatatype(graph);
-                               if (dt instanceof ArrayType) {
-                                       ChildReference ref = getPossibleIndexReference(name);
-                                       if (ref != null)
-                                               return new SubliteralPropertyVariableDeprecated(variable, ref);
-                               }
-                               
-                               // Check for a child node provided by the NodeManager
-                               if (variable.node != null) {
-                                       Object childNode = getPossibleNodeChild(graph, variable, name);
-                                       if (childNode != null)
-                                               return createStandardGraphChildVariable(variable, childNode);
-                               }
-                               return standardChildDomainChildren.getVariable(graph, context, name);
-                       } else if (context instanceof StandardGraphChildVariable) {
-                               return standardChildDomainChildren.getVariable(graph, context, name);
-                       } else {
-                               throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
-                       }
-               }
-
-               @Override
-               public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-                       // Delegate call to a non-standard variable map?
-                       VariableMap valueMap = getValueVariableMap(graph, context);
-                       if(valueMap != null) return valueMap.getVariables(graph, context, map);
-                       
-                       if(context instanceof StandardGraphPropertyVariable) {
-                               // Get child variables provided by the NodeManager
-                               Map<String, Variable> result = getStandardNodeChildVariables(graph, context, map); 
-                               return standardChildDomainChildren.getVariables(graph, context, result);
-                       } else if (context instanceof StandardGraphChildVariable) {
-                               return standardChildDomainChildren.getVariables(graph, context, map);
-                       } else {
-                               throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
-                       }       
-               }
-               
-       };
-       
-       protected static ChildReference getPossibleIndexReference(String name) {
-               if (name.startsWith("i-")) {
-                   try {
-                       int index = Integer.parseInt(name.substring(2));
-                       return new IndexReference(index);
-                   } catch (NumberFormatException e) {}
-               }
-               return null;
-       }
-
-       protected static ValueAccessor getPossiblePropertyValueAccessor(ReadGraph graph, StandardGraphPropertyVariable variable) throws DatabaseException {
-           if(variable.property == null) return null;
-           return variable.property.valueAccessor;
+    public static VariableMap standardPropertyDomainChildren = new VariableMapImpl() {
+
+        /**
+         * Get a possible non-standard VariableMap defined in the graph.
+         * @param graph  The graph
+         * @param context  The context node
+         * @return  A non-standard VariableMap instance for the context node,
+         *          or null, if not defined or defined as this instance.
+         * @throws DatabaseException
+         */
+        VariableMap getValueVariableMap(ReadGraph graph, Variable context) throws DatabaseException {
+            Resource represents = context.getPossibleRepresents(graph);
+            if(represents == null) return null;
+            VariableMap map = graph.syncRequest(new ChildVariableMapRequest(represents));
+            if(map == standardPropertyDomainChildren) return null;
+            else return map;
+        }
+
+        @Override
+        public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+            // Delegate call to a non-standard variable map?
+            VariableMap valueMap = getValueVariableMap(graph, context);
+            if(valueMap != null) return valueMap.getVariable(graph, context, name);
+
+            if(context instanceof StandardGraphPropertyVariable) {
+                StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+                Datatype dt = variable.getDatatype(graph);
+                if (dt instanceof ArrayType) {
+                    ChildReference ref = getPossibleIndexReference(name);
+                    if (ref != null)
+                        return new SubliteralPropertyVariableDeprecated(variable, ref);
+                }
+
+                // Check for a child node provided by the NodeManager
+                if (variable.node != null) {
+                    Object childNode = getPossibleNodeChild(graph, variable, name);
+                    if (childNode != null)
+                        return createStandardGraphChildVariable(variable, childNode);
+                }
+                return standardChildDomainChildren.getVariable(graph, context, name);
+            } else if (context instanceof StandardGraphChildVariable) {
+                return standardChildDomainChildren.getVariable(graph, context, name);
+            } else {
+                throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+            }
+        }
+
+        @Override
+        public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+            // Delegate call to a non-standard variable map?
+            VariableMap valueMap = getValueVariableMap(graph, context);
+            if(valueMap != null) return valueMap.getVariables(graph, context, map);
+
+            if(context instanceof StandardGraphPropertyVariable) {
+                // Get child variables provided by the NodeManager
+                Map<String, Variable> result = getStandardNodeChildVariables(graph, context, map); 
+                return standardChildDomainChildren.getVariables(graph, context, result);
+            } else if (context instanceof StandardGraphChildVariable) {
+                return standardChildDomainChildren.getVariables(graph, context, map);
+            } else {
+                throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+            }  
+        }
+
+    };
+
+    protected static ChildReference getPossibleIndexReference(String name) {
+        if (name.startsWith("i-")) {
+            try {
+                int index = Integer.parseInt(name.substring(2));
+                return new IndexReference(index);
+            } catch (NumberFormatException e) {}
+        }
+        return null;
+    }
+
+    protected static ValueAccessor getPossiblePropertyValueAccessor(ReadGraph graph, StandardGraphPropertyVariable variable) throws DatabaseException {
+        if(variable.property == null) return null;
+        return variable.property.valueAccessor;
 //        return graph.syncRequest(new PropertyValueAccessorRequest(variable.property), TransientCacheAsyncListener.<ValueAccessor>instance());
 //             return graph.syncRequest(new PossibleRelatedValueImplied2<ValueAccessor>(variable.property, Layer0.getInstance(graph).valueAccessor));
-       }
-
-       public static ValueAccessor getPossibleValueValueAccessor(ReadGraph graph, Variable variable) throws DatabaseException {
-           Resource value = variable.getPossibleRepresents(graph);
-           if(value == null) return null;
-           //return graph.syncRequest(new PropertyValueAccessorRequest(value));
-               return graph.syncRequest(new PossibleRelatedValueImplied2<ValueAccessor>(value, Layer0.getInstance(graph).valueAccessor));      
-       }
-       
-       public static PropertyInfo getPossiblePropertyInfoFromContext(ReadGraph graph, Variable variable, Resource context, String name) throws DatabaseException {
-           if(context == null) return null;
-               Map<String, PropertyInfo> predicates = graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheListener.instance());
-               return predicates.get(name);
-       }
+    }
+
+    public static ValueAccessor getPossibleValueValueAccessor(ReadGraph graph, Variable variable) throws DatabaseException {
+        Resource value = variable.getPossibleRepresents(graph);
+        if(value == null) return null;
+        //return graph.syncRequest(new PropertyValueAccessorRequest(value));
+        return graph.syncRequest(new PossibleRelatedValueImplied2<ValueAccessor>(value, Layer0.getInstance(graph).valueAccessor));     
+    }
+
+    public static PropertyInfo getPossiblePropertyInfoFromContext(ReadGraph graph, Variable variable, Resource context, String name) throws DatabaseException {
+        if(context == null) return null;
+        Map<String, PropertyInfo> predicates = graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheListener.instance());
+        return predicates.get(name);
+    }
 
     public static Variable getPossiblePropertyFromContext(ReadGraph graph, Variable variable, Resource context, String name, Object propertyNode) throws DatabaseException {
         PropertyInfo info = getPossiblePropertyInfoFromContext(graph, variable, context, name);
         if(info == null || info.builder == null) return null;
         return buildPropertyVariable(graph, variable, context, info, propertyNode);
     }
-    
+
     public static Variable getPossibleSubliteralPropertyFromContext(ReadGraph graph, StandardGraphPropertyVariable variable, String name) throws DatabaseException {
-       
-               Resource predicate = variable.property.predicate;
-               if(predicate == null) return null;
 
-       PropertyInfo info = getPropertyInfo(graph, predicate);
-       Pair<Resource, ChildReference> p = info.subliteralPredicates.get(name);
-       if(p == null) return null;
-       
-               return new SubliteralPropertyVariable(graph, variable, p.first, p.second);
-       
+        Resource predicate = variable.property.predicate;
+        if(predicate == null) return null;
+
+        PropertyInfo info = getPropertyInfo(graph, predicate);
+        Pair<Resource, ChildReference> p = info.subliteralPredicates.get(name);
+        if(p == null) return null;
+
+        return new SubliteralPropertyVariable(graph, variable, p.first, p.second);
+
     }
 
     public static Map<String, PropertyInfo> collectPropertyInfosFromContext(ReadGraph graph, Variable variable, Resource context) throws DatabaseException {
         if(context == null) return Collections.emptyMap();
-               return graph.isImmutable(context) ?
-                               graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance()) :
-                               graph.syncRequest(new UnescapedPropertyMapOfResource(context));
-    }
-
-       public static Map<String, Variable> collectPropertiesFromContext(ReadGraph graph, Variable variable, Resource context, Map<String, Variable> map) throws DatabaseException {
-
-               Map<String,PropertyInfo> properties = graph.isImmutable(context) ?
-                               graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance()) :
-                               graph.syncRequest(new UnescapedPropertyMapOfResource(context));
-                               
-               if(properties.isEmpty()) return map;
-               
-               map = ensureVariableMap(map, properties.size());
-               
-               for(PropertyInfo info : properties.values()) {
-                       String name = info.name;
-                       if (info.builder != null) {
-                               Variable v = info.builder.buildProperty(graph, variable, null, context, info.predicate);
-                               map.put(name, v);
-                       }
-               }
-               
-               return map;
-               
-       }
-
-       public static Map<String, Variable> collectSubliteralProperties(ReadGraph graph, StandardGraphPropertyVariable variable, Map<String, Variable> map) throws DatabaseException {
-
-               Resource predicate = variable.property.predicate;
-               if(predicate == null) return map;
-               
-               PropertyInfo info = getPropertyInfo(graph, predicate);
-               if(info.subliteralPredicates.isEmpty()) return map;
-               
-               map = ensureVariableMap(map, info.subliteralPredicates.size());
-               
-               for(Map.Entry<String, Pair<Resource, ChildReference>> entry : info.subliteralPredicates.entrySet()) {
-                       String key = entry.getKey();
-                       Pair<Resource, ChildReference> p = entry.getValue();
-                       if(map == null) map = new THashMap<String,Variable>();
-                       map.put(key, new SubliteralPropertyVariable(graph, variable, p.first, p.second));
-               }
-       
-       return map;
-               
-       }
-
-       public static Map<String, Variable> collectPropertiesFromContext(ReadGraph graph, Variable variable, Resource context, String classification, Map<String, Variable> map) throws DatabaseException {
-
-               if(graph.isImmutable(context)) {
-
-                       Map<String,PropertyInfo> properties = graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance());
-                       for(PropertyInfo info : properties.values()) {
-
-                               if(info.classifications.contains(classification) && info.builder != null) {
-                                       String name = info.name;
-                                       Variable v = info.builder.buildProperty(graph, variable, null, context, info.predicate);
-                                       if(map == null) map = new THashMap<String,Variable>();
-                                       map.put(name, v);
-                               }
-
-                       }
-
-               } else {
-                               
-                       Collection<Resource> predicates = graph.getPredicates(context);
-                                       
-                       if(predicates.isEmpty()) return map;
-                       
-                       map = ensureVariableMap(map, predicates.size());
-               
-                       for(Resource predicate : predicates) {
-                               
-                               PropertyInfo info = graph.isImmutable(predicate) ?
-                                               graph.syncRequest(new PropertyInfoRequest(predicate), TransientCacheAsyncListener.<PropertyInfo>instance()) :
-                                                       graph.syncRequest(new PropertyInfoRequest(predicate));
-                                               
-                               if(!info.isHasProperty) continue;
-       
-                               if(info.classifications.contains(classification) && info.builder != null) {
-                                       String name = info.name;
-                                       Variable v = info.builder.buildProperty(graph, variable, null, context, info.predicate);
-                                       if(map == null) map = new THashMap<String,Variable>();
-                                       map.put(name, v);
-                               }
-                               
-                       }
-                       
-               }
-               
-               return map;
-               
-       }       
-       
+        return graph.isImmutable(context) ?
+                graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance()) :
+                    graph.syncRequest(new UnescapedPropertyMapOfResource(context));
+    }
+
+    public static Map<String, Variable> collectPropertiesFromContext(ReadGraph graph, Variable variable, Resource context, Map<String, Variable> map) throws DatabaseException {
+
+        Map<String,PropertyInfo> properties = graph.isImmutable(context) ?
+                graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance()) :
+                    graph.syncRequest(new UnescapedPropertyMapOfResource(context));
+
+                if(properties.isEmpty()) return map;
+
+                map = ensureVariableMap(map, properties.size());
+
+                for(PropertyInfo info : properties.values()) {
+                    String name = info.name;
+                    if (info.builder != null) {
+                        Variable v = info.builder.buildProperty(graph, variable, null, context, info.predicate);
+                        map.put(name, v);
+                    }
+                }
+
+                return map;
+
+    }
+
+    public static Map<String, Variable> collectSubliteralProperties(ReadGraph graph, StandardGraphPropertyVariable variable, Map<String, Variable> map) throws DatabaseException {
+
+        Resource predicate = variable.property.predicate;
+        if(predicate == null) return map;
+
+        PropertyInfo info = getPropertyInfo(graph, predicate);
+        if(info.subliteralPredicates.isEmpty()) return map;
+
+        map = ensureVariableMap(map, info.subliteralPredicates.size());
+
+        for(Map.Entry<String, Pair<Resource, ChildReference>> entry : info.subliteralPredicates.entrySet()) {
+            String key = entry.getKey();
+            Pair<Resource, ChildReference> p = entry.getValue();
+            if(map == null) map = new THashMap<String,Variable>();
+            map.put(key, new SubliteralPropertyVariable(graph, variable, p.first, p.second));
+        }
+
+        return map;
+
+    }
+
+    public static Map<String, Variable> collectPropertiesFromContext(ReadGraph graph, Variable variable, Resource context, String classification, Map<String, Variable> map) throws DatabaseException {
+
+        if(graph.isImmutable(context)) {
+
+            Map<String,PropertyInfo> properties = graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance());
+            for(PropertyInfo info : properties.values()) {
+
+                if(info.classifications.contains(classification) && info.builder != null) {
+                    String name = info.name;
+                    Variable v = info.builder.buildProperty(graph, variable, null, context, info.predicate);
+                    if(map == null) map = new THashMap<String,Variable>();
+                    map.put(name, v);
+                }
+
+            }
+
+        } else {
+
+            Collection<Resource> predicates = graph.getPredicates(context);
+
+            if(predicates.isEmpty()) return map;
+
+            map = ensureVariableMap(map, predicates.size());
+
+            for(Resource predicate : predicates) {
+
+                PropertyInfo info = graph.isImmutable(predicate) ?
+                        graph.syncRequest(new PropertyInfoRequest(predicate), TransientCacheAsyncListener.<PropertyInfo>instance()) :
+                            graph.syncRequest(new PropertyInfoRequest(predicate));
+
+                        if(!info.isHasProperty) continue;
+
+                        if(info.classifications.contains(classification) && info.builder != null) {
+                            String name = info.name;
+                            Variable v = info.builder.buildProperty(graph, variable, null, context, info.predicate);
+                            if(map == null) map = new THashMap<String,Variable>();
+                            map.put(name, v);
+                        }
+
+            }
+
+        }
+
+        return map;
+
+    }  
+
     @SCLValue(type = "ReadGraph -> Resource -> a -> String")
     public static String entityLabel(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       if(context instanceof Resource) {
-               return NameUtils.getSafeLabel(graph, ((Resource)context));      
-       } else if (context instanceof Variable) {
-               Variable parent = ((Variable)context).getParent(graph);
-               Resource represents = parent.getRepresents(graph);
-               return NameUtils.getSafeLabel(graph, represents);
-       } else {
-               throw new DatabaseException("Unknown context " + context);
-       }
+        if(context instanceof Resource) {
+            return NameUtils.getSafeLabel(graph, ((Resource)context)); 
+        } else if (context instanceof Variable) {
+            Variable parent = ((Variable)context).getParent(graph);
+            Resource represents = parent.getRepresents(graph);
+            return NameUtils.getSafeLabel(graph, represents);
+        } else {
+            throw new DatabaseException("Unknown context " + context);
+        }
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object listResources(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       return ListUtils.toList(graph, resource);
+        return ListUtils.toList(graph, resource);
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> [String]")
     public static List<String> standardClassifications(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
-       ArrayList<String> result = new ArrayList<String>();
-       Resource predicate = context.getParent(graph).getPossiblePredicateResource(graph);
-       if(predicate != null) {
-               for(Resource type : graph.getTypes(predicate)) {
-                       String uri = graph.getPossibleURI(type);
-                       if(uri != null) result.add(uri);
-               }
-       }
-       return result;
+        ArrayList<String> result = new ArrayList<String>();
+        Resource predicate = context.getParent(graph).getPossiblePredicateResource(graph);
+        if(predicate != null) {
+            for(Resource type : graph.getTypes(predicate)) {
+                String uri = graph.getPossibleURI(type);
+                if(uri != null) result.add(uri);
+            }
+        }
+        return result;
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> Boolean")
     public static Boolean standardValidValue(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       return Boolean.TRUE;
+        return Boolean.TRUE;
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> StringInputValidator")
     public static StringInputValidator standardValidator(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       return StringInputValidator.PASS;
+        return StringInputValidator.PASS;
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> Boolean")
     public static Boolean standardRequiredValue(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       return Boolean.FALSE;
+        return Boolean.FALSE;
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> Boolean")
     public static Boolean standardDefaultValue(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
-       Variable property = context.getParent(graph);
-       if(property instanceof StandardGraphPropertyVariable) {
-               StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)property;
-               if (variable.parentResource != null) {
-                       Resource predicate = variable.getPossiblePredicateResource(graph);
-                       if (predicate != null) {
-                                       Statement stm = graph.getPossibleStatement(variable.parentResource, predicate);
-                                       return stm != null && stm.isAsserted(variable.parentResource);
-                       }
-                       }
-       }
-       return Boolean.FALSE;
+        Variable property = context.getParent(graph);
+        if(property instanceof StandardGraphPropertyVariable) {
+            StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)property;
+            if (variable.parentResource != null) {
+                Resource predicate = variable.getPossiblePredicateResource(graph);
+                if (predicate != null) {
+                    Statement stm = graph.getPossibleStatement(variable.parentResource, predicate);
+                    return stm != null && stm.isAsserted(variable.parentResource);
+                }
+            }
+        }
+        return Boolean.FALSE;
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> Boolean")
     public static Boolean standardReadOnlyValue(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       return Boolean.FALSE;
+        return Boolean.FALSE;
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object resourceAsValue(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       return resource;
+        return resource;
     }
-    
+
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object functionApplication(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-       return Functions.exec(graph, resource, graph, resource, context);
+        return Functions.exec(graph, resource, graph, resource, context);
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object computeExpression(ReadGraph graph, Resource converter, Object context) throws DatabaseException {
-       if(context instanceof Variable) {
+        if(context instanceof Variable) {
             return CompileValueRequest.compileAndEvaluate(graph, (Variable)context);
-       } if (context instanceof Resource) {
+        } if (context instanceof Resource) {
             return CompileResourceValueRequest.compileAndEvaluate(graph, (Resource)converter);
-       } else {
-               throw new IllegalStateException("Unknown context " + context);
-       }
+        } else {
+            throw new IllegalStateException("Unknown context " + context);
+        }
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object composedPropertyValue(ReadGraph graph, Resource converter, Object context) throws DatabaseException {
-       if(context instanceof Variable) {
-               return new StandardComposedProperty();
-       } if (context instanceof Resource) {
-               return new StandardComposedProperty();
-       } else {
-               throw new IllegalStateException("Unknown context " + context);
-       }
-    }
-    
+        if(context instanceof Variable) {
+            return new StandardComposedProperty();
+        } if (context instanceof Resource) {
+            return new StandardComposedProperty();
+        } else {
+            throw new IllegalStateException("Unknown context " + context);
+        }
+    }
+
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object numberInputValidator(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-        
+
         class Validator extends FunctionImpl1<String, String> {
 
             private final Datatype datatype;
-            
+
             public Validator(Datatype datatype) {
                 this.datatype = datatype;
             }
-            
+
             @Override
             public String apply(String input) {
-                
+
                 if(datatype == null) return null;
-                
+
                 try {
 
                     if(datatype instanceof NumberType) {
-                        
+
                         Number number = (Number)PrimitiveValueParser.parse(input, datatype);
                         NumberType nt = (NumberType)datatype;
                         Range r = nt.getRange();
@@ -1239,130 +1244,130 @@ public class All {
                         }
                     }
                     return null;
-                    
+
                 } catch (NumberFormatException e) {
                     return "Not a valid floating-point number";
                 } catch (IllegalArgumentException e) {
                     return "Not a valid floating-point number";
                 }
-                
+
             }
-            
+
         }
 
         if(context instanceof Variable) {
-            
+
             Variable variable = (Variable)context;
             Variable property = variable.getParent(graph);
             Datatype datatype = property.getPossibleDatatype(graph);
             return new Validator(datatype);
-            
+
         } else if (context instanceof Resource) {
 
             Layer0 L0 = Layer0.getInstance(graph);
             Resource literal = (Resource)context;
             Datatype datatype = graph.getRelatedValue(literal, L0.HasDataType, Bindings.getBindingUnchecked(Datatype.class));
             return new Validator(datatype);
-            
+
         } else {
-            
+
             return new Validator(null);
-            
+
         }
-        
+
     }
-    
+
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object booleanInputValidator(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-        
+
         return new FunctionImpl1<String, String>() {
 
             @Override
             public String apply(String input) {
-                
-               String lower = input.toLowerCase();
-               if("true".equals(lower) || "false".equals(lower)) return null;
 
-               return "Not a valid boolean: " + input;
-                
+                String lower = input.toLowerCase();
+                if("true".equals(lower) || "false".equals(lower)) return null;
+
+                return "Not a valid boolean: " + input;
+
             }
-            
+
         };
-        
+
     }
 
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> Resource")
     public static Resource hasStandardResource(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
-       Variable parent = context.getParent(graph);
-       if(parent instanceof StandardGraphChildVariable) {
-               StandardGraphChildVariable variable = (StandardGraphChildVariable)parent;
-               return variable.resource;
-       }
-       return null;
+        Variable parent = context.getParent(graph);
+        if(parent instanceof StandardGraphChildVariable) {
+            StandardGraphChildVariable variable = (StandardGraphChildVariable)parent;
+            return variable.resource;
+        }
+        return null;
     }
 
 
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
-       public static Object valueWithoutBinding(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
-
-       StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
-               
-               if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {
-                       Layer0 L0 = Layer0.getInstance(graph);
-                       return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel);
-               }
-
-               if (variable.parentResource == null)
-                       throw new InvalidVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").");
-
-               try {
-                       return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
-               } catch (NoSingleResultException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               } catch (DoesNotContainValueException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               }
-               
-       }
+    public static Object valueWithoutBinding(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+
+        StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+
+        if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {
+            Layer0 L0 = Layer0.getInstance(graph);
+            return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel);
+        }
+
+        if (variable.parentResource == null)
+            throw new InvalidVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").");
+
+        try {
+            return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
+        } catch (NoSingleResultException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        } catch (DoesNotContainValueException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        }
+
+    }
 
     @SCLValue(type = "ReadGraph -> Variable -> Binding -> a")
-       public static Object valueWithBinding(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {
-
-       StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
-               
-               if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {
-                       Layer0 L0 = Layer0.getInstance(graph);
-                       return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);
-               }
-
-               if (variable.parentResource == null)
-                       throw new MissingVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").", context.getPossibleRepresents(graph));
-               
-
-               try {
-                       return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
-               } catch (NoSingleResultException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               } catch (DoesNotContainValueException e) {
-                       throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
-               }
-               
-       }
+    public static Object valueWithBinding(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {
+
+        StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+
+        if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {
+            Layer0 L0 = Layer0.getInstance(graph);
+            return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);
+        }
+
+        if (variable.parentResource == null)
+            throw new MissingVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").", context.getPossibleRepresents(graph));
+
+
+        try {
+            return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
+        } catch (NoSingleResultException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        } catch (DoesNotContainValueException e) {
+            throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
+        }
+
+    }
 
     @SCLValue(type = "WriteGraph -> Variable -> a -> Binding -> b")
-       public static Object valueSetterWithBinding(WriteGraph graph, Variable variable, Object value, Binding binding) throws DatabaseException {
-               
-               Function4<WriteGraph, Variable, Object, Object, String> modifier = variable.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);
-               if(modifier == null) modifier = VariableUtils.defaultInputModifier; 
-               modifier.apply(graph, variable, value, binding);
-               return null;
-               
-       }
-    
+    public static Object valueSetterWithBinding(WriteGraph graph, Variable variable, Object value, Binding binding) throws DatabaseException {
+
+        Function4<WriteGraph, Variable, Object, Object, String> modifier = variable.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);
+        if(modifier == null) modifier = VariableUtils.defaultInputModifier; 
+        modifier.apply(graph, variable, value, binding);
+        return null;
+
+    }
+
     static class L0Issue extends StandardIssue {
-        
+
         private final String description;
-        
+
         public L0Issue(String description, Resource type, Resource ... contexts) {
             super(type, contexts);
             this.description = description;
@@ -1377,63 +1382,63 @@ public class All {
             graph.addLiteral(issue, L0.HasDescription, L0.HasDescription_Inverse, description, Bindings.STRING);
             return issue;
         }
-        
-    }
-    
-       private static List<Issue> reportInconsistency(ReadGraph graph, Resource subject, String description, List<Issue> issues) throws DatabaseException {
-           if(issues == null) issues = new ArrayList<Issue>();
-               System.err.println("Change set validation reports the following issue: " + NameUtils.getSafeName(graph, subject, true) + ": " + description);
-               IssueResource IR = IssueResource.getInstance(graph);
-               issues.add(new L0Issue(description, IR.Issue, subject));
-               return issues;
-       }
-    
+
+    }
+
+    private static List<Issue> reportInconsistency(ReadGraph graph, Resource subject, String description, List<Issue> issues) throws DatabaseException {
+        if(issues == null) issues = new ArrayList<Issue>();
+        System.err.println("Change set validation reports the following issue: " + NameUtils.getSafeName(graph, subject, true) + ": " + description);
+        IssueResource IR = IssueResource.getInstance(graph);
+        issues.add(new L0Issue(description, IR.Issue, subject));
+        return issues;
+    }
+
     @SCLValue(type = "ReadGraph -> Resource -> [Issue]")
     public static List<Issue> relationValidator(ReadGraph graph, Resource resource) throws DatabaseException {
 
-       Layer0 L0 = Layer0.getInstance(graph);
-
-       List<Issue> issues = null;
-       
-       for(Statement stm : graph.getStatements(resource, L0.IsWeaklyRelatedTo)) {
-               Resource predicate = stm.getPredicate();
-               Resource object = stm.getObject();
-               if(!isRelation(graph, L0, predicate)) {
-                       issues = reportInconsistency(graph, resource, "The predicate of a statement must be a relation: " + NameUtils.toString(graph, stm), issues);
-               }
-               if(graph.isInstanceOf(predicate, L0.FunctionalRelation)) {
-                       if(graph.getObjects(resource, predicate).size() > 1)
-                               issues = reportInconsistency(graph, resource, 
-                                               "Relation " +
-                                                               NameUtils.getSafeName(graph, predicate)
-                                                               + " is functional.", issues);
-               }
-               {
-                       Collection<Resource> domain = graph.getObjects(predicate, L0.HasDomain);
-                       if (!isInstanceOfAny(graph, resource, domain, true)) {
-                               StringBuilder sb = new StringBuilder()
-                               .append("The domain of ")
-                               .append(NameUtils.getSafeName(graph, predicate))
-                               .append(" relation is ");
-                               orString(graph, sb, domain).append(".");
-                               issues = reportInconsistency(graph, resource, sb.toString(), issues);
-                       }
-               }
-               {
-                       Collection<Resource> range = graph.getObjects(predicate, L0.HasRange);
-                       if (!isInstanceOfAny(graph, object, range, true) && !graph.isInstanceOf(object, L0.SCLValue)) {
-                               StringBuilder sb = new StringBuilder()
-                               .append("The range of ")
-                               .append(NameUtils.getSafeName(graph, predicate))
-                               .append(" relation is ");
-                               orString(graph, sb, range).append(" but current object is ")
-                               .append(NameUtils.getSafeName(graph, object)).append(".");
-                               issues = reportInconsistency(graph, resource, sb.toString(), issues);
-                       }
-               }               
-       }
-               
-               return issues != null ? issues : Collections.<Issue>emptyList();
+        Layer0 L0 = Layer0.getInstance(graph);
+
+        List<Issue> issues = null;
+
+        for(Statement stm : graph.getStatements(resource, L0.IsWeaklyRelatedTo)) {
+            Resource predicate = stm.getPredicate();
+            Resource object = stm.getObject();
+            if(!isRelation(graph, L0, predicate)) {
+                issues = reportInconsistency(graph, resource, "The predicate of a statement must be a relation: " + NameUtils.toString(graph, stm), issues);
+            }
+            if(graph.isInstanceOf(predicate, L0.FunctionalRelation)) {
+                if(graph.getObjects(resource, predicate).size() > 1)
+                    issues = reportInconsistency(graph, resource, 
+                            "Relation " +
+                                    NameUtils.getSafeName(graph, predicate)
+                            + " is functional.", issues);
+            }
+            {
+                Collection<Resource> domain = graph.getObjects(predicate, L0.HasDomain);
+                if (!isInstanceOfAny(graph, resource, domain, true)) {
+                    StringBuilder sb = new StringBuilder()
+                            .append("The domain of ")
+                            .append(NameUtils.getSafeName(graph, predicate))
+                            .append(" relation is ");
+                    orString(graph, sb, domain).append(".");
+                    issues = reportInconsistency(graph, resource, sb.toString(), issues);
+                }
+            }
+            {
+                Collection<Resource> range = graph.getObjects(predicate, L0.HasRange);
+                if (!isInstanceOfAny(graph, object, range, true) && !graph.isInstanceOf(object, L0.SCLValue)) {
+                    StringBuilder sb = new StringBuilder()
+                            .append("The range of ")
+                            .append(NameUtils.getSafeName(graph, predicate))
+                            .append(" relation is ");
+                    orString(graph, sb, range).append(" but current object is ")
+                    .append(NameUtils.getSafeName(graph, object)).append(".");
+                    issues = reportInconsistency(graph, resource, sb.toString(), issues);
+                }
+            }                  
+        }
+
+        return issues != null ? issues : Collections.<Issue>emptyList();
 
     }
 
@@ -1443,197 +1448,197 @@ public class All {
         List<Issue> issues = null;
 
         Layer0 L0 = Layer0.getInstance(graph);
-       for(Statement stm : graph.getStatements(resource, L0.HasProperty)) {
-               Resource subject = stm.getSubject();
-               Resource predicate = stm.getPredicate();
-               String error = L0Validations.checkValueType(graph, subject, predicate);
-               if(error != null) issues = reportInconsistency(graph, subject, error, issues);
-       }
-               
+        for(Statement stm : graph.getStatements(resource, L0.HasProperty)) {
+            Resource subject = stm.getSubject();
+            Resource predicate = stm.getPredicate();
+            String error = L0Validations.checkValueType(graph, subject, predicate);
+            if(error != null) issues = reportInconsistency(graph, subject, error, issues);
+        }
+
         return issues != null ? issues : Collections.<Issue>emptyList();
 
     }
-    
-    
+
+
     @SCLValue(type = "ReadGraph -> Resource -> [Issue]")
     public static List<Issue> valueValidator(ReadGraph graph, Resource resource) throws DatabaseException {
 
         List<Issue> issues = null;
 
         Layer0 L0 = Layer0.getInstance(graph);
-       if(graph.hasValue(resource)) {
-               if(!graph.isInstanceOf(resource, L0.Literal)) {
-                       issues = reportInconsistency(graph, resource, 
-                                       "Resource has a value but it is not a literal.", issues);
-               }
-               else {
-                       // TODO check that the value is valid for the data type
-               }
-       }
-       else {
-               if(graph.isInstanceOf(resource, L0.Literal)) {
-                       issues = reportInconsistency(graph, resource, 
-                                       "Resource is a literal but it does not have a value.", issues);
-               }
-       }
-       
+        if(graph.hasValue(resource)) {
+            if(!graph.isInstanceOf(resource, L0.Literal)) {
+                issues = reportInconsistency(graph, resource, 
+                        "Resource has a value but it is not a literal.", issues);
+            }
+            else {
+                // TODO check that the value is valid for the data type
+            }
+        }
+        else {
+            if(graph.isInstanceOf(resource, L0.Literal)) {
+                issues = reportInconsistency(graph, resource, 
+                        "Resource is a literal but it does not have a value.", issues);
+            }
+        }
+
         return issues != null ? issues : Collections.<Issue>emptyList();
-       
+
     }
 
-    
+
     @SCLValue(type = "ReadGraph -> Resource -> [Issue]")
     public static List<Issue> uriValidator(ReadGraph graph, Resource resource) throws DatabaseException {
-       
+
         List<Issue> issues = null;
 
         Layer0 L0 = Layer0.getInstance(graph);
         Resource parent = graph.getPossibleObject(resource, L0.PartOf);
-       if(parent != null) {
-           String parentURI = graph.syncRequest(new PossibleURI(parent));
-           if(parentURI != null) {
-                       String name = graph.getPossibleRelatedValue(resource, L0.HasName);
-                       if(name == null) {
-                               issues = reportInconsistency(graph, resource, "Resource has a parent with URI but has no valid HasName.", issues);
-                       }
-           }
-       }
+        if(parent != null) {
+            String parentURI = graph.syncRequest(new PossibleURI(parent));
+            if(parentURI != null) {
+                String name = graph.getPossibleRelatedValue(resource, L0.HasName);
+                if(name == null) {
+                    issues = reportInconsistency(graph, resource, "Resource has a parent with URI but has no valid HasName.", issues);
+                }
+            }
+        }
 
         return issues != null ? issues : Collections.<Issue>emptyList();
-       
+
     }
-    
+
     private static Resource getPossibleNearestClusterSet(ReadGraph graph, Resource base, Resource resource) throws DatabaseException {
 
         ClusteringSupport cs = graph.getService(ClusteringSupport.class);
         if(cs.isClusterSet(resource) && !base.equals(resource)) return resource;
-        
+
         Resource nearest = NearestOwnerFinder.getNearestOwner(graph, resource);
         if(nearest == null) return null;
-        
+
         return getPossibleNearestClusterSet(graph, base, nearest);
 
     }
 
     private static boolean quirks(ReadGraph graph, Resource resource) throws DatabaseException {
 
-       if(!resource.isPersistent()) return true;
-       if(graph.isImmutable(resource)) return true;
-       if(resource.getResourceId() < 0x2000) return true;
+        if(!resource.isPersistent()) return true;
+        if(graph.isImmutable(resource)) return true;
+        if(resource.getResourceId() < 0x2000) return true;
+
+        return false;
 
-       return false;
-       
     }
-    
+
     @SCLValue(type = "ReadGraph -> Resource -> [Issue]")
     public static List<Issue> clusterValidator(ReadGraph graph, Resource resource) throws DatabaseException {
 
-       if(!Development.DEVELOPMENT) return Collections.<Issue>emptyList();
-       
-       if(quirks(graph, resource)) return Collections.<Issue>emptyList();
-       
+        if(!Development.DEVELOPMENT) return Collections.<Issue>emptyList();
+
+        if(quirks(graph, resource)) return Collections.<Issue>emptyList();
+
         List<Issue> issues = null;
 
         ClusteringSupport cs = graph.getService(ClusteringSupport.class);
         Resource set = cs.getClusterSetOfCluster(resource);
-        
+
         if(set == null) return reportInconsistency(graph, resource, "Resource cluster is not part of any cluster set", issues);
-        
+
         Resource nearestSet = getPossibleNearestClusterSet(graph, resource, resource);
         if(nearestSet == null) {
-               // This means that there is no owner since RootLibrary is a cluster set
-               return Collections.<Issue>emptyList();
+            // This means that there is no owner since RootLibrary is a cluster set
+            return Collections.<Issue>emptyList();
         }
-        
+
         if(!set.equals(nearestSet)) return reportInconsistency(graph, resource, "The cluster set of a resource is not the nearest owner set", issues);
 
         return Collections.<Issue>emptyList();
-       
+
     }
 
     private static boolean isInstanceOfAny(ReadGraph graph, Resource r, Collection<Resource> types, boolean ifEmpty) throws DatabaseException {
-               if (types.isEmpty())
-                       return ifEmpty;
-               for (Resource type : types) {
-                       if (graph.isInstanceOf(r, type)) {
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-       private static StringBuilder orString(ReadGraph graph, StringBuilder sb, Collection<Resource> rs) throws DatabaseException {
-               sb.append("(");
-               boolean first = true;
-               for (Resource r : rs) {
-                       if (!first)
-                               sb.append(" | ");
-                       first = false;
-                       sb.append(NameUtils.getSafeName(graph, r));
-               }
-               sb.append(")");
-               return sb;
-       }
+        if (types.isEmpty())
+            return ifEmpty;
+        for (Resource type : types) {
+            if (graph.isInstanceOf(r, type)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static StringBuilder orString(ReadGraph graph, StringBuilder sb, Collection<Resource> rs) throws DatabaseException {
+        sb.append("(");
+        boolean first = true;
+        for (Resource r : rs) {
+            if (!first)
+                sb.append(" | ");
+            first = false;
+            sb.append(NameUtils.getSafeName(graph, r));
+        }
+        sb.append(")");
+        return sb;
+    }
 
     public static boolean isRelation(ReadGraph g, Layer0 l0, Resource relation) throws DatabaseException {
-               return g.hasStatement(relation, l0.SubrelationOf) || relation == l0.IsWeaklyRelatedTo;
-       }
-       
-       public static boolean isType(ReadGraph g, Layer0 l0, Resource type) throws DatabaseException {
-               return g.hasStatement(type, l0.Inherits) || type == l0.Entity;
-       }
-       
+        return g.hasStatement(relation, l0.SubrelationOf) || relation == l0.IsWeaklyRelatedTo;
+    }
+
+    public static boolean isType(ReadGraph g, Layer0 l0, Resource type) throws DatabaseException {
+        return g.hasStatement(type, l0.Inherits) || type == l0.Entity;
+    }
+
     public static Variable buildChildVariable(ReadGraph graph, Variable context, Resource graphChild, Object nodeChild) throws DatabaseException {
         VariableBuilder builder = graph.adapt(graphChild, VariableBuilder.class);
-       return builder.buildChild(graph, context, build(((AbstractVariable)context).node, nodeChild), graphChild);
-       }
-
-       private static Variable buildPropertyVariable(ReadGraph graph, Variable variable, Resource parentResource, PropertyInfo graphProperty, Object propertyNode) throws DatabaseException {
-               VariableNode<?> node = variable instanceof AbstractVariable ? build(((AbstractVariable)variable).node, propertyNode) : null;
-               return graphProperty.builder.buildProperty(graph, variable, node, parentResource, graphProperty.predicate);
-       }
-       
-       static StandardGraphChildVariable createStandardGraphChildVariable(
-                       AbstractVariable parent, Object child) {
-               return new StandardGraphChildVariable(parent, build(parent.node, child), null);
-       }
-
-       private static StandardGraphPropertyVariable createStandardGraphPropertyVariable(
-                       ReadGraph graph, AbstractVariable variable, Object nodeProperty) throws DatabaseException {
+        return builder.buildChild(graph, context, build(((AbstractVariable)context).node, nodeChild), graphChild);
+    }
+
+    private static Variable buildPropertyVariable(ReadGraph graph, Variable variable, Resource parentResource, PropertyInfo graphProperty, Object propertyNode) throws DatabaseException {
+        VariableNode<?> node = variable instanceof AbstractVariable ? build(((AbstractVariable)variable).node, propertyNode) : null;
+        return graphProperty.builder.buildProperty(graph, variable, node, parentResource, graphProperty.predicate);
+    }
+
+    static StandardGraphChildVariable createStandardGraphChildVariable(
+            AbstractVariable parent, Object child) {
+        return new StandardGraphChildVariable(parent, build(parent.node, child), null);
+    }
+
+    private static StandardGraphPropertyVariable createStandardGraphPropertyVariable(
+            ReadGraph graph, AbstractVariable variable, Object nodeProperty) throws DatabaseException {
         Resource propertyResource = getPossiblePropertyResource(graph, variable, nodeProperty);
         return new StandardGraphPropertyVariable(graph, variable, build(variable.node, nodeProperty), null, propertyResource);
-       }
-        
-       static Map<String, Variable> ensureVariableMap(
-                       Map<String, Variable> map, int size) {
-               if(map == null) map = new THashMap<String,Variable>(size);
-               return map;
-       }
-
-       private static PropertyInfo getPropertyInfo(ReadGraph graph, Resource predicate) throws DatabaseException {
-               return graph.syncRequest(new PropertyInfoRequest(predicate));
-       }
-
-       @SuppressWarnings("unchecked")
-       static String getNodeName(AbstractVariable parent, Object child) {
-               return parent.node.support.manager.getName(child);
-       }
-
-       @SuppressWarnings("unchecked")
-       private static Object getNodeValue(final AbstractVariable variable, final Binding binding) throws NodeManagerException, BindingException {
-               return variable.node.support.manager.getValue(variable.node.node, binding);
-       }
-
-       @SuppressWarnings("unchecked")
-       private static void setNodeValue(final AbstractVariable variable, final Object value, final Binding binding) throws NodeManagerException, BindingException {
-               variable.node.support.manager.setValue(variable.node.node, value, binding);
-       }
-       
-       @SuppressWarnings("unchecked")
-       private static String getPossiblePropertyURI(AbstractVariable parent, Object node) {
-               return parent.node.support.manager.getPropertyURI(parent.node.node, node);
-       }
-    
+    }
+
+    static Map<String, Variable> ensureVariableMap(
+            Map<String, Variable> map, int size) {
+        if(map == null) map = new THashMap<String,Variable>(size);
+        return map;
+    }
+
+    private static PropertyInfo getPropertyInfo(ReadGraph graph, Resource predicate) throws DatabaseException {
+        return graph.syncRequest(new PropertyInfoRequest(predicate));
+    }
+
+    @SuppressWarnings("unchecked")
+    static String getNodeName(AbstractVariable parent, Object child) {
+        return parent.node.support.manager.getName(child);
+    }
+
+    @SuppressWarnings("unchecked")
+    private static Object getNodeValue(final AbstractVariable variable, final Binding binding) throws NodeManagerException, BindingException {
+        return variable.node.support.manager.getValue(variable.node.node, binding);
+    }
+
+    @SuppressWarnings("unchecked")
+    private static void setNodeValue(final AbstractVariable variable, final Object value, final Binding binding) throws NodeManagerException, BindingException {
+        variable.node.support.manager.setValue(variable.node.node, value, binding);
+    }
+
+    @SuppressWarnings("unchecked")
+    private static String getPossiblePropertyURI(AbstractVariable parent, Object node) {
+        return parent.node.support.manager.getPropertyURI(parent.node.node, node);
+    }
+
 
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
     public static Object defaultInstantiateUnder(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
index 2bd089d1e8ed1589ecadb76f6f18662169b405ef..140ee8fa0841648805803c027686ac2b6efb2441 100644 (file)
@@ -6,44 +6,48 @@ import org.simantics.databoard.binding.mutable.Variant;
 import org.simantics.databoard.util.ObjectUtils;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.common.request.ParametrizedPrimitiveRead;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.Listener;
+import org.simantics.simulator.variable.NodeManager;
 import org.simantics.simulator.variable.exceptions.NodeIsNotValidAnymoreException;
 import org.simantics.simulator.variable.exceptions.NodeManagerException;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @SuppressWarnings("rawtypes")
 class NodeValueRequest extends ParametrizedPrimitiveRead<Pair<VariableNode,Binding>, Variant> implements VariableNodeReadRunnable {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(NodeValueRequest.class);
+
     private Listener<Variant> listener = null;
     private Variant value = Variables.PENDING_NODE_VALUE;
     private boolean wasRun = false;
 
     static class Probe implements Runnable {
 
-       private Pair<VariableNode,Binding> parameter;
-               public Variant result;
-       
-       public Probe(Pair<VariableNode,Binding> parameter) {
-               this.parameter = parameter;
-       }
-       
-               @SuppressWarnings("unchecked")
-               @Override
-               public void run() {
-                       try {
-                               result = NodeValueRequest.get(parameter);
-                               parameter.first.support.valueCache.put(parameter.first.node, result, 1000000000L);
-                       } catch (NodeManagerException e) {
-                               e.printStackTrace();
-                       } catch (BindingException e) {
-                               e.printStackTrace();
-                       }
-               }
-       
+        private Pair<VariableNode,Binding> parameter;
+        public Variant result;
+
+        public Probe(Pair<VariableNode,Binding> parameter) {
+            this.parameter = parameter;
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public void run() {
+            try {
+                result = NodeValueRequest.get(parameter);
+                parameter.first.support.valueCache.put(parameter.first.node, result, 1000000000L);
+            } catch (NodeManagerException e) {
+                e.printStackTrace();
+            } catch (BindingException e) {
+                e.printStackTrace();
+            }
+        }
+
     }
-    
+
     public NodeValueRequest(VariableNode node) {
         super(Pair.<VariableNode, Binding>make(node, null));
     }
@@ -55,18 +59,18 @@ class NodeValueRequest extends ParametrizedPrimitiveRead<Pair<VariableNode,Bindi
     @SuppressWarnings("unchecked")
     @Override
     public void register(ReadGraph graph, final Listener<Variant> procedure) {
-       
-       VariableNode node = parameter.first;
+
+        VariableNode node = parameter.first;
 
         if(procedure.isDisposed()) {
-               
-               // We are not listening
-               Variant result = (Variant)node.support.valueCache.get(node.node);
 
-               if(result != null) {
-                       // Return cached value immediately
-                       procedure.execute(result);
-               } else {
+            // We are not listening
+            Variant result = (Variant)node.support.valueCache.get(node.node);
+
+            if(result != null) {
+                // Return cached value immediately
+                procedure.execute(result);
+            } else {
 
 //             
 //            listener = procedure;
@@ -87,37 +91,37 @@ class NodeValueRequest extends ParametrizedPrimitiveRead<Pair<VariableNode,Bindi
 //                }
 //            }
 //            return;
-            
-                       NodeValueRequest.Probe probe = new Probe(parameter);
-                       node.support.manager.getRealm().asyncExec(probe);
-                       if(probe.result != null) {
-                               procedure.execute(probe.result);
-                       } else {
-                               procedure.execute(Variables.PENDING_NODE_VALUE);
-                       }
-
-               }
-
-               return;            
+
+                NodeValueRequest.Probe probe = new Probe(parameter);
+                node.support.manager.getRealm().asyncExec(probe);
+                if(probe.result != null) {
+                    procedure.execute(probe.result);
+                } else {
+                    procedure.execute(Variables.PENDING_NODE_VALUE);
+                }
+
+            }
+
+            return;            
         }
-        
-       // We need to listen
+
+        // We need to listen
         listener = procedure;
-               // Register listening
-               node.support.manager.addNodeListener(node.node, this);
-               synchronized(this) {
-                       if(wasRun) {
-                               procedure.execute(value);
-                       } else {
-                               Variant result = (Variant)node.support.valueCache.get(node.node);
-                               if(result != null) {
-                                       procedure.execute(result);
-                               } else {
-                       procedure.execute(Variables.PENDING_NODE_VALUE);
-                               }
-                       }
-               }
-        
+        // Register listening
+        node.support.manager.addNodeListener(node.node, this);
+        synchronized(this) {
+            if(wasRun) {
+                procedure.execute(value);
+            } else {
+                Variant result = (Variant)node.support.valueCache.get(node.node);
+                if(result != null) {
+                    procedure.execute(result);
+                } else {
+                    procedure.execute(Variables.PENDING_NODE_VALUE);
+                }
+            }
+        }
+
 //        if(listener != null) {
 //            throw new UnsupportedOperationException();
 //        }
@@ -145,61 +149,64 @@ class NodeValueRequest extends ParametrizedPrimitiveRead<Pair<VariableNode,Bindi
 //            parameter.support.manager.addNodeListener(parameter.node, this);
 //            if(value == Variables.PENDING_NODE_VALUE) procedure.execute(Variables.PENDING_NODE_VALUE);
 //        }
-               
+
     }
-    
+
     static class NodeListener implements VariableNodeReadRunnable {
-       
-       private VariableNode node;
-       private NodeValueRequest request;
-       
-       public NodeListener(VariableNode node, NodeValueRequest request) {
-               this.node = node;
-               this.request = request;
-       }
-
-       @SuppressWarnings("unchecked")
-       @Override
-       public void run() {
+
+        private VariableNode node;
+        private NodeValueRequest request;
+
+        public NodeListener(VariableNode node, NodeValueRequest request) {
+            this.node = node;
+            this.request = request;
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public void run() {
             node.support.manager.addNodeListener(node.node, request);
-       }
-       
+        }
+
     }
 
 
     @SuppressWarnings("unchecked")
     @Override
     public void unregistered() {
-       VariableNode node = parameter.first;
-       node.support.manager.removeNodeListener(node.node, this);
+        VariableNode node = parameter.first;
+        node.support.manager.removeNodeListener(node.node, this);
         node.support.valueCache.removeListening(node.node);
         listener = null;
     }
-    
+
     @SuppressWarnings("unchecked")
     public static Variant get(Pair<VariableNode,Binding> parameter) throws NodeManagerException, BindingException {
 
-       VariableNode node = parameter.first;
-       Binding binding = parameter.second;
-       
-       if (binding != null) {
-               Object raw = node.support.manager.getValue(node.node, binding);
-               if(raw == null) return null;
-               else return new Variant(binding, raw);
-       } else {
-               return node.support.manager.getValue(node.node);
-       }
-       
+        VariableNode node = parameter.first;
+        Binding binding = parameter.second;
+
+        if (binding != null) {
+            Object raw = node.support.manager.getValue(node.node, binding);
+            if(raw == null)
+                return null;
+            else if(NodeManager.PENDING_NODE_VALUE == raw)
+                return NodeManager.PENDING_NODE_VALUE;
+            else return new Variant(binding, raw);
+        } else {
+            return node.support.manager.getValue(node.node);
+        }
+
     }
-    
+
     @SuppressWarnings("unchecked")
     @Override
     public synchronized void run() {
-       
-       VariableNode node = parameter.first;
-       
+
+        VariableNode node = parameter.first;
+
         try {
-               Variant newValue = get(parameter);
+            Variant newValue = get(parameter);
             if (wasRun && ObjectUtils.objectEquals(value, newValue)) {
                 //System.out.println("CACHE VALUE MATCH (" + newValue + ") for " + node.node);
                 return;
@@ -209,7 +216,7 @@ class NodeValueRequest extends ParametrizedPrimitiveRead<Pair<VariableNode,Bindi
         } catch (Throwable e) {
             // Must catch everything to prevent DB client from getting stuck.
             if(!(e instanceof NodeIsNotValidAnymoreException))
-               Logger.defaultLogError(e);
+                LOGGER.error("Error while computing node value", e);
             // Invoke the exception method of the listener
             Listener<Variant> listener = this.listener;
             if (listener != null) listener.exception(new DatabaseException("External data access error", e));
index 341a496a4ff2778a3e9972cb2c0c998dbe9f6114..218a268a464097916f666d44cf3c20f91115a166 100644 (file)
@@ -32,7 +32,6 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.PossibleIndexRoot;
 import org.simantics.db.common.request.TernaryRead;
 import org.simantics.db.common.utils.CommonDBUtils;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.exception.InvalidVariableException;
 import org.simantics.db.layer0.exception.MissingVariableException;
@@ -53,14 +52,19 @@ import org.simantics.scl.runtime.function.Function1;
 import org.simantics.scl.runtime.function.Function2;
 import org.simantics.scl.runtime.function.Function3;
 import org.simantics.simulation.ontology.SimulationResource;
+import org.simantics.simulator.variable.NodeManager;
 import org.simantics.simulator.variable.exceptions.NodeManagerException;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.TObjectIntHashMap;
 
 final public class Variables {
 
-    public static final Variant PENDING_NODE_VALUE = new Variant();
+    private static final Logger LOGGER = LoggerFactory.getLogger(Variables.class);
+
+    public static final Variant PENDING_NODE_VALUE = NodeManager.PENDING_NODE_VALUE;
 
     public static final NodeStructure PENDING_NODE_STRUCTURE = new NodeStructure(Collections.emptyMap(), Collections.emptyMap()) {
         public boolean equals(Object object) {
@@ -154,8 +158,8 @@ final public class Variables {
 
     @Deprecated
     public final static String[] builtins = {
-        TYPE, RESOURCE, URI
-        //, SERIALISED
+            TYPE, RESOURCE, URI
+            //, SERIALISED
     };
 
     public static Variable getPossibleVariable(ReadGraph graph, Resource resource) throws DatabaseException {
@@ -309,15 +313,15 @@ final public class Variables {
     public static Variable getRootVariable(ReadGraph graph) throws DatabaseException {
         return graph.adapt(graph.getRootLibrary(), Variable.class);
     }
-    
+
     public static Resource getPossibleIndexRoot(ReadGraph graph, Variable variable) throws DatabaseException {
-       return graph.syncRequest(new PossibleVariableIndexRoot(variable));
+        return graph.syncRequest(new PossibleVariableIndexRoot(variable));
     }
-    
+
     public static Resource getIndexRoot(ReadGraph graph, Variable variable) throws DatabaseException {
-       return graph.syncRequest(new VariableIndexRoot(variable));
+        return graph.syncRequest(new VariableIndexRoot(variable));
     }
-    
+
     public static Resource getModel(ReadGraph graph, Variable variable) throws DatabaseException {
         String URI = variable.getURI(graph);
         return VariablesImpl.getFirst(graph, SimulationResource.getInstance(graph).Model, URI, 8);
@@ -382,7 +386,7 @@ final public class Variables {
         Variable context = getConfigurationContext(graph, resource);
         return context.browse(graph, RVI);
     }
-    
+
     public static Variable getConfigurationVariable(ReadGraph graph, Variable variable) throws DatabaseException {
         Variable context = getConfigurationContext(graph, variable);
         RVI rvi = variable.getRVI(graph);
@@ -546,12 +550,12 @@ final public class Variables {
     }
 
     public static Variable toPossibleConfigurationVariable(ReadGraph graph, Variable variable) throws DatabaseException {
-       
+
         Resource represents = variable.getPossibleRepresents(graph);
         if(represents == null) return null;
         Resource config = getPossibleConfigurationContextResource(graph, represents);
         if(config == null) return null;
-       return switchPossibleContext(graph, variable, config);
+        return switchPossibleContext(graph, variable, config);
 
     }
 
@@ -641,25 +645,26 @@ final public class Variables {
     }
 
     public static Variant requestNodeValue(ReadGraph graph, VariableNode<?> node, final Binding binding) throws DatabaseException {
-       Variant value = graph.syncRequest(new NodeValueRequest(node, binding));
-       if(PENDING_NODE_VALUE == value && graph.getSynchronous()) {
-               // In this case a PENDING value was previously cached but now the value needs to be obtained for real.
-               
-                       ValueGetter getter = new ValueGetter(node, binding);
-                       try {
-                               node.support.manager.getRealm().syncExec(getter);
-                       } catch (InterruptedException e) {
-                               Logger.defaultLogError(e);
-                       }
-                       
-                       if (getter.exception != null)
-                               throw new MissingVariableValueException("No value for node " + node, getter.exception);
-                       
-                       return getter.result;
-       }
+        Variant value = graph.syncRequest(new NodeValueRequest(node, binding));
+        if(PENDING_NODE_VALUE == value && graph.getSynchronous()) {
+            // In this case a PENDING value was previously cached but now the value needs to be obtained for real.
+
+            ValueGetter getter = new ValueGetter(node, binding);
+            try {
+                node.support.manager.getRealm().syncExec(getter);
+            } catch (InterruptedException e) {
+                LOGGER.error("Error while getting node value", e);
+                throw new InvalidVariableException("External data access error " + String.valueOf(node), e);
+            }
+
+            if (getter.exception != null)
+                throw new MissingVariableValueException("No value for node " + node, getter.exception);
+
+            return getter.result;
+        }
         return value; 
     }
-    
+
     public static class NodeStructure {
         // Immutable but wrapped with Collections.unmodifiableMap as an optimization
         public final Map<String,Object> children;
@@ -699,51 +704,51 @@ final public class Variables {
         NodeStructure value = graph.syncRequest(new NodeStructureRequest(node));
         if (value == null)
             throw new InvalidVariableException("External data access error " + String.valueOf(node));
-       if(PENDING_NODE_STRUCTURE == value && graph.getSynchronous()) {
-               // In this case a PENDING value was previously cached but now the value needs to be obtained for real.
-               
-                       StructureGetter getter = new StructureGetter(node);
-                       try {
-                               node.support.manager.getRealm().syncExec(getter);
-                       } catch (InterruptedException e) {
-                               Logger.defaultLogError(e);
-                               throw new InvalidVariableException("External data access error " + String.valueOf(node), e);
-                       }
-                       
-                       if (getter.exception != null)
-                               throw new InvalidVariableException("External data access error " + String.valueOf(node), getter.exception);
-                       if (getter.result == null)
-                               throw new InvalidVariableException("External data access error " + String.valueOf(node));
-                       
-                       return getter.result;
-               
-       }
+        if(PENDING_NODE_STRUCTURE == value && graph.getSynchronous()) {
+            // In this case a PENDING value was previously cached but now the value needs to be obtained for real.
+
+            StructureGetter getter = new StructureGetter(node);
+            try {
+                node.support.manager.getRealm().syncExec(getter);
+            } catch (InterruptedException e) {
+                LOGGER.error("Error while getting node structure", e);
+                throw new InvalidVariableException("External data access error " + String.valueOf(node), e);
+            }
+
+            if (getter.exception != null)
+                throw new InvalidVariableException("External data access error " + String.valueOf(node), getter.exception);
+            if (getter.result == null)
+                throw new InvalidVariableException("External data access error " + String.valueOf(node));
+
+            return getter.result;
+
+        }
         return value; 
 
     }
-    
+
     public static String getPossibleUnit(ReadGraph graph, Variable variable) throws DatabaseException {
-       
-       try {
-               
-               Resource predicate = variable.getPossiblePredicateResource(graph);
-               if(predicate != null) {
-                       PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(predicate));
-                       if(info.definedUnit != null) return info.definedUnit;
-               }
-               
-               Variant variant = variable.getVariantValue(graph);
-               Binding binding = variant.getBinding();
-               if(binding == null) return null;
-               Datatype dt = binding.type();
-               if(!(dt instanceof NumberType)) return null;
-               NumberType nt = (NumberType)dt;
-               return nt.getUnit();
-               
-       } catch (DatabaseException e) {
-               return null;
-       }
-       
+
+        try {
+
+            Resource predicate = variable.getPossiblePredicateResource(graph);
+            if(predicate != null) {
+                PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(predicate));
+                if(info.definedUnit != null) return info.definedUnit;
+            }
+
+            Variant variant = variable.getVariantValue(graph);
+            Binding binding = variant.getBinding();
+            if(binding == null) return null;
+            Datatype dt = binding.type();
+            if(!(dt instanceof NumberType)) return null;
+            NumberType nt = (NumberType)dt;
+            return nt.getUnit();
+
+        } catch (DatabaseException e) {
+            return null;
+        }
+
     }
 
     /**
@@ -790,8 +795,10 @@ final public class Variables {
                     result = new Variant(binding, n.support.manager.getValue(n.node, binding));
                 else
                     result = n.support.manager.getValue(n.node);
+            } catch (NodeManagerException e) {
+                exception = e;
             } catch (Exception e) {
-                Logger.defaultLogError(e);
+                LOGGER.error("Error while getting node value", e);
                 exception = e;
             }
         }
@@ -814,10 +821,9 @@ final public class Variables {
             try {
                 result = NodeStructureRequest.get(n);
             } catch (NodeManagerException e) {
-                Logger.defaultLogError(e);
                 exception = e;
             }
-        }
+         }
 
     };
 
@@ -825,12 +831,12 @@ final public class Variables {
         Variable v = Variables.getPossibleVariable(graph, entity);
         return v != null ? v.getPossibleProperty(graph, property) : null;
     }
-    
-       public static ValueAccessor createValueAccessor(Function1<Variable, Object> getValue1, Function2<Variable, Binding, Object> getValue2,
-                       Function2<Variable, Object, Object> setValue2, Function3<Variable, Object, Binding, Object> setValue3,
-                       Function1<Variable, Datatype> getDatatype) {
-               return new SCLValueAccessor(getValue1, getValue2, setValue2, setValue3, getDatatype);
-       }
+
+    public static ValueAccessor createValueAccessor(Function1<Variable, Object> getValue1, Function2<Variable, Binding, Object> getValue2,
+            Function2<Variable, Object, Object> setValue2, Function3<Variable, Object, Binding, Object> setValue3,
+            Function1<Variable, Datatype> getDatatype) {
+        return new SCLValueAccessor(getValue1, getValue2, setValue2, setValue3, getDatatype);
+    }
 
     public static void setRVIProperty(WriteGraph graph, Variable variable, RVI rvi) throws DatabaseException {
         Layer0 L0 = Layer0.getInstance(graph);
index 402f3884d433270d9161594224d971469f297b3c..e09b3136e6307c7750f81f2ab1271ed340e4a2b4 100644 (file)
@@ -194,7 +194,10 @@ public class StandardNodeManager<Node, Engine extends StandardNodeManagerSupport
     @Override
     public Object getValue(Node node, Binding binding) throws NodeManagerException, BindingException {
         try {
-            return getValue(node).getValue(binding);
+            Variant value = getValue(node);
+            if(NodeManager.PENDING_NODE_VALUE == value)
+                return value;
+            return value.getValue(binding);
         } catch (AdaptException e) {
             throw new BindingException(e);
         }
@@ -296,6 +299,8 @@ public class StandardNodeManager<Node, Engine extends StandardNodeManagerSupport
         Variant variant = valueCache.get(node);
         if(variant == null) {
             Object value = realm.getEngine().getEngineValue(node);
+            if(NodeManager.PENDING_NODE_VALUE == value)
+                return (Variant)value;
             Binding binding = realm.getEngine().getEngineBinding(node);
             variant = new Variant(binding, value);
             valueCache.put(node, variant);
index 345aff81f82e88771156ff69b5f19c67901719f0..27bf8c51b4d03757db7d7e98dec8fdf66acb30a6 100644 (file)
@@ -36,112 +36,114 @@ import org.simantics.simulator.variable.exceptions.NotInRealmException;
  */
 public interface NodeManager<Node> {
 
-       // --- Do not require a realm access ---
-       
-       /**
-        * The realm of the node manager. Almost all other methods
-        * of this class must be called inside this realm.
-        */
-       Realm getRealm();
-
-       /**
-        * Returns the name of the node. This method does not require 
-        * that caller is in realm.
-        */
-       String getName(Node node);
-
-       /**
-        * Adds a listener to a certain node. The new listener is called as
-        * soon as possible (for example before simulator takes the next simulation
-        * step). After the first call, it is called always the node value 
-        * or structure may have changed. This can be called outside of the realm.
-        */
-       void addNodeListener(Node node, Runnable listener);
-       
-       /**
-        * Removes previously added listener. This can be called outside of
-        * the realm.
-        */
-       void removeNodeListener(Node node, Runnable listener);
-       
-       // --- Require a realm access ---
-       
-       /**
-        * @return {@code null} if node cannot be found, otherwise a node with the given path
-        * @throws InvalidPathException if the path is not in a valid path format
-        * @throws NotInRealmException if not synchronized to the realm
-        */
-       Node getNode(String path) throws NodeManagerException;  
-       /**
-        * @return {@code null} if node cannot be found, otherwise a child node with the given name
-        * @throws NotInRealmException if not synchronized to the realm
-        */
-       Node getChild(Node node, String name) throws NodeManagerException;
-       Node getProperty(Node node, String name) throws NodeManagerException;
-       List<String> getChildNames(Node node) throws NodeManagerException;
-       List<String> getPropertyNames(Node node) throws NodeManagerException;
-       List<Node> getChildren(Node node) throws NodeManagerException;
-       List<Node> getProperties(Node node) throws NodeManagerException;
-
-       /**
-        * @throws NoValueException if the node has no value (and therefore no datatype)
-        * @throws NotInRealmException if not synchronized to the realm
-        */
-       Datatype getDatatype(Node node) throws NodeManagerException;
-       /**
-        * @throws NoValueException if the node has no value
-        * @throws BindingException if the value can not be bound to the given binding
-        * @throws NotInRealmException if not synchronized to the realm
-        */
-       Object getValue(Node node, Binding binding) throws NodeManagerException, BindingException;
-       /**
-        * A variant of {@link #getValue(Object, Binding)} that uses
-        * a binding chosen by the node manager.
-        */
-       Variant getValue(Node node) throws NodeManagerException;
-       /**
-        * @throws NoSuchNodeException if the property does not exist
-        * @throws NoValueException if the property has no value
-        * @throws NotInRealmException if not synchronized to the realm
-        * @throws BindingException if the value can not be bound to the given binding
-        */
-       Object getValue(Node node, String property, Binding binding) throws NodeManagerException, BindingException;
-       /**
-        * A variant of {@link #getValue(Object, String, Binding)} that uses
-        * a binding chosen by the node manager.
-        */
-       Variant getValue(Node node, String property) throws NodeManagerException;       
-       
-       /**
-        * @throws BindingException if the value can not be bound to the given binding
-        * @throws NoValueException if the property has no value that could be assigned
-        * @throws NotInRealmException if not synchronized to the realm
-        */
-       void setValue(Node node, Object value, Binding binding) throws NodeManagerException, BindingException;
-       /**
-        * @throws BindingException if the value can not be bound to the given binding
-        * @throws NoSuchNodeException if the property does not exist
-        * @throws NoValueException if the property has no value that could be assigned
-        * @throws NotInRealmException if not synchronized to the realm
-        */
-       void setValue(Node node, String property, Object value, Binding binding) throws NodeManagerException, BindingException;
-
-       /**
-        * Asks the full URI of a property node. The parent of the property is also given as a parameter.
-        * This is an optional method, NodeManager does not have to implement it for all nodes.
-        */
+    public static final Variant PENDING_NODE_VALUE = new Variant();
+
+    // --- Do not require a realm access ---
+
+    /**
+     * The realm of the node manager. Almost all other methods
+     * of this class must be called inside this realm.
+     */
+    Realm getRealm();
+
+    /**
+     * Returns the name of the node. This method does not require 
+     * that caller is in realm.
+     */
+    String getName(Node node);
+
+    /**
+     * Adds a listener to a certain node. The new listener is called as
+     * soon as possible (for example before simulator takes the next simulation
+     * step). After the first call, it is called always the node value 
+     * or structure may have changed. This can be called outside of the realm.
+     */
+    void addNodeListener(Node node, Runnable listener);
+
+    /**
+     * Removes previously added listener. This can be called outside of
+     * the realm.
+     */
+    void removeNodeListener(Node node, Runnable listener);
+
+    // --- Require a realm access ---
+
+    /**
+     * @return {@code null} if node cannot be found, otherwise a node with the given path
+     * @throws InvalidPathException if the path is not in a valid path format
+     * @throws NotInRealmException if not synchronized to the realm
+     */
+    Node getNode(String path) throws NodeManagerException;     
+    /**
+     * @return {@code null} if node cannot be found, otherwise a child node with the given name
+     * @throws NotInRealmException if not synchronized to the realm
+     */
+    Node getChild(Node node, String name) throws NodeManagerException;
+    Node getProperty(Node node, String name) throws NodeManagerException;
+    List<String> getChildNames(Node node) throws NodeManagerException;
+    List<String> getPropertyNames(Node node) throws NodeManagerException;
+    List<Node> getChildren(Node node) throws NodeManagerException;
+    List<Node> getProperties(Node node) throws NodeManagerException;
+
+    /**
+     * @throws NoValueException if the node has no value (and therefore no datatype)
+     * @throws NotInRealmException if not synchronized to the realm
+     */
+    Datatype getDatatype(Node node) throws NodeManagerException;
+    /**
+     * @throws NoValueException if the node has no value
+     * @throws BindingException if the value can not be bound to the given binding
+     * @throws NotInRealmException if not synchronized to the realm
+     */
+    Object getValue(Node node, Binding binding) throws NodeManagerException, BindingException;
+    /**
+     * A variant of {@link #getValue(Object, Binding)} that uses
+     * a binding chosen by the node manager.
+     */
+    Variant getValue(Node node) throws NodeManagerException;
+    /**
+     * @throws NoSuchNodeException if the property does not exist
+     * @throws NoValueException if the property has no value
+     * @throws NotInRealmException if not synchronized to the realm
+     * @throws BindingException if the value can not be bound to the given binding
+     */
+    Object getValue(Node node, String property, Binding binding) throws NodeManagerException, BindingException;
+    /**
+     * A variant of {@link #getValue(Object, String, Binding)} that uses
+     * a binding chosen by the node manager.
+     */
+    Variant getValue(Node node, String property) throws NodeManagerException;  
+
+    /**
+     * @throws BindingException if the value can not be bound to the given binding
+     * @throws NoValueException if the property has no value that could be assigned
+     * @throws NotInRealmException if not synchronized to the realm
+     */
+    void setValue(Node node, Object value, Binding binding) throws NodeManagerException, BindingException;
+    /**
+     * @throws BindingException if the value can not be bound to the given binding
+     * @throws NoSuchNodeException if the property does not exist
+     * @throws NoValueException if the property has no value that could be assigned
+     * @throws NotInRealmException if not synchronized to the realm
+     */
+    void setValue(Node node, String property, Object value, Binding binding) throws NodeManagerException, BindingException;
+
+    /**
+     * Asks the full URI of a property node. The parent of the property is also given as a parameter.
+     * This is an optional method, NodeManager does not have to implement it for all nodes.
+     */
     String getPropertyURI(Node parent, Node property);
 
-       /**
-        * Asks for the classifications of a property node.
-        * This is an optional method, NodeManager does not have to implement it for all nodes.
-        * A default implementation should just return {@link Collections#emptySet()}.
-        * Classifications can be any strings, however a recommended interpretation is to return
-        * the URIs of the primary ontological types that this node corresponds to.
-        
-        * @param node the node to classify
-        * @return classifications of the node, empty set if the node has no classifications
-        */
-       Set<String> getClassifications(Node node) throws NodeManagerException;
+    /**
+     * Asks for the classifications of a property node.
+     * This is an optional method, NodeManager does not have to implement it for all nodes.
+     * A default implementation should just return {@link Collections#emptySet()}.
+     * Classifications can be any strings, however a recommended interpretation is to return
+     * the URIs of the primary ontological types that this node corresponds to.
+     * 
+     * @param node the node to classify
+     * @return classifications of the node, empty set if the node has no classifications
+     */
+    Set<String> getClassifications(Node node) throws NodeManagerException;
 
 }
\ No newline at end of file