X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.graph.db%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fdb%2FTransferableGraphs.java;h=0841e1455569ed08e0f184c750c5125e9fe55aa3;hp=67689ff46320c44b71de5e2a19a404f42376f16b;hb=e209f1fed1443bfdfe6ba721e63df496da3c36fe;hpb=550e12043381d305cb3248bfee1a39fa9b47e814;ds=sidebyside 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 67689ff46..0841e1455 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 @@ -440,15 +440,23 @@ public class TransferableGraphs { } public static void writeTransferableGraph(RequestProcessor processor, String format, int version, TreeMap metadata, TransferableGraphSource source, File target, TGStatusMonitor monitor) throws Exception { - final Serializer datatypeSerializer = Bindings.getSerializerUnchecked(Datatype.class); try (RandomAccessBinary out = new BinaryFile(target, 128*1024)) { - DataContainer container = new DataContainer(format, version, metadata, null); - DataContainers.writeHeader(out, container); - datatypeSerializer.serialize((DataOutput) out, Datatypes.getDatatypeUnchecked(TransferableGraph1.class)); - writeTransferableGraph(processor, source, out, monitor); + DataContainers.writeHeader(out, new DataContainer(format, version, metadata, null)); + writeTransferableGraphVariant(processor, source, out, monitor); } } + public static void writeTransferableGraph(RequestProcessor processor, TransferableGraphSource source, File target, TGStatusMonitor monitor) throws Exception { + try (RandomAccessBinary out = new BinaryFile(target, 128*1024)) { + writeTransferableGraphVariant(processor, source, out, monitor); + } + } + + public static void writeTransferableGraphVariant(RequestProcessor processor, TransferableGraphSource source, RandomAccessBinary out, TGStatusMonitor monitor) throws Exception { + Bindings.getSerializerUnchecked(Datatype.class).serialize(out, Datatypes.getDatatypeUnchecked(TransferableGraph1.class)); + writeTransferableGraph(processor, source, out, monitor); + } + private static TGStatusMonitor safeMonitor(TGStatusMonitor mon) { return mon == null ? TGStatusMonitor.NULL_MONITOR : mon; }