From: jprocter Date: Tue, 21 Mar 2006 11:59:49 +0000 (+0000) Subject: rearranged some todos and preparing to implement SimpleClient and ClientDocument... X-Git-Tag: Release_0.2~325 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=50dbf081e4cdad62da0a65993793e2382f0a5f92;p=vamsas.git rearranged some todos and preparing to implement SimpleClient and ClientDocument IO stuff. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@195 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/org/vamsas/client/ClientDocument.java b/src/org/vamsas/client/ClientDocument.java index 005cb60..0bbdebc 100644 --- a/src/org/vamsas/client/ClientDocument.java +++ b/src/org/vamsas/client/ClientDocument.java @@ -37,7 +37,7 @@ public abstract class ClientDocument implements IClientDocument { else if (unregistered.__vorba!=vorbafactory) { // LATER: decide if this is allowed - it isn't for the moment. - log.error("Attempt to overwrite info in a registered vorba Vobject (under a different IVorgaIdFactory) ! - Implementation fix needed."); + log.error("Attempt to overwrite info in a registered vorba Vobject (under a different IVorbaIdFactory) ! - Implementation fix needed."); return null; } else { // probably didn't need to call registerObject. diff --git a/src/org/vamsas/client/simpleclient/ClientDocument.java b/src/org/vamsas/client/simpleclient/ClientDocument.java index dd1d695..71365ee 100644 --- a/src/org/vamsas/client/simpleclient/ClientDocument.java +++ b/src/org/vamsas/client/simpleclient/ClientDocument.java @@ -21,8 +21,8 @@ import org.vamsas.objects.core.VamsasDocument; import org.vamsas.objects.utils.AppDataReference; /** - * @author jimp Contains a collection of vamsas objects and reference to a - * specified ClientHandle's information. + * Maintains a collection of vamsas objects, appdatas and states, and provides api for a SimpleClient's client. + * @author jimp */ public class ClientDocument extends org.vamsas.client.ClientDocument implements IClientDocument { private static Log log = LogFactory.getLog(ClientDocument.class); @@ -30,6 +30,17 @@ public class ClientDocument extends org.vamsas.client.ClientDocument implements protected SimpleClient sclient; protected VamsasArchive archive = null; /** + * indicate if new data has been incorporated + */ + private boolean isModified = false; + /** + * Public method for internal use by SimpleClient. + * @return true if document has been modified. + */ + public boolean isModified() { + return isModified; + } + /** * * prepare Application-side dataset from the vamsas Document archive * @param doc - the dataset @@ -37,13 +48,13 @@ public class ClientDocument extends org.vamsas.client.ClientDocument implements * @param Factory - the source of current and new vorbaIds * @param sclient - the simpleclient instance */ - protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, SimpleClient vorba) { + protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, SimpleClient sclient) { super(Factory.getVorbaIdHash(), Factory); /** * prepare Application-side dataset from the vamsas Document archive */ - this.sclient = vorba; + this.sclient = sclient; archive = docHandler; this.doc = doc; } @@ -68,23 +79,120 @@ public class ClientDocument extends org.vamsas.client.ClientDocument implements // TODO: getObject in bulk return null; } - + /** + * internal reference to single copy of Document Roots array + */ + private VAMSAS[] _VamsasRoots=null; /* * (non-Javadoc) - * + * LATER: currently there is only one Vector of roots ever passed to client - decide if this is correct (means this is not thread safe and may behave unexpectedly) * @see org.vamsas.client.IClientDocument#getVamsasRoots() */ public VAMSAS[] getVamsasRoots() { - if (doc.getVAMSAS() == null) + if (_VamsasRoots!=null) + return _VamsasRoots; + VAMSAS[] roots = doc.getVAMSAS(); + if (roots == null) { // Make a new one to return to client : TODO: Decide if this is correct - return new VAMSAS[] { new VAMSAS() }; - return doc.getVAMSAS(); + _VamsasRoots = new VAMSAS[] { new VAMSAS() }; + } else { + _VamsasRoots = new VAMSAS[roots.length]; + for (int r=0;r-1) { + if (isValidUpdate(newr[k], original[i])) { + modified=true; + rts.add(newr[k]); + newr[k]=null; + } else { + // LATER: try harder to merge ducument roots. + log.warn("Couldn't merge new VAMSAS root "+newr[k].getId()); + newr[k] = null; // LATER: this means we ignore mangled roots. NOT GOOD + } + } else { + // add in order. + rts.add(original[i]); + } + } + // add remaining (new) roots + for (int i=0,j=newr.length; i