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 voidaddPrefix(String prefix, String uri)Add a namespace prefixvoidaddURI(String uri)Add a namespace URIvoiddestroy()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)TypeDefinitiongetAnonymousType(QName type, Collection<QName> aspects)Construct an anonymous type that combines a primary type definition and and one or more aspectsAspectDefinitiongetAspect(QName aspectName)Collection<QName>getAspects(boolean includeInherited)Collection<AspectDefinition>getAspects(QName modelName)AssociationDefinitiongetAssociation(QName assocName)Collection<QName>getAssociations(boolean includeInherited)Collection<AssociationDefinition>getAssociations(QName modelName)ClassDefinitiongetClass(QName className)CompiledModelgetCompiledModel(QName modelName)ConstraintDefinitiongetConstraint(QName constraintQName)Collection<ConstraintDefinition>getConstraints(QName modelName)Collection<ConstraintDefinition>getConstraints(QName modelName, boolean referenceableDefsOnly)DataTypeDefinitiongetDataType(Class javaClass)DataTypeDefinitiongetDataType(QName typeName)Collection<DataTypeDefinition>getDataTypes(QName modelName)StringgetDefaultAnalyserResourceBundleName()List<DictionaryListener>getDictionaryListeners()get DictionaryListener registered by calls to registerListenerDictionaryRegistrygetDictionaryRegistry(String tenantDomain)ModelDefinitiongetModel(QName name)Collection<QName>getModels()Collection<QName>getModels(boolean includeInherited)Collection<NamespaceDefinition>getNamespaces(QName modelName)StringgetNamespaceURI(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.PropertyDefinitiongetProperty(QName propertyName)ClassLoadergetResourceClassLoader()Collection<QName>getSubAspects(QName superAspect, boolean follow)Collection<QName>getSubTypes(QName superType, boolean follow)TypeDefinitiongetType(QName typeName)Collection<QName>getTypes(boolean includeInherited)Collection<TypeDefinition>getTypes(QName modelName)Collection<String>getURIs()Gets all registered Urisvoidinit()Initialise a reload of the dictionary for the current tenant.DictionaryRegistryinitDictionaryRegistry(String tenantDomain)For cache use only.booleanisContextRefreshed()booleanisModelInherited(QName modelName)voidonApplicationEvent(org.springframework.context.ApplicationEvent event)QNameputModel(M2Model model)Adds a model to the dictionary.QNameputModelIgnoringConstraints(M2Model model)Adds a model to the dictionary.voidregister(DictionaryListener dictionaryListener)Deprecated.voidregisterListener(DictionaryListener dictionaryListener)Register with the DictionaryvoidremoveModel(QName modelName)Removes a model from the dictionary.voidremovePrefix(String prefix)Remove a namspace prefixvoidremoveURI(String uri)Remove the specified URIvoidreset()Reset the Dictionary for the current tenant.voidsetDefaultAnalyserResourceBundleName(String defaultAnalyserResourceBundleName)voidsetDictionaryRegistryCache(CompiledModelsCache dictionaryRegistryCache)voidsetResourceClassLoader(ClassLoader resourceClassLoader)voidsetTenantService(TenantService tenantService)
-
-
-
Method Detail
-
setTenantService
public void setTenantService(TenantService tenantService)
-
setDictionaryRegistryCache
public void setDictionaryRegistryCache(CompiledModelsCache dictionaryRegistryCache)
-
getDefaultAnalyserResourceBundleName
public String getDefaultAnalyserResourceBundleName()
- Specified by:
getDefaultAnalyserResourceBundleNamein 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:
registerin interfaceDictionaryDAO- Parameters:
dictionaryListener-
-
registerListener
public void registerListener(DictionaryListener dictionaryListener)
Register with the Dictionary- Specified by:
registerListenerin interfaceDictionaryDAO- Parameters:
dictionaryListener- DictionaryListener
-
getDictionaryListeners
public List<DictionaryListener> getDictionaryListeners()
Description copied from interface:DictionaryDAOget DictionaryListener registered by calls to registerListener- Specified by:
getDictionaryListenersin interfaceDictionaryDAO- Returns:
- read only list of dictionary listeners
- See Also:
DictionaryListener
-
init
public void init()
Description copied from interface:DictionaryDAOInitialise 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:
initin interfaceDictionaryDAO
-
destroy
public void destroy()
Description copied from interface:DictionaryDAODestroy 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:
destroyin interfaceDictionaryDAO
-
reset
public void reset()
Description copied from interface:DictionaryDAOReset 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:
resetin interfaceDictionaryDAO
-
putModel
public QName putModel(M2Model model)
Description copied from interface:DictionaryDAOAdds a model to the dictionary. The model is compiled and validated.- Specified by:
putModelin interfaceDictionaryDAO- Parameters:
model- the model to add- Returns:
- QName name of model
-
putModelIgnoringConstraints
public QName putModelIgnoringConstraints(M2Model model)
Description copied from interface:DictionaryDAOAdds 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:
putModelIgnoringConstraintsin interfaceDictionaryDAO- Parameters:
model- the model to add- Returns:
- QName name of model
-
removeModel
public void removeModel(QName modelName)
Description copied from interface:DictionaryDAORemoves a model from the dictionary. The types and aspect in the model will no longer be available.- Specified by:
removeModelin 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:
getDataTypesin 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:
getSubTypesin 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:
getSubAspectsin 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:
getAssociationsin interfaceDictionaryDAO- Parameters:
modelName- the model to retrieve associations for- Returns:
- the associations of the model
-
getModels
public Collection<QName> getModels(boolean includeInherited)
- Specified by:
getModelsin interfaceDictionaryDAO
-
getModels
public Collection<QName> getModels()
- Specified by:
getModelsin interfaceDictionaryDAO- Returns:
- the models known by the dictionary
-
getTypes
public Collection<QName> getTypes(boolean includeInherited)
- Specified by:
getTypesin interfaceDictionaryDAO
-
getAssociations
public Collection<QName> getAssociations(boolean includeInherited)
- Specified by:
getAssociationsin interfaceDictionaryDAO
-
getAspects
public Collection<QName> getAspects(boolean includeInherited)
- Specified by:
getAspectsin interfaceDictionaryDAO
-
isModelInherited
public boolean isModelInherited(QName modelName)
- Specified by:
isModelInheritedin interfaceDictionaryDAO
-
getModel
public ModelDefinition getModel(QName name)
- Specified by:
getModelin interfaceDictionaryDAO- Parameters:
name- the model to retrieve- Returns:
- the named model definition
-
getTypes
public Collection<TypeDefinition> getTypes(QName modelName)
- Specified by:
getTypesin interfaceDictionaryDAO- Parameters:
modelName- the model to retrieve types for- Returns:
- the types of the model
-
getAspects
public Collection<AspectDefinition> getAspects(QName modelName)
- Specified by:
getAspectsin 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:DictionaryDAOConstruct an anonymous type that combines a primary type definition and and one or more aspects- Specified by:
getAnonymousTypein interfaceDictionaryDAO- Parameters:
type- the primary typeaspects- the aspects to combine- Returns:
- the anonymous type definition
-
getProperties
public Collection<PropertyDefinition> getProperties(QName modelName)
- Specified by:
getPropertiesin 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:DictionaryDAOGet 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:
getPropertiesin 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:DictionaryDAOGet all properties for all models of the given data type.- Specified by:
getPropertiesOfDataTypein interfaceDictionaryDAO- Parameters:
dataType- QName
-
getNamespaces
public Collection<NamespaceDefinition> getNamespaces(QName modelName)
- Specified by:
getNamespacesin interfaceDictionaryDAO- Parameters:
modelName- the model to retrieve namespaces for- Returns:
- the namespaces of the model
-
getConstraints
public Collection<ConstraintDefinition> getConstraints(QName modelName)
- Specified by:
getConstraintsin 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:
getConstraintsin 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:
getDictionaryRegistryin 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:
diffModelin interfaceDictionaryDAO- Parameters:
model- M2Model- Returns:
- model diffs (if any)
-
diffModelIgnoringConstraints
public List<M2ModelDiff> diffModelIgnoringConstraints(M2Model model)
- Specified by:
diffModelIgnoringConstraintsin 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:
getResourceClassLoaderin interfaceDictionaryDAO- Returns:
- ClassLoader
-
setResourceClassLoader
public void setResourceClassLoader(ClassLoader resourceClassLoader)
- Specified by:
setResourceClassLoaderin interfaceDictionaryDAO- Parameters:
resourceClassLoader- ClassLoader
-
getNamespaceURI
public String getNamespaceURI(String prefix)
Description copied from interface:NamespacePrefixResolverGets the namespace URI registered for the given prefix- Specified by:
getNamespaceURIin interfaceNamespacePrefixResolver- Parameters:
prefix- prefix to lookup- Returns:
- the namespace
-
getPrefixes
public Collection<String> getPrefixes(String URI)
Description copied from interface:NamespacePrefixResolverGets the registered prefixes for the given namespace URI- Specified by:
getPrefixesin 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:NamespaceDAOAdd a namespace URI- Specified by:
addURIin interfaceNamespaceDAO- Parameters:
uri- the namespace uri to add
-
getPrefixes
public Collection<String> getPrefixes()
Description copied from interface:NamespacePrefixResolverGets all registered Prefixes- Specified by:
getPrefixesin interfaceNamespacePrefixResolver- Returns:
- collection of all registered namespace prefixes
-
getURIs
public Collection<String> getURIs()
Description copied from interface:NamespacePrefixResolverGets all registered Uris- Specified by:
getURIsin interfaceNamespacePrefixResolver- Returns:
- collection of all registered namespace uris
-
removeURI
public void removeURI(String uri)
Description copied from interface:NamespaceDAORemove the specified URI- Specified by:
removeURIin interfaceNamespaceDAO- Parameters:
uri- the uri to remove
-
addPrefix
public void addPrefix(String prefix, String uri)
Description copied from interface:NamespaceDAOAdd a namespace prefix- Specified by:
addPrefixin interfaceNamespaceDAO- Parameters:
prefix- the prefixuri- the uri to prefix
-
removePrefix
public void removePrefix(String prefix)
Description copied from interface:NamespaceDAORemove a namspace prefix- Specified by:
removePrefixin interfaceNamespaceDAO- Parameters:
prefix- the prefix to remove
-
isContextRefreshed
public boolean isContextRefreshed()
- Specified by:
isContextRefreshedin interfaceDictionaryDAO
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
-
-