1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.graph.db.old;
14 import java.util.function.BiFunction;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Session;
18 import org.simantics.db.WriteGraph;
19 import org.simantics.db.WriteOnlyGraph;
20 import org.simantics.db.common.request.ReadRequest;
21 import org.simantics.db.common.request.WriteOnlyRequest;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.graph.db.IImportAdvisor;
24 import org.simantics.graph.db.ImportAdvisor;
25 import org.simantics.graph.db.TransferableGraphException;
26 import org.simantics.graph.representation.old.OldTransferableGraph1;
28 public class OldTransferableGraphs {
30 public static void importGraph1(Session session, final OldTransferableGraph1 tg, IImportAdvisor advisor, final BiFunction<WriteOnlyGraph, OldTransferableGraphImportProcess1, Boolean> callback) throws DatabaseException, TransferableGraphException {
31 final OldTransferableGraphImportProcess1 process = new OldTransferableGraphImportProcess1(tg,
32 advisor == null ? new ImportAdvisor() : advisor);
33 session.syncRequest(new ReadRequest() {
35 public void run(ReadGraph graph) throws DatabaseException {
36 process.prepare(graph);
39 session.syncRequest(new WriteOnlyRequest() {
41 public void perform(WriteOnlyGraph graph) throws DatabaseException {
44 callback.apply(graph, process);
49 public static void importGraph1(WriteGraph graph, final OldTransferableGraph1 tg, IImportAdvisor advisor) throws DatabaseException {
50 final OldTransferableGraphImportProcess1 process = new OldTransferableGraphImportProcess1(tg,
51 advisor == null ? new ImportAdvisor() : advisor);
52 process.prepare(graph);
53 process.write2(graph);