Class DictionaryDAOImpl

  • All Implemented Interfaces:
    java.util.EventListener, DictionaryDAO, NamespaceDAO, NamespacePrefixResolver, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>

    public class DictionaryDAOImpl
    extends java.lang.Object
    implements DictionaryDAO, NamespaceDAO, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
    Default implementation of the Dictionary.
    Author:
    David Caruana, janv, sglover
    • Constructor Detail

      • DictionaryDAOImpl

        public DictionaryDAOImpl()
        Construct
    • Method Detail

      • setTenantService

        public void setTenantService​(TenantService tenantService)
      • setDictionaryRegistryCache

        public void setDictionaryRegistryCache​(CompiledModelsCache dictionaryRegistryCache)
      • setDefaultAnalyserResourceBundleName

        public void setDefaultAnalyserResourceBundleName​(java.lang.String defaultAnalyserResourceBundleName)
      • 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 interface DictionaryDAO
      • 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 interface DictionaryDAO
      • 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 interface DictionaryDAO
      • 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 interface DictionaryDAO
        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 interface DictionaryDAO
        Parameters:
        model - the model to add
        Returns:
        QName name of model
      • getCompiledModel

        public CompiledModel getCompiledModel​(QName modelName)
        Parameters:
        modelName - the model name
        Returns:
        the compiled model of the given name
      • getDataTypes

        public java.util.Collection<DataTypeDefinition> getDataTypes​(QName modelName)
        Specified by:
        getDataTypes in interface DictionaryDAO
        Parameters:
        modelName - the model to retrieve property types for
        Returns:
        the property types of the model
      • getSubTypes

        public java.util.Collection<QName> getSubTypes​(QName superType,
                                                       boolean follow)
        Specified by:
        getSubTypes in interface DictionaryDAO
        Parameters:
        superType - QName
        follow - true => follow up the super-class hierarchy, false => immediate sub types only
      • getSubAspects

        public java.util.Collection<QName> getSubAspects​(QName superAspect,
                                                         boolean follow)
        Specified by:
        getSubAspects in interface DictionaryDAO
        Parameters:
        superAspect - QName
        follow - true => follow up the super-class hierarchy, false => immediate sub aspects only
      • getModels

        public java.util.Collection<QName> getModels​(boolean includeInherited)
        Specified by:
        getModels in interface DictionaryDAO
      • getModels

        public java.util.Collection<QName> getModels()
        Specified by:
        getModels in interface DictionaryDAO
        Returns:
        the models known by the dictionary
      • getTypes

        public java.util.Collection<QName> getTypes​(boolean includeInherited)
        Specified by:
        getTypes in interface DictionaryDAO
      • getAspects

        public java.util.Collection<QName> getAspects​(boolean includeInherited)
        Specified by:
        getAspects in interface DictionaryDAO
      • getTypes

        public java.util.Collection<TypeDefinition> getTypes​(QName modelName)
        Specified by:
        getTypes in interface DictionaryDAO
        Parameters:
        modelName - the model to retrieve types for
        Returns:
        the types of the model
      • getAspects

        public java.util.Collection<AspectDefinition> getAspects​(QName modelName)
        Specified by:
        getAspects in interface DictionaryDAO
        Parameters:
        modelName - the model to retrieve aspects for
        Returns:
        the aspects of the model
      • getAnonymousType

        public TypeDefinition getAnonymousType​(QName type,
                                               java.util.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 interface DictionaryDAO
        Parameters:
        type - the primary type
        aspects - the aspects to combine
        Returns:
        the anonymous type definition
      • getProperties

        public java.util.Collection<PropertyDefinition> getProperties​(QName modelName)
        Specified by:
        getProperties in interface DictionaryDAO
        Parameters:
        modelName - the model for which to get properties for
        Returns:
        the properties of the model
      • getProperties

        public java.util.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 interface DictionaryDAO
        Parameters:
        modelName - the name of the model
        dataType - null to get all properties
        Returns:
        the properties associated with the model
      • getNamespaces

        public java.util.Collection<NamespaceDefinition> getNamespaces​(QName modelName)
        Specified by:
        getNamespaces in interface DictionaryDAO
        Parameters:
        modelName - the model to retrieve namespaces for
        Returns:
        the namespaces of the model
      • getConstraints

        public java.util.Collection<ConstraintDefinition> getConstraints​(QName modelName)
        Specified by:
        getConstraints in interface DictionaryDAO
        Parameters:
        modelName - the model to retrieve constraint defs (including property constaint refs)
        Returns:
        the constraints of the model
      • getConstraints

        public java.util.Collection<ConstraintDefinition> getConstraints​(QName modelName,
                                                                         boolean referenceableDefsOnly)
        Specified by:
        getConstraints in interface DictionaryDAO
        Parameters:
        modelName - the model to retrieve constraint defs (optionally only referenceable constraints)
        Returns:
        the constraints of the model
      • initDictionaryRegistry

        public DictionaryRegistry initDictionaryRegistry​(java.lang.String tenantDomain)
        For cache use only.
        Parameters:
        tenantDomain - String
        Returns:
        constructed DictionaryRegistry
      • diffModel

        public java.util.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 interface DictionaryDAO
        Parameters:
        model - M2Model
        Returns:
        model diffs (if any)
      • diffModel

        public java.util.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 - M2Model
        enableConstraintClassLoading - boolean
        Returns:
        model diffs (if any)
      • setResourceClassLoader

        public void setResourceClassLoader​(java.lang.ClassLoader resourceClassLoader)
        Specified by:
        setResourceClassLoader in interface DictionaryDAO
        Parameters:
        resourceClassLoader - ClassLoader
      • getNamespaceURI

        public java.lang.String getNamespaceURI​(java.lang.String prefix)
        Description copied from interface: NamespacePrefixResolver
        Gets the namespace URI registered for the given prefix
        Specified by:
        getNamespaceURI in interface NamespacePrefixResolver
        Parameters:
        prefix - prefix to lookup
        Returns:
        the namespace
      • getPrefixes

        public java.util.Collection<java.lang.String> getPrefixes​(java.lang.String URI)
        Description copied from interface: NamespacePrefixResolver
        Gets the registered prefixes for the given namespace URI
        Specified by:
        getPrefixes in interface NamespacePrefixResolver
        Parameters:
        URI - namespace URI to lookup
        Returns:
        the prefixes (or empty collection, if no prefixes registered against URI)
      • addURI

        public void addURI​(java.lang.String uri)
        Description copied from interface: NamespaceDAO
        Add a namespace URI
        Specified by:
        addURI in interface NamespaceDAO
        Parameters:
        uri - the namespace uri to add
      • getPrefixes

        public java.util.Collection<java.lang.String> getPrefixes()
        Description copied from interface: NamespacePrefixResolver
        Gets all registered Prefixes
        Specified by:
        getPrefixes in interface NamespacePrefixResolver
        Returns:
        collection of all registered namespace prefixes
      • getURIs

        public java.util.Collection<java.lang.String> getURIs()
        Description copied from interface: NamespacePrefixResolver
        Gets all registered Uris
        Specified by:
        getURIs in interface NamespacePrefixResolver
        Returns:
        collection of all registered namespace uris
      • removeURI

        public void removeURI​(java.lang.String uri)
        Description copied from interface: NamespaceDAO
        Remove the specified URI
        Specified by:
        removeURI in interface NamespaceDAO
        Parameters:
        uri - the uri to remove
      • addPrefix

        public void addPrefix​(java.lang.String prefix,
                              java.lang.String uri)
        Description copied from interface: NamespaceDAO
        Add a namespace prefix
        Specified by:
        addPrefix in interface NamespaceDAO
        Parameters:
        prefix - the prefix
        uri - the uri to prefix
      • removePrefix

        public void removePrefix​(java.lang.String prefix)
        Description copied from interface: NamespaceDAO
        Remove a namspace prefix
        Specified by:
        removePrefix in interface NamespaceDAO
        Parameters:
        prefix - the prefix to remove
      • onApplicationEvent

        public void onApplicationEvent​(org.springframework.context.ApplicationEvent event)
        Specified by:
        onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>