import org.simantics.databoard.accessor.error.AccessorException;
import org.simantics.databoard.adapter.AdaptException;
import org.simantics.databoard.binding.mutable.Variant;
+import org.simantics.databoard.util.URIStringUtils;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.WriteOnlyGraph;
if(child == null) {
String uri = graph.getPossibleURI(parent);
if(uri == null) {
- addMissing(NameUtils.getSafeName(graph, parent) + " /" + def.name);
+ addMissing(URIStringUtils.escape(NameUtils.getSafeName(graph, parent)) + " /" + URIStringUtils.escape(def.name));
} else {
- addMissing(graph.getURI(parent) + "/" + def.name);
+ addMissing(graph.getURI(parent) + "/" + URIStringUtils.escape(def.name));
}
}
resources[identity.resource] = child;
} else {
- addMissing(TransferableGraphUtils.getURI(tg, def.parent) + "/" + def.name);
+ addMissing(TransferableGraphUtils.getURI(tg, def.parent) + "/" + URIStringUtils.escape(def.name));
}
}
}
package org.simantics.graph.query;
+import org.simantics.databoard.util.URIStringUtils;
public class UriUtils {
return cur;
}
+ public static Path uriToPathUnescaped(String uri) {
+ String[] segments;
+ Path cur;
+ if(uri.startsWith("http:/")) {
+ if(uri.length() == 6)
+ return Paths.Root;
+ segments = uri.substring(7).split("/");
+ cur = Paths.Root;
+ }
+ else {
+ int p = uri.indexOf('/');
+ if(p == -1)
+ return new PathRoot(URIStringUtils.unescape(uri));
+ else {
+ segments = uri.substring(p+1).split("/");
+ cur = new PathRoot(URIStringUtils.unescape(uri.substring(0, p)));
+ }
+ }
+
+ for(String segment : segments)
+ cur = new PathChild(URIStringUtils.unescape(segment), cur);
+ return cur;
+ }
+
}
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;
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);
tg.identities = tgNew.identities;
tg.values = tgNew.values;
tg.statements = tgNew.statements;
-
+
return;
} else if (ext.type.startsWith("http://")) {
- String first = "http://Projects/Development Project";
+ 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.uriToPath(first + "/" + ext.name));
+ int rootId = store.identities.createPathToId(UriUtils.uriToPathUnescaped(first + "/" + ext.name));
propagateNewMarks(store.identities, rootId);
TransferableGraph1 tgNew = TransferableGraphConversion.convert(store);
tg.identities = tgNew.identities;
tg.values = tgNew.values;
tg.statements = tgNew.statements;
-
+
}
}
}
import org.simantics.databoard.parser.DataValuePrinter;
import org.simantics.databoard.parser.PrintFormat;
import org.simantics.databoard.parser.repository.DataValueRepository;
+import org.simantics.databoard.util.URIStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// else {
Identity id = query.getIdentity(parentId);
if (id.definition instanceof External) {
- return getExternalURI((External) id.definition) + "/" + name;
+ return getExternalURI((External) id.definition) + "/" + URIStringUtils.escape(name);
} else if (id.definition instanceof Root) {
Root root = (Root) id.definition;
- return "http:/" + root.name + "/" + name;
+ return "http:/" + URIStringUtils.escape(root.name) + "/" + URIStringUtils.escape(name);
} else {
return null;
}
import java.util.TreeMap;
import java.util.TreeSet;
+import org.simantics.databoard.util.URIStringUtils;
+
import gnu.trove.impl.Constants;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.hash.TIntObjectHashMap;
if(definition instanceof External) {
External def = (External)definition;
if(def.parent == -1) return "http:/";
- else return getURI(def.parent) + "/" + def.name;
+ else return getURI(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 getURI(def.parent) + "/" + def.name;
+ return getURI(def.parent) + "/" + URIStringUtils.escape(def.name);
} else {
return "";
}
if("http:/".equals(uri)) return identity;
String[] tokens = uri.substring("http://".length()).split("/");
for(String token : tokens) {
- identity = findExternalWithNameAndParent(tg, identity.resource, token);
+ identity = findExternalWithNameAndParent(tg, identity.resource, URIStringUtils.unescape(token));
if (identity == null) {
return null;
}
if(definition instanceof External) {
External def = (External)definition;
if(def.parent == -1) return "http:/";
- else return getURI(identities, def.parent) + "/" + def.name;
+ else return getURI(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 getURI(identities, def.parent) + "/" + def.name;
+ return getURI(identities, def.parent) + "/" + URIStringUtils.escape(def.name);
} else {
return "";
}