--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.graph.db.old;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.WriteOnlyGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.request.WriteOnlyRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.graph.db.IImportAdvisor;\r
+import org.simantics.graph.db.ImportAdvisor;\r
+import org.simantics.graph.db.TransferableGraphException;\r
+import org.simantics.graph.representation.old.OldTransferableGraph1;\r
+import org.simantics.utils.datastructures.BinaryFunction;\r
+\r
+public class OldTransferableGraphs {\r
+\r
+ public static void importGraph1(Session session, final OldTransferableGraph1 tg, IImportAdvisor advisor, final BinaryFunction<Boolean, WriteOnlyGraph, OldTransferableGraphImportProcess1> callback) throws DatabaseException, TransferableGraphException {\r
+ final OldTransferableGraphImportProcess1 process = new OldTransferableGraphImportProcess1(tg, \r
+ advisor == null ? new ImportAdvisor() : advisor);\r
+ session.syncRequest(new ReadRequest() {\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ process.prepare(graph);\r
+ }\r
+ });\r
+ session.syncRequest(new WriteOnlyRequest() {\r
+ @Override\r
+ public void perform(WriteOnlyGraph graph) throws DatabaseException {\r
+ process.write(graph);\r
+ if(callback != null)\r
+ callback.call(graph, process);\r
+ }\r
+ });\r
+ }\r
+ \r
+ public static void importGraph1(WriteGraph graph, final OldTransferableGraph1 tg, IImportAdvisor advisor) throws DatabaseException {\r
+ final OldTransferableGraphImportProcess1 process = new OldTransferableGraphImportProcess1(tg, \r
+ advisor == null ? new ImportAdvisor() : advisor);\r
+ process.prepare(graph);\r
+ process.write2(graph);\r
+ \r
+ }\r
+ \r
+}\r