X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Forg%2Fvamsas%2Ftest%2Fsimpleclient%2FClientDoc.java;h=da05e0090027c26f51c20a4b59522a36ae1e1947;hb=7700d838b129db99edacb208b3153546795a33c7;hp=d5b0d4207191a4768563ef0d8287c7a355fbd091;hpb=46ac66bbd8528819331c18cca14c7c4c96580997;p=vamsas.git diff --git a/src/org/vamsas/test/simpleclient/ClientDoc.java b/src/org/vamsas/test/simpleclient/ClientDoc.java index d5b0d42..da05e00 100644 --- a/src/org/vamsas/test/simpleclient/ClientDoc.java +++ b/src/org/vamsas/test/simpleclient/ClientDoc.java @@ -1,9 +1,12 @@ package org.vamsas.test.simpleclient; +import java.util.Hashtable; import java.util.Vector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.vamsas.client.IClientAppdata; +import org.vamsas.client.Vobject; import org.vamsas.client.VorbaId; import org.vamsas.client.simpleclient.ClientDocument; import org.vamsas.client.simpleclient.VamsasArchive; @@ -14,7 +17,13 @@ import org.vamsas.objects.core.VamsasDocument; import org.vamsas.objects.utils.ProvenanceStuff; // simple holder to pass to client. -public class ClientDoc { +public class ClientDoc extends org.vamsas.client.ClientDocument { + /* (non-Javadoc) + * @see org.vamsas.client.IClientDocument#getClientAppdata() + */ + public IClientAppdata getClientAppdata() { + throw new Error("Appdata access is not implemented in the test.simpleclient.ClientDoc instance."); // TODO Auto-generated method stub + } protected boolean isModified=false; private Log log = LogFactory.getLog(ClientDoc.class); protected VamsasDocument doc; @@ -22,19 +31,23 @@ public class ClientDoc { protected VamsasArchive iohandler=null; protected VamsasArchiveReader reader=null; private String user=null; + private String app=null; /** * @param doc * @param iohandler * @param reader + * @param app * @param user */ - public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, VamsasArchiveReader reader, String user) { - super(); + public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, VamsasArchiveReader reader, String app, String user, Hashtable objrefs) { + super(objrefs, (iohandler!=null) ? iohandler.getVorba() : null); this.doc = doc; this.iohandler = iohandler; this.reader = reader; + this.app = app; this.user = user; + this.objrefs = objrefs; _VamsasRoots = doc.getVAMSAS(); } // AppDataOutputStream appd; @@ -44,7 +57,7 @@ public class ClientDoc { */ protected Entry getProvenanceEntry(String action) { // VAMSAS: modify schema to allow referencing of user field (plus other issues, ClientUrn field, machine readable action, input parameters, additional data generated notes - Entry prov = ProvenanceStuff.newProvenanceEntry(user, action); + Entry prov = ProvenanceStuff.newProvenanceEntry(app, user, action); return prov; } public VAMSAS[] getVamsasRoots() { @@ -203,14 +216,140 @@ public class ClientDoc { public VamsasArchiveReader getReader() { return reader; } + private void _finalize() { + log.debug("finalizing clientDoc"); + if (doc!=null) { + doc = null; + } + if (_VamsasRoots!=null) { + for (int i=0; i<_VamsasRoots.length; i++) + _VamsasRoots[i]=null; + _VamsasRoots=null; + + } + + if (reader!=null) { + log.debug("Closing and removing reader reference"); + reader.close(); + reader=null; + } + if (iohandler!=null) { + log.debug("Removing ioHandler reference."); + iohandler.cancelArchive(); + iohandler=null; + } + } protected void finalize() throws Throwable { + _finalize(); super.finalize(); - //if (reader!=null) - // reader.close(); - //reader=null; -// if (iohandler!=null) { -// iohandler.cancelArchive(); // otherwise the original may be overwritten. -// } + } + private java.util.Hashtable objrefs=null; + + public VorbaId[] registerObjects(Vobject[] unregistered) { + if (doc==null) { + log.warn("registerObjects[] called on null document."); + return null; + } + if (objrefs==null) { + log.warn("registerObjects[] called for null objrefs hasharray."); + return null; + } + if (unregistered!=null) { + VorbaId ids[] = new VorbaId[unregistered.length]; + for (int i=0,k=unregistered.length; i