X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph.db%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fdb%2FTransferableGraphs.java;h=67689ff46320c44b71de5e2a19a404f42376f16b;hb=57f274203cf0046f2680fdb201759fe4f30ace34;hp=bdfd3de6e2ae326ad739468ac913f1f58fcbe274;hpb=81169c54002f4a9f89db5b6821f3e5a70dad2da7;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 bdfd3de6e..67689ff46 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 @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.TreeMap; import java.util.UUID; +import java.util.function.BiFunction; import org.simantics.databoard.Accessors; import org.simantics.databoard.Bindings; @@ -61,7 +62,6 @@ import org.simantics.graph.representation.External; import org.simantics.graph.representation.Identity; import org.simantics.graph.representation.TransferableGraph1; import org.simantics.graph.representation.Value; -import org.simantics.utils.datastructures.BinaryFunction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -154,7 +154,7 @@ public class TransferableGraphs { session.getService(SerialisationSupport.class)); } - public static void importGraph1(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BinaryFunction callback) throws DatabaseException, TransferableGraphException { + public static void importGraph1(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BiFunction callback) throws DatabaseException, TransferableGraphException { final TransferableGraphImportProcess process = new TransferableGraphImportProcess(tg, advisor == null ? new ImportAdvisor() : advisor); session.syncRequest(new ReadRequest() { @@ -168,24 +168,24 @@ public class TransferableGraphs { public void perform(WriteOnlyGraph graph) throws DatabaseException { process.write(graph); if(callback != null) - callback.call(graph, process); + callback.apply(graph, process); } }); } - public static void importGraph1(Session session, final TransferableGraphSource tg, IImportAdvisor advisor) throws Exception { - importGraph1(session, tg, advisor, null); + public static ImportResult importGraph1(Session session, final TransferableGraphSource tg, IImportAdvisor advisor) throws Exception { + return importGraph1(session, tg, advisor, null); } - public static void importGraph1(Session session, final TransferableGraphSource tg, IImportAdvisor advisor, TGStatusMonitor monitor) throws DatabaseException { - importGraph1(session, null, tg, advisor, monitor); + public static ImportResult importGraph1(Session session, final TransferableGraphSource tg, IImportAdvisor advisor, TGStatusMonitor monitor) throws DatabaseException { + return importGraph1(session, null, tg, advisor, monitor); } - public static void importGraph1(Session session, VirtualGraph vg, final TransferableGraphSource tg, IImportAdvisor advisor_, TGStatusMonitor monitor) throws DatabaseException { + public static ImportResult importGraph1(Session session, VirtualGraph vg, final TransferableGraphSource tg, IImportAdvisor advisor_, TGStatusMonitor monitor) throws DatabaseException { final IImportAdvisor2 advisor = (advisor_ instanceof IImportAdvisor2) ? ((IImportAdvisor2)advisor_) : new WrapperAdvisor(advisor_); - final StreamingTransferableGraphImportProcess process = new StreamingTransferableGraphImportProcess(session, vg, tg, advisor); + final StreamingTransferableGraphImportProcess process = new StreamingTransferableGraphImportProcess(session, vg, tg, advisor, monitor); session.syncRequest(new ReadRequest() { @Override public void run(ReadGraph graph) throws DatabaseException { @@ -210,6 +210,8 @@ public class TransferableGraphs { } } }); + + return new ImportResult(process.missingExternals); } public static void importGraph1WithMonitor(Session session, final TransferableGraph1 tg, IImportAdvisor advisor_, TGStatusMonitor monitor) throws DatabaseException { @@ -235,7 +237,7 @@ public class TransferableGraphs { }); } - public static void importGraph1WithChanges(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BinaryFunction callback) throws DatabaseException, TransferableGraphException { + public static void importGraph1WithChanges(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BiFunction callback) throws DatabaseException, TransferableGraphException { final TransferableGraphImportProcess process = new TransferableGraphImportProcess(tg, advisor == null ? new ImportAdvisor() : advisor); session.syncRequest(new ReadRequest() { @@ -252,7 +254,7 @@ public class TransferableGraphs { comments.add("Imported transferable graph with " + tg.resourceCount + " resources"); graph.addMetadata(comments); if(callback != null) - callback.call(graph, process); + callback.apply(graph, process); } }); }