From ee84f0b8a58b513ef47968a83ad7ffadd931af55 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Tue, 25 Aug 2015 10:48:39 +0000 Subject: [PATCH] Interop mapping changes/ fixes fixes #6005 git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@31640 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../interop/mapping/IdentificationRule.java | 3 ++- .../src/org/simantics/interop/mapping/Mapper.java | 9 +++++---- .../simantics/interop/mapping/data/GraphNode.java | 14 +++++++++----- .../org/simantics/interop/mapping/data/Link.java | 4 ++++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java index a723d48..6c666de 100644 --- a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java @@ -1,10 +1,11 @@ package org.simantics.interop.mapping; import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; import org.simantics.interop.mapping.data.GraphNode; import org.simantics.interop.mapping.data.Identifiable; public interface IdentificationRule { - boolean matches(ReadGraph g, GraphNode node); + boolean matches(ReadGraph g, GraphNode node) throws DatabaseException; } diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java index 3414d4d..60c5c48 100644 --- a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java @@ -17,7 +17,6 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.request.WriteResultRequest; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.ServiceException; import org.simantics.db.layer0.util.SessionGarbageCollection; import org.simantics.db.request.Read; import org.simantics.interop.mapping.data.GraphNode; @@ -353,9 +352,11 @@ public class Mapper { for (GraphNode n : nodes) { MapList priRules = n.getHint(MappingHints.KEY_GENERATION_RULES); - List rules = priRules.getValues(stage); - for (GenerationRule r : rules) { - r.generate(graph, n); + if (priRules != null) { + List rules = priRules.getValues(stage); + for (GenerationRule r : rules) { + r.generate(graph, n); + } } monitor.subTask("Generating objects, stage " + stage + " : ("+ (++count) + "/" + size + ")"); diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java index c775e8b..d9bbb50 100644 --- a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java @@ -713,7 +713,7 @@ public class GraphNode extends HintContext { /** - * Disposes this node. Removes all the links that connect to thi snode. + * Disposes this node. Removes all the links that connect to this node. */ public void destroy() { if (disposed) @@ -743,10 +743,10 @@ public class GraphNode extends HintContext { } else { for (int i = 0; i < nodes.size() -1 ; i++) { Link link1 = nodes.get(i); - link1.to().removeLink(link1.getInverseName(), link1.getName(), this); - for (int j = i; j < nodes.size(); j++) { + link1.to()._removeLink(link1.getInverseName(), link1.getName(), this); + for (int j = i+1; j < nodes.size(); j++) { Link link2 = nodes.get(j); - link2.to().removeLink(link2.getInverseName(), link2.getName(), this); + link2.to()._removeLink(link2.getInverseName(), link2.getName(), this); if (link1.to().equals(link2.to())) continue; link1.to().addLink(link1.getInverseName(),link2.getInverseName(),link2.to()); @@ -770,7 +770,7 @@ public class GraphNode extends HintContext { } /** - * Disposed the node and all nodes that are in the same graph. + * Dispose the node and all nodes that are in the same graph. */ public void dispose() { if (disposed) @@ -817,4 +817,8 @@ public class GraphNode extends HintContext { return count; } } + + public String toString() { + return "Node : " + data; + } } diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java index f03f10f..7b659f4 100644 --- a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java @@ -92,4 +92,8 @@ public class Link extends HintContext { super.setHint(key, value); } + + public String toString() { + return name + "/" + getInverseName() + " -> " + to.toString(); + } } -- 2.47.1