]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/DependenciesRelation.java
Ignore NoSingleResultException in DependenciesRelation
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / genericrelation / DependenciesRelation.java
index 4162f91636d0b39dfb193d7bb93c076e9885b849..fc32222084c0f7e08509c152a882b893e7bd5b61 100644 (file)
@@ -40,10 +40,10 @@ import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.common.request.SuperTypeString;
 import org.simantics.db.common.request.TypeString;
 import org.simantics.db.common.request.UnaryRead;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.event.ChangeListener;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.NoSingleResultException;
 import org.simantics.db.layer0.adapter.GenericRelation;
 import org.simantics.db.layer0.adapter.GenericRelationIndex;
 import org.simantics.db.layer0.genericrelation.DependencyChanges.Change;
@@ -62,9 +62,11 @@ import org.simantics.layer0.Layer0;
 import org.simantics.operation.Layer0X;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.logging.TimeLogger;
+import org.slf4j.LoggerFactory;
 
 public class DependenciesRelation extends UnsupportedRelation implements GenericRelationIndex {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DependenciesRelation.class);
        private static final boolean DEBUG = false;
        static final boolean DEBUG_LISTENERS = false;
        private static final boolean PROFILE = false;
@@ -112,7 +114,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
 
                                @Override
                                public void exception(AsyncReadGraph graph, Throwable throwable) {
-                                       Logger.defaultLogError(throwable);
+                                       LOGGER.error("Could not compile possible related value for resource {}", resource, throwable);
                                }
 
                        });
@@ -126,7 +128,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
 
                                @Override
                                public void exception(AsyncReadGraph graph, Throwable throwable) {
-                                       Logger.defaultLogError(throwable);
+                                       LOGGER.error("Could not find type for resource {}", resource, throwable);
                                }
 
                        };
@@ -150,7 +152,13 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
 
                                @Override
                                public void exception(AsyncReadGraph graph, Throwable throwable) {
-                                       Logger.defaultLogError(throwable);
+                                   if (throwable instanceof NoSingleResultException) {
+                                       // Ignore
+                                       if (LOGGER.isDebugEnabled())
+                                           LOGGER.debug("Could not compile for resource {}", resource, throwable);
+                                   } else {
+                                       LOGGER.error("Could not compile for resource {}", resource, throwable);
+                                   }
                                }
 
                        });
@@ -171,7 +179,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                                    if(typeString == null) {
                                        typeString = graph.syncRequest(new SuperTypeString(e.principalType));
                                        if (typeString.isEmpty()) {
-                                           Logger.defaultLogError(new DatabaseException("No name for type " + NameUtils.getURIOrSafeNameInternal(graph, e.resource) + " (" + e.resource + ")"));
+                                           LOGGER.error("No name for type", new DatabaseException("No name for type " + NameUtils.getURIOrSafeNameInternal(graph, e.resource) + " (" + e.resource + ")"));
                                        }
                                        typeStrings.put(e.principalType, typeString);
                                    }
@@ -277,6 +285,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                        Resource changeInformation = graph.getPossibleResource("http://www.simantics.org/Modeling-1.2/changeInformation/Inverse");
 
                        for (Resource value : parameter.changedValues()) {
+                               if(!value.isPersistent()) continue;
                                Statement modifiedComponent = graph.getPossibleStatement(value, l0.PropertyOf);
                                if (modifiedComponent == null
                                                || modifiedComponent.getPredicate().equals(changeInformation))
@@ -506,9 +515,8 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
 
                                        } catch (Throwable t) {
                                            // Just to know if something unexpected happens here.
-                                           Logger.defaultLogError("Dependencies index update failed for model "
-                                                   + model + " and relation " + resource + ".", t);
-                                           t.printStackTrace();
+                                           LOGGER.error("Dependencies index update failed for model "
+                                                + model + " and relation " + resource + ".", t);
 
                                            // NOTE: Last resort: failure to update index
                                            // properly results in removal of the whole index.