2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.io.vamsas;
21 import uk.ac.vamsas.client.Vobject;
24 * Implement the basic logic for synchronising changes to or from the Vamsas
25 * Document. This is a more generic and normalised framework than the one implemented in DatastoreItem,
26 * but probably more tedious to implement.
27 * .. abandoned. Nov 2008
30 public abstract class LocalDocSyncObject extends DatastoreItem
34 * @return null or the local object that is being worked on.
36 public abstract Object getLObject();
40 * @return null or the document object that is being worked on
42 public abstract Vobject getVObject();
45 * endpoint for synchronize when all opreations are finished.
47 public abstract void nextObject();
50 * called if the local object can be safely updated from the bound document
52 public abstract void updateToDoc();
56 * called if the associated document object can be safely updated with the
58 public abstract void updateToDoc();
62 * @return true if the local object is modified
64 public abstract boolean locallyModified();
68 * @return true if the bound document object is modified
70 public abstract boolean documentModified();
74 * @return true if the document object is locked w.r.t. this object's update.
76 public abstract boolean documentObjectLocked();
80 * @return a new datastore item instance which binds the local object to a new
83 public abstract LocalDocSyncObject newDocumentObject(); // could make this
84 // constructor(Lobject)
88 * @return a new datastore item instance which binds the document object to a
91 public abstract LocalDocSyncObject newLocalObject(); // make this
92 // constructor(Vobject)
95 * apply the update/commit logic as defined in the vamsas paper
97 * @param documentIsUpdated
98 * true if a document update event is being handled
100 public void synchronize(boolean documentIsUpdated)
102 Object Lobject = getLObject();
103 Vobject Vobject = getVObject();
106 // no local binding for document object
107 newLocalObject().synchronize(documentIsUpdated);
112 // no document binding for local object
113 newDocumentObject().synchronize(documentIsUpdated);
115 // Check binding is valid
116 if (getjv2vObj(Lobject) != Vobject)
118 // no local binding for document object
119 newLocalObject().synchronize(documentIsUpdated);
120 // no document binding for local object
121 newDocumentObject().synchronize(documentIsUpdated);