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