X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2Fsimpleclient%2FClientDocument.java;h=f518f718ba92f69958941384b2313f6b12b11671;hb=1eea4b639911330e7cd65e17c5421cc584f0d22e;hp=b9e918e2475d02185fb24944cc492d351381ca9d;hpb=616cdc52fd0e998a95ceb3f7a56a2d4eee20e68f;p=vamsas.git diff --git a/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java b/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java index b9e918e..f518f71 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.2. + * Copyright 2010 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; @@ -23,281 +41,302 @@ 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. - * TODO: test and migrate ArchiveClient.getAppData methods to here and retest in ExampleApplication - * @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 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; } + /** - * - * 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 + * + * 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 iohandler */ this.sclient = sclient; iohandler = docHandler; this.doc = doc; - _VamsasRoots=doc.getVAMSAS(); + _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 (k > -1) { if (isValidUpdate(newr[k], original[i], modflag)) { - // set by isValidUpdate if the hashcodes were really different from last store + // 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 { @@ -306,136 +345,153 @@ public class ClientDocument extends uk.ac.vamsas.client.ClientDocument implement } } // add remaining (new) roots - for (int i=0,j=newr.length; i