Package org.mycore.datamodel.metadata
Class MCRObjectService
java.lang.Object
org.mycore.datamodel.metadata.MCRObjectService
This class implements all methods for handling MCRObject service data.
The service data stores technical information that is no metadata.
The service data holds six types of data (dates, rules flags, messages,
classifications and states). The flags and messages are text strings
and are optional.
The dates are represent by a date and a type. Two types are in service data at every time and can't remove:
- createdate - for the creating date of the object, this was set only one time
- modifydate - for the accepting date of the object, this was set at every changes
- submitdate - for the submiting date of the object
- acceptdate - for the accepting date of the object
- validfromdate - for the date of the object, at this the object is valid to use
- validtodate - for the date of the object, at this the object is no more valid to use
- Version:
- $Revision$ $Date$
- Author:
- Jens Kupferschmidt, Matthias Eichner, Robert Stephan
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addClassification
(String type, MCRCategoryID value) This method adds a classification to the classification list.final void
addClassification
(MCRCategoryID value) This method adds a classification to the classification list.final void
This method add a flag to the flag list.final void
This method adds a flag to the flag list.final void
addMessage
(String value) This method add a message to the flag list.final void
addMessage
(String type, String value) This method adds a message to the message list.final void
addMessage
(String type, String value, String form) This method adds a message to the message list.final void
This method add a rule to the rules list.final com.google.gson.JsonObject
Creates the JSON representation of this service.final Element
This method create a XML stream for all structure data.final MCRCategoryID
getClassification
(int index) This method get a single classification from the classification list as a string.final MCRMetaClassification
getClassificationAsMCRMetaClassification
(int index) This method get a single classification from the classification list as.final ArrayList<MCRCategoryID>
This method returns all classification values of any type.final ArrayList<MCRCategoryID>
getClassifications
(String type) This method returns all classification values of the specified type.protected final ArrayList<MCRMetaClassification>
This method returns all classification values.protected final ArrayList<MCRMetaClassification>
This method returns all classification values of the specified type.final int
This method return the size of the classification list.final String
getClassificationType
(int index) This method gets a single classification type from the classification list as a string.final Date
This method get a date for a given type.protected ArrayList<MCRMetaISO8601Date>
getDates()
Returns the dates.final int
This method return the size of the date list.final String
getFlag
(int index) This method get a single flag from the flag list as a string.final int
getFlagIndex
(String value) This method returns the index for the given flag value.final String
getFlags()
This method get all flags from the flag list as a string.This method returns all flag values of the specified type.protected final List<MCRMetaLangText>
Returns the flags as list.protected final ArrayList<MCRMetaLangText>
This method returns all flag values of the specified type.final int
This method return the size of the flag list.final String
getFlagType
(int index) This method gets a single flag type from the flag list as a string.final String
getMessage
(int index) This method get a single messages from the message list as a string.final MCRISO8601Date
getMessageDate
(int index) This method gets a single message date from the message list as aMCRISO8601Date
.This method returns all messages values of any type.getMessages
(String type) This method returns all messages values of the specified type.protected final ArrayList<MCRMetaDateLangText>
Returns the messages as list.protected final ArrayList<MCRMetaDateLangText>
This method returns all message values of the specified type.final int
This method return the size of the message list.final String
getMessageType
(int index) This method gets a single message type from the message list as a string.final MCRMetaAccessRule
getRule
(int index) This method get a single rule from the rules list as a JDOM Element.final int
getRuleIndex
(String permission) This method return the index of a permission in the rules list.final String
getRulePermission
(int index) This method get a single permission name of rule from the rules list as a string.protected final ArrayList<MCRMetaAccessRule>
getRules()
Returns the rules.final int
This method return the size of the rules list.final MCRCategoryID
getState()
This method returns the status classificationfinal boolean
This method return a boolean value if the given flag is set or not.final boolean
isFlagTypeSet
(String type) Proves if the type is set in the flag list.final boolean
isValid()
This method check the validation of the content of this class.final void
removeClassification
(int index) This method remove a classification from the classification list.final void
removeClassifications
(String type) This method removes all classification with the specified type from the classification list.final void
removeDate
(String type) This method removes the date of the specified type from the date list.final void
removeFlag
(int index) This method remove a flag from the flag list.final void
removeFlags
(String type) This method removes all flags of the specified type from the flag list.final void
removeMessage
(int index) This method remove a message from the message list.final void
removeMessages
(String type) This method removes all messages of the specified type from the message list.final void
removeRule
(int index) This method remove a rule from the rules list.final void
This method removes the current statefinal void
replaceClassification
(int index, MCRCategoryID value) This method set a classification in the classification list.final void
replaceClassificationType
(int index, String type) This method sets the type value of a classification at the specified index.final void
replaceFlag
(int index, String value) This method set a flag in the flag list.final void
replaceFlagType
(int index, String type) This method sets the type value of a flag at the specified index.final void
replaceMessage
(int index, String value) This method set a message in the message list.final void
replaceMessageType
(int index, String type) This method sets the type value of a message at the specified index.final void
This method set a date element in the dates list to a actual date value.final void
This method set a date element in the dates list to a given date value.final void
setFromDOM
(Element service) This method read the XML input stream part from a DOM part for the structure data of the document.final void
This method sets the status classification with the given string as categid and the default classid ('state')final void
setState
(MCRCategoryID state) This method sets the status classificationvoid
validate()
Validates the content of this class.
-
Field Details
-
DATE_TYPE_CREATEDATE
constant for create date- See Also:
-
DATE_TYPE_MODIFYDATE
constant for modify date- See Also:
-
FLAG_TYPE_CREATEDBY
constant for create user- See Also:
-
FLAG_TYPE_MODIFIEDBY
constant for modify user- See Also:
-
-
Constructor Details
-
MCRObjectService
public MCRObjectService()This is the constructor of the MCRObjectService class. All data are set to null.
-
-
Method Details
-
setFromDOM
This method read the XML input stream part from a DOM part for the structure data of the document.- Parameters:
service
- a list of relevant DOM elements for the metadata
-
getDateSize
public final int getDateSize()This method return the size of the date list.- Returns:
- the size of the date list
-
getDates
Returns the dates.- Returns:
- list of dates
-
getState
This method returns the status classification- Returns:
- the status as MCRMetaClassification, can return null
-
getDate
This method get a date for a given type. If the type was not found, an null was returned.- Parameters:
type
- the type of the date- Returns:
- the date as GregorianCalendar
- See Also:
-
setDate
This method set a date element in the dates list to a actual date value. If the given type exists, the date was update.- Parameters:
type
- the type of the date
-
setDate
This method set a date element in the dates list to a given date value. If the given type exists, the date was update.- Parameters:
type
- the type of the datedate
- set time to this Calendar null means the actual date
-
removeDate
This method removes the date of the specified type from the date list.- Parameters:
type
- a type as string
-
setState
This method sets the status classification -
setState
This method sets the status classification with the given string as categid and the default classid ('state') -
removeState
public final void removeState()This method removes the current state -
addFlag
This method add a flag to the flag list.- Parameters:
value
- - the new flag as string
-
addFlag
This method adds a flag to the flag list.- Parameters:
type
- a type as stringvalue
- the new flag value as string
-
getFlags
This method get all flags from the flag list as a string.- Returns:
- the flags string
-
getFlagsAsList
Returns the flags as list.- Returns:
- flags as list
-
getFlagsAsMCRMetaLangText
This method returns all flag values of the specified type.- Parameters:
type
- a type as string.- Returns:
- a list of flag values
-
getFlags
This method returns all flag values of the specified type.- Parameters:
type
- a type as string.- Returns:
- a list of flag values
-
getFlagSize
public final int getFlagSize()This method return the size of the flag list.- Returns:
- the size of the flag list
-
getFlag
This method get a single flag from the flag list as a string.- Returns:
- a flag string
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
getFlagType
This method gets a single flag type from the flag list as a string.- Returns:
- a flag type
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
isFlagSet
This method return a boolean value if the given flag is set or not.- Parameters:
value
- a searched flag- Returns:
- true if the flag was found in the list
-
isFlagTypeSet
Proves if the type is set in the flag list.- Parameters:
type
- a type as string- Returns:
- true if the flag list contains flags with this type, otherwise false
-
removeFlag
This method remove a flag from the flag list.- Parameters:
index
- a index in the list- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
removeFlags
This method removes all flags of the specified type from the flag list.- Parameters:
type
- a type as string
-
replaceFlag
This method set a flag in the flag list.- Parameters:
index
- a index in the listvalue
- the value of a flag as string- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
replaceFlagType
This method sets the type value of a flag at the specified index.- Parameters:
index
- a index in the listtype
- the type a flag as string- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
addRule
This method add a rule to the rules list.- Parameters:
permission
- - the new permission as stringcondition
- - the new rule as JDOM tree Element
-
getRulesSize
public final int getRulesSize()This method return the size of the rules list.- Returns:
- the size of the rules list
-
getRuleIndex
This method return the index of a permission in the rules list.- Returns:
- the index of a permission in the rules list
-
getRule
This method get a single rule from the rules list as a JDOM Element.- Returns:
- a the MCRMetaAccessRule instance
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
getRulePermission
This method get a single permission name of rule from the rules list as a string.- Returns:
- a rule permission string
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
removeRule
This method remove a rule from the rules list.- Parameters:
index
- a index in the list- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
getRules
Returns the rules.- Returns:
- list of rules
-
createXML
This method create a XML stream for all structure data.- Returns:
- a JDOM Element with the XML data of the structure data part
- Throws:
MCRException
- if the content of this class is not valid
-
createJSON
public final com.google.gson.JsonObject createJSON()Creates the JSON representation of this service.{ dates: [
MCRMetaISO8601Date.createJSON()
, ... ], rules: [MCRMetaDefault.createJSON()
, ... ], flags: [MCRMetaLangText.createJSON()
, ... ], messages: [MCRMetaDateLangText.createJSON()
, ... ], classifications: [MCRMetaClassification.createJSON()
, ... ], state: { } }- Returns:
- a json gson representation of this service
-
isValid
public final boolean isValid()This method check the validation of the content of this class. The method returns true if- the date value of "createdate" is not null or empty
- the date value of "modifydate" is not null or empty
- Returns:
- a boolean value
-
validate
public void validate()Validates the content of this class. This method throws an exception if:- the date value of "createdate" is not null or empty
- the date value of "modifydate" is not null or empty
- Throws:
MCRException
- the content is invalid
-
getFlagIndex
This method returns the index for the given flag value.- Parameters:
value
- the value of a flag as string- Returns:
- the index number or -1 if the value was not found
-
getMessagesSize
public final int getMessagesSize()This method return the size of the message list.- Returns:
- the size of the message list
-
getMessagesAsList
Returns the messages as list.- Returns:
- messages as list
-
getMessagesAsMCRMetaDateLangText
This method returns all message values of the specified type.- Parameters:
type
- a type as string.- Returns:
- a list of message values
-
getMessages
This method returns all messages values of any type.- Returns:
- a list of message values
-
getMessages
This method returns all messages values of the specified type.- Parameters:
type
- a type as string.- Returns:
- a list of message values
-
getMessage
This method get a single messages from the message list as a string.- Returns:
- a message string
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
getMessageType
This method gets a single message type from the message list as a string.- Returns:
- a message type
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
getMessageDate
This method gets a single message date from the message list as aMCRISO8601Date
.- Returns:
- a message value
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
addMessage
This method add a message to the flag list.- Parameters:
value
- - the new messages as string
-
addMessage
This method adds a message to the message list.- Parameters:
type
- a type as stringvalue
- the new message value as string
-
addMessage
This method adds a message to the message list.- Parameters:
type
- a type as stringvalue
- the new message value as stringform
- a form as string, defaults to 'plain'
-
replaceMessage
This method set a message in the message list.- Parameters:
index
- a index in the listvalue
- the value of a message as string- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
replaceMessageType
This method sets the type value of a message at the specified index.- Parameters:
index
- a index in the listtype
- the type of a message as string- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
removeMessage
This method remove a message from the message list.- Parameters:
index
- a index in the list- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
removeMessages
This method removes all messages of the specified type from the message list.- Parameters:
type
- a type as string
-
getClassificationsSize
public final int getClassificationsSize()This method return the size of the classification list.- Returns:
- the size of the classification list
-
getClassificationsAsList
This method returns all classification values.- Returns:
- classifications as list
-
getClassificationsAsMCRMetaClassification
protected final ArrayList<MCRMetaClassification> getClassificationsAsMCRMetaClassification(String type) This method returns all classification values of the specified type.- Parameters:
type
- a type as string.- Returns:
- a list of classification values
-
getClassifications
This method returns all classification values of any type.- Returns:
- a list of classification values
-
getClassifications
This method returns all classification values of the specified type.- Parameters:
type
- a type as string.- Returns:
- a list of classification values
-
getClassification
This method get a single classification from the classification list as a string.- Returns:
- a classification string
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
getClassificationType
This method gets a single classification type from the classification list as a string.- Returns:
- a classification type
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
getClassificationAsMCRMetaClassification
public final MCRMetaClassification getClassificationAsMCRMetaClassification(int index) throws IndexOutOfBoundsException This method get a single classification from the classification list as.- Returns:
- a classification value
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
addClassification
This method adds a classification to the classification list.- Parameters:
value
- - the new classification
-
addClassification
This method adds a classification to the classification list.- Parameters:
type
- a type as stringvalue
- the new classification value asMCRCategoryID
-
replaceClassification
public final void replaceClassification(int index, MCRCategoryID value) throws IndexOutOfBoundsException This method set a classification in the classification list.- Parameters:
index
- a index in the listvalue
- the classification asMCRCategoryID
- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
replaceClassificationType
public final void replaceClassificationType(int index, String type) throws IndexOutOfBoundsException This method sets the type value of a classification at the specified index.- Parameters:
index
- a index in the listtype
- the type of a flag as string- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
removeClassification
This method remove a classification from the classification list.- Parameters:
index
- a index in the list- Throws:
IndexOutOfBoundsException
- throw this exception, if the index is invalid
-
removeClassifications
This method removes all classification with the specified type from the classification list.- Parameters:
type
- a type as string
-