X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2FVorbaXmlBinder.java;h=94624943cf42597a0d8d697bc1d84e5507d3d08d;hb=0a868a9601b051aeaf439a8d73f6fc070044a02c;hp=12543f2a8984c189180882477f3ac2011d97048e;hpb=4b707f884b9300b927dba2fbfccfe2694eef7894;p=vamsas.git diff --git a/src/uk/ac/vamsas/client/VorbaXmlBinder.java b/src/uk/ac/vamsas/client/VorbaXmlBinder.java index 12543f2..9462494 100644 --- a/src/uk/ac/vamsas/client/VorbaXmlBinder.java +++ b/src/uk/ac/vamsas/client/VorbaXmlBinder.java @@ -25,7 +25,6 @@ import org.exolab.castor.xml.UnmarshalListener; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; -import uk.ac.vamsas.client.utils.ChecksummedReader; import uk.ac.vamsas.objects.core.VamsasDocument; /** * Implements the Vamsas Vobject ID machinery for translating @@ -43,14 +42,7 @@ public class VorbaXmlBinder implements UnmarshalListener { private final Hashtable oldobjhashes; private final Hashtable objrefs; private final Vector updatedobjs; // not yet used elswhere ? - private final ChecksummedReader inStream; - public VorbaXmlBinder(IVorbaIdFactory vorbafactory, Vector obj, Hashtable objrefs, Hashtable oldobjhashes, Vector updatedobjs) { - this(vorbafactory, obj, objrefs, oldobjhashes, updatedobjs, null); - - } - - public VorbaXmlBinder(IVorbaIdFactory vorbafactory2, Vector unrefedObj, Hashtable objrefs2, Hashtable oldobjhashes, Vector updatedObj, ChecksummedReader ckedInstream) { - this.inStream = ckedInstream; + public VorbaXmlBinder(IVorbaIdFactory vorbafactory2, Vector unrefedObj, Hashtable objrefs2, Hashtable oldobjhashes, Vector updatedObj) { this.vorbafactory = vorbafactory2; this.obj = unrefedObj; this.objrefs = objrefs2; @@ -90,8 +82,6 @@ public class VorbaXmlBinder implements UnmarshalListener { public void initialized(Object object) { if (object instanceof Vobject) { Vobject nobj = (Vobject) object; - if (nobj.isRegisterable() && nobj.___id_field!=null && inStream!=null) - nobj.__setInitHash(inStream.getChecksum()); // record start tag position } } @@ -107,8 +97,6 @@ public class VorbaXmlBinder implements UnmarshalListener { nobj.set__stored_in_document(true); try { if (nobj.isRegisterable() && nobj.___id_field!=null) { - if (inStream!=null) - nobj.__setFinalHash(inStream.getChecksum()); // compute LHash as difference between end and start tag positions VorbaId nobj_id=null; // look for the id field (should be an NCName string) nobj.__vorba = vorbafactory; @@ -131,8 +119,7 @@ public class VorbaXmlBinder implements UnmarshalListener { // TODO: add to list of objects without a valid vorbaId obj.add(nobj); } - nobj.doHash(); // TODO: DECIDE IF WE NEED TO DO THIS STILL: THIS DOESNT WORK! updates detected by comparing with last hash when marshalling - + nobj.doHash(); // updates detected by comparing with last hash when marshalling // check to see if new object was present in old object hash if (nobj_id!=null) { if (oldobjhashes.containsKey(nobj_id)) { @@ -140,7 +127,6 @@ public class VorbaXmlBinder implements UnmarshalListener { if (oldhash.isUpdated(nobj)) { // mark the object as updated in this document read. nobj.set__updated_since_last_read(true); - oldobjhashes.put(nobj_id, new Vobjhash(nobj)); updatedobjs.addElement(nobj); } } else { @@ -181,7 +167,8 @@ public class VorbaXmlBinder implements UnmarshalListener { if (doc.__vorba==null) doc.__vorba = vorba; doc.__ensure_instance_ids(); // this may take a while. Do we allow for cyclic references ? - doc.marshal(outstream); + Marshaller mshl = new Marshaller(outstream); + mshl.marshal(doc); } /** @@ -230,8 +217,9 @@ public class VorbaXmlBinder implements UnmarshalListener { Unmarshaller unmarshaller = new Unmarshaller(root); unmarshaller.setIDResolver(new IDResolver() { public Object resolve(String id) { + // TODO: allow for external ID resolution VorbaXmlBinder.log.warn("Warning - id " + id - + " is not found in the Vamsas XML!"); + + " is not found in the Vamsas XML! (TODO: Ignore if this is a forward reference!)"); return null; } }); @@ -242,14 +230,13 @@ public class VorbaXmlBinder implements UnmarshalListener { final VorbaIdFactory vorbafactory = factory; final Vector unrefedObj = new Vector(); final Vector updatedObj = new Vector(); - ChecksummedReader ckedInstream = new ChecksummedReader(instream); - unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, unrefedObj, objrefs, oobjhashes,updatedObj, ckedInstream)); + unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, unrefedObj, objrefs, oobjhashes,updatedObj)); // Call the unmarshaller. try { while (instream.ready()) { // TODO: mark objects in oobjhash prior to unmarshalling, to detect when objects have been lost through an update. //tohere - Object obj = unmarshaller.unmarshal(ckedInstream); + Object obj = unmarshaller.unmarshal(instream); boolean sync=ensure_references(unrefedObj, objrefs); if (!(obj instanceof Vobject)) return null;