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.diagram.synchronization.graph;
14 import org.simantics.db.WriteGraph;
15 import org.simantics.db.common.request.WriteRequest;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.request.Write;
18 import org.simantics.diagram.internal.DebugPolicy;
19 import org.simantics.diagram.internal.timing.GTask;
20 import org.simantics.diagram.internal.timing.Timing;
21 import org.simantics.diagram.synchronization.ErrorHandler;
22 import org.simantics.diagram.synchronization.IModification;
23 import org.simantics.utils.logging.TimeLogger;
26 * A graph database write request that composes several {@link IModification}
27 * instances into a single {@link Write} request.
29 * @author Tuukka Lehtonen
33 public class ModificationProcessRequest extends WriteRequest {
35 ErrorHandler errorHandler;
36 IModification[] modifications;
38 public ModificationProcessRequest(ErrorHandler errorHandler, IModification[] modifications) {
39 this.errorHandler = errorHandler;
40 this.modifications = modifications;
44 public void perform(final WriteGraph g) throws DatabaseException {
46 if (DebugPolicy.DEBUG_GRAPH_WRITEBACK)
47 System.out.println(Thread.currentThread() + " Performing " + modifications.length + " modifications");
48 Timing.timed("" + modifications.length + " MODIFICATIONS", new GTask() {
50 public void run() throws DatabaseException {
51 for (IModification m : modifications) {
60 public void modification(final WriteGraph g, final IModification m) throws DatabaseException {
61 Timing.timed(m.toString(), new GTask() {
63 public void run() throws DatabaseException {
66 if (DebugPolicy.DEBUG_GRAPH_WRITEBACK_MODIFICATION)
67 System.out.println(Thread.currentThread() + " Performing modification: " + m);
69 } catch (Exception e) {
71 errorHandler.error(e.getMessage(), e);
74 errorHandler.error(e.getMessage(), e);