From: jprocter Date: Mon, 27 Mar 2006 12:18:18 +0000 (+0000) Subject: added registration/object retrieval methods to ClientDoc. X-Git-Tag: Release_0.2~302 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c48e7dc90f1cc593738404dcf83a8a36e1b9a3b0;p=vamsas.git added registration/object retrieval methods to ClientDoc. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@218 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/org/vamsas/test/simpleclient/ArchiveClient.java b/src/org/vamsas/test/simpleclient/ArchiveClient.java index 253e993..0ba0a93 100644 --- a/src/org/vamsas/test/simpleclient/ArchiveClient.java +++ b/src/org/vamsas/test/simpleclient/ArchiveClient.java @@ -6,6 +6,7 @@ package org.vamsas.test.simpleclient; import java.io.File; import java.io.IOException; import java.util.Date; +import java.util.Hashtable; import java.util.Vector; import org.apache.commons.logging.Log; @@ -16,6 +17,8 @@ import org.vamsas.client.ClientHandle; import org.vamsas.client.IVorbaIdFactory; import org.vamsas.client.SessionHandle; import org.vamsas.client.UserHandle; +import org.vamsas.client.Vobject; +import org.vamsas.client.VorbaId; import org.vamsas.client.simpleclient.AppDataOutputStream; import org.vamsas.client.simpleclient.FileWatcher; import org.vamsas.client.simpleclient.IdFactory; @@ -150,7 +153,7 @@ public class ArchiveClient extends IdFactory { d = docb.getVamsasDocument(vreader); if (d!=null) { - ClientDoc creader = new ClientDoc(d, null, vreader, getProvenanceUser()); + ClientDoc creader = new ClientDoc(d, null, vreader, getProvenanceUser(), getVorbaIdHash()); return creader; } } @@ -177,7 +180,7 @@ public class ArchiveClient extends IdFactory { varc.cancelArchive(); return null; } - ClientDoc cdoc = new ClientDoc(d, varc, varc.getOriginalArchiveReader(), getProvenanceUser()); + ClientDoc cdoc = new ClientDoc(d, varc, varc.getOriginalArchiveReader(), getProvenanceUser(), getVorbaIdHash()); return cdoc; // do appHandle? } catch (Exception e) { @@ -259,5 +262,10 @@ public class ArchiveClient extends IdFactory { } System.out.println("Finished at "+new Date()); } - + public org.vamsas.client.Vobject getObject(VorbaId id) { + Hashtable idhash = this.getVorbaIdHash(); + if (idhash!=null && idhash.containsKey(id)) + return (Vobject) idhash.get(id); + return null; + } } diff --git a/src/org/vamsas/test/simpleclient/ClientDoc.java b/src/org/vamsas/test/simpleclient/ClientDoc.java index d5b0d42..f15eec5 100644 --- a/src/org/vamsas/test/simpleclient/ClientDoc.java +++ b/src/org/vamsas/test/simpleclient/ClientDoc.java @@ -1,9 +1,11 @@ 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.Vobject; import org.vamsas.client.VorbaId; import org.vamsas.client.simpleclient.ClientDocument; import org.vamsas.client.simpleclient.VamsasArchive; @@ -29,12 +31,13 @@ public class ClientDoc { * @param reader * @param user */ - public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, VamsasArchiveReader reader, String user) { + public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, VamsasArchiveReader reader, String user, Hashtable objrefs) { super(); this.doc = doc; this.iohandler = iohandler; this.reader = reader; this.user = user; + this.objrefs = objrefs; _VamsasRoots = doc.getVAMSAS(); } // AppDataOutputStream appd; @@ -212,5 +215,90 @@ public class ClientDoc { // 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