X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2FSCLScenegraph.java;h=6345a132985c875bdf5b02cf5b2bc73e6d06f9a3;hp=bfab7fc6c0f7f8472a4c4158f547a0cf6acce68e;hb=76061fee3ffb1b66ed4d78ce711ab44f38b7ffdf;hpb=241a1dddfbaa9c46832f443884ca1bbfd1beb2c9 diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java index bfab7fc6c..6345a1329 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java @@ -30,6 +30,7 @@ import org.apache.batik.dom.GenericDOMImplementation; import org.apache.batik.svggen.SVGGeneratorContext; import org.apache.batik.svggen.SVGGraphics2D; import org.simantics.Simantics; +import org.simantics.datatypes.literal.GUID; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.UnaryRead; @@ -498,29 +499,27 @@ public class SCLScenegraph { try { if (p instanceof Resource) { Resource element = (Resource) p; - if (graph.isInstanceOf(element, DIA.Connection) || graph.isInstanceOf(element, DIA.Terminal)) { - // Ok, lets create a hashcode for connections and terminals as they do not have identifiers - return graph.getURI(element).hashCode(); - } else if (graph.isInstanceOf(element, DIA.Element)) { + if (graph.isInstanceOf(element, DIA.Element)) { Resource component = graph.getPossibleObject(element, MOD.ElementToComponent); if (component != null) { - Object relatedValue = graph.getPossibleRelatedValue(component, L0.identifier); - if (relatedValue != null) { - if (relatedValue instanceof Object[]) { - // OK, found guid, lets generate new based on URI - return Arrays.toString(createURIBasedL0Identifier(graph, component)); - } else { - System.err.println("Component " + component + " identifeir is not normal: " + relatedValue); - } + GUID identifier = graph.getPossibleRelatedValue(component, L0.identifier, GUID.BINDING); + if (identifier != null) { + return Arrays.toString(createURIBasedL0Identifier(graph, component)); } else { - System.err.println("Compoennt " + component + " dooes not have identifier"); + LOGGER.error("Component {} does not have GUID identifier!", component); } + } else if (graph.isInstanceOf(element, DIA.Connection) || graph.isInstanceOf(element, DIA.Terminal)) { + // Ok, lets create a hashcode for connections and terminals as they do not have identifiers + return graph.getURI(element).hashCode(); } else { - System.err.println("Element " + element + " does not have component"); + // Ok, lets create a hashcode or either return empty string in cases where no ID is required + if (graph.hasStatement(element, L0.HasName)) + return graph.getURI(element).hashCode(); + return ""; } } } else { - System.err.println("p is not resource but is " + p); + LOGGER.error("Parameter p {} is not resource but it is {}", p, p.getClass()); } return p; } catch (DatabaseException e) {