Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 18:27:33 GMT
  2. Package jalview.io.vamsas

File LocalDocSyncObject.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
59% of files have more coverage

Code metrics

6
10
1
1
127
32
4
0.4
10
1
4

Classes

Class Line # Actions
LocalDocSyncObject 33 10 4
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.io.vamsas;
22   
23    import uk.ac.vamsas.client.Vobject;
24   
25    /**
26    * Implement the basic logic for synchronising changes to or from the Vamsas
27    * Document. This is a more generic and normalised framework than the one
28    * implemented in DatastoreItem, but probably more tedious to implement. ..
29    * abandoned. Nov 2008
30    *
31    * @author JimP
32    */
 
33    public abstract class LocalDocSyncObject extends DatastoreItem
34    {
35    /**
36    *
37    * @return null or the local object that is being worked on.
38    */
39    public abstract Object getLObject();
40   
41    /**
42    *
43    * @return null or the document object that is being worked on
44    */
45    public abstract Vobject getVObject();
46   
47    /**
48    * endpoint for synchronize when all opreations are finished.
49    */
50    public abstract void nextObject();
51   
52    /**
53    * called if the local object can be safely updated from the bound document
54    * object. public abstract void updateToDoc();
55    */
56   
57    /**
58    * called if the associated document object can be safely updated with the
59    * local changes public abstract void updateToDoc();
60    */
61   
62    /**
63    * @return true if the local object is modified
64    */
65    public abstract boolean locallyModified();
66   
67    /**
68    *
69    * @return true if the bound document object is modified
70    */
71    public abstract boolean documentModified();
72   
73    /**
74    *
75    * @return true if the document object is locked w.r.t. this object's update.
76    */
77    public abstract boolean documentObjectLocked();
78   
79    /**
80    *
81    * @return a new datastore item instance which binds the local object to a new
82    * document object
83    */
84    public abstract LocalDocSyncObject newDocumentObject(); // could make this
85   
86    // constructor(Lobject)
87   
88    /**
89    *
90    * @return a new datastore item instance which binds the document object to a
91    * new local object.
92    */
93    public abstract LocalDocSyncObject newLocalObject(); // make this
94   
95    // constructor(Vobject)
96   
97    /**
98    * apply the update/commit logic as defined in the vamsas paper
99    *
100    * @param documentIsUpdated
101    * true if a document update event is being handled
102    */
 
103  0 toggle public void synchronize(boolean documentIsUpdated)
104    {
105  0 Object Lobject = getLObject();
106  0 Vobject Vobject = getVObject();
107  0 if (Lobject == null)
108    {
109    // no local binding for document object
110  0 newLocalObject().synchronize(documentIsUpdated);
111  0 return;
112    }
113  0 if (Vobject == null)
114    {
115    // no document binding for local object
116  0 newDocumentObject().synchronize(documentIsUpdated);
117    }
118    // Check binding is valid
119  0 if (getjv2vObj(Lobject) != Vobject)
120    {
121    // no local binding for document object
122  0 newLocalObject().synchronize(documentIsUpdated);
123    // no document binding for local object
124  0 newDocumentObject().synchronize(documentIsUpdated);
125    }
126    }
127    }