refactored org to uk
[vamsas.git] / src / uk / ac / vamsas / client / ClientDocument.java
1 /*
2  *
3  */
4 package uk.ac.vamsas.client;
5
6 import java.util.Hashtable;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10 import org.vamsas.objects.core.VAMSAS;
11
12 /**
13  * skeleton abstract class to allow client implementations 
14  * access to vamsas.client.Vobject registry mechanism.
15  */
16 public abstract class ClientDocument implements IClientDocument {
17   static Log log = LogFactory.getLog(ClientDocument.class);
18   
19   /**
20    * collection of uk.ac.vamsas.client.Vobject references
21    */
22   protected Hashtable vamsasObjects;
23   protected IVorbaIdFactory vorbafactory;
24   
25   protected ClientDocument(Hashtable objects, IVorbaIdFactory factory) {
26     vamsasObjects = objects;
27     vorbafactory = factory;
28   }
29   
30   /**
31    * @see IClientHandle.registerObject(Vobject unregistered)
32    */
33   protected VorbaId _registerObject(Vobject unregistered) {
34     // be ultra safe here because the user may be trying to mix different factories
35     if (unregistered.__vorba==null)
36         unregistered.__vorba = vorbafactory;
37     else
38       if (unregistered.__vorba!=vorbafactory) {
39         // LATER: decide if this is allowed - it isn't for the moment.
40         log.error("Attempt to overwrite info in a registered vorba Vobject (under a different IVorbaIdFactory) ! - Implementation fix needed.");
41         return null;
42       } else {
43         // probably didn't need to call registerObject.
44         log.debug("Redundant call to registerObject");
45       }
46     // TODO: add default provenance.
47     // TODO: decide if we need to do call __ensure_instance_ids here
48     // TODO: check if __ensure_instance_ids works correctly with new 'visit flag' mechanism
49     unregistered.__ensure_instance_ids(); // call cascade method here : 
50     return unregistered.getVorbaId();
51   }
52 }