- String rootName = ext.name.substring(ext.name.lastIndexOf("/")+1);
- String path = ext.name.substring(0, ext.name.lastIndexOf("/"));
- Identity pathId = TransferableGraphUtils.findExternal(tg, path);
- System.err.println("GraphRefactoringUtils.rootName=" + rootName);
- System.err.println("GraphRefactoringUtils.path2=" + path);
- if(pathId == null) {
- if(!tryToFix) return;
- IdentityStore idStore = TransferableGraphConversion.extractIdentities(tg);
- idStore.createPathToId(UriUtils.uriToPath(path));
- tg.resourceCount = idStore.getResourceCount();
- tg.identities = idStore.toArray();
- fixOntologyRoot(tg, false);
- return;
- } else {
- id.definition = new Internal(pathId.resource, rootName);
- TIntArrayList stms = new TIntArrayList(tg.statements);
- Identity consistsOf = TransferableGraphUtils.findExternal(tg, "http://www.simantics.org/Layer0-1.1/ConsistsOf");
- Identity partOf = TransferableGraphUtils.findExternal(tg, "http://www.simantics.org/Layer0-1.1/PartOf");
- stms.add(id.resource);
- stms.add(partOf.resource);
- stms.add(consistsOf.resource);
- stms.add(pathId.resource);
- tg.statements = stms.toArray();
- return;
- }
+
+ String[] parts = URIStringUtils.splitURI(ext.name);
+ Identity path = recursePath(tg, parts[0]);
+ id.definition = new Internal(path.resource, parts[1]);
+
+ GraphStore store = TransferableGraphConversion.convert(tg);
+ int rootId = store.identities.createPathToId(UriUtils.uriToPath(ext.name));
+ propagateNewMarks(store.identities, rootId);
+
+ TransferableGraph1 tgNew = TransferableGraphConversion.convert(store);
+
+ tg.resourceCount = tgNew.resourceCount;
+ tg.identities = tgNew.identities;
+ tg.values = tgNew.values;
+ tg.statements = tgNew.statements;
+
+ return;