]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Interop mapping changes/ fixes
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 25 Aug 2015 10:48:39 +0000 (10:48 +0000)
committerMarko Luukkainen <marko.luukkainen@vtt.fi>
Thu, 2 Feb 2017 12:01:33 +0000 (14:01 +0200)
fixes #6005

git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@31640 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java
org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java
org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java
org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java

index a723d48739aedbc00f86675bb4e6cfe02cddb62a..6c666deba341610d66e94dfe00e77038fb059a37 100644 (file)
@@ -1,10 +1,11 @@
 package org.simantics.interop.mapping;\r
 \r
 import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.interop.mapping.data.GraphNode;\r
 import org.simantics.interop.mapping.data.Identifiable;\r
 \r
 public interface IdentificationRule {\r
 \r
-       boolean matches(ReadGraph g, GraphNode<Identifiable> node);\r
+       boolean matches(ReadGraph g, GraphNode<Identifiable> node) throws DatabaseException;\r
 }\r
index 3414d4d05f17aafada5b733579783ae245974865..60c5c4835862dd683b78c8ab1c4149b13ebd0200 100644 (file)
@@ -17,7 +17,6 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.request.WriteResultRequest;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.ServiceException;\r
 import org.simantics.db.layer0.util.SessionGarbageCollection;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.interop.mapping.data.GraphNode;\r
@@ -353,9 +352,11 @@ public class Mapper {
                        for (GraphNode<Identifiable> n : nodes) {\r
 \r
                                MapList<Integer,GenerationRule> priRules = n.getHint(MappingHints.KEY_GENERATION_RULES);\r
-                               List<GenerationRule> rules = priRules.getValues(stage);\r
-                               for (GenerationRule r : rules) {\r
-                                       r.generate(graph, n);\r
+                               if (priRules != null) {\r
+                                       List<GenerationRule> rules = priRules.getValues(stage);\r
+                                       for (GenerationRule r : rules) {\r
+                                               r.generate(graph, n);\r
+                                       }\r
                                }\r
 \r
                                monitor.subTask("Generating objects, stage " + stage + " :  ("+ (++count) + "/" + size + ")");\r
index c775e8b1c68e62df7b1f0c6d2f1976b721703b7d..d9bbb5099c788927b11918e3920b9be716c6e96f 100644 (file)
@@ -713,7 +713,7 @@ public class GraphNode<T> extends HintContext {
        \r
 \r
        /**\r
-        * Disposes this node. Removes all the links that connect to thi snode.\r
+        * Disposes this node. Removes all the links that connect to thinode.\r
         */\r
        public void destroy() {\r
                if (disposed)\r
@@ -743,10 +743,10 @@ public class GraphNode<T> extends HintContext {
                } else {\r
                        for (int i = 0; i < nodes.size() -1 ; i++) {\r
                                Link<T> link1 = nodes.get(i);\r
-                               link1.to().removeLink(link1.getInverseName(), link1.getName(), this);\r
-                               for (int j = i; j < nodes.size(); j++) {\r
+                               link1.to()._removeLink(link1.getInverseName(), link1.getName(), this);\r
+                               for (int j = i+1; j < nodes.size(); j++) {\r
                                        Link<T> link2 = nodes.get(j);\r
-                                       link2.to().removeLink(link2.getInverseName(), link2.getName(), this);\r
+                                       link2.to()._removeLink(link2.getInverseName(), link2.getName(), this);\r
                                        if (link1.to().equals(link2.to()))\r
                                                continue;\r
                                        link1.to().addLink(link1.getInverseName(),link2.getInverseName(),link2.to());\r
@@ -770,7 +770,7 @@ public class GraphNode<T> extends HintContext {
        }\r
        \r
        /**\r
-        * Disposed the node and all nodes that are in the same graph.\r
+        * Dispose the node and all nodes that are in the same graph.\r
         */\r
        public void dispose() {\r
                if (disposed)\r
@@ -817,4 +817,8 @@ public class GraphNode<T> extends HintContext {
                                return count;\r
                }\r
        }\r
+       \r
+       public String toString() {\r
+               return "Node : " + data;\r
+       }\r
 }\r
index f03f10f124b6f7227fb14c33792267a141d2d8af..7b659f49b1cb63c0de366794ee3395743b3b4066 100644 (file)
@@ -92,4 +92,8 @@ public class Link <T> extends HintContext {
                super.setHint(key, value);\r
        }\r
 \r
+       \r
+       public String toString() {\r
+               return name + "/" + getInverseName() + " -> " + to.toString();\r
+       }\r
 }\r