]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/scl/CompileStructuralValueRequest.java
Simantics Console
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / scl / CompileStructuralValueRequest.java
index 7a8eb715f26362fdc8726d680e3d485fd340d873..ce824090dce3f686af4a37d77096218f4e9e6f8b 100644 (file)
@@ -5,6 +5,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
 import org.simantics.db.common.request.IndexRoot;
+import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.layer0.Layer0;
@@ -43,7 +44,14 @@ public class CompileStructuralValueRequest extends AbstractCompileStructuralValu
             sclContext.put("graph", graph);
             return exp.apply(context);
         } catch (Throwable t) {
-            throw new DatabaseException("Compiling structural value request for component=" + request.component + ", literal=" + request.literal + " and relation " + request.relation + " failed!", t);
+            String componentName = NameUtils.getSafeName(graph, request.component);
+            String literalName = NameUtils.getSafeName(graph, request.literal);
+            String relationName = NameUtils.getSafeName(graph, request.relation);
+            StringBuilder sb = new StringBuilder("Compiling structural value request for component ")
+                    .append(componentName).append(" ").append(request.component).append(" , literal ")
+                    .append(literalName).append(" ").append(request.literal).append(" and relation ")
+                    .append(relationName).append(" ").append(request.relation).append(" failed!");
+            throw new DatabaseException(sb.toString(), t);
         } finally {
             sclContext.put("graph", oldGraph);
         }
@@ -77,6 +85,7 @@ public class CompileStructuralValueRequest extends AbstractCompileStructuralValu
        public int hashCode() {
                final int prime = 31;
                int result = 1;
+               result = prime * result + ((relation == null) ? 0 : relation.hashCode());
                result = prime * result + ((component == null) ? 0 : component.hashCode());
                result = prime * result + ((literal == null) ? 0 : literal.hashCode());
                return result;
@@ -91,6 +100,11 @@ public class CompileStructuralValueRequest extends AbstractCompileStructuralValu
                if (getClass() != obj.getClass())
                        return false;
                CompileStructuralValueRequest other = (CompileStructuralValueRequest) obj;
+               if (relation == null) {
+                       if (other.relation != null)
+                               return false;
+               } else if (!relation.equals(other.relation))
+                       return false;
                if (component == null) {
                        if (other.component != null)
                                return false;
@@ -104,4 +118,16 @@ public class CompileStructuralValueRequest extends AbstractCompileStructuralValu
                return true;
        }
        
+       @Override
+       protected String getContextDescription(ReadGraph graph) throws DatabaseException {
+           if(component != null) {
+               String uri = graph.getPossibleURI(component);
+               if(uri != null) {
+                   String propertyName = NameUtils.getSafeName(graph, relation);
+                   return uri + "#" + propertyName;
+               }
+           }
+           return super.getContextDescription(graph);
+       }
+       
 }