Class ChoiceAuthorityServiceImpl

java.lang.Object
org.dspace.content.authority.ChoiceAuthorityServiceImpl
All Implemented Interfaces:
ChoiceAuthorityService

public final class ChoiceAuthorityServiceImpl extends Object implements ChoiceAuthorityService
Broker for ChoiceAuthority plugins, and for other information configured about the choice aspect of authority control for a metadata field. Configuration keys, per metadata field (e.g. "dc.contributor.author") # names the ChoiceAuthority plugin called for this field choices.plugin.<FIELD> = name-of-plugin # mode of UI presentation desired in submission UI: # "select" is dropdown menu, "lookup" is popup with selector, "suggest" is autocomplete/suggest choices.presentation.<FIELD> = "select" | "suggest" # is value "closed" to the set of these choices or are non-authority values permitted? choices.closed.<FIELD> = true | false
Author:
Larry Stone
See Also:
  • Field Details

  • Constructor Details

    • ChoiceAuthorityServiceImpl

      protected ChoiceAuthorityServiceImpl()
  • Method Details

    • config2fkey

      protected String config2fkey(String field)
    • getChoiceAuthoritiesNames

      public Set<String> getChoiceAuthoritiesNames()
      Specified by:
      getChoiceAuthoritiesNames in interface ChoiceAuthorityService
      Returns:
      the names of all the defined choice authorities
    • getMatches

      public Choices getMatches(String schema, String element, String qualifier, String query, Collection collection, int start, int limit, String locale)
      Description copied from interface: ChoiceAuthorityService
      Wrapper that calls getMatches method of the plugin corresponding to the metadata field defined by schema,element,qualifier.
      Specified by:
      getMatches in interface ChoiceAuthorityService
      Parameters:
      schema - schema of metadata field
      element - element of metadata field
      qualifier - qualifier of metadata field
      query - user's value to match
      collection - database ID of Collection for context (owner of Item)
      start - choice at which to start, 0 is first.
      limit - maximum number of choices to return, 0 for no limit.
      locale - explicit localization key if available, or null
      Returns:
      a Choices object (never null).
      See Also:
      • org.dspace.content.authority.ChoiceAuthority#getMatches(java.lang.String, java.lang.String, org.dspace.content.Collection, int, int, java.lang.String)
    • getMatches

      public Choices getMatches(String fieldKey, String query, Collection collection, int start, int limit, String locale)
      Description copied from interface: ChoiceAuthorityService
      Wrapper calls getMatches method of the plugin corresponding to the metadata field defined by single field key.
      Specified by:
      getMatches in interface ChoiceAuthorityService
      Parameters:
      fieldKey - single string identifying metadata field
      query - user's value to match
      collection - database ID of Collection for context (owner of Item)
      start - choice at which to start, 0 is first.
      limit - maximum number of choices to return, 0 for no limit.
      locale - explicit localization key if available, or null
      Returns:
      a Choices object (never null).
      See Also:
      • org.dspace.content.authority.ChoiceAuthority#getMatches(java.lang.String, java.lang.String, org.dspace.content.Collection, int, int, java.lang.String)
    • getBestMatch

      public Choices getBestMatch(String fieldKey, String query, Collection collection, String locale)
      Description copied from interface: ChoiceAuthorityService
      Wrapper that calls getBestMatch method of the plugin corresponding to the metadata field defined by single field key.
      Specified by:
      getBestMatch in interface ChoiceAuthorityService
      Parameters:
      fieldKey - single string identifying metadata field
      query - user's value to match
      collection - database ID of Collection for context (owner of Item)
      locale - explicit localization key if available, or null
      Returns:
      a Choices object (never null) with 1 or 0 values.
      See Also:
      • org.dspace.content.authority.ChoiceAuthority#getBestMatch(java.lang.String, java.lang.String, org.dspace.content.Collection, java.lang.String)
    • getLabel

      public String getLabel(MetadataValue metadataValue, Collection collection, String locale)
      Description copied from interface: ChoiceAuthorityService
      Wrapper that calls getLabel method of the plugin corresponding to the metadata field defined by schema,element,qualifier.
      Specified by:
      getLabel in interface ChoiceAuthorityService
      Parameters:
      metadataValue - metadata value
      collection - Collection owner of Item
      locale - explicit localization key if available
      Returns:
      label
    • getLabel

      public String getLabel(String fieldKey, Collection collection, String authKey, String locale)
      Description copied from interface: ChoiceAuthorityService
      Wrapper that calls getLabel method of the plugin corresponding to the metadata field defined by single field key.
      Specified by:
      getLabel in interface ChoiceAuthorityService
      Parameters:
      fieldKey - single string identifying metadata field
      collection - Collection owner of Item
      authKey - authority key
      locale - explicit localization key if available
      Returns:
      label
    • isChoicesConfigured

      public boolean isChoicesConfigured(String fieldKey, Collection collection)
      Description copied from interface: ChoiceAuthorityService
      Predicate, is there a Choices configuration of any kind for the given metadata field?
      Specified by:
      isChoicesConfigured in interface ChoiceAuthorityService
      Parameters:
      fieldKey - single string identifying metadata field
      collection - Collection owner of Item
      Returns:
      true if choices are configured for this field.
    • getPresentation

      public String getPresentation(String fieldKey)
      Description copied from interface: ChoiceAuthorityService
      Get the presentation keyword (should be "lookup", "select" or "suggest", but this is an informal convention so it can be easily extended) for this field.
      Specified by:
      getPresentation in interface ChoiceAuthorityService
      Parameters:
      fieldKey - field key
      Returns:
      configured presentation type for this field, or null if none found
    • isClosed

      public boolean isClosed(String fieldKey)
      Description copied from interface: ChoiceAuthorityService
      Get the configured "closed" value for this field.
      Specified by:
      isClosed in interface ChoiceAuthorityService
      Parameters:
      fieldKey - single string identifying metadata field
      Returns:
      true if choices are closed for this field.
    • getVariants

      public List<String> getVariants(MetadataValue metadataValue, Collection collection)
      Description copied from interface: ChoiceAuthorityService
      Wrapper to call plugin's getVariants().
      Specified by:
      getVariants in interface ChoiceAuthorityService
      Parameters:
      metadataValue - metadata value
      Returns:
      List of variants
    • getChoiceAuthorityName

      public String getChoiceAuthorityName(String schema, String element, String qualifier, Collection collection)
      Specified by:
      getChoiceAuthorityName in interface ChoiceAuthorityService
      Parameters:
      schema - schema of metadata field
      element - element of metadata field
      qualifier - qualifier of metadata field
      Returns:
      the name of the choice authority associated with the specified metadata. Throw IllegalArgumentException if the supplied metadata is not associated with an authority choice
    • makeFieldKey

      protected String makeFieldKey(String schema, String element, String qualifier)
    • clearCache

      public void clearCache() throws SubmissionConfigReaderException
      Description copied from interface: ChoiceAuthorityService
      This method has been created to have a way of clearing the cache kept inside the service
      Specified by:
      clearCache in interface ChoiceAuthorityService
      Throws:
      SubmissionConfigReaderException
    • getChoiceAuthorityByAuthorityName

      public ChoiceAuthority getChoiceAuthorityByAuthorityName(String authorityName)
      Description copied from interface: ChoiceAuthorityService
      Return the ChoiceAuthority instance identified by the specified name
      Specified by:
      getChoiceAuthorityByAuthorityName in interface ChoiceAuthorityService
      Parameters:
      authorityName - the ChoiceAuthority instance name
      Returns:
      the ChoiceAuthority identified by the specified name
    • storeAuthority

      public boolean storeAuthority(String fieldKey, Collection collection)
      Description copied from interface: ChoiceAuthorityService
      Should we store the authority key (if any) for such field key and collection?
      Specified by:
      storeAuthority in interface ChoiceAuthorityService
      Parameters:
      fieldKey - single string identifying metadata field
      collection - Collection owner of Item or where the item is submitted to
      Returns:
      true if the configuration allows to store the authority value
    • getChoicesByParent

      public Choices getChoicesByParent(String authorityName, String parentId, int start, int limit, String locale)
      Wrapper that calls getChoicesByParent method of the plugin.
      Specified by:
      getChoicesByParent in interface ChoiceAuthorityService
      Parameters:
      authorityName - authority name
      parentId - parent Id
      start - choice at which to start, 0 is first.
      limit - maximum number of choices to return, 0 for no limit.
      locale - explicit localization key if available, or null
      Returns:
      a Choices object (never null).
      See Also:
      • org.dspace.content.authority.ChoiceAuthority#getChoicesByParent(java.lang.String, java.lang.String, int, int, java.lang.String)
    • getTopChoices

      public Choices getTopChoices(String authorityName, int start, int limit, String locale)
      Wrapper that calls getTopChoices method of the plugin.
      Specified by:
      getTopChoices in interface ChoiceAuthorityService
      Parameters:
      authorityName - authority name
      start - choice at which to start, 0 is first.
      limit - maximum number of choices to return, 0 for no limit.
      locale - explicit localization key if available, or null
      Returns:
      a Choices object (never null).
      See Also:
      • org.dspace.content.authority.ChoiceAuthority#getTopChoices(java.lang.String, int, int, java.lang.String)
    • getParentChoice

      public Choice getParentChoice(String authorityName, String vocabularyId, String locale)
      Description copied from interface: ChoiceAuthorityService
      Return the direct parent of an entry identified by its id in an hierarchical authority.
      Specified by:
      getParentChoice in interface ChoiceAuthorityService
      Parameters:
      authorityName - authority name
      vocabularyId - child id
      locale - explicit localization key if available, or null
      Returns:
      the parent Choice object if any
    • getVocabularyIndex

      public DSpaceControlledVocabularyIndex getVocabularyIndex(String nameVocab)
      Specified by:
      getVocabularyIndex in interface ChoiceAuthorityService