X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Fprocedure%2Fadapter%2FDirectStatementProcedure.java;fp=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Fprocedure%2Fadapter%2FDirectStatementProcedure.java;h=398b1851a9c92ed7df4fce77740cb2eaa5b9bbfb;hb=bfdceb3b5b0e4967358277cd506f237c9ee364c3;hp=0000000000000000000000000000000000000000;hpb=bc872011464c2c2f2b8c1dc045e71a1c748e827e;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/procedure/adapter/DirectStatementProcedure.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/procedure/adapter/DirectStatementProcedure.java new file mode 100644 index 000000000..398b1851a --- /dev/null +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/procedure/adapter/DirectStatementProcedure.java @@ -0,0 +1,32 @@ +package org.simantics.db.common.procedure.adapter; + +import org.simantics.db.AsyncReadGraph; +import org.simantics.db.DirectStatements; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.procedure.AsyncProcedure; + +public class DirectStatementProcedure implements AsyncProcedure { + + DirectStatements result = null; + DatabaseException exception = null; + + @Override + public void execute(AsyncReadGraph graph, final DirectStatements ds) { + result = ds; + } + + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + if(throwable instanceof DatabaseException) { + exception = (DatabaseException)throwable; + } else { + exception = new DatabaseException(throwable); + } + } + + public DirectStatements getOrThrow() throws DatabaseException { + if(exception != null) throw exception; + return result; + } + +} \ No newline at end of file