X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.graph.db%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fdb%2FTransferableGraphs.java;h=42bae14bf0a989b545fac4980c831b159e489fae;hb=a472ceaa29534d553e2af893e268b6a13bffa441;hp=2b93df74dceeb0fed0b3f0c871a62fe043968d8a;hpb=b6e702e0d16d951a25380f08de6dd2e7d4a0b127;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphs.java b/bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphs.java index 2b93df74d..42bae14bf 100644 --- a/bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphs.java +++ b/bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphs.java @@ -182,10 +182,15 @@ public class TransferableGraphs { } public static ImportResult importGraph1(Session session, VirtualGraph vg, final TransferableGraphSource tg, IImportAdvisor advisor_, TGStatusMonitor monitor) throws DatabaseException { + return importGraph1(session, vg, tg, advisor_, monitor, null); + } + + public static ImportResult importGraph1(Session session, VirtualGraph vg, final TransferableGraphSource tg, IImportAdvisor advisor_, TGStatusMonitor monitor, Boolean failOnMissing) throws DatabaseException { final IImportAdvisor2 advisor = (advisor_ instanceof IImportAdvisor2) ? ((IImportAdvisor2)advisor_) : new WrapperAdvisor(advisor_); - final StreamingTransferableGraphImportProcess process = new StreamingTransferableGraphImportProcess(session, vg, tg, advisor, monitor); + final StreamingTransferableGraphImportProcess process = failOnMissing == null ? new StreamingTransferableGraphImportProcess(session, vg, tg, advisor, monitor) + : new StreamingTransferableGraphImportProcess(session, vg, tg, advisor, monitor, failOnMissing); session.syncRequest(new ReadRequest() { @Override public void run(ReadGraph graph) throws DatabaseException { @@ -489,7 +494,7 @@ public class TransferableGraphs { private static void writeTransferableGraph(RequestProcessor processor, final TransferableGraphSource source, final RandomAccessBinary out, TGStatusMonitor monitor) throws Exception { long start = System.nanoTime(); - + try { final Serializer datatypeSerializer = Bindings.getSerializerUnchecked(Datatype.class); final Serializer identitySerializer = Bindings.getSerializerUnchecked(Identity.class); final Serializer extensionSerializer = Bindings.getSerializerUnchecked(Extensions.class); @@ -590,6 +595,9 @@ public class TransferableGraphs { } } }); + } finally { + source.close(); + } long end = System.nanoTime(); LOGGER.info("Wrote transferable graph in {} seconds.", 1e-9*(end-start));