]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Tried to improve the implementation of getPossibleDomainProperty"
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 6 Mar 2018 07:15:30 +0000 (09:15 +0200)
committerGerrit Code Review <gerrit2@www.simantics.org>
Tue, 6 Mar 2018 07:15:30 +0000 (09:15 +0200)
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/function/All.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java

index 08ed3edf2650873f316c8ceb1228bcf89e1afee1..604faa69ed63d99f944bfabac8686eea2437750f 100644 (file)
@@ -608,6 +608,8 @@ public class All {
                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) {
index 9d7fded696ce2e7c06f572e46c164406907a1e6f..582277c905bbcbd19a2a1308021f5f71c66510f6 100644 (file)
@@ -15,7 +15,6 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.common.validation.L0Validations;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ValidationException;
@@ -29,9 +28,12 @@ import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.Development;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
-
+    private static final Logger LOGGER = LoggerFactory.getLogger(StandardGraphPropertyVariable.class);
+    
        protected static final PropertyInfo NO_PROPERTY = new PropertyInfo(null, null,
                        false, Collections.<String> emptySet(), null, null, null, null, null, null,
                        Collections.<String, Pair<Resource, ChildReference>> emptyMap(),
@@ -119,7 +121,7 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                if(Development.DEVELOPMENT) {
                        String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
                        if(error != null) {
-                               Logger.defaultLogError(new ValidationException(error));
+                           LOGGER.error(error);
                                //throw new ValidationException(error);
                        }
                }
@@ -138,7 +140,7 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                if(Development.DEVELOPMENT) {
                        String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
                        if(error != null) {
-                               Logger.defaultLogError(new ValidationException(error));
+                           LOGGER.error(error);
                                throw new ValidationException(error);
                        }
                }
@@ -175,7 +177,7 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                if(Development.DEVELOPMENT) {
                        String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
                        if(error != null) {
-                               Logger.defaultLogError(new ValidationException(error));
+                           LOGGER.error(error);
                                //throw new ValidationException(error);
                        }
                }
@@ -190,7 +192,7 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                if(Development.DEVELOPMENT) {
                        String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
                        if(error != null) {
-                               Logger.defaultLogError(new ValidationException(error));
+                           LOGGER.error(error);
                                throw new ValidationException(error);
                        }
                }
@@ -304,8 +306,8 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                        return valueMap.getVariable(graph, this, name);
                } catch (DatabaseException e) {
                        return null;
-               } catch (Throwable t) {
-                       System.err.println("err: " + getURI(graph) + "  # " + name);
+               } catch (Exception t) {
+                       LOGGER.error("getPossibleDomainProperty is implemented incorrectly, but returns null on Exception for backward compatibility. URI="+getURI(graph)+", name="+name+".", t);
                        return null;
                }