Package org.dspace.content.authority
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.contributer.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:
ChoiceAuthority
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>authoritiesprotected Map<String,Boolean>closedprotected ConfigurationServiceconfigurationServiceprotected Map<String,ChoiceAuthority>controllerprotected PluginServicepluginServiceprotected Map<String,String>presentation
-
Constructor Summary
Constructors Modifier Constructor Description protectedChoiceAuthorityServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()This method has been created to have a way of clearing the cache kept inside the serviceprotected Stringconfig2fkey(String field)ChoicesgetBestMatch(String fieldKey, String query, Collection collection, String locale)Wrapper that calls getBestMatch method of the plugin corresponding to the metadata field defined by single field key.ChoicegetChoice(String fieldKey, String authKey, String locale)Set<String>getChoiceAuthoritiesNames()ChoiceAuthoritygetChoiceAuthorityByAuthorityName(String authorityName)StringgetChoiceAuthorityName(String schema, String element, String qualifier)StringgetChoiceMetadatabyAuthorityName(String name)StringgetLabel(String fieldKey, String authKey, String locale)Wrapper that calls getLabel method of the plugin corresponding to the metadata field defined by single field key.StringgetLabel(MetadataValue metadataValue, String locale)Wrapper that calls getLabel method of the plugin corresponding to the metadata field defined by schema,element,qualifier.ChoicesgetMatches(String schema, String element, String qualifier, String query, Collection collection, int start, int limit, String locale)Wrapper that calls getMatches method of the plugin corresponding to the metadata field defined by schema,element,qualifier.ChoicesgetMatches(String fieldKey, String query, Collection collection, int start, int limit, String locale)Wrapper calls getMatches method of the plugin corresponding to the metadata field defined by single field key.ChoicesgetMatches(String fieldKey, String query, Collection collection, int start, int limit, String locale, boolean externalInput)StringgetPresentation(String fieldKey)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.List<String>getVariants(MetadataValue metadataValue)Wrapper to call plugin's getVariants().booleanisChoicesConfigured(String fieldKey)Predicate, is there a Choices configuration of any kind for the given metadata field?booleanisClosed(String fieldKey)Get the configured "closed" value for this field.protected StringmakeFieldKey(String schema, String element, String qualifier)
-
-
-
Field Detail
-
controller
protected Map<String,ChoiceAuthority> controller
-
configurationService
@Autowired(required=true) protected ConfigurationService configurationService
-
pluginService
@Autowired(required=true) protected PluginService pluginService
-
-
Method Detail
-
getChoiceAuthoritiesNames
public Set<String> getChoiceAuthoritiesNames()
- Specified by:
getChoiceAuthoritiesNamesin interfaceChoiceAuthorityService- 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:ChoiceAuthorityServiceWrapper that calls getMatches method of the plugin corresponding to the metadata field defined by schema,element,qualifier.- Specified by:
getMatchesin interfaceChoiceAuthorityService- Parameters:
schema- schema of metadata fieldelement- element of metadata fieldqualifier- qualifier of metadata fieldquery- user's value to matchcollection- 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:
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:ChoiceAuthorityServiceWrapper calls getMatches method of the plugin corresponding to the metadata field defined by single field key.- Specified by:
getMatchesin interfaceChoiceAuthorityService- Parameters:
fieldKey- single string identifying metadata fieldquery- user's value to matchcollection- 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:
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, boolean externalInput)
- Specified by:
getMatchesin interfaceChoiceAuthorityService
-
getBestMatch
public Choices getBestMatch(String fieldKey, String query, Collection collection, String locale)
Description copied from interface:ChoiceAuthorityServiceWrapper that calls getBestMatch method of the plugin corresponding to the metadata field defined by single field key.- Specified by:
getBestMatchin interfaceChoiceAuthorityService- Parameters:
fieldKey- single string identifying metadata fieldquery- user's value to matchcollection- 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:
ChoiceAuthority.getBestMatch(java.lang.String, java.lang.String, org.dspace .content.Collection, java.lang.String)
-
getLabel
public String getLabel(MetadataValue metadataValue, String locale)
Description copied from interface:ChoiceAuthorityServiceWrapper that calls getLabel method of the plugin corresponding to the metadata field defined by schema,element,qualifier.- Specified by:
getLabelin interfaceChoiceAuthorityService- Parameters:
metadataValue- metadata valuelocale- explicit localization key if available- Returns:
- label
-
getLabel
public String getLabel(String fieldKey, String authKey, String locale)
Description copied from interface:ChoiceAuthorityServiceWrapper that calls getLabel method of the plugin corresponding to the metadata field defined by single field key.- Specified by:
getLabelin interfaceChoiceAuthorityService- Parameters:
fieldKey- single string identifying metadata fieldauthKey- authority keylocale- explicit localization key if available- Returns:
- label
-
isChoicesConfigured
public boolean isChoicesConfigured(String fieldKey)
Description copied from interface:ChoiceAuthorityServicePredicate, is there a Choices configuration of any kind for the given metadata field?- Specified by:
isChoicesConfiguredin interfaceChoiceAuthorityService- Parameters:
fieldKey- single string identifying metadata field- Returns:
- true if choices are configured for this field.
-
getPresentation
public String getPresentation(String fieldKey)
Description copied from interface:ChoiceAuthorityServiceGet 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:
getPresentationin interfaceChoiceAuthorityService- 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:ChoiceAuthorityServiceGet the configured "closed" value for this field.- Specified by:
isClosedin interfaceChoiceAuthorityService- Parameters:
fieldKey- single string identifying metadata field- Returns:
- true if choices are closed for this field.
-
getVariants
public List<String> getVariants(MetadataValue metadataValue)
Description copied from interface:ChoiceAuthorityServiceWrapper to call plugin's getVariants().- Specified by:
getVariantsin interfaceChoiceAuthorityService- Parameters:
metadataValue- metadata value- Returns:
- List of variants
-
getChoiceAuthorityName
public String getChoiceAuthorityName(String schema, String element, String qualifier)
- Specified by:
getChoiceAuthorityNamein interfaceChoiceAuthorityService- Parameters:
schema- schema of metadata fieldelement- element of metadata fieldqualifier- qualifier of metadata field- Returns:
- the name of the choice authority associated with the specified metadata. Throw IllegalArgumentException if the supplied metadat is not associated with an authority choice
-
clearCache
public void clearCache()
Description copied from interface:ChoiceAuthorityServiceThis method has been created to have a way of clearing the cache kept inside the service- Specified by:
clearCachein interfaceChoiceAuthorityService
-
getChoiceMetadatabyAuthorityName
public String getChoiceMetadatabyAuthorityName(String name)
- Specified by:
getChoiceMetadatabyAuthorityNamein interfaceChoiceAuthorityService
-
getChoice
public Choice getChoice(String fieldKey, String authKey, String locale)
- Specified by:
getChoicein interfaceChoiceAuthorityService
-
getChoiceAuthorityByAuthorityName
public ChoiceAuthority getChoiceAuthorityByAuthorityName(String authorityName)
- Specified by:
getChoiceAuthorityByAuthorityNamein interfaceChoiceAuthorityService
-
-