X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FURIToResource.java;h=918f882f179c2acd4ba8b79677f473abacf67deb;hb=4af843556485409e1c018e58eb2409f116e4d40c;hp=78ae0d12d0ba0a147ca79b7ac65f894952e2bf47;hpb=378f6f82ce88c8ba2ba9f7345cb25679b508bae5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/URIToResource.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/URIToResource.java index 78ae0d12d..918f882f1 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/URIToResource.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/URIToResource.java @@ -15,6 +15,7 @@ import org.simantics.databoard.util.URIStringUtils; import org.simantics.db.ObjectResourceIdMap; import org.simantics.db.common.exception.DebugException; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.ResourceNotFoundException; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; @@ -29,7 +30,7 @@ public class URIToResource extends StringQuery> { provider.cache.remove(this); } - @Override + //@Override public Object compute(ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { computeForEach(graph, id, this, procedure); return getResult(); @@ -48,20 +49,49 @@ public class URIToResource extends StringQuery> { final String[] parts = URIStringUtils.splitURI(id); if (parts != null) { - Integer parentId = QueryCache.resultURIToResource(graph, parts[0], entry, null); - ObjectResourceIdMap map = QueryCache.resultChildMap(graph, parentId, entry, null); - if(map == null) { - procedure.execute(graph, 0); - if(entry != null) entry.addOrSet(graph, graph.processor, 0); - } else { - int result = map.getId(URIStringUtils.unescape(parts[1])); - if(entry != null) entry.addOrSet(graph, graph.processor, result); - procedure.execute(graph, result); - } + //Integer parentId = QueryCache.resultURIToResource(graph, parts[0], entry, null); + + QueryCache.runnerURIToResource(graph, parts[0], entry, null, new InternalProcedure() { + + @Override + public void execute(ReadGraphImpl graph, Integer parentId) throws DatabaseException { + + ObjectResourceIdMap map = QueryCache.resultChildMap(graph, parentId, entry, null); + assert(map != null); +// if(map == null) { +// throw new DatabaseException("Internal Error, contact application support."); +// if(entry != null) entry.except(e); +// procedure.exception(graph, e); +//// procedure.execute(graph, 0); +//// if(entry != null) entry.addOrSet(graph, graph.processor, 0); +// } else { + int result = map.getId(URIStringUtils.unescape(parts[1])); + if(result == 0) { + ResourceNotFoundException e = new ResourceNotFoundException("No resource for URI: " + id); + if(entry != null) entry.except(e); + procedure.exception(graph, e); + } else { + if(entry != null) entry.addOrSet(graph, graph.processor, result); + procedure.execute(graph, result); + } +// } + + // TODO Auto-generated method stub + + } + + @Override + public void exception(ReadGraphImpl graph, Throwable throwable) throws DatabaseException { + if(entry != null) entry.except(throwable); + procedure.exception(graph, throwable); + } + + }); + } else { - DatabaseException e = new DatabaseException("No URI for " + id); + ResourceNotFoundException e = new ResourceNotFoundException("No resource for URI: " + id); if(entry != null) entry.except(e); procedure.exception(graph, e); @@ -92,7 +122,7 @@ public class URIToResource extends StringQuery> { assert(isReady()); - if(handleException(graph, procedure)) return (Throwable)statusOrException; + if(handleException(graph, procedure)) return (Throwable)getResult(); Integer result = (Integer)getResult(); procedure.execute(graph, result);