]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.db/src/org/simantics/graph/db/old/OldTransferableGraphs.java
Enhancements to modelled STS-tests
[simantics/platform.git] / bundles / org.simantics.graph.db / src / org / simantics / graph / db / old / OldTransferableGraphs.java
index 10794a189afe809bed38c323815255900a03d558..4786abd3b6d30aaa8ea0250e09a814c280cf9e0f 100644 (file)
@@ -1,56 +1,57 @@
-/*******************************************************************************\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
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.graph.db.old;
+
+import java.util.function.BiFunction;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Session;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.WriteOnlyGraph;
+import org.simantics.db.common.request.ReadRequest;
+import org.simantics.db.common.request.WriteOnlyRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.graph.db.IImportAdvisor;
+import org.simantics.graph.db.ImportAdvisor;
+import org.simantics.graph.db.TransferableGraphException;
+import org.simantics.graph.representation.old.OldTransferableGraph1;
+
+public class OldTransferableGraphs {
+
+    public static void importGraph1(Session session, final OldTransferableGraph1 tg, IImportAdvisor advisor, final BiFunction<WriteOnlyGraph, OldTransferableGraphImportProcess1, Boolean> callback) throws DatabaseException, TransferableGraphException {
+        final OldTransferableGraphImportProcess1 process = new OldTransferableGraphImportProcess1(tg, 
+                advisor == null ? new ImportAdvisor() : advisor);
+        session.syncRequest(new ReadRequest() {
+            @Override
+            public void run(ReadGraph graph) throws DatabaseException {
+                process.prepare(graph);
+            }
+        });
+        session.syncRequest(new WriteOnlyRequest() {
+            @Override
+            public void perform(WriteOnlyGraph graph) throws DatabaseException {
+                process.write(graph);
+                if(callback != null)
+                    callback.apply(graph, process);
+            }
+        });
+    }
+    
+    public static void importGraph1(WriteGraph graph, final OldTransferableGraph1 tg, IImportAdvisor advisor) throws DatabaseException {
+        final OldTransferableGraphImportProcess1 process = new OldTransferableGraphImportProcess1(tg, 
+                advisor == null ? new ImportAdvisor() : advisor);
+        process.prepare(graph);
+        process.write2(graph);
+       
+    }
+    
+}