uk.ac.vamsas.client.simpleclient
Class ClientDocument

java.lang.Object
  extended byuk.ac.vamsas.client.ClientDocument
      extended byuk.ac.vamsas.client.simpleclient.ClientDocument
All Implemented Interfaces:
IClientDocument

public class ClientDocument
extends ClientDocument
implements IClientDocument

Maintains a collection of vamsas objects, appdatas and states, and provides api for a SimpleClient's client. TODO: test and migrate ArchiveClient.getAppData methods to here and retest in ExampleApplication

Author:
jimp

Field Summary
protected  VamsasArchive iohandler
           
protected  SimpleClient sclient
           
 
Fields inherited from class uk.ac.vamsas.client.ClientDocument
vamsasObjects, vorbafactory
 
Constructor Summary
protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, SimpleClient sclient)
          prepare Application-side dataset from the vamsas Document iohandler
 
Method Summary
 void addVamsasRoot(VAMSAS newroot)
          Adds a new VAMSAS root entry TODO: decide on same InvalidVamsasObject exceptions.
protected  void finalize()
           
 IClientAppdata getClientAppdata()
          Get instance of Client and User specific vamsas document data access interface.
 Vobject getObject(VorbaId id)
          Get a single Vobject.
 Vobject[] getObjects(VorbaId[] ids)
          Get a list of objects.
 java.util.Vector getUpdatedObjects()
           
protected  VamsasArchiveReader getVamsasArchiveReader()
          returns the read-only IO interface for the vamsas document Jar file
protected  VamsasDocument getVamsasDocument()
          access the vamsas document
 VAMSAS[] getVamsasRoots()
          Returns all root objects in document.
 boolean isInvalidModification()
          if this is set the document will never be written back to the session unless the corruption is fixed.
 boolean isModified()
          Public method for internal use by SimpleClient.
 VorbaId registerObject(Vobject unregistered)
          Returns an Vobject with a valid VorbaId, and provenance element.
 VorbaId[] registerObjects(Vobject[] unregistered)
          Returns an array of objects, each with a valid VorbaId (and completed provenance entry).
 void setInvalidModification(boolean invalidModification)
          set if the client has corrupted the Vamsas Document structure somehow.
 void setVamsasRoots(VAMSAS[] newroots)
          update the document with new roots.
protected  void updateDocumentRoots()
           
protected  boolean updateSessionDocument()
          called by vamsas api to write updated document to session
 
Methods inherited from class uk.ac.vamsas.client.ClientDocument
_registerObject
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sclient

protected SimpleClient sclient

iohandler

protected VamsasArchive iohandler
Constructor Detail

ClientDocument

protected ClientDocument(VamsasDocument doc,
                         VamsasArchive docHandler,
                         IdFactory Factory,
                         SimpleClient sclient)
prepare Application-side dataset from the vamsas Document iohandler

Parameters:
doc - - the dataset
docHandler - - the sessionFile IO handler
Factory - - the source of current and new vorbaIds
sclient - - the simpleclient instance
Method Detail

isModified

public boolean isModified()
Public method for internal use by SimpleClient.

Returns:
true if document has been modified.

getObject

public Vobject getObject(VorbaId id)
Description copied from interface: IClientDocument
Get a single Vobject.

Specified by:
getObject in interface IClientDocument
Parameters:
id -
Returns:
Vobject referred to by id or null if it doesn't exist.

getObjects

public Vobject[] getObjects(VorbaId[] ids)
Description copied from interface: IClientDocument
Get a list of objects.

Specified by:
getObjects in interface IClientDocument
Parameters:
ids -
Returns:
array of objects using a vector of VorbaId ids.

updateDocumentRoots

protected void updateDocumentRoots()

getVamsasRoots

public VAMSAS[] getVamsasRoots()
Description copied from interface: IClientDocument
Returns all root objects in document. All objects inherit from uk.ac.vamsas.client.Vobject and have valid VorbaIds and provenance entries.

Specified by:
getVamsasRoots in interface IClientDocument
Returns:
array of root Vamsas element objects.

setVamsasRoots

public void setVamsasRoots(VAMSAS[] newroots)
update the document with new roots. LATER: decide: this affects the next call to getVamsasRoots()

Specified by:
setVamsasRoots in interface IClientDocument
Parameters:
newroots -
See Also:
org.vamsas.IClientDocument.setVamsasRoots

addVamsasRoot

public void addVamsasRoot(VAMSAS newroot)
Description copied from interface: IClientDocument
Adds a new VAMSAS root entry TODO: decide on same InvalidVamsasObject exceptions. TODO: decide if a 'removeVamsasRoot' method is really needed.

Specified by:
addVamsasRoot in interface IClientDocument
Parameters:
newroot -

registerObjects

public VorbaId[] registerObjects(Vobject[] unregistered)
Description copied from interface: IClientDocument
Returns an array of objects, each with a valid VorbaId (and completed provenance entry). Note: An Vobject with valid VorbaId will not be reregistered.

Specified by:
registerObjects in interface IClientDocument
Parameters:
unregistered - array of unregistered objects.
Returns:
array of VorbaIds for the registered objects

registerObject

public VorbaId registerObject(Vobject unregistered)
Description copied from interface: IClientDocument
Returns an Vobject with a valid VorbaId, and provenance element. The VorbaId is so the application may refer to it in its own dataspace. Note: An Vobject with valid VorbaId will not be reregistered. Advice: Calling this method for a high-level Vobject (such as uk.ac.vamsas.objects.core.VAMSAS) will register all its component objects too.

Specified by:
registerObject in interface IClientDocument
Parameters:
unregistered - unregistered vamsas Vobject
Returns:
VorbaId registered for vamsas Vobject

getClientAppdata

public IClientAppdata getClientAppdata()
Description copied from interface: IClientDocument
Get instance of Client and User specific vamsas document data access interface.

Specified by:
getClientAppdata in interface IClientDocument
Returns:
Interface to Client and user specific application data

getVamsasDocument

protected VamsasDocument getVamsasDocument()
access the vamsas document

Returns:
the session's vamsas document

getVamsasArchiveReader

protected VamsasArchiveReader getVamsasArchiveReader()
returns the read-only IO interface for the vamsas document Jar file

Returns:

updateSessionDocument

protected boolean updateSessionDocument()
                                 throws java.io.IOException
called by vamsas api to write updated document to session

Returns:
true if update was successful
Throws:
java.io.IOException

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

getUpdatedObjects

public java.util.Vector getUpdatedObjects()

isInvalidModification

public boolean isInvalidModification()
if this is set the document will never be written back to the session unless the corruption is fixed.

Returns:
the invalidModification

setInvalidModification

public void setInvalidModification(boolean invalidModification)
set if the client has corrupted the Vamsas Document structure somehow. if this is set the document will never be written back to the session unless the corruption is fixed.

Parameters:
invalidModification - the invalidModification to set