/******************************************************************************* * 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 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; import org.simantics.utils.datastructures.BinaryFunction; public class OldTransferableGraphs { public static void importGraph1(Session session, final OldTransferableGraph1 tg, IImportAdvisor advisor, final BinaryFunction 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.call(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); } }