X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.graph%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Frepresentation%2FTransferableGraphUtils.java;h=a7b92c8d015727880d256a9c17494bed54b70ce9;hp=4646116dc37d784255466ad55f1914e94c545596;hb=1cc487c3f6cf4b46b1fdd727183a9483e3bc05bb;hpb=9acebe9584f8f2a78f0322b6e0e24438e7ceb984 diff --git a/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphUtils.java b/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphUtils.java index 4646116dc..a7b92c8d0 100644 --- a/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphUtils.java +++ b/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphUtils.java @@ -8,6 +8,7 @@ import java.util.TreeMap; import org.simantics.databoard.Bindings; import org.simantics.databoard.adapter.AdaptException; +import org.simantics.databoard.util.URIStringUtils; import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.TIntObjectMap; @@ -70,6 +71,9 @@ public class TransferableGraphUtils { String[] tokens = uri.substring("http://".length()).split("/"); for(String token : tokens) { identity = findExternalWithNameAndParent(tg, identity.resource, token); + if (identity == null) { + return null; + } } return identity; @@ -266,5 +270,27 @@ public class TransferableGraphUtils { } return ":"; } + + public static String getTrueURI(int resourceCount, TIntObjectMap identities, int id) { + Identity identity = identities.get(id); + if(identity != null) { + IdentityDefinition definition = identity.definition; + if(definition instanceof External) { + External def = (External)definition; + if(def.parent == -1) return "http:/"; + else return getTrueURI(resourceCount, identities, def.parent) + "/" + URIStringUtils.escape(def.name); + } else if(definition instanceof Root) { + Root def = (Root)definition; + if(def.name.isEmpty()) return "http:/"; + return def.name; + } else if (definition instanceof Internal) { + Internal def = (Internal)definition; + return getTrueURI(resourceCount, identities, def.parent) + "/" + URIStringUtils.escape(def.name); + } else { + return ""; + } + } + return ":"; + } }