import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import org.simantics.databoard.util.binary.RandomAccessBinary;
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.DevelopmentKeys;
-import org.simantics.db.ExternalValue;
import org.simantics.db.ExternalValueSupport;
import org.simantics.db.ReadGraph;
import org.simantics.db.RelationContext;
}
}
+
+ @Override
+ public Map<String, Resource> getChildren(Resource resource) throws ValidationException, ServiceException {
+
+ assert (resource != null);
+
+ try {
+
+ int rId = processor.querySupport.getId(resource);
+ return QueryCache.resultChildMap(this, rId, parent, null);
+
+ } catch (ValidationException e) {
+
+ throw new ValidationException(e);
+
+ } catch (ServiceException e) {
+
+ throw new ServiceException(e);
+
+ } catch (DatabaseException e) {
+
+ throw new ServiceException(INTERNAL_ERROR_STRING, e);
+
+ }
+
+ }
final public Resource getRootLibrary() {
return processor.getRootLibraryResource();
assert (request != null);
// AsyncReadProcedure<T> procedure = new AsyncReadProcedure<T>();
- BlockingAsyncProcedure<T> ap = new BlockingAsyncProcedure<>(null, request);
+ BlockingAsyncProcedure<T> ap = new BlockingAsyncProcedure<>(this, null, request);
syncRequest(request, ap);
return ap.get();
// procedure.checkAndThrow();
ListenerBase listener = getListenerBase(procedure);
- BlockingAsyncProcedure<T> ap = new BlockingAsyncProcedure<>(procedure, request);
+ BlockingAsyncProcedure<T> ap = new BlockingAsyncProcedure<>(this, procedure, request);
// final ResultCallWrappedSingleQueryProcedure4<T> wrapper = new ResultCallWrappedSingleQueryProcedure4<T>(
// procedure, request);
ListenerBase listener = getListenerBase(procedure);
assert(listener == null);
- BlockingAsyncProcedure<T> ap = new BlockingAsyncProcedure<>(procedure, request);
+ BlockingAsyncProcedure<T> ap = new BlockingAsyncProcedure<>(this, procedure, request);
// final ResultCallWrappedSingleQueryProcedure4<T> wrapper = new ResultCallWrappedSingleQueryProcedure4<T>(
// procedure, request);
assert (request != null);
assert (procedure != null);
- processor.schedule(Integer.MIN_VALUE, new SessionTask(request, processor.THREAD_MASK+1, -1) {
+ processor.schedule(new SessionTask(false) {
@Override
public void run(int thread) {
});
-
-// quer
-//
-// final ListenerBase listener = getListenerBase(procedure);
-//
-// if (parent != null || listener != null) {
-//
-// try {
-// QueryCache.runnerReadEntry(this, request, parent, listener, procedure);
-// //processor.query(this, request, parent, procedure,listener);
-// } catch (DatabaseException e) {
-// Logger.defaultLogError(e);
-// // This throwable has already been transferred to procedure at this point - do nothing about it
-// //
-// }
-//
-// } else {
-//
-//// final ReadGraphImpl newGraph = newSync();
-//
-// try {
-//
-// T result = request.perform(this);
-//
-// try {
-// procedure.execute(this, result);
-// } catch (Throwable t) {
-// Logger.defaultLogError(t);
-// }
-//
-// } catch (Throwable t) {
-//
-// try {
-// procedure.exception(this, t);
-// } catch (Throwable t2) {
-// Logger.defaultLogError(t2);
-// }
-//
-// } finally {
-//
-// }
-//
-// }
-
}
public static ReadGraphImpl createAsync(QueryProcessor support) {
assert (request != null);
assert (procedure != null);
- //final ListenerBase listener = getListenerBase(procedure);
-
- processor.schedule(Integer.MIN_VALUE, new SessionTask(request, processor.THREAD_MASK+1, -1) {
+ processor.schedule(new SessionTask(false) {
@Override
public void run(int thread) {
});
-
-
-
-// if (parent != null || listener != null) {
-//
-// try {
-// QueryCache.runnerAsyncReadEntry(this, request, parent, listener, procedure);
-// //processor.query(this, request, parent, procedure, listener);
-// } catch (DatabaseException e) {
-// Logger.defaultLogError(e);
-// }
-//
-// } else {
-//
-// try {
-//
-// request.perform(this, new CallWrappedSingleQueryProcedure4<T>(procedure, request));
-//
-// } catch (Throwable t) {
-//
-// if (t instanceof DatabaseException)
-// procedure.exception(this, t);
-// else
-// procedure
-// .exception(
-// this,
-// new DatabaseException(
-// "Unexpected exception in ReadGraph.asyncRequest(SingleAsyncRead, SingleProcedure)",
-// t));
-//
-// }
-//
-// }
-
}
@Override
return getValue(r);
}
}
- else if(types.contains(L0.Function)) {
- return Functions.exec(this, r, this, r, context);
- }
else if(types.contains(L0.ExternalValue)) {
return (T)syncRequest(new AdaptValue(r), TransientCacheListener.<Object>instance());
}
return getVariantValue(r);
}
}
- else if(types.contains(L0.Function)) {
- Object value = Functions.exec(this, r, this, r, context);
- try {
- return new Variant(Bindings.OBJECT.getContentBinding(value), value);
- } catch ( org.simantics.databoard.binding.error.BindingException e ) {
- throw new BindingException( "No binding found for class " + value.getClass().getName(), e );
- }
- }
else if(types.contains(L0.ExternalValue)) {
Object value = syncRequest(new AdaptValue(r), TransientCacheListener.<Object>instance());
try {
for(Resource converter : graph.getObjects(resource, L0.ConvertsToValueWith)) {
try {
if(L0.Functions_functionApplication.equals(converter)) {
- return AdaptValue.functionApplication;
- //return (Function3<ReadGraph,Resource,Object,T>)graph.syncRequest(new AdaptValue(resource));
+ return (Function3<ReadGraph,Resource,Object,T>)graph.syncRequest(new AdaptValue(resource));
} else {
return graph.getValue2(converter, resource);
}
} else {
return getValue(r, binding);
}
- } else if(types.contains(L0.Function)) {
- Object value = Functions.exec(this, r, this, r, context);
- if(binding.isInstance(value)) return (T)value;
- try {
- Binding srcBinding = Bindings.OBJECT.getContentBinding(value);
- return (T)Bindings.adapt(value, srcBinding, binding);
- } catch(RuntimeException e) {
- DatabaseException dte = findPossibleRootException(e);
- if(dte != null) throw dte;
- else throw new DatabaseException(e);
- } catch (AdaptException e) {
- throw new DatabaseException(e);
- } catch (org.simantics.databoard.binding.error.BindingException e) {
- throw new DatabaseException(e);
- }
} else if(types.contains(L0.ExternalValue)) {
try {
- ExternalValue ev = adapt(r, ExternalValue.class);
- return ev.getValue(this, r);
- //return (T)ReflectionUtils.getValue(getURI(r)).getValue();
-// } catch(ValueNotFoundException e) {
-// throw new DatabaseException(e);
+ return (T)ReflectionUtils.getValue(getURI(r)).getValue();
+ } catch(ValueNotFoundException e) {
+ throw new DatabaseException(e);
} catch(ClassCastException e) {
throw new DatabaseException(e);
}
public Object getModificationCounter() {
return processor.getSession().getModificationCounter();
}
+
+ @Override
+ public boolean performPending() {
+ return processor.performPending(processor.thread.get());
+ }
}