Class MCRObjectService

java.lang.Object
org.mycore.datamodel.metadata.MCRObjectService

public class MCRObjectService extends Object
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
Other date types are optional, but as example in Dublin Core:
  • 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
The state is optional and represented by a MyCoRe classification object.
Version:
$Revision$ $Date$
Author:
Jens Kupferschmidt, Matthias Eichner, Robert Stephan
  • Field Details

  • Constructor Details

    • MCRObjectService

      public MCRObjectService()
      This is the constructor of the MCRObjectService class. All data are set to null.
  • Method Details

    • setFromDOM

      public final void setFromDOM(Element service)
      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

      protected ArrayList<MCRMetaISO8601Date> getDates()
      Returns the dates.
      Returns:
      list of dates
    • getState

      public final MCRCategoryID getState()
      This method returns the status classification
      Returns:
      the status as MCRMetaClassification, can return null
    • getDate

      public final Date getDate(String type)
      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

      public final void setDate(String type)
      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

      public final void setDate(String type, Date date)
      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 date
      date - set time to this Calendar null means the actual date
    • removeDate

      public final void removeDate(String type)
      This method removes the date of the specified type from the date list.
      Parameters:
      type - a type as string
    • setState

      public final void setState(MCRCategoryID state)
      This method sets the status classification
    • setState

      public final void setState(String state)
      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

      public final void addFlag(String value)
      This method add a flag to the flag list.
      Parameters:
      value - - the new flag as string
    • addFlag

      public final void addFlag(String type, String value)
      This method adds a flag to the flag list.
      Parameters:
      type - a type as string
      value - the new flag value as string
    • getFlags

      public final String getFlags()
      This method get all flags from the flag list as a string.
      Returns:
      the flags string
    • getFlagsAsList

      protected final List<MCRMetaLangText> getFlagsAsList()
      Returns the flags as list.
      Returns:
      flags as list
    • getFlagsAsMCRMetaLangText

      protected final ArrayList<MCRMetaLangText> getFlagsAsMCRMetaLangText(String type)
      This method returns all flag values of the specified type.
      Parameters:
      type - a type as string.
      Returns:
      a list of flag values
    • getFlags

      public final ArrayList<String> getFlags(String type)
      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

      public final String getFlag(int index) throws IndexOutOfBoundsException
      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

      public final String getFlagType(int index) throws IndexOutOfBoundsException
      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

      public final boolean isFlagSet(String value)
      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

      public final boolean isFlagTypeSet(String type)
      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

      public final void removeFlag(int index) throws IndexOutOfBoundsException
      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

      public final void removeFlags(String type)
      This method removes all flags of the specified type from the flag list.
      Parameters:
      type - a type as string
    • replaceFlag

      public final void replaceFlag(int index, String value) throws IndexOutOfBoundsException
      This method set a flag in the flag list.
      Parameters:
      index - a index in the list
      value - the value of a flag as string
      Throws:
      IndexOutOfBoundsException - throw this exception, if the index is invalid
    • replaceFlagType

      public final void replaceFlagType(int index, String type) throws IndexOutOfBoundsException
      This method sets the type value of a flag at the specified index.
      Parameters:
      index - a index in the list
      type - the type a flag as string
      Throws:
      IndexOutOfBoundsException - throw this exception, if the index is invalid
    • addRule

      public final void addRule(String permission, Element condition)
      This method add a rule to the rules list.
      Parameters:
      permission - - the new permission as string
      condition - - 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

      public final int getRuleIndex(String permission)
      This method return the index of a permission in the rules list.
      Returns:
      the index of a permission in the rules list
    • getRule

      public final MCRMetaAccessRule getRule(int index) throws IndexOutOfBoundsException
      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

      public final String getRulePermission(int index) throws IndexOutOfBoundsException
      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

      public final void removeRule(int index) throws IndexOutOfBoundsException
      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

      protected final ArrayList<MCRMetaAccessRule> getRules()
      Returns the rules.
      Returns:
      list of rules
    • createXML

      public final Element createXML() throws MCRException
      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
      otherwise the method return false
      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

      public final int getFlagIndex(String value)
      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

      protected final ArrayList<MCRMetaDateLangText> getMessagesAsList()
      Returns the messages as list.
      Returns:
      messages as list
    • getMessagesAsMCRMetaDateLangText

      protected final ArrayList<MCRMetaDateLangText> getMessagesAsMCRMetaDateLangText(String type)
      This method returns all message values of the specified type.
      Parameters:
      type - a type as string.
      Returns:
      a list of message values
    • getMessages

      public final ArrayList<String> getMessages()
      This method returns all messages values of any type.
      Returns:
      a list of message values
    • getMessages

      public final ArrayList<String> getMessages(String type)
      This method returns all messages values of the specified type.
      Parameters:
      type - a type as string.
      Returns:
      a list of message values
    • getMessage

      public final String getMessage(int index) throws IndexOutOfBoundsException
      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

      public final String getMessageType(int index) throws IndexOutOfBoundsException
      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

      public final MCRISO8601Date getMessageDate(int index) throws IndexOutOfBoundsException
      This method gets a single message date from the message list as a MCRISO8601Date.
      Returns:
      a message value
      Throws:
      IndexOutOfBoundsException - throw this exception, if the index is invalid
    • addMessage

      public final void addMessage(String value)
      This method add a message to the flag list.
      Parameters:
      value - - the new messages as string
    • addMessage

      public final void addMessage(String type, String value)
      This method adds a message to the message list.
      Parameters:
      type - a type as string
      value - the new message value as string
    • addMessage

      public final void addMessage(String type, String value, String form)
      This method adds a message to the message list.
      Parameters:
      type - a type as string
      value - the new message value as string
      form - a form as string, defaults to 'plain'
    • replaceMessage

      public final void replaceMessage(int index, String value) throws IndexOutOfBoundsException
      This method set a message in the message list.
      Parameters:
      index - a index in the list
      value - the value of a message as string
      Throws:
      IndexOutOfBoundsException - throw this exception, if the index is invalid
    • replaceMessageType

      public final void replaceMessageType(int index, String type) throws IndexOutOfBoundsException
      This method sets the type value of a message at the specified index.
      Parameters:
      index - a index in the list
      type - the type of a message as string
      Throws:
      IndexOutOfBoundsException - throw this exception, if the index is invalid
    • removeMessage

      public final void removeMessage(int index) throws IndexOutOfBoundsException
      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

      public final void removeMessages(String type)
      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

      protected final ArrayList<MCRMetaClassification> 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

      public final ArrayList<MCRCategoryID> getClassifications()
      This method returns all classification values of any type.
      Returns:
      a list of classification values
    • getClassifications

      public final ArrayList<MCRCategoryID> getClassifications(String type)
      This method returns all classification values of the specified type.
      Parameters:
      type - a type as string.
      Returns:
      a list of classification values
    • getClassification

      public final MCRCategoryID getClassification(int index) throws IndexOutOfBoundsException
      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

      public final String getClassificationType(int index) throws IndexOutOfBoundsException
      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

      public final void addClassification(MCRCategoryID value)
      This method adds a classification to the classification list.
      Parameters:
      value - - the new classification
    • addClassification

      public final void addClassification(String type, MCRCategoryID value)
      This method adds a classification to the classification list.
      Parameters:
      type - a type as string
      value - the new classification value as MCRCategoryID
    • 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 list
      value - the classification as MCRCategoryID
      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 list
      type - the type of a flag as string
      Throws:
      IndexOutOfBoundsException - throw this exception, if the index is invalid
    • removeClassification

      public final void removeClassification(int index) throws IndexOutOfBoundsException
      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

      public final void removeClassifications(String type)
      This method removes all classification with the specified type from the classification list.
      Parameters:
      type - a type as string