X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Frepresentation%2FTransferableGraphUtils.java;h=b210d8dd713348cb38fa846f6558509442d05276;hb=839ee9ef190509b9bf956dafc0287e98cc7ab930;hp=4b113fa499b6bc1208d64b62e2be5be66713cc10;hpb=f7acb1a086643d1a88cf7246fcc11d12c1703dd9;p=simantics%2Fplatform.git 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 4b113fa49..b210d8dd7 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 @@ -71,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; @@ -143,22 +146,53 @@ public class TransferableGraphUtils { return result; } + /** + * This implementation is no longer advised to use because it returns 0 as + * NOT_FOUND which is in fact a valid ID for resource in graph + */ + @Deprecated public static int getPossibleObject(TransferableGraph1 tg, int subject, Identity predicate) { int result = 0; for(int i=0;i getNames(TransferableGraph1 tg, Collection ids) { Map result = new HashMap(); @@ -253,36 +287,14 @@ public class TransferableGraphUtils { if(definition instanceof External) { External def = (External)definition; if(def.parent == -1) return "http:/"; - else return getURI(resourceCount, identities, def.parent) + "/" + 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 getURI(resourceCount, identities, def.parent) + "/" + def.name; - } else { - return ""; - } - } - 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 return getURI(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); + return getURI(resourceCount, identities, def.parent) + "/" + URIStringUtils.escape(def.name); } else { return ""; }