This removes lots of deprecation warnings from the DB codebase.
refs #7655
Change-Id: Ibdfbac83c69d5af3823a28447256176183ab335a
import org.simantics.acorn.exception.AcornAccessVerificationException;
import org.simantics.acorn.exception.IllegalAcornStateException;
-import org.simantics.db.exception.SDBException;
public interface Persistable {
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.function.Consumer;
import org.simantics.acorn.exception.AcornAccessVerificationException;
import org.simantics.acorn.exception.IllegalAcornStateException;
import org.simantics.db.procore.cluster.ResourceTable;
import org.simantics.db.procore.cluster.ValueTable;
import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
final public class ClusterBig extends ClusterImpl {
private static final int TABLE_HEADER_SIZE = TableHeader.HEADER_SIZE + TableHeader.EXTRA_SIZE;
}
@Override
- public void load(Callback<DatabaseException> r) {
+ public void load(Consumer<DatabaseException> r) {
throw new Error("Not supported.");
}
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.function.Consumer;
import org.simantics.acorn.exception.IllegalAcornStateException;
import org.simantics.acorn.internal.ClusterChange;
import org.simantics.db.service.Bytes;
import org.simantics.db.service.ClusterUID;
import org.simantics.db.service.ResourceUID;
-import org.simantics.utils.datastructures.Callback;
import gnu.trove.map.hash.TIntShortHashMap;
import gnu.trove.procedure.TIntProcedure;
}
@Override
- public void load(Callback<DatabaseException> r) {
+ public void load(Consumer<DatabaseException> r) {
throw new Error("Not supported.");
}
}
@Override
- public Table getForeignTable() {
+ public Table<?> getForeignTable() {
return foreignTable;
}
*******************************************************************************/
package org.simantics.acorn.internal;
-import java.util.ArrayList;
-
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.service.ClusterUID;
-
final public class ClusterStream {
// // public static long duration2 = 0;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Semaphore;
+import java.util.function.Consumer;
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.AsyncRequestProcessor;
import org.simantics.db.request.WriteOnlyResult;
import org.simantics.db.request.WriteResult;
import org.simantics.utils.DataContainer;
-import org.simantics.utils.datastructures.Callback;
import org.simantics.utils.datastructures.Pair;
public class MergingGraphRequestProcessor implements RequestProcessor {
}
@SuppressWarnings("unchecked")
- Callback<Throwable> callback = (Callback<Throwable>)currentRequest.second;
+ Consumer<Throwable> callback = (Consumer<Throwable>)currentRequest.second;
if (currentRequest.first.getClass().equals(SyncWriteRequestAdapter.class)) {
try {
// System.out.println("merg.sync " + adapter);
graph.syncRequest(adapter);
- if(callback != null) callback.run(null);
+ if(callback != null) callback.accept(null);
} catch(Throwable t) {
Logger.defaultLogError(t);
- if(callback != null) callback.run(t);
+ if(callback != null) callback.accept(t);
}
adapter.release();
try {
if(currentRequest.first instanceof Write) graph.syncRequest((Write)currentRequest.first);
else if(currentRequest.first instanceof DelayedWrite) graph.syncRequest((DelayedWrite)currentRequest.first);
- if(callback != null) callback.run(null);
+ if(callback != null) callback.accept(null);
} catch(Throwable t) {
Logger.defaultLogError(t);
- if(callback != null) callback.run(t);
+ if(callback != null) callback.accept(t);
}
}
}
@Override
- public synchronized void asyncRequest(Write request, Callback<DatabaseException> callback) {
+ public synchronized void asyncRequest(Write request, Consumer<DatabaseException> callback) {
// System.out.println(this + " asyncRequest(WriteGraphRequest request)");
}
@Override
- public synchronized void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback) {
+ public synchronized void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback) {
// System.out.println(this + " asyncRequest(WriteGraphRequest request)");
}
@Override
- public synchronized void asyncRequest(WriteOnly request, Callback<DatabaseException> callback) {
+ public synchronized void asyncRequest(WriteOnly request, Consumer<DatabaseException> callback) {
// System.out.println(this + " asyncRequest(WriteGraphRequest request)");
package org.simantics.db.common.processor;
import java.util.Collection;
+import java.util.function.Consumer;
import org.simantics.db.RequestProcessor;
import org.simantics.db.Resource;
import org.simantics.db.request.WriteOnly;
import org.simantics.db.request.WriteOnlyResult;
import org.simantics.db.request.WriteResult;
-import org.simantics.utils.datastructures.Callback;
public class ProcessorBase implements RequestProcessor {
}
@Override
- public void asyncRequest(Write request, Callback<DatabaseException> callback) {
+ public void asyncRequest(Write request, Consumer<DatabaseException> callback) {
throw new UnsupportedOperationException();
}
@Override
- public void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback) {
+ public void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback) {
throw new UnsupportedOperationException();
}
@Override
- public void asyncRequest(WriteOnly request, Callback<DatabaseException> callback) {
+ public void asyncRequest(WriteOnly request, Consumer<DatabaseException> callback) {
throw new UnsupportedOperationException();
}
package org.simantics.db.impl;
import java.io.InputStream;
+import java.util.function.Consumer;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.impl.graph.ReadGraphImpl;
import org.simantics.db.procedure.AsyncMultiProcedure;
import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
public interface ClusterI {
public enum TypeEnum {
public void load()
throws DatabaseException;
- public void load(Callback<DatabaseException> callback);
+ public void load(Consumer<DatabaseException> callback);
public void load(ClusterSupport session, Runnable callback);
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
+import java.util.function.Consumer;
import org.simantics.databoard.Bindings;
import org.simantics.databoard.binding.Binding;
import org.simantics.db.request.Write;
import org.simantics.db.request.WriteOnly;
import org.simantics.db.service.SerialisationSupport;
-import org.simantics.utils.datastructures.Callback;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.hash.TIntObjectHashMap;
}
@Override
- public void load(ReadGraphImpl graph, int resource, int predicate, final Callback<ReadGraphImpl> callback) throws DatabaseException {
+ public void load(ReadGraphImpl graph, int resource, int predicate, final Consumer<ReadGraphImpl> callback) throws DatabaseException {
producePartialStatements(graph, resource, predicate, new AsyncProcedure<Object>() {
@Override
public void execute(AsyncReadGraph graph, Object result) {
- callback.run((ReadGraphImpl)graph);
+ callback.accept((ReadGraphImpl)graph);
}
@Override
public void exception(AsyncReadGraph graph, Throwable throwable) {
- callback.run((ReadGraphImpl)graph);
+ callback.accept((ReadGraphImpl)graph);
}
});
}
@Override
- public void load(ReadGraphImpl graph, int resource, final Callback<ReadGraphImpl> callback) throws DatabaseException {
+ public void load(ReadGraphImpl graph, int resource, final Consumer<ReadGraphImpl> callback) throws DatabaseException {
produceAllStatements(graph, resource, new AsyncProcedure<Object>() {
@Override
public void execute(AsyncReadGraph graph, Object result) {
- callback.run((ReadGraphImpl)graph);
+ callback.accept((ReadGraphImpl)graph);
}
@Override
public void exception(AsyncReadGraph graph, Throwable throwable) {
- callback.run((ReadGraphImpl)graph);
+ callback.accept((ReadGraphImpl)graph);
}
});
*******************************************************************************/
package org.simantics.db.impl;
+import java.util.function.Consumer;
+
import org.simantics.db.VirtualGraph;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.impl.graph.ReadGraphImpl;
-import org.simantics.utils.datastructures.Callback;
public interface VirtualGraphImpl extends VirtualGraph {
public boolean isPending(int resource);
public boolean isPending(int resource, int predicate);
- public void load(ReadGraphImpl graph, int resource, int predicate, Callback<ReadGraphImpl> callback) throws DatabaseException;
- public void load(ReadGraphImpl graph, int resource, Callback<ReadGraphImpl> callback) throws DatabaseException;
+ public void load(ReadGraphImpl graph, int resource, int predicate, Consumer<ReadGraphImpl> callback) throws DatabaseException;
+ public void load(ReadGraphImpl graph, int resource, Consumer<ReadGraphImpl> callback) throws DatabaseException;
}
*******************************************************************************/
package org.simantics.db.impl.graph;
-import gnu.trove.map.hash.TObjectIntHashMap;
-
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
+import java.util.function.Consumer;
import org.eclipse.core.runtime.Platform;
import org.simantics.databoard.Accessors;
import org.simantics.scl.runtime.function.Function3;
import org.simantics.utils.DataContainer;
import org.simantics.utils.Development;
-import org.simantics.utils.datastructures.Callback;
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.datastructures.collections.CollectionUtils;
+import gnu.trove.map.hash.TObjectIntHashMap;
+
public class ReadGraphImpl implements ReadGraph {
final static boolean EMPTY_RESOURCE_CHECK = false;
}
@Override
- public void asyncRequest(Write request, Callback<DatabaseException> callback) {
+ public void asyncRequest(Write request, Consumer<DatabaseException> callback) {
assert (request != null);
@Override
public void asyncRequest(DelayedWrite r,
- Callback<DatabaseException> callback) {
+ Consumer<DatabaseException> callback) {
throw new Error("Not implemented.");
}
}
@Override
- public void asyncRequest(WriteOnly r, Callback<DatabaseException> callback) {
+ public void asyncRequest(WriteOnly r, Consumer<DatabaseException> callback) {
throw new Error("Not implemented.");
}
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.TreeMap;
+import java.util.function.Consumer;
import org.simantics.databoard.Bindings;
import org.simantics.databoard.accessor.Accessor;
import org.simantics.db.request.WriteTraits;
import org.simantics.layer0.Layer0;
import org.simantics.utils.Development;
-import org.simantics.utils.datastructures.Callback;
import org.simantics.utils.datastructures.Pair;
import gnu.trove.map.hash.THashMap;
@Override
public void asyncRequest(DelayedWrite request) {
assert (request != null);
- getWriteRequestScheduler().scheduleRequest(request, new Callback<DatabaseException>() {
-
- @Override
- public void run(DatabaseException parameter) {
- if(parameter != null)
- Logger.defaultLogError(parameter);
- }
-
+ getWriteRequestScheduler().scheduleRequest(request, e -> {
+ if(e != null)
+ Logger.defaultLogError(e);
}, null, Boolean.TRUE);
}
@Override
- public void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback) {
+ public void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback) {
assert (request != null);
getWriteRequestScheduler().scheduleRequest(request, callback, null, Boolean.TRUE);
}
@Override
public void asyncRequest(final Write r) {
assert (r != null);
- getWriteRequestScheduler().scheduleRequest(r, new Callback<DatabaseException>() {
-
- @Override
- public void run(DatabaseException parameter) {
- if(parameter != null)
- Logger.defaultLogError(parameter);
- }
-
+ getWriteRequestScheduler().scheduleRequest(r, e -> {
+ if(e != null)
+ Logger.defaultLogError(e);
}, null, Boolean.TRUE);
}
@Override
- public void asyncRequest(Write request, Callback<DatabaseException> callback) {
+ public void asyncRequest(Write request, Consumer<DatabaseException> callback) {
assert (request != null);
getWriteRequestScheduler().scheduleRequest(request, callback, null, Boolean.TRUE);
}
@Override
public void asyncRequest(WriteOnly request) {
assert (request != null);
- getWriteRequestScheduler().scheduleRequest(request, new Callback<DatabaseException>() {
-
- @Override
- public void run(DatabaseException parameter) {
- if(parameter != null)
- Logger.defaultLogError(parameter);
- }
-
+ getWriteRequestScheduler().scheduleRequest(request, e -> {
+ if(e != null)
+ Logger.defaultLogError(e);
}, null, Boolean.TRUE);
}
@Override
- public void asyncRequest(WriteOnly request, Callback<DatabaseException> callback) {
+ public void asyncRequest(WriteOnly request, Consumer<DatabaseException> callback) {
assert (request != null);
getWriteRequestScheduler().scheduleRequest(request, callback, null, Boolean.TRUE);
}
package org.simantics.db.impl.support;
import java.util.concurrent.Semaphore;
+import java.util.function.Consumer;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.Procedure;
import org.simantics.db.request.WriteOnly;
import org.simantics.db.request.WriteOnlyResult;
import org.simantics.db.request.WriteResult;
-import org.simantics.utils.datastructures.Callback;
/**
* @author Tuukka Lehtonen
*/
public interface WriteRequestScheduleSupport {
- <T> void scheduleRequest(DelayedWrite request, Callback<DatabaseException> callback, Semaphore notify,
+ <T> void scheduleRequest(DelayedWrite request, Consumer<DatabaseException> callback, Semaphore notify,
Boolean combine);
<T> void scheduleRequest(DelayedWriteResult<T> request, Procedure<T> procedure, Semaphore notify, Boolean combine);
- <T> void scheduleRequest(Write request, Callback<DatabaseException> callback, Semaphore notify, Boolean combine);
+ <T> void scheduleRequest(Write request, Consumer<DatabaseException> callback, Semaphore notify, Boolean combine);
- <T> void scheduleRequest(WriteOnly request, Callback<DatabaseException> callback, Semaphore notify, Boolean combine);
+ <T> void scheduleRequest(WriteOnly request, Consumer<DatabaseException> callback, Semaphore notify, Boolean combine);
<T> void scheduleRequest(WriteOnlyResult<T> request, Procedure<T> callback, Semaphore notify, Boolean combine);
package fi.vtt.simantics.procore.internal;
import java.io.InputStream;
+import java.util.function.Consumer;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procore.cluster.ClusterImpl;
import org.simantics.db.procore.cluster.ClusterTraits;
import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
import fi.vtt.simantics.procore.DebugPolicy;
public void load() {
}
@Override
- public void load(Callback<DatabaseException> r) {
+ public void load(Consumer<DatabaseException> r) {
}
@Override
import org.simantics.db.procore.cluster.ValueTableSmall;
import org.simantics.db.request.AsyncRead;
import org.simantics.db.service.DirectQuerySupport;
-import org.simantics.utils.datastructures.Callback;
public class DirectQuerySupportImpl implements DirectQuerySupport {
if(subject < 0) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getRelatedValue4(graph, subject, context, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+ g -> getRelatedValue4(g, subject, context, procedure)
+ );
return;
}
final org.simantics.db.procore.cluster.ClusterImpl cluster = session.clusterTable.getClusterByResourceKey(subject);
if(!cluster.isLoaded()) {
- cluster.load(session.clusterTranslator, new Runnable() {
-
- @Override
- public void run() {
- getRelatedValue4(graph, subject, context, procedure);
- }
-
- });
+ cluster.load(session.clusterTranslator, () -> getRelatedValue4(graph, subject, context, procedure));
return;
}
if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getRelatedValue4(graph, subject, context, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+ g -> getRelatedValue4(g, subject, context, procedure)
+ );
return;
}
if(subject < 0) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getValue4(graph, containerCluster, subject, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject,
+ g -> getValue4(g, containerCluster, subject, procedure)
+ );
return;
}
if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getValue4(graph, containerCluster, subject, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject,
+ g -> getValue4(g, containerCluster, subject, procedure)
+ );
return;
}
if(subject < 0) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getValue4(graph, containerCluster, subject, context, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject,
+ g -> getValue4(g, containerCluster, subject, context, procedure)
+ );
return;
}
if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getValue4(graph, containerCluster, subject, context, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject,
+ g -> getValue4(g, containerCluster, subject, context, procedure)
+ );
return;
}
if(subject < 0) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getRelatedValue4(graph, subject, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+ g -> getRelatedValue4(g, subject, procedure)
+ );
return;
}
if(cluster.hasVirtual() && session.virtualGraphServerSupport.virtuals.contains(subject)) {
if(!SessionImplSocket.areVirtualStatementsLoaded(session.virtualGraphServerSupport, subject, predicate)) {
- SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl graph) {
- getRelatedValue4(graph, subject, procedure);
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(session.virtualGraphServerSupport, graph, subject, predicate,
+ g -> getRelatedValue4(graph, subject, procedure)
+ );
return;
}
throw new IllegalArgumentException();
if(null == predicate)
throw new IllegalArgumentException();
- if(null == predicate)
+ if(null == object)
throw new IllegalArgumentException();
this.subject = (ResourceImpl)subject;
this.predicate = (ResourceImpl)predicate;
}
@Override
- public Set<CacheEntry> getParents(AsyncRead request) {
+ public Set<CacheEntry> getParents(AsyncRead<?> request) {
HashSet<CacheEntry> result = new HashSet<CacheEntry>();
CacheEntryBase entry = session.queryProvider2.asyncReadMap.get(request);
if(entry != null) {
}
@Override
- public Set<CacheEntry> getParents(AsyncMultiRead request) {
+ public Set<CacheEntry> getParents(AsyncMultiRead<?> request) {
HashSet<CacheEntry> result = new HashSet<CacheEntry>();
CacheEntryBase entry = session.queryProvider2.asyncMultiReadMap.get(request);
if(entry != null) {
}
@Override
- public Set<CacheEntry> getParents(Read request) {
+ public Set<CacheEntry> getParents(Read<?> request) {
HashSet<CacheEntry> result = new HashSet<CacheEntry>();
CacheEntryBase entry = session.queryProvider2.readMap.get(request);
if(entry != null) {
}
@Override
- public Set<CacheEntry> getParents(MultiRead request) {
+ public Set<CacheEntry> getParents(MultiRead<?> request) {
HashSet<CacheEntry> result = new HashSet<CacheEntry>();
CacheEntryBase entry = session.queryProvider2.multiReadMap.get(request);
if(entry != null) {
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Collection;
+import java.util.function.Consumer;
import org.simantics.db.Resource;
import org.simantics.db.Session;
import org.simantics.db.procore.cluster.ClusterSmall;
import org.simantics.db.service.SerialisationSupport;
import org.simantics.utils.DataContainer;
-import org.simantics.utils.datastructures.Callback;
public class QuerySupportImpl implements QuerySupport {
@Override
public void requestCluster(ReadGraphImpl graph, final long clusterId, final Runnable r) {
- class CallbackAdapter implements Callback<DatabaseException> {
+ class CallbackAdapter implements Consumer<DatabaseException> {
final Runnable r;
CallbackAdapter(final Runnable r) {
this.r = r;
}
@Override
- public void run(DatabaseException e) {
+ public void accept(DatabaseException e) {
if (null != e)
e.printStackTrace();
else
if(subject < 0) {
- SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl parameter) {
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, g -> {});
} else {
if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject, predicate)) {
- SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl parameter) {
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, g -> {});
} else {
if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject, predicate)) {
- SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl parameter) {
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, predicate, g -> {});
} else {
if(subject < 0) {
- SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl parameter) {
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, g -> {});
} else {
if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject)) {
- SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl parameter) {
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, g -> {});
} else {
if(cluster.hasVirtual() && virtualGraphServerSupport.virtuals.contains(subject) && !SessionImplSocket.areVirtualStatementsLoaded(virtualGraphServerSupport, subject)) {
- SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, new Callback<ReadGraphImpl>() {
-
- @Override
- public void run(ReadGraphImpl parameter) {
- }
-
- });
+ SessionImplSocket.loadVirtualStatements(virtualGraphServerSupport, graph, subject, g -> {});
} else {
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
import org.eclipse.core.runtime.Platform;
import org.simantics.databoard.Bindings;
import org.simantics.layer0.Layer0;
import org.simantics.utils.DataContainer;
import org.simantics.utils.Development;
-import org.simantics.utils.datastructures.Callback;
import org.simantics.utils.threads.logger.ITask;
import org.simantics.utils.threads.logger.ThreadLogger;
private Object result;
final Semaphore sema = new Semaphore(0);
private Throwable throwable = null;
- final Callback<DatabaseException> callback = new Callback<DatabaseException>() {
- @Override
- public void run(DatabaseException e) {
- synchronized (TaskHelper.this) {
- throwable = e;
- }
+ final Consumer<DatabaseException> callback = e -> {
+ synchronized (TaskHelper.this) {
+ throwable = e;
}
};
final Procedure<Object> proc = new Procedure<Object>() {
@Override
public void execute(Object result) {
- callback.run(null);
+ callback.accept(null);
}
@Override
public void exception(Throwable t) {
if (t instanceof DatabaseException)
- callback.run((DatabaseException)t);
+ callback.accept((DatabaseException)t);
else
- callback.run(new DatabaseException("" + name + "operation failed.", t));
+ callback.accept(new DatabaseException("" + name + "operation failed.", t));
}
};
final WriteTraits writeTraits = new WriteTraits() {};
TaskHelper(String name) {
this.name = name;
}
+ @SuppressWarnings("unchecked")
<T> T getResult() {
return (T)result;
}
return null;
}
- public <T> void scheduleRequest(final Write request, final Callback<DatabaseException> callback, final Semaphore notify) {
+ public <T> void scheduleRequest(final Write request, final Consumer<DatabaseException> callback, final Semaphore notify) {
scheduleRequest(request, callback, notify, null);
}
* @see fi.vtt.simantics.procore.internal.WriteRequestScheduler#scheduleRequest(org.simantics.db.request.Write, org.simantics.utils.datastructures.Callback, java.util.concurrent.Semaphore, java.lang.Boolean)
*/
@Override
- public <T> void scheduleRequest(final Write request, final Callback<DatabaseException> callback, final Semaphore notify, Boolean combine) {
+ public <T> void scheduleRequest(final Write request, final Consumer<DatabaseException> callback, final Semaphore notify, Boolean combine) {
assert (request != null);
@Override
public void execute(Object result) {
- if(callback != null) callback.run(null);
+ if(callback != null) callback.accept(null);
}
@Override
public void exception(Throwable t) {
- if(callback != null) callback.run((DatabaseException)t);
+ if(callback != null) callback.accept((DatabaseException)t);
}
});
}
- public <T> void scheduleRequest(final DelayedWrite request, final Callback<DatabaseException> callback, final Semaphore notify) {
+ public <T> void scheduleRequest(final DelayedWrite request, final Consumer<DatabaseException> callback, final Semaphore notify) {
scheduleRequest(request, callback, notify, null);
}
* @see fi.vtt.simantics.procore.internal.WriteRequestScheduler#scheduleRequest(org.simantics.db.request.DelayedWrite, org.simantics.utils.datastructures.Callback, java.util.concurrent.Semaphore, java.lang.Boolean)
*/
@Override
- public <T> void scheduleRequest(final DelayedWrite request, final Callback<DatabaseException> callback, final Semaphore notify, Boolean combine) {
+ public <T> void scheduleRequest(final DelayedWrite request, final Consumer<DatabaseException> callback, final Semaphore notify, Boolean combine) {
final ITask total = ThreadLogger.getInstance().begin("ScheduleDelayedWrite");
@Override
public void execute(Object result) {
if (callback != null)
- callback.run(null);
+ callback.accept(null);
}
@Override
public void exception(Throwable t) {
if (callback != null) {
- if (t instanceof DatabaseException) callback.run((DatabaseException) t);
- else callback.run(new DatabaseException(t));
+ if (t instanceof DatabaseException) callback.accept((DatabaseException) t);
+ else callback.accept(new DatabaseException(t));
} else
Logger.defaultLogError("Unhandled exception", t);
}
try {
- int thread = request.hashCode() & queryProvider2.THREAD_MASK;
+ //int thread = request.hashCode() & queryProvider2.THREAD_MASK;
fireSessionVariableChange(SessionVariables.QUEUED_WRITES);
}
- public <T> void scheduleRequest(final WriteOnly request, final Callback<DatabaseException> callback, final Semaphore notify) {
+ public <T> void scheduleRequest(final WriteOnly request, final Consumer<DatabaseException> callback, final Semaphore notify) {
scheduleRequest(request, callback, notify, null);
}
@Override
- public <T> void scheduleRequest(final WriteOnly request, final Callback<DatabaseException> callback, final Semaphore notify, Boolean combine) {
+ public <T> void scheduleRequest(final WriteOnly request, final Consumer<DatabaseException> callback, final Semaphore notify, Boolean combine) {
assertAlive();
@Override
public void execute(Object result) {
- if(callback != null) callback.run(null);
+ if(callback != null) callback.accept(null);
}
@Override
public void exception(Throwable t) {
- if(callback != null) callback.run((DatabaseException)t);
+ if(callback != null) callback.accept((DatabaseException)t);
}
});
if(!(e instanceof CancelTransactionException)) {
if (callback != null)
- callback.run(new DatabaseException(e));
+ callback.accept(new DatabaseException(e));
}
writeState.except(e);
assertAlive();
Semaphore notify = new Semaphore(0);
final DataContainer<DatabaseException> exception = new DataContainer<DatabaseException>();
- scheduleRequest(request, new Callback<DatabaseException>() {
-
- @Override
- public void run(DatabaseException e) {
- exception.set(e);
- }
-
- }, notify);
+ scheduleRequest(request, e -> exception.set(e), notify);
acquire(notify, request);
if(exception.get() != null) throw exception.get();
}
assertNotSession();
Semaphore notify = new Semaphore(0);
final DataContainer<DatabaseException> exception = new DataContainer<DatabaseException>();
- scheduleRequest(request, new Callback<DatabaseException>() {
- @Override
- public void run(DatabaseException e) {
- exception.set(e);
- }
- }, notify);
+ scheduleRequest(request, e -> exception.set(e), notify);
acquire(notify, request);
if(exception.get() != null) throw exception.get();
}
assertAlive();
Semaphore notify = new Semaphore(0);
final DataContainer<DatabaseException> exception = new DataContainer<DatabaseException>();
- scheduleRequest(request, new Callback<DatabaseException>() {
- @Override
- public void run(DatabaseException e) {
- exception.set(e);
- }
- }, notify);
+ scheduleRequest(request, e -> exception.set(e), notify);
acquire(notify, request);
if(exception.get() != null) throw exception.get();
}
}
@Override
- public void asyncRequest(final Write request, final Callback<DatabaseException> callback) {
+ public void asyncRequest(final Write request, final Consumer<DatabaseException> callback) {
scheduleRequest(request, callback, null);
}
@Override
- public void asyncRequest(final DelayedWrite request, final Callback<DatabaseException> callback) {
+ public void asyncRequest(final DelayedWrite request, final Consumer<DatabaseException> callback) {
scheduleRequest(request, callback, null);
}
@Override
- public void asyncRequest(final WriteOnly request, final Callback<DatabaseException> callback) {
+ public void asyncRequest(final WriteOnly request, final Consumer<DatabaseException> callback) {
scheduleRequest(request, callback, null);
return true;
}
- static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, final Callback<ReadGraphImpl> runnable) {
+ static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, final Consumer<ReadGraphImpl> runnable) {
- Callback<ReadGraphImpl> composite = new Callback<ReadGraphImpl>() {
+ Consumer<ReadGraphImpl> composite = new Consumer<ReadGraphImpl>() {
AtomicInteger ready = new AtomicInteger(support.providers.size() + 1);
@Override
- public void run(ReadGraphImpl graph) {
+ public void accept(ReadGraphImpl graph) {
if(ready.decrementAndGet() == 0) {
- runnable.run(graph);
+ runnable.accept(graph);
}
}
e.printStackTrace();
}
} else {
- composite.run(graph);
+ composite.accept(graph);
}
}
- composite.run(graph);
+ composite.accept(graph);
}
- static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, int predicate, final Callback<ReadGraphImpl> runnable) {
+ static void loadVirtualStatements(final VirtualGraphServerSupportImpl support, ReadGraphImpl graph, int subject, int predicate, final Consumer<ReadGraphImpl> runnable) {
- Callback<ReadGraphImpl> composite = new Callback<ReadGraphImpl>() {
+ Consumer<ReadGraphImpl> composite = new Consumer<ReadGraphImpl>() {
AtomicInteger ready = new AtomicInteger(support.providers.size() + 1);
@Override
- public void run(ReadGraphImpl graph) {
+ public void accept(ReadGraphImpl graph) {
if(ready.decrementAndGet() == 0) {
- runnable.run(graph);
+ runnable.accept(graph);
}
}
e.printStackTrace();
}
} else {
- composite.run(graph);
+ composite.accept(graph);
}
}
- composite.run(graph);
+ composite.accept(graph);
}
import org.simantics.db.impl.graph.WriteSupport;
import org.simantics.db.procore.protocol.Constants;
import org.simantics.db.request.WriteTraits;
-import org.simantics.db.service.ClusterSetsSupport;
import org.simantics.db.service.ClusterUID;
import org.simantics.db.service.ExternalOperation;
import org.simantics.db.service.TransactionPolicySupport;
import java.util.TreeMap;
import org.simantics.db.Metadata;
-import org.simantics.db.Operation;
import org.simantics.db.Resource;
import org.simantics.db.VirtualGraph;
import org.simantics.db.WriteGraph;
MetadataUtils.addMetadata(session, metadata, data);
}
- @SuppressWarnings("unchecked")
@Override
public <T extends Metadata> T getMetadata(Class<T> clazz) throws ServiceException {
return MetadataUtils.getMetadata(session, metadata, clazz);
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.function.Consumer;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.AsyncContextMultiProcedure;
import org.simantics.db.procedure.AsyncMultiProcedure;
import org.simantics.db.service.ClusterUID;
-import org.simantics.utils.datastructures.Callback;
import fi.vtt.simantics.procore.DebugPolicy;
import fi.vtt.simantics.procore.internal.ClusterChange;
}
@Override
- public void load(Callback<DatabaseException> r) {
+ public void load(Consumer<DatabaseException> r) {
throw new Error("Not supported.");
}
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.function.Consumer;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.AsyncMultiProcedure;
import org.simantics.db.service.ClusterUID;
import org.simantics.db.service.ResourceUID;
-import org.simantics.utils.datastructures.Callback;
import fi.vtt.simantics.procore.DebugPolicy;
import fi.vtt.simantics.procore.internal.ClusterChange;
}
@Override
- public void load(Callback<DatabaseException> r) {
+ public void load(Consumer<DatabaseException> r) {
if (deleted) return;
throw new Error("Not supported.");
}
*******************************************************************************/
package org.simantics.db.procore.cluster;
-import gnu.trove.map.hash.TIntIntHashMap;
-import gnu.trove.procedure.TIntIntProcedure;
-import gnu.trove.set.hash.TIntHashSet;
-
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ValidationException;
import org.simantics.db.impl.ClusterBase;
import org.simantics.db.impl.ClusterI;
-import org.simantics.db.impl.ClusterI.ObjectProcedure;
import org.simantics.db.impl.ClusterI.PredicateProcedure;
import org.simantics.db.impl.ClusterI.Procedure;
import org.simantics.db.impl.ClusterSupport;
import org.simantics.db.impl.TableSizeListener;
import org.simantics.db.procore.cluster.TableIntArraySet2.Tables;
+import gnu.trove.map.hash.TIntIntHashMap;
+import gnu.trove.procedure.TIntIntProcedure;
+import gnu.trove.set.hash.TIntHashSet;
+
public final class PredicateTable extends Table<int[]> {
final TableIntAllocatorAdapter allocator;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ValidationException;
-import org.simantics.db.impl.ClusterI.ObjectProcedure;
import org.simantics.db.impl.ClusterI.Procedure;
import org.simantics.db.impl.ClusterSupport;
import org.simantics.db.impl.Modifier;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ValidationException;
-import org.simantics.db.impl.ClusterI.ObjectProcedure;
import org.simantics.db.impl.ClusterI.Procedure;
import org.simantics.db.impl.ClusterSupport;
import org.simantics.db.impl.Modifier;
*******************************************************************************/
package org.simantics.db;
+import java.util.function.Consumer;
+
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.AsyncListener;
import org.simantics.db.procedure.AsyncMultiListener;
import org.simantics.db.request.WriteOnly;
import org.simantics.db.request.WriteOnlyResult;
import org.simantics.db.request.WriteResult;
-import org.simantics.utils.datastructures.Callback;
/**
*
/**
* Asynchronously performs the given {@link Write}. The outcome of the
- * request will be reported to given {@link Callback} in the form of a
+ * request will be reported to given {@link Consumer} in the form of a
* DatabaseException raised during request processing or null upon success.
*
* @param request an instance of {@link Write}.
- * @param request an instance of {@link Callback}.
+ * @param request an instance of {@link Consumer}.
*/
- void asyncRequest(Write request, Callback<DatabaseException> callback);
+ void asyncRequest(Write request, Consumer<DatabaseException> callback);
<T> void asyncRequest(WriteResult<T> r, Procedure<T> procedure);
/**
* Asynchronously performs the given {@link WriteOnly}. The outcome of the
- * request will be reported to given {@link Callback} in the form of a
+ * request will be reported to given {@link Consumer} in the form of a
* DatabaseException raised during request processing or null upon success.
*
* @param request an instance of {@link WriteOnly}.
- * @param request an instance of {@link Callback}.
+ * @param request an instance of {@link Consumer}.
*/
- void asyncRequest(DelayedWrite request, Callback<DatabaseException> callback);
+ void asyncRequest(DelayedWrite request, Consumer<DatabaseException> callback);
<T> void asyncRequest(DelayedWriteResult<T> r, Procedure<T> procedure);
/**
* Asynchronously performs the given {@link WriteOnly}. The outcome of the
- * request will be reported to given {@link Callback} in the form of a
+ * request will be reported to given {@link Consumer} in the form of a
* DatabaseException raised during request processing or null upon success.
*
* @param request an instance of {@link WriteOnly}.
- * @param request an instance of {@link Callback}.
+ * @param request an instance of {@link Consumer}.
*/
- void asyncRequest(WriteOnly r, Callback<DatabaseException> callback);
+ void asyncRequest(WriteOnly r, Consumer<DatabaseException> callback);
<T> void asyncRequest(WriteOnlyResult<T> r, Procedure<T> procedure);