]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph/src/org/simantics/graph/refactoring/GraphRefactoringUtils.java
Escape/unescape names of the externals when converting to/from URIs
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / refactoring / GraphRefactoringUtils.java
index 9f8eca398f139c10a5a18801522230427fa29f08..2f00156c3b36dfdd93db0010f38ec3d54af2b0d3 100644 (file)
@@ -96,7 +96,7 @@ public class GraphRefactoringUtils {
        String[] parts = URIStringUtils.splitURI(path);
        Identity parentId = recursePath(tg, parts[0]);
        tg.identities = Arrays.copyOf(tg.identities, tg.identities.length+1);
-       Identity childIdentity = new Identity(tg.resourceCount++, new External(parentId.resource, parts[1]));
+       Identity childIdentity = new Identity(tg.resourceCount++, new External(parentId.resource, URIStringUtils.unescape(parts[1])));
                tg.identities[tg.identities.length-1] = childIdentity;
                return childIdentity;
        
@@ -113,10 +113,10 @@ public class GraphRefactoringUtils {
                        
                        String[] parts = URIStringUtils.splitURI(ext.name);
                        Identity path = recursePath(tg, parts[0]);
-                       id.definition = new Internal(path.resource, parts[1]);
+                       id.definition = new Internal(path.resource, URIStringUtils.unescape(parts[1]));
                        
                        GraphStore store = TransferableGraphConversion.convert(tg);
-                       int rootId = store.identities.createPathToId(UriUtils.uriToPath(ext.name));
+                       int rootId = store.identities.createPathToId(UriUtils.uriToPathUnescaped(ext.name));
                        propagateNewMarks(store.identities, rootId);
 
                        TransferableGraph1 tgNew = TransferableGraphConversion.convert(store);
@@ -125,9 +125,25 @@ public class GraphRefactoringUtils {
                        tg.identities = tgNew.identities;
                        tg.values = tgNew.values;
                        tg.statements = tgNew.statements;
-                               
+
                        return;
                        
+                } else if (ext.type.startsWith("http://")) {
+                    String first = "http://Projects/Development%20Project";
+                    Identity path = recursePath(tg, first);
+                    id.definition = new Internal(path.resource, ext.name);
+                    
+                    GraphStore store = TransferableGraphConversion.convert(tg);
+                    int rootId = store.identities.createPathToId(UriUtils.uriToPathUnescaped(first + "/" + 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;
+                    
                 }
             }
         }