Package org.alfresco.repo.dictionary
Class DictionaryDAOImpl
java.lang.Object
org.alfresco.repo.dictionary.DictionaryDAOImpl
- All Implemented Interfaces:
EventListener
,DictionaryDAO
,NamespaceDAO
,NamespacePrefixResolver
,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
public class DictionaryDAOImpl
extends Object
implements DictionaryDAO, NamespaceDAO, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
Default implementation of the Dictionary.
- Author:
- David Caruana, janv, sglover
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a namespace prefixvoid
Add a namespace URIvoid
destroy()
Destroy the Dictionary.Return diffs between input model and model in the Dictionary.Return diffs between input model and model in the Dictionary.getAnonymousType
(QName type, Collection<QName> aspects) Construct an anonymous type that combines a primary type definition and and one or more aspectsgetAspects
(boolean includeInherited) getAspects
(QName modelName) getAssociation
(QName assocName) getAssociations
(boolean includeInherited) getAssociations
(QName modelName) getCompiledModel
(QName modelName) getConstraint
(QName constraintQName) getConstraints
(QName modelName) getConstraints
(QName modelName, boolean referenceableDefsOnly) getDataType
(Class javaClass) getDataType
(QName typeName) getDataTypes
(QName modelName) get DictionaryListener registered by calls to registerListenergetDictionaryRegistry
(String tenantDomain) getModels
(boolean includeInherited) getNamespaces
(QName modelName) getNamespaceURI
(String prefix) Gets the namespace URI registered for the given prefixGets all registered PrefixesgetPrefixes
(String URI) Gets the registered prefixes for the given namespace URIgetProperties
(QName modelName) getProperties
(QName modelName, QName dataType) Get all properties for the model and that are of the given data type.getPropertiesOfDataType
(QName dataType) Get all properties for all models of the given data type.getProperty
(QName propertyName) getSubAspects
(QName superAspect, boolean follow) getSubTypes
(QName superType, boolean follow) getTypes
(boolean includeInherited) getURIs()
Gets all registered Urisvoid
init()
Initialise a reload of the dictionary for the current tenant.initDictionaryRegistry
(String tenantDomain) For cache use only.boolean
boolean
isModelInherited
(QName modelName) void
onApplicationEvent
(org.springframework.context.ApplicationEvent event) Adds a model to the dictionary.Adds a model to the dictionary.void
register
(DictionaryListener dictionaryListener) Deprecated.void
registerListener
(DictionaryListener dictionaryListener) Register with the Dictionaryvoid
removeModel
(QName modelName) Removes a model from the dictionary.void
removePrefix
(String prefix) Remove a namspace prefixvoid
Remove the specified URIvoid
reset()
Reset the Dictionary for the current tenant.void
setDictionaryRegistryCache
(CompiledModelsCache dictionaryRegistryCache) void
setResourceClassLoader
(ClassLoader resourceClassLoader) void
setTenantService
(TenantService tenantService)
-
Constructor Details
-
DictionaryDAOImpl
public DictionaryDAOImpl()Construct
-
-
Method Details
-
setTenantService
-
setDictionaryRegistryCache
-
register
Deprecated.Register listener with the DictionaryThis method is deprecated, use
registerListener(DictionaryListener dictionaryListener)
instead.- Specified by:
register
in interfaceDictionaryDAO
- Parameters:
dictionaryListener
-
-
registerListener
Register with the Dictionary- Specified by:
registerListener
in interfaceDictionaryDAO
- Parameters:
dictionaryListener
- DictionaryListener
-
getDictionaryListeners
Description copied from interface:DictionaryDAO
get DictionaryListener registered by calls to registerListener- Specified by:
getDictionaryListeners
in interfaceDictionaryDAO
- Returns:
- read only list of dictionary listeners
- See Also:
-
init
public void init()Description copied from interface:DictionaryDAO
Initialise a reload of the dictionary for the current tenant. The current version of the dictionary will be accessible during this call, however it will only return once the dictionary has undergone a reload for the current tenant.- Specified by:
init
in interfaceDictionaryDAO
-
destroy
public void destroy()Description copied from interface:DictionaryDAO
Destroy the Dictionary. After this call, there will be no dictionary available for the current tenant; reloading will be done lazily as required.WARNING: This method can cause 'stutter' on user threads as they wait for the dictionary to reload. It is safer to call
DictionaryDAO.init()
, which will also rebuild the dictionary but will not destroy the old one, thereby allowing other threads to continue operating.- Specified by:
destroy
in interfaceDictionaryDAO
-
reset
public void reset()Description copied from interface:DictionaryDAO
Reset the Dictionary for the current tenant. The current dictionary will be discarded and reloaded before the method returns i.e. upon return the dictionary will be current.- Specified by:
reset
in interfaceDictionaryDAO
-
putModel
Description copied from interface:DictionaryDAO
Adds a model to the dictionary. The model is compiled and validated.- Specified by:
putModel
in interfaceDictionaryDAO
- Parameters:
model
- the model to add- Returns:
- QName name of model
-
putModelIgnoringConstraints
Description copied from interface:DictionaryDAO
Adds a model to the dictionary. The model is compiled and validated. Constraints are not loaded. This method should only be used to load models where the enforcement of constraints is never required. For example, SOLR read only use of the index where contraints are not required and thier definitions may not be available.- Specified by:
putModelIgnoringConstraints
in interfaceDictionaryDAO
- Parameters:
model
- the model to add- Returns:
- QName name of model
-
removeModel
Description copied from interface:DictionaryDAO
Removes a model from the dictionary. The types and aspect in the model will no longer be available.- Specified by:
removeModel
in interfaceDictionaryDAO
- Parameters:
modelName
- the qname of the model to remove- See Also:
-
getCompiledModel
- Parameters:
modelName
- the model name- Returns:
- the compiled model of the given name
-
getDataType
-
getDataType
-
getDataTypes
- Specified by:
getDataTypes
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve property types for- Returns:
- the property types of the model
-
getType
-
getSubTypes
- Specified by:
getSubTypes
in interfaceDictionaryDAO
- Parameters:
superType
- QNamefollow
- true => follow up the super-class hierarchy, false => immediate sub types only
-
getAspect
-
getSubAspects
- Specified by:
getSubAspects
in interfaceDictionaryDAO
- Parameters:
superAspect
- QNamefollow
- true => follow up the super-class hierarchy, false => immediate sub aspects only
-
getClass
-
getProperty
-
getConstraint
-
getAssociation
-
getAssociations
- Specified by:
getAssociations
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve associations for- Returns:
- the associations of the model
-
getModels
- Specified by:
getModels
in interfaceDictionaryDAO
-
getModels
- Specified by:
getModels
in interfaceDictionaryDAO
- Returns:
- the models known by the dictionary
-
getTypes
- Specified by:
getTypes
in interfaceDictionaryDAO
-
getAssociations
- Specified by:
getAssociations
in interfaceDictionaryDAO
-
getAspects
- Specified by:
getAspects
in interfaceDictionaryDAO
-
isModelInherited
- Specified by:
isModelInherited
in interfaceDictionaryDAO
-
getModel
- Specified by:
getModel
in interfaceDictionaryDAO
- Parameters:
name
- the model to retrieve- Returns:
- the named model definition
-
getTypes
- Specified by:
getTypes
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve types for- Returns:
- the types of the model
-
getAspects
- Specified by:
getAspects
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve aspects for- Returns:
- the aspects of the model
-
getAnonymousType
Description copied from interface:DictionaryDAO
Construct an anonymous type that combines a primary type definition and and one or more aspects- Specified by:
getAnonymousType
in interfaceDictionaryDAO
- Parameters:
type
- the primary typeaspects
- the aspects to combine- Returns:
- the anonymous type definition
-
getProperties
- Specified by:
getProperties
in interfaceDictionaryDAO
- Parameters:
modelName
- the model for which to get properties for- Returns:
- the properties of the model
-
getProperties
Description copied from interface:DictionaryDAO
Get all properties for the model and that are of the given data type. If dataType is null then the all properties will be returned.- Specified by:
getProperties
in interfaceDictionaryDAO
- Parameters:
modelName
- the name of the modeldataType
- null to get all properties- Returns:
- the properties associated with the model
-
getPropertiesOfDataType
Description copied from interface:DictionaryDAO
Get all properties for all models of the given data type.- Specified by:
getPropertiesOfDataType
in interfaceDictionaryDAO
- Parameters:
dataType
- QName
-
getNamespaces
- Specified by:
getNamespaces
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve namespaces for- Returns:
- the namespaces of the model
-
getConstraints
- Specified by:
getConstraints
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve constraint defs (including property constaint refs)- Returns:
- the constraints of the model
-
getConstraints
public Collection<ConstraintDefinition> getConstraints(QName modelName, boolean referenceableDefsOnly) - Specified by:
getConstraints
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve constraint defs (optionally only referenceable constraints)- Returns:
- the constraints of the model
-
getDictionaryRegistry
- Specified by:
getDictionaryRegistry
in interfaceDictionaryDAO
-
initDictionaryRegistry
For cache use only.- Parameters:
tenantDomain
- String- Returns:
- constructed DictionaryRegistry
-
diffModel
Return diffs between input model and model in the Dictionary. If the input model does not exist in the Dictionary then no diffs will be returned.- Specified by:
diffModel
in interfaceDictionaryDAO
- Parameters:
model
- M2Model- Returns:
- model diffs (if any)
-
diffModelIgnoringConstraints
- Specified by:
diffModelIgnoringConstraints
in interfaceDictionaryDAO
-
diffModel
Return diffs between input model and model in the Dictionary. If the input model does not exist in the Dictionary then no diffs will be returned.- Parameters:
model
- M2ModelenableConstraintClassLoading
- boolean- Returns:
- model diffs (if any)
-
getResourceClassLoader
- Specified by:
getResourceClassLoader
in interfaceDictionaryDAO
- Returns:
- ClassLoader
-
setResourceClassLoader
- Specified by:
setResourceClassLoader
in interfaceDictionaryDAO
- Parameters:
resourceClassLoader
- ClassLoader
-
getNamespaceURI
Description copied from interface:NamespacePrefixResolver
Gets the namespace URI registered for the given prefix- Specified by:
getNamespaceURI
in interfaceNamespacePrefixResolver
- Parameters:
prefix
- prefix to lookup- Returns:
- the namespace
-
getPrefixes
Description copied from interface:NamespacePrefixResolver
Gets the registered prefixes for the given namespace URI- Specified by:
getPrefixes
in interfaceNamespacePrefixResolver
- Parameters:
URI
- namespace URI to lookup- Returns:
- the prefixes (or empty collection, if no prefixes registered against URI)
-
addURI
Description copied from interface:NamespaceDAO
Add a namespace URI- Specified by:
addURI
in interfaceNamespaceDAO
- Parameters:
uri
- the namespace uri to add
-
getPrefixes
Description copied from interface:NamespacePrefixResolver
Gets all registered Prefixes- Specified by:
getPrefixes
in interfaceNamespacePrefixResolver
- Returns:
- collection of all registered namespace prefixes
-
getURIs
Description copied from interface:NamespacePrefixResolver
Gets all registered Uris- Specified by:
getURIs
in interfaceNamespacePrefixResolver
- Returns:
- collection of all registered namespace uris
-
removeURI
Description copied from interface:NamespaceDAO
Remove the specified URI- Specified by:
removeURI
in interfaceNamespaceDAO
- Parameters:
uri
- the uri to remove
-
addPrefix
Description copied from interface:NamespaceDAO
Add a namespace prefix- Specified by:
addPrefix
in interfaceNamespaceDAO
- Parameters:
prefix
- the prefixuri
- the uri to prefix
-
removePrefix
Description copied from interface:NamespaceDAO
Remove a namspace prefix- Specified by:
removePrefix
in interfaceNamespaceDAO
- Parameters:
prefix
- the prefix to remove
-
isContextRefreshed
public boolean isContextRefreshed()- Specified by:
isContextRefreshed
in interfaceDictionaryDAO
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event) - Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
-