]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java
Merge "Expose History REST API implementation to other plug-ins"
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / StandardGraphPropertyVariable.java
index 9d7fded696ce2e7c06f572e46c164406907a1e6f..2dcb6e00ab08871f296c7af6d5a498115edf7d60 100644 (file)
@@ -15,13 +15,14 @@ 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.DatatypeNotFoundException;
 import org.simantics.db.exception.ValidationException;
+import org.simantics.db.exception.VariableException;
+import org.simantics.db.layer0.exception.InvalidVariableException;
 import org.simantics.db.layer0.exception.MissingVariableValueException;
 import org.simantics.db.layer0.exception.PendingVariableException;
-import org.simantics.db.layer0.exception.VariableException;
 import org.simantics.db.layer0.function.All;
 import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.db.layer0.request.PropertyInfoRequest;
@@ -29,9 +30,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 +123,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 +142,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);
                        }
                }
@@ -157,7 +161,7 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        @Override
        public Resource getRepresents(ReadGraph graph) throws DatabaseException {
                if(represents == null)
-                       throw new VariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ").");
+                       throw new InvalidVariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ").");
                return represents;
 //             return graph.getSingleObject(parentResource, property.predicate);
        }
@@ -175,7 +179,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 +194,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);
                        }
                }
@@ -231,9 +235,9 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                if (type == null) {
                        String uri = this.getPossibleURI(graph);
                        if (uri != null)
-                               throw new DatabaseException("No data type for " + uri);
+                               throw new DatatypeNotFoundException("No data type for " + uri);
                        else
-                               throw new DatabaseException("No data type for " + this.getIdentifier());
+                               throw new DatatypeNotFoundException("No data type for " + this.getIdentifier());
                }
                
                return type;
@@ -304,8 +308,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;
                }