org.mycore.datamodel.common
Class MCRXMLTableManager

java.lang.Object
  extended by org.mycore.datamodel.common.MCRXMLTableManager

public class MCRXMLTableManager
extends Object

This class manage all accesses to the XML table database. This database holds all informations about the MCRObjectID and the corresponding XML file.

Version:
$Revision: 15621 $ $Date: 2009-07-25 08:32:01 +0200 (Sat, 25 Jul 2009) $
Author:
Jens Kupferschmidt, Thomas Scheffler (yagee)

Field Summary
(package private) static MCRConfiguration CONFIG
           
(package private) static MCRCache jdomCache
           
(package private) static Logger LOGGER
           
 
Constructor Summary
protected MCRXMLTableManager()
          The constructor of this class.
 
Method Summary
 void create(MCRObjectID mcrid, Document xml, Date lastModified)
          The method create a new item in the datastore.
 void delete(MCRObjectID mcrid)
          The method remove a item for the MCRObjectID from the datastore.
 boolean exist(MCRObjectID mcrid)
          This method check that the MCRObjectID exist in this store.
 List<String> getAllAllowedMCRObjectIDTypes()
          The method return a Array list with all MCRObjectID-Types, stored in the XML table.
 int getHighestStoredID(String idproject, String idtype)
          This method returns the highest stored ID number for a given MCRObjectID base, or 0 if no object is stored for this type and project.
 long getLastModified()
           
static MCRXMLTableManager instance()
          Returns the link table manager singleton.
 List<MCRObjectIDDate> listObjectDates(String type)
          lists objects of the specified type and their last modified date.
 Document readDocument(MCRObjectID id)
          returns the JDOM-Document of the given MCRObjectID.
 List<String> retrieveAllIDs()
          The method return a list with all stored MCRObjectID's of the XML table
 List<String> retrieveAllIDs(String type)
          The method return a Array list with all stored MCRObjectID's of the XML table of a MCRObjectID type.
 Document retrieveAsJDOM(MCRObjectID mcrid)
          The method retrieve a dataset for the given MCRObjectID and returns the corresponding JDOM Document.
 byte[] retrieveAsXML(MCRObjectID mcrid)
          The method retrieve a dataset for the given MCRObjectID and returns the corresponding XML file as byte array.
 void update(MCRObjectID mcrid, byte[] xml, Date lastModified)
          The method update an item in the datastore.
 void update(MCRObjectID mcrid, Document xml, Date lastModified)
          The method update an item in the datastore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

static Logger LOGGER

CONFIG

static MCRConfiguration CONFIG

jdomCache

static MCRCache jdomCache
Constructor Detail

MCRXMLTableManager

protected MCRXMLTableManager()
The constructor of this class.

Method Detail

instance

public static MCRXMLTableManager instance()
Returns the link table manager singleton.


create

public void create(MCRObjectID mcrid,
                   Document xml,
                   Date lastModified)
            throws MCRException
The method create a new item in the datastore.

Parameters:
mcrid - a MCRObjectID
xml - a JDOM Document
Throws:
MCRException - if the method arguments are not correct

delete

public void delete(MCRObjectID mcrid)
            throws MCRException
The method remove a item for the MCRObjectID from the datastore.

Parameters:
mcrid - a MCRObjectID
Throws:
MCRException - if the method argument is not correct

update

public void update(MCRObjectID mcrid,
                   Document xml,
                   Date lastModified)
            throws MCRException
The method update an item in the datastore.

Parameters:
mcrid - a MCRObjectID
xml - a byte array with the XML file
Throws:
MCRException - if the method arguments are not correct

update

public void update(MCRObjectID mcrid,
                   byte[] xml,
                   Date lastModified)
            throws MCRException
The method update an item in the datastore.

Parameters:
mcrid - a MCRObjectID
xml - a byte array with the XML file
Throws:
MCRException - if the method arguments are not correct

retrieveAsXML

public byte[] retrieveAsXML(MCRObjectID mcrid)
                     throws MCRException
The method retrieve a dataset for the given MCRObjectID and returns the corresponding XML file as byte array.

Parameters:
mcrid - a MCRObjectID
Returns:
the byte array of data or NULL
Throws:
MCRException - if the method arguments are not correct

retrieveAsJDOM

public Document retrieveAsJDOM(MCRObjectID mcrid)
                        throws MCRException
The method retrieve a dataset for the given MCRObjectID and returns the corresponding JDOM Document.

Parameters:
mcrid - a MCRObjectID
Returns:
the JDOM Document of data or NULL
Throws:
MCRException - if the method arguments are not correct

getHighestStoredID

public int getHighestStoredID(String idproject,
                              String idtype)
                       throws MCRPersistenceException
This method returns the highest stored ID number for a given MCRObjectID base, or 0 if no object is stored for this type and project.

Parameters:
project - the project ID part of the MCRObjectID base
type - the type ID part of the MCRObjectID base
Returns:
the highest stored ID number as a String
Throws:
MCRPersistenceException - if a persistence problem is occured

exist

public boolean exist(MCRObjectID mcrid)
This method check that the MCRObjectID exist in this store.

Parameters:
mcrid - a MCRObjectID
Returns:
true if the MCRObjectID exist, else return false

retrieveAllIDs

public List<String> retrieveAllIDs(String type)
The method return a Array list with all stored MCRObjectID's of the XML table of a MCRObjectID type.

Parameters:
type - a MCRObjectID type string
Returns:
a ArrayList of MCRObjectID's

retrieveAllIDs

public List<String> retrieveAllIDs()
The method return a list with all stored MCRObjectID's of the XML table

Returns:
a ArrayList of MCRObjectID's

getAllAllowedMCRObjectIDTypes

public List<String> getAllAllowedMCRObjectIDTypes()
The method return a Array list with all MCRObjectID-Types, stored in the XML table. reads the mycore.properties-configuration for datamodel-types

Returns:
a ArrayList of MCRObjectID-Types for which MCR.Metadata.Type.{datamodel}=true

readDocument

public Document readDocument(MCRObjectID id)
returns the JDOM-Document of the given MCRObjectID. This method uses caches to save database connections. Use this if you want to get a JDOM Document not just plain xml. Be aware that any changes done to the Document will be applied to the copy in the cache. So if you made any changes to the Document make a clone of the Document to avoid side effects.

Parameters:
id - ObjectID of MyCoRe Document
Returns:
MyCoRe Document as JDOM or NULL

listObjectDates

public List<MCRObjectIDDate> listObjectDates(String type)
lists objects of the specified type and their last modified date.

Parameters:
type - type of object
Returns:

getLastModified

public long getLastModified()