]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/DependenciesRelation.java
Multiple reader thread support for db client
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / genericrelation / DependenciesRelation.java
index fc32222084c0f7e08509c152a882b893e7bd5b61..4f98af7b4ab33fe4349e7bae9845fe703e728e98 100644 (file)
@@ -23,7 +23,6 @@ import java.util.UUID;
 import org.simantics.databoard.Bindings;
 import org.simantics.databoard.util.ObjectUtils;
 import org.simantics.datatypes.literal.GUID;
-import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ChangeSet;
 import org.simantics.db.ChangeSet.StatementChange;
 import org.simantics.db.MetadataI;
@@ -51,8 +50,8 @@ import org.simantics.db.layer0.genericrelation.DependencyChanges.ComponentAdditi
 import org.simantics.db.layer0.genericrelation.DependencyChanges.ComponentModification;
 import org.simantics.db.layer0.genericrelation.DependencyChanges.ComponentRemoval;
 import org.simantics.db.layer0.genericrelation.DependencyChanges.LinkChange;
-import org.simantics.db.procedure.AsyncContextMultiProcedure;
-import org.simantics.db.procedure.AsyncContextProcedure;
+import org.simantics.db.procedure.SyncContextMultiProcedure;
+import org.simantics.db.procedure.SyncContextProcedure;
 import org.simantics.db.service.CollectionSupport;
 import org.simantics.db.service.DirectQuerySupport;
 import org.simantics.db.service.GraphChangeListenerSupport;
@@ -95,9 +94,9 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
        class Process {
 
                final ArrayList<Entry> result = new ArrayList<Entry>();
-               final AsyncContextMultiProcedure<Resource, Resource> structure;
-               final AsyncContextProcedure<Entry, String> names;
-               final AsyncContextProcedure<Entry, Resource> type;
+               final SyncContextMultiProcedure<Resource, Resource> structure;
+               final SyncContextProcedure<Entry, String> names;
+               final SyncContextProcedure<Entry, Resource> type;
 
                Process(ReadGraph graph, final Resource resource) throws DatabaseException {
 
@@ -105,38 +104,38 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                        final DirectQuerySupport dqs = graph.getService(DirectQuerySupport.class);
                        final CollectionSupport cs = graph.getService(CollectionSupport.class);
 
-                       names = dqs.compilePossibleRelatedValue(graph, L0.HasName, new AsyncContextProcedure<Entry, String>() {
+                       names = dqs.compilePossibleRelatedValue(graph, L0.HasName, new SyncContextProcedure<Entry, String>() {
 
                                @Override
-                               public void execute(AsyncReadGraph graph, Entry entry, String name) {
+                               public void execute(ReadGraph graph, Entry entry, String name) {
                                        entry.name = name;
                                }
 
                                @Override
-                               public void exception(AsyncReadGraph graph, Throwable throwable) {
+                               public void exception(ReadGraph graph, Throwable throwable) {
                                        LOGGER.error("Could not compile possible related value for resource {}", resource, throwable);
                                }
 
                        });
 
-                       type = new AsyncContextProcedure<Entry, Resource>() {
+                       type = new SyncContextProcedure<Entry, Resource>() {
 
                                @Override
-                               public void execute(AsyncReadGraph graph, Entry entry, Resource type) {
+                               public void execute(ReadGraph graph, Entry entry, Resource type) {
                                        entry.principalType = type;
                                }
 
                                @Override
-                               public void exception(AsyncReadGraph graph, Throwable throwable) {
+                               public void exception(ReadGraph graph, Throwable throwable) {
                                        LOGGER.error("Could not find type for resource {}", resource, throwable);
                                }
 
                        };
 
-                       structure = dqs.compileForEachObject(graph, L0.ConsistsOf, new AsyncContextMultiProcedure<Resource, Resource>() {
+                       structure = dqs.compileForEachObject(graph, L0.ConsistsOf, new SyncContextMultiProcedure<Resource, Resource>() {
 
                                @Override
-                               public void execute(AsyncReadGraph graph, Resource parent, Resource child) {
+                               public void execute(ReadGraph graph, Resource parent, Resource child) {
                                        // WORKAROUND: don't browse virtual child resources
                                        if(!child.isPersistent()) return;
                                        Entry entry = new Entry(parent, child, "", "", "");
@@ -147,11 +146,11 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                                }
 
                                @Override
-                               public void finished(AsyncReadGraph graph, Resource parent) {
+                               public void finished(ReadGraph graph, Resource parent) {
                                }
 
                                @Override
-                               public void exception(AsyncReadGraph graph, Throwable throwable) {
+                               public void exception(ReadGraph graph, Throwable throwable) {
                                    if (throwable instanceof NoSingleResultException) {
                                        // Ignore
                                        if (LOGGER.isDebugEnabled())
@@ -233,6 +232,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
 
                                ArrayList<Object[]> result = new ArrayList<Object[]>();
                                for (Entry entry : entries) {
+                                       if(entry.name == null) continue;
                                        result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id });
                                }
                                return result;