}
}
else if(definition instanceof Internal) {
- String uri = TransferableGraphUtils.getURI(resourceCount, identityMap, identity.resource);
+ String uri = TransferableGraphUtils.getTrueURI(resourceCount, identityMap, identity.resource);
Resource existing = graph.getPossibleResource(uri);
if(existing != null) {
existingInternalMap.put(identity.resource, existing);
Resource parent = resolvedParents.get(parts[0]);
// TODO: proper exception message
- if(parent == null) throw new IllegalStateException("!!");
+ if(parent == null) {
+ throw new IllegalStateException("!!");
+ }
Resource childResource = graph.newResource();
graph.claim(childResource, InstanceOf, null, ExternalEntity);
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;
}
return "<internal reference " + id + ">:";
}
+
+ public static String getTrueURI(int resourceCount, TIntObjectMap<Identity> 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 "<internal reference " + id + ">:";
+ }
}