org.mycore.datamodel.metadata
Class MCRObject

java.lang.Object
  extended by org.mycore.datamodel.metadata.MCRBase
      extended by org.mycore.datamodel.metadata.MCRObject

public final class MCRObject
extends MCRBase

This class implements all methode for handling one metadata object. Methodes of this class can read the XML metadata by using a XML parser, manipulate the data in the abstract persistence data store and return the XML stream to the user application. Additionally, this class provides the public user interface for the linking of MCRObjects against other MCRObjects with metadata inheritance.

Version:
$Revision: 15276 $ $Date: 2009-05-26 14:52:53 +0200 (Tue, 26 May 2009) $
Author:
Jens Kupferschmidt, Mathias Hegner

Field Summary
 
Fields inherited from class org.mycore.datamodel.metadata.MCRBase
importMode, jdom_document, LOGGER, MAX_LABEL_LENGTH, mcr_conf, mcr_encoding, mcr_id, mcr_label, mcr_schema, mcr_service, mcr_version, NL, SLASH
 
Constructor Summary
MCRObject()
          This is the constructor of the MCRObject class.
 
Method Summary
 void addDerivateInDatastore(String id, MCRMetaLinkID link)
          The methode add a derivate MCRMetaLinkID to the structure part and update the object with the ID in the data store.
 void createInDatastore()
          The methode create the object in the data store.
 Document createXML()
          This methode create a XML stream for all object data.
 void debug()
          The method print all informations about this MCRObject.
 void deleteFromDatastore(String id)
          The methode delete the object for the given ID from the data store.
static boolean existInDatastore(MCRObjectID id)
          The methode return true if the object is in the data store, else return false.
static boolean existInDatastore(String id)
          The methode return true if the object is in the data store, else return false.
 MCRObjectMetadata getMetadata()
          This method returns the instance of the MCRObjectMetadata class.
 MCRMetaElement getMetadataElement(String tag)
          This methode return the object metadata element selected by tag.
 MCRObjectStructure getStructure()
          This methode return the instance of the MCRObjectStructure class.
 void receiveFromDatastore(MCRObjectID id)
          The methode receive the object for the given MCRObjectID and stored it in this MCRObject.
 void receiveFromDatastore(String id)
          The methode receive the object for the given MCRObjectID and stored it in this MCRObject.
 Document receiveJDOMFromDatastore(MCRObjectID id)
          The methode receive the object for the given MCRObjectID and returned it as JDOM Document.
 Document receiveJDOMFromDatastore(String id)
          The methode receive the object for the given MCRObjectID and returned it as JDOM Document.
static byte[] receiveXMLFromDatastore(MCRObjectID id)
          The methode receive the object for the given MCRObjectID and returned it as XML stream.
static byte[] receiveXMLFromDatastore(String id)
          The methode receive the object for the given MCRObjectID and returned it as XML stream.
 void removeDerivateInDatastore(String id, String der_id)
          The methode remove a derivate MCRMetaLinkID from the structure part and update the object with the ID in the data store.
 void repairPersitenceDatastore(MCRObjectID id)
          The method updates the search index with the data from the XLM store.
 void repairPersitenceDatastore(String id)
          The method updates the search index with the data from the XLM store.
 void setFromJDOM(Document doc)
          This methode gets a JDOM-Document to build up the MyCoRe-Object.
 void setFromURI(URI uri)
          This method read the XML input stream from an URI to build up the MyCoRe-Object.
 void setFromXML(byte[] xml, boolean valid)
          This method read the XML input stream from a byte array to build up the MyCoRe-Object.
 boolean setMetadataElement(MCRMetaElement obj, String tag)
          This methode set the object metadata part named by a tag.
 void setStructure(MCRObjectStructure structure)
          This methode set the object MCRObjectStructure.
 void updateInDatastore()
          The methode update the object in the data store.
 void updateThisInDatastore()
          The method updates this object in the persistence layer.
 
Methods inherited from class org.mycore.datamodel.metadata.MCRBase
getId, getLabel, getSchema, getService, getVersion, isImportMode, isValid, setId, setImportMode, setLabel, setSchema, setService, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRObject

public MCRObject()
          throws MCRException,
                 MCRConfigurationException
This is the constructor of the MCRObject class. It creates an instance of the parser class and the metadata class.
The constructor reads the following information from the property file:

Throws:
MCRException - general Exception of MyCoRe
MCRConfigurationException - a special exception for configuartion data
Method Detail

getMetadataElement

public final MCRMetaElement getMetadataElement(String tag)
This methode return the object metadata element selected by tag. If this was not found, null was returned.

Returns:
the metadata tag part as a object that extend MCRMetaElement

getMetadata

public final MCRObjectMetadata getMetadata()
This method returns the instance of the MCRObjectMetadata class. If there was no MCRObjectMetadata found, null will be returned.

Returns:
the instance of the MCRObjectMetadata class

getStructure

public final MCRObjectStructure getStructure()
This methode return the instance of the MCRObjectStructure class. If this was not found, null was returned.

Returns:
the instance of the MCRObjectStructure class

setFromURI

public final void setFromURI(URI uri)
                      throws MCRException
This method read the XML input stream from an URI to build up the MyCoRe-Object.

Specified by:
setFromURI in class MCRBase
Parameters:
uri - an URI
Throws:
MCRException - general Exception of MyCoRe

setFromXML

public final void setFromXML(byte[] xml,
                             boolean valid)
                      throws MCRException
This method read the XML input stream from a byte array to build up the MyCoRe-Object.

Specified by:
setFromXML in class MCRBase
Parameters:
xml - a XML string
Throws:
MCRException - general Exception of MyCoRe

setFromJDOM

public final void setFromJDOM(Document doc)
                       throws MCRException
This methode gets a JDOM-Document to build up the MyCoRe-Object.

Parameters:
doc - an JDOM Object
Throws:
MCRException - general Exception of MyCoRe

setMetadataElement

public final boolean setMetadataElement(MCRMetaElement obj,
                                        String tag)
This methode set the object metadata part named by a tag.

Parameters:
obj - the class object of a metadata part
tag - the tag of a metadata part
Returns:
true if set was succesful, otherwise false

setStructure

public final void setStructure(MCRObjectStructure structure)
This methode set the object MCRObjectStructure.

Parameters:
structure - the object MCRObjectStructure part

createXML

public final Document createXML()
                         throws MCRException
This methode create a XML stream for all object data.

Specified by:
createXML in class MCRBase
Returns:
a JDOM Document with the XML data of the object as byte array
Throws:
MCRException - if the content of this class is not valid

createInDatastore

public final void createInDatastore()
                             throws MCRPersistenceException,
                                    MCRActiveLinkException
The methode create the object in the data store.

Specified by:
createInDatastore in class MCRBase
Throws:
MCRPersistenceException - if a persistence problem is occured
MCRActiveLinkException

addDerivateInDatastore

public final void addDerivateInDatastore(String id,
                                         MCRMetaLinkID link)
                                  throws MCRPersistenceException
The methode add a derivate MCRMetaLinkID to the structure part and update the object with the ID in the data store.

Parameters:
id - the object ID
link - a link to a derivate as MCRMetaLinkID
Throws:
MCRPersistenceException - if a persistence problem is occured

removeDerivateInDatastore

public final void removeDerivateInDatastore(String id,
                                            String der_id)
                                     throws MCRPersistenceException
The methode remove a derivate MCRMetaLinkID from the structure part and update the object with the ID in the data store.

Parameters:
id - the object ID
der_id - the derivate ID
Throws:
MCRPersistenceException - if a persistence problem is occured

deleteFromDatastore

public final void deleteFromDatastore(String id)
                               throws MCRPersistenceException,
                                      MCRActiveLinkException
The methode delete the object for the given ID from the data store.

Specified by:
deleteFromDatastore in class MCRBase
Parameters:
id - the object ID
Throws:
MCRPersistenceException - if a persistence problem is occured
MCRActiveLinkException

existInDatastore

public static final boolean existInDatastore(String id)
                                      throws MCRPersistenceException
The methode return true if the object is in the data store, else return false.

Parameters:
id - the object ID
Throws:
MCRPersistenceException - if a persistence problem is occured

existInDatastore

public static final boolean existInDatastore(MCRObjectID id)
                                      throws MCRPersistenceException
The methode return true if the object is in the data store, else return false.

Parameters:
id - the object ID
Throws:
MCRPersistenceException - if a persistence problem is occured

receiveFromDatastore

public final void receiveFromDatastore(String id)
                                throws MCRPersistenceException
The methode receive the object for the given MCRObjectID and stored it in this MCRObject.

Specified by:
receiveFromDatastore in class MCRBase
Parameters:
id - the object ID
Throws:
MCRPersistenceException - if a persistence problem is occured

receiveFromDatastore

public final void receiveFromDatastore(MCRObjectID id)
                                throws MCRPersistenceException
The methode receive the object for the given MCRObjectID and stored it in this MCRObject.

Parameters:
id - the object ID
Throws:
MCRPersistenceException - if a persistence problem is occured

receiveXMLFromDatastore

public static final byte[] receiveXMLFromDatastore(String id)
                                            throws MCRPersistenceException
The methode receive the object for the given MCRObjectID and returned it as XML stream.

Parameters:
id - the object ID
Returns:
the XML stream of the object as string
Throws:
MCRPersistenceException - if a persistence problem is occured

receiveXMLFromDatastore

public static final byte[] receiveXMLFromDatastore(MCRObjectID id)
                                            throws MCRPersistenceException
The methode receive the object for the given MCRObjectID and returned it as XML stream.

Parameters:
id - the object ID
Returns:
the XML stream of the object as string
Throws:
MCRPersistenceException - if a persistence problem is occured

receiveJDOMFromDatastore

public final Document receiveJDOMFromDatastore(String id)
                                        throws MCRPersistenceException
The methode receive the object for the given MCRObjectID and returned it as JDOM Document.

Parameters:
id - the object ID
Returns:
the JDOM Document of the object
Throws:
MCRPersistenceException - if a persistence problem is occured

receiveJDOMFromDatastore

public final Document receiveJDOMFromDatastore(MCRObjectID id)
                                        throws MCRPersistenceException
The methode receive the object for the given MCRObjectID and returned it as JDOM Document.

Parameters:
id - the object ID
Returns:
the JDOM Document of the object
Throws:
MCRPersistenceException - if a persistence problem is occured

updateInDatastore

public final void updateInDatastore()
                             throws MCRPersistenceException,
                                    MCRActiveLinkException
The methode update the object in the data store.

Specified by:
updateInDatastore in class MCRBase
Throws:
MCRPersistenceException - if a persistence problem is occured
MCRActiveLinkException - if object is created (no real update) and references to it's id already exist

updateThisInDatastore

public final void updateThisInDatastore()
                                 throws MCRPersistenceException
The method updates this object in the persistence layer.

Throws:
MCRPersistenceException

repairPersitenceDatastore

public final void repairPersitenceDatastore(String id)
                                     throws MCRPersistenceException
The method updates the search index with the data from the XLM store. Also it check the derivate links of itself.

Specified by:
repairPersitenceDatastore in class MCRBase
Parameters:
id - the MCRObjectID as string
Throws:
MCRPersistenceException

repairPersitenceDatastore

public final void repairPersitenceDatastore(MCRObjectID id)
                                     throws MCRPersistenceException
The method updates the search index with the data from the XLM store. Also it check the derivate links of itself.

Specified by:
repairPersitenceDatastore in class MCRBase
Parameters:
id - the MCRObjectID
Throws:
MCRPersistenceException

debug

public final void debug()
The method print all informations about this MCRObject.