1 package jalview.io.vamsas;
\r
3 import uk.ac.vamsas.client.Vobject;
\r
6 * Implement the basic logic for synchronising changes to or from the Vamsas Document
\r
9 public abstract class LocalDocSyncObject extends DatastoreItem
\r
13 * @return null or the local object that is being worked on.
\r
15 public abstract Object getLObject();
\r
18 * @return null or the document object that is being worked on
\r
20 public abstract Vobject getVObject();
\r
23 * endpoint for synchronize when all opreations are finished.
\r
25 public abstract void nextObject();
\r
27 * called if the local object can be safely updated from the bound document object.
\r
29 public abstract void updateFromDoc();
\r
31 * called if the associated document object can be safely updated with the local changes
\r
33 public abstract void updateToDoc();
\r
35 * @return true if the local object is modified
\r
37 public abstract boolean locallyModified();
\r
40 * @return true if the bound document object is modified
\r
42 public abstract boolean documentModified();
\r
45 * @return true if the document object is locked w.r.t. this object's update.
\r
47 public abstract boolean documentObjectLocked();
\r
50 * @return a new datastore item instance which binds the local object to a new document object
\r
52 public abstract LocalDocSyncObject newDocumentObject(); // could make this constructor(Lobject)
\r
55 * @return a new datastore item instance which binds the document object to a new local object.
\r
57 public abstract LocalDocSyncObject newLocalObject(); // make this constructor(Vobject)
\r
59 * apply the update/commit logic as defined in the vamsas paper
\r
60 * @param documentIsUpdated true if a document update event is being handled
\r
62 public void synchronize(boolean documentIsUpdated) {
\r
63 Object Lobject = getLObject();
\r
64 Vobject Vobject = getVObject();
\r
67 // no local binding for document object
\r
68 newLocalObject().synchronize(documentIsUpdated);
\r
73 // no document binding for local object
\r
74 newDocumentObject().synchronize(documentIsUpdated);
\r
76 // Check binding is valid
\r
77 if (getjv2vObj(Lobject)!=Vobject)
\r
79 // no local binding for document object
\r
80 newLocalObject().synchronize(documentIsUpdated);
\r
81 // no document binding for local object
\r
82 newDocumentObject().synchronize(documentIsUpdated);
\r