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 Constructor Description DictionaryDAOImpl()
Construct
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addPrefix(String prefix, String uri)
Add a namespace prefixvoid
addURI(String uri)
Add a namespace URIvoid
destroy()
Destroy the Dictionary.List<M2ModelDiff>
diffModel(M2Model model)
Return diffs between input model and model in the Dictionary.List<M2ModelDiff>
diffModel(M2Model model, boolean enableConstraintClassLoading)
Return diffs between input model and model in the Dictionary.List<M2ModelDiff>
diffModelIgnoringConstraints(M2Model model)
TypeDefinition
getAnonymousType(QName type, Collection<QName> aspects)
Construct an anonymous type that combines a primary type definition and and one or more aspectsAspectDefinition
getAspect(QName aspectName)
Collection<QName>
getAspects(boolean includeInherited)
Collection<AspectDefinition>
getAspects(QName modelName)
AssociationDefinition
getAssociation(QName assocName)
Collection<QName>
getAssociations(boolean includeInherited)
Collection<AssociationDefinition>
getAssociations(QName modelName)
ClassDefinition
getClass(QName className)
CompiledModel
getCompiledModel(QName modelName)
ConstraintDefinition
getConstraint(QName constraintQName)
Collection<ConstraintDefinition>
getConstraints(QName modelName)
Collection<ConstraintDefinition>
getConstraints(QName modelName, boolean referenceableDefsOnly)
DataTypeDefinition
getDataType(Class javaClass)
DataTypeDefinition
getDataType(QName typeName)
Collection<DataTypeDefinition>
getDataTypes(QName modelName)
String
getDefaultAnalyserResourceBundleName()
List<DictionaryListener>
getDictionaryListeners()
get DictionaryListener registered by calls to registerListenerDictionaryRegistry
getDictionaryRegistry(String tenantDomain)
ModelDefinition
getModel(QName name)
Collection<QName>
getModels()
Collection<QName>
getModels(boolean includeInherited)
Collection<NamespaceDefinition>
getNamespaces(QName modelName)
String
getNamespaceURI(String prefix)
Gets the namespace URI registered for the given prefixCollection<String>
getPrefixes()
Gets all registered PrefixesCollection<String>
getPrefixes(String URI)
Gets the registered prefixes for the given namespace URICollection<PropertyDefinition>
getProperties(QName modelName)
Collection<PropertyDefinition>
getProperties(QName modelName, QName dataType)
Get all properties for the model and that are of the given data type.Collection<PropertyDefinition>
getPropertiesOfDataType(QName dataType)
Get all properties for all models of the given data type.PropertyDefinition
getProperty(QName propertyName)
ClassLoader
getResourceClassLoader()
Collection<QName>
getSubAspects(QName superAspect, boolean follow)
Collection<QName>
getSubTypes(QName superType, boolean follow)
TypeDefinition
getType(QName typeName)
Collection<QName>
getTypes(boolean includeInherited)
Collection<TypeDefinition>
getTypes(QName modelName)
Collection<String>
getURIs()
Gets all registered Urisvoid
init()
Initialise a reload of the dictionary for the current tenant.DictionaryRegistry
initDictionaryRegistry(String tenantDomain)
For cache use only.boolean
isContextRefreshed()
boolean
isModelInherited(QName modelName)
void
onApplicationEvent(org.springframework.context.ApplicationEvent event)
QName
putModel(M2Model model)
Adds a model to the dictionary.QName
putModelIgnoringConstraints(M2Model model)
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
removeURI(String uri)
Remove the specified URIvoid
reset()
Reset the Dictionary for the current tenant.void
setDefaultAnalyserResourceBundleName(String defaultAnalyserResourceBundleName)
void
setDictionaryRegistryCache(CompiledModelsCache dictionaryRegistryCache)
void
setResourceClassLoader(ClassLoader resourceClassLoader)
void
setTenantService(TenantService tenantService)
-
-
-
Method Detail
-
setTenantService
public void setTenantService(TenantService tenantService)
-
setDictionaryRegistryCache
public void setDictionaryRegistryCache(CompiledModelsCache dictionaryRegistryCache)
-
getDefaultAnalyserResourceBundleName
public String getDefaultAnalyserResourceBundleName()
- Specified by:
getDefaultAnalyserResourceBundleName
in interfaceDictionaryDAO
- Returns:
- String
-
setDefaultAnalyserResourceBundleName
public void setDefaultAnalyserResourceBundleName(String defaultAnalyserResourceBundleName)
-
register
@Deprecated public void register(DictionaryListener dictionaryListener)
Deprecated.Register listener with the DictionaryThis method is deprecated, use
registerListener(DictionaryListener dictionaryListener)
instead.- Specified by:
register
in interfaceDictionaryDAO
- Parameters:
dictionaryListener
-
-
registerListener
public void registerListener(DictionaryListener dictionaryListener)
Register with the Dictionary- Specified by:
registerListener
in interfaceDictionaryDAO
- Parameters:
dictionaryListener
- DictionaryListener
-
getDictionaryListeners
public List<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:
DictionaryListener
-
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
public QName putModel(M2Model model)
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
public QName putModelIgnoringConstraints(M2Model model)
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
public void removeModel(QName modelName)
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:
DictionaryDAO.removeModel(org.alfresco.service.namespace.QName)
-
getCompiledModel
public CompiledModel getCompiledModel(QName modelName)
- Parameters:
modelName
- the model name- Returns:
- the compiled model of the given name
-
getDataType
public DataTypeDefinition getDataType(QName typeName)
-
getDataType
public DataTypeDefinition getDataType(Class javaClass)
-
getDataTypes
public Collection<DataTypeDefinition> getDataTypes(QName modelName)
- Specified by:
getDataTypes
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve property types for- Returns:
- the property types of the model
-
getType
public TypeDefinition getType(QName typeName)
-
getSubTypes
public Collection<QName> getSubTypes(QName superType, boolean follow)
- Specified by:
getSubTypes
in interfaceDictionaryDAO
- Parameters:
superType
- QNamefollow
- true => follow up the super-class hierarchy, false => immediate sub types only
-
getAspect
public AspectDefinition getAspect(QName aspectName)
-
getSubAspects
public Collection<QName> getSubAspects(QName superAspect, boolean follow)
- Specified by:
getSubAspects
in interfaceDictionaryDAO
- Parameters:
superAspect
- QNamefollow
- true => follow up the super-class hierarchy, false => immediate sub aspects only
-
getClass
public ClassDefinition getClass(QName className)
-
getProperty
public PropertyDefinition getProperty(QName propertyName)
-
getConstraint
public ConstraintDefinition getConstraint(QName constraintQName)
-
getAssociation
public AssociationDefinition getAssociation(QName assocName)
-
getAssociations
public Collection<AssociationDefinition> getAssociations(QName modelName)
- Specified by:
getAssociations
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve associations for- Returns:
- the associations of the model
-
getModels
public Collection<QName> getModels(boolean includeInherited)
- Specified by:
getModels
in interfaceDictionaryDAO
-
getModels
public Collection<QName> getModels()
- Specified by:
getModels
in interfaceDictionaryDAO
- Returns:
- the models known by the dictionary
-
getTypes
public Collection<QName> getTypes(boolean includeInherited)
- Specified by:
getTypes
in interfaceDictionaryDAO
-
getAssociations
public Collection<QName> getAssociations(boolean includeInherited)
- Specified by:
getAssociations
in interfaceDictionaryDAO
-
getAspects
public Collection<QName> getAspects(boolean includeInherited)
- Specified by:
getAspects
in interfaceDictionaryDAO
-
isModelInherited
public boolean isModelInherited(QName modelName)
- Specified by:
isModelInherited
in interfaceDictionaryDAO
-
getModel
public ModelDefinition getModel(QName name)
- Specified by:
getModel
in interfaceDictionaryDAO
- Parameters:
name
- the model to retrieve- Returns:
- the named model definition
-
getTypes
public Collection<TypeDefinition> getTypes(QName modelName)
- Specified by:
getTypes
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve types for- Returns:
- the types of the model
-
getAspects
public Collection<AspectDefinition> getAspects(QName modelName)
- Specified by:
getAspects
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve aspects for- Returns:
- the aspects of the model
-
getAnonymousType
public TypeDefinition getAnonymousType(QName type, Collection<QName> aspects)
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
public Collection<PropertyDefinition> getProperties(QName modelName)
- Specified by:
getProperties
in interfaceDictionaryDAO
- Parameters:
modelName
- the model for which to get properties for- Returns:
- the properties of the model
-
getProperties
public Collection<PropertyDefinition> getProperties(QName modelName, QName dataType)
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
public Collection<PropertyDefinition> getPropertiesOfDataType(QName dataType)
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
public Collection<NamespaceDefinition> getNamespaces(QName modelName)
- Specified by:
getNamespaces
in interfaceDictionaryDAO
- Parameters:
modelName
- the model to retrieve namespaces for- Returns:
- the namespaces of the model
-
getConstraints
public Collection<ConstraintDefinition> getConstraints(QName modelName)
- 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
public DictionaryRegistry getDictionaryRegistry(String tenantDomain)
- Specified by:
getDictionaryRegistry
in interfaceDictionaryDAO
-
initDictionaryRegistry
public DictionaryRegistry initDictionaryRegistry(String tenantDomain)
For cache use only.- Parameters:
tenantDomain
- String- Returns:
- constructed DictionaryRegistry
-
diffModel
public List<M2ModelDiff> diffModel(M2Model model)
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
public List<M2ModelDiff> diffModelIgnoringConstraints(M2Model model)
- Specified by:
diffModelIgnoringConstraints
in interfaceDictionaryDAO
-
diffModel
public List<M2ModelDiff> diffModel(M2Model model, boolean enableConstraintClassLoading)
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
public ClassLoader getResourceClassLoader()
- Specified by:
getResourceClassLoader
in interfaceDictionaryDAO
- Returns:
- ClassLoader
-
setResourceClassLoader
public void setResourceClassLoader(ClassLoader resourceClassLoader)
- Specified by:
setResourceClassLoader
in interfaceDictionaryDAO
- Parameters:
resourceClassLoader
- ClassLoader
-
getNamespaceURI
public String getNamespaceURI(String prefix)
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
public Collection<String> getPrefixes(String URI)
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
public void addURI(String uri)
Description copied from interface:NamespaceDAO
Add a namespace URI- Specified by:
addURI
in interfaceNamespaceDAO
- Parameters:
uri
- the namespace uri to add
-
getPrefixes
public Collection<String> getPrefixes()
Description copied from interface:NamespacePrefixResolver
Gets all registered Prefixes- Specified by:
getPrefixes
in interfaceNamespacePrefixResolver
- Returns:
- collection of all registered namespace prefixes
-
getURIs
public Collection<String> getURIs()
Description copied from interface:NamespacePrefixResolver
Gets all registered Uris- Specified by:
getURIs
in interfaceNamespacePrefixResolver
- Returns:
- collection of all registered namespace uris
-
removeURI
public void removeURI(String uri)
Description copied from interface:NamespaceDAO
Remove the specified URI- Specified by:
removeURI
in interfaceNamespaceDAO
- Parameters:
uri
- the uri to remove
-
addPrefix
public void addPrefix(String prefix, String uri)
Description copied from interface:NamespaceDAO
Add a namespace prefix- Specified by:
addPrefix
in interfaceNamespaceDAO
- Parameters:
prefix
- the prefixuri
- the uri to prefix
-
removePrefix
public void removePrefix(String prefix)
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>
-
-