X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2Fsimpleclient%2FClientDocument.java;h=9fbfc15571ea8e4462cabe2d35a6341ab734570e;hb=2a1989506952d17c665b046c43de2e0e02ccda84;hp=86294be3ae8e6dfd3a95ddb92d52abbf76fc4c57;hpb=ea8b10ee787a2b1e2b35f2acb4dccaf12fd2a6fd;p=vamsas.git diff --git a/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java b/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java index 86294be..9fbfc15 100644 --- a/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java +++ b/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java @@ -1,5 +1,23 @@ /* - * + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client.simpleclient; @@ -8,12 +26,6 @@ import java.util.Vector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.vamsas.objects.core.ApplicationData; -import org.vamsas.objects.core.User; -import org.vamsas.objects.core.VAMSAS; -import org.vamsas.objects.core.VamsasDocument; -import org.vamsas.objects.utils.AppDataReference; -import org.vamsas.test.objects.Core; import uk.ac.vamsas.client.ClientHandle; import uk.ac.vamsas.client.IClientAppdata; @@ -21,222 +33,310 @@ import uk.ac.vamsas.client.IClientDocument; import uk.ac.vamsas.client.UserHandle; import uk.ac.vamsas.client.Vobject; import uk.ac.vamsas.client.VorbaId; +import uk.ac.vamsas.objects.core.ApplicationData; +import uk.ac.vamsas.objects.core.User; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.objects.utils.AppDataReference; +import uk.ac.vamsas.test.objects.Core; /** - * Maintains a collection of vamsas objects, appdatas and states, and provides api for a SimpleClient's client. - * @author jimp + * Maintains a collection of vamsas objects, appdatas and states, and provides + * api for a SimpleClient's client. TODO: test and migrate + * ArchiveClient.getAppData methods to here and retest in ExampleApplication + * + * @author jimp */ -public class ClientDocument extends uk.ac.vamsas.client.ClientDocument implements IClientDocument { +public class ClientDocument extends uk.ac.vamsas.client.ClientDocument + implements IClientDocument { private static Log log = LogFactory.getLog(ClientDocument.class); + private VamsasDocument doc; + protected SimpleClient sclient; - protected VamsasArchive archive = null; + + protected VamsasArchive iohandler = 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; } - private Vector updatedObjects=null; + /** - * - * prepare Application-side dataset from the vamsas Document archive - * @param doc - the dataset - * @param docHandler - the sessionFile IO handler - * @param Factory - the source of current and new vorbaIds - * @param sclient - the simpleclient instance + * + * prepare Application-side dataset from the vamsas Document iohandler + * + * @param doc + * - the dataset + * @param docHandler + * - the sessionFile IO handler + * @param Factory + * - the source of current and new vorbaIds + * @param sclient + * - the simpleclient instance */ - protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, SimpleClient sclient) { + protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, + IdFactory Factory, SimpleClient sclient) { super(Factory.getVorbaIdHash(), Factory); - - + /** - * prepare Application-side dataset from the vamsas Document archive + * prepare Application-side dataset from the vamsas Document iohandler */ this.sclient = sclient; - archive = docHandler; + iohandler = docHandler; this.doc = doc; - updatedObjects=null; /// TODO: correct this line + _VamsasRoots = doc.getVAMSAS(); } - + /* * (non-Javadoc) * - * @see uk.ac.vamsas.client.IClientDocument#getObject(uk.ac.vamsas.client.VorbaId) + * @see + * uk.ac.vamsas.client.IClientDocument#getObject(uk.ac.vamsas.client.VorbaId) */ public Vobject getObject(VorbaId id) { - if (vamsasObjects==null) { + if (vamsasObjects == null) { log.debug("getObject called on null objrefs list."); return null; } if (vamsasObjects.containsKey(id)) return (Vobject) vamsasObjects.get(id); - log.debug("Returning null Vobject reference for id "+id.getId()); + log.debug("Returning null Vobject reference for id " + id.getId()); return null; } - + /* * (non-Javadoc) * - * @see uk.ac.vamsas.client.IClientDocument#getObjects(uk.ac.vamsas.client.VorbaId[]) + * @see + * uk.ac.vamsas.client.IClientDocument#getObjects(uk.ac.vamsas.client.VorbaId + * []) */ public Vobject[] getObjects(VorbaId[] ids) { - if (vamsasObjects==null) { + if (vamsasObjects == null) { log.debug("getObject[] called on null vamsasObjects list."); return null; } Vobject[] vo = new Vobject[ids.length]; - for (int i=0,j=ids.length; i-1) { - if (isValidUpdate(newr[k], original[i])) { - modified=true; + if (k > -1) { + if (isValidUpdate(newr[k], original[i], modflag)) { + // set by isValidUpdate if the hashcodes were really different from + // last store rts.add(newr[k]); - newr[k]=null; + newr[k] = null; } else { // LATER: try harder to merge ducument roots. - log.warn("Couldn't merge new VAMSAS root "+newr[k].getId()); + log.warn("Couldn't merge new VAMSAS root " + newr[k].getId()); newr[k] = null; // LATER: this means we ignore mangled roots. NOT GOOD } } else { @@ -245,131 +345,153 @@ public class ClientDocument extends uk.ac.vamsas.client.ClientDocument implement } } // add remaining (new) roots - for (int i=0,j=newr.length; i