- * update the document with new roots.
- */
- public void setVamsasRoots(VAMSAS[] newroots) {
- // extract root objects
- VAMSAS[] roots = doc.getVAMSAS();
- if (newroots != null) {
- // check newroots for objects that were present in the old document
- // check to see if the 'old' objects have been modified
- // if they have ? we overwrite them with their new version, ensuring that
- // provenance is updated.
- // if they haven't ? do nothing ?
-
- for (int i = 0, k = newroots.length; i < k; i++) {
- if (newroots[i].isRegistered()) {
- // easy - just check if anything has changed and do provenance
- object oldversion = getObject(newroots[i].getVorbaId());
- if (oldversion instanceof VAMSAS) {
- // TODO: appropriate merging behaviour when two clients have
- // modified the same registered object independently
- if (newroots[i].get__last_hash() != newroots[i].hashCode()) {
- // client has modified this object since last retrieval.
- if (newroots[i].get__last_hash() != oldversion.get__last_hash()) {
- // object has been modified by another client since this
- // client's
- // last access to document.
- }
- }
- } else {
- throw new Error(
- "Client error when using setVamsasRoots : The vorbaId for object "
- + i
- + " does not refer to an object of type VAMSAS in the current document!");
- }
- } else {
- if (!newroots[i].is__stored_in_document()) {
- // check if object is modified
- if (newroots[i].get__last_hash() != newroots[i].hashCode()) {
- // it is - so we add newroots[i] as a new object, with updated
- // provenance.
- } else {
- // do nothing
- newroots[i] = null;
- }
- } else {
- // just add newroots[i] as a new object in the document
- // - with appropriate provenance.
- }
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.vamsas.client.IClientDocument#registerObject(org.vamsas.client.object)