Class CacheManager


  • public class CacheManager
    extends Object
    Manages the caching strategy
    Author:
    Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
    • Method Detail

      • getClass

        public ClassMetadata getClass​(String className)
        Tries to retrieve a cached class
        Parameters:
        className - the class to be retrieved from the cache
        Returns:
        the cached version of the class. Null if it's not cached
      • putClass

        public void putClass​(ClassMetadata newClass)
        Put/replaces an entry into the class cache
        Parameters:
        newClass -
      • removeClass

        public void removeClass​(String className)
        Remove a class from cache
        Parameters:
        className - The class name
      • putPossibleChildren

        public void putPossibleChildren​(String parent,
                                        List<ClassMetadata> children)
        Adds an entry to the possible children index
        Parameters:
        parent -
        children -
      • putPossibleSpecialChildren

        public void putPossibleSpecialChildren​(String parent,
                                               List<String> children)
        Adds an entry to the possible special children index
        Parameters:
        parent - The parent class
        children - the list of possible special children classes
      • putSubclasses

        public void putSubclasses​(String className,
                                  List<ClassMetadataLight> subClasses)
        Adds an entry to the subclasses index
        Parameters:
        className - the given class
        subClasses - the subclasses of the given class
      • putSubclassesNorecursive

        public void putSubclassesNorecursive​(String className,
                                             List<ClassMetadataLight> subClasses)
        Adds an entry to the subclasses index
        Parameters:
        className - the given class
        subClasses - the subclasses of the given class
      • putUniqueAttributeValueIndex

        public void putUniqueAttributeValueIndex​(String className,
                                                 String attributeName,
                                                 Object value)
        adds an entry for every unique attribute value of every class that has unique attributes
        Parameters:
        className - class name
        attributeName - attribute name
        value - new value of an unique attribute
      • putUniqueAttributeValuesIndex

        public void putUniqueAttributeValuesIndex​(String className,
                                                  String attributeName,
                                                  List<Object> values)
      • putPossibleChild

        public void putPossibleChild​(String parent,
                                     ClassMetadata child)
        Adds an entry to the possible children index
        Parameters:
        parent -
        child -
      • putPossibleSpecialChild

        public void putPossibleSpecialChild​(String parent,
                                            String child)
        Adds a single entry to the possible special children index
        Parameters:
        parent -
        child -
      • getPossibleSpecialChildren

        public List<String> getPossibleSpecialChildren​(String parent)
      • getUniqueAttributeValues

        public List<Object> getUniqueAttributeValues​(String className,
                                                     String attributeName)
      • getUser

        public UserProfile getUser​(String userName)
        Tries to retrieve a cached user
        Parameters:
        userName - the class to be retrieved from the cache
        Returns:
        the cached version of the class. Null if it's not cached
      • putUser

        public void putUser​(UserProfile newUser)
        Put/replaces an entry into the users cache
        Parameters:
        newUser - user to be added
      • getGroup

        public GroupProfile getGroup​(String groupName)
        Tries to retrieve a cached user
        Parameters:
        groupName - the class to be retrieved from the cache
        Returns:
        the cached version of the group. Null if it's not cached
      • putGroup

        public void putGroup​(GroupProfile newGroup)
        Put/replaces an entry into the group cache
        Parameters:
        newGroup - user to be added
      • removeUser

        public void removeUser​(String userName)
        Removes an entry into the users cache
        Parameters:
        userName -
      • removeGroup

        public void removeGroup​(String groupName)
        Removes an entry into the group cache
        Parameters:
        groupName -
      • removeUniqueAttribute

        public void removeUniqueAttribute​(String className,
                                          String attributeName)
      • removeUniqueAttributeValue

        public void removeUniqueAttributeValue​(String className,
                                               String attributeName,
                                               Object attributeValue)
      • getListType

        public GenericObjectList getListType​(String listTypeName)
        Tries to retrieve a cached list type
        Parameters:
        listTypeName - the list type to be retrieved from the cache
        Returns:
        the cached version of the group. Null if it's not cached
      • putListType

        public void putListType​(GenericObjectList newListType)
        Put/replaces an entry into the list type cache
        Parameters:
        newListType - list type to be added
      • removeListType

        public void removeListType​(String listTypeName)
        Removes an entry into the list type
        Parameters:
        listTypeName - list type to be deleted
      • addUpstreamClassHierarchy

        public void addUpstreamClassHierarchy​(String className,
                                              List<ClassMetadataLight> superClasses)
        Adds or replaces an entry in the upstream class hierarchy index.
        Parameters:
        className - The name of the class the provided class hierarchy belongs to.
        superClasses - The super classes of the given class (including itself)
      • getUpstreamClassHierarchy

        public List<ClassMetadataLight> getUpstreamClassHierarchy​(String className)
        Retrieves the cached upstream class hierarchy of a given class.
        Parameters:
        className - The name of the class.
        Returns:
        The list of cached super classes up to RootObject (including itself). Null of the class provided is not cached
      • addValidatorDefinitions

        public void addValidatorDefinitions​(String className,
                                            List<ValidatorDefinition> validatorDefinitions)
        Adds or replaces an entry in the validator definitions index.
        Parameters:
        className - The name of the class the provided class hierarchy belongs to.
        validatorDefinitions - The super classes of the given class (including itself)
      • getValidatorDefinitions

        public List<ValidatorDefinition> getValidatorDefinitions​(String className)
        Retrieves the cached validator definitions associated to the given class.
        Parameters:
        className - The name of the class.
        Returns:
        The list of cached validator definitions. Null of the class provided is not cached
      • clearValidatorDefinitionsCache

        public void clearValidatorDefinitionsCache()
        Clears the cached validator definitions
      • addFilterDefinition

        public void addFilterDefinition​(String className,
                                        FilterDefinition filterDefinition)
        Adds or replaces an entry of a single filter in all the filter definitions index for a class.
        Parameters:
        className - The name of the class
        filterDefinition - a filter definition for the class to be included in the cache
      • updateFilterInFilterDefinition

        public void updateFilterInFilterDefinition​(String className,
                                                   FilterDefinition filterDefinition)
        Updates or replaces the Filter of an entry in the filter definitions index. this happen when the script has changes an ins compiled again
        Parameters:
        className - The name of the class the provided class hierarchy belongs to.
        filterDefinition - the filter definition to update
      • getFilterDefinitionsForClass

        public List<FilterDefinition> getFilterDefinitionsForClass​(String className)
        Retrieves the cached filter definitions associated to the given class.
        Parameters:
        className - The name of the class.
        Returns:
        The list of cached filter definitions. Null of the class provided is not cached
      • getFilterDefinitionByClassNameAndFilterId

        public FilterDefinition getFilterDefinitionByClassNameAndFilterId​(String className,
                                                                          long filterId)
        Retrieves the cached filter definitions associated to the given class.
        Parameters:
        className - The name of the class.
        filterId - the filter definition id.
        Returns:
        The list of cached filter definitions. Null of the class provided is not cached
      • removeFilterDefinitionsForClass

        public void removeFilterDefinitionsForClass​(String className,
                                                    long filterId)
        Removes a cached filter definition
        Parameters:
        className - The name of the class.
        filterId - the filter definition id.
      • clearFiltersCache

        public void clearFiltersCache()
        Clears the cached filter definitions
      • addConfigurationValue

        public void addConfigurationValue​(String configVariableName,
                                          Object configVariableValue)
        Adds (or replaces) the value of a configuration variable.
        Parameters:
        configVariableName - The name of the configuration variable.
        configVariableValue - The value of the configuration value.
      • getConfigurationVariableValue

        public Object getConfigurationVariableValue​(String configVariableName)
        Gets the cached value of a configuration variable.
        Parameters:
        configVariableName - The name of the configuration variable.
        Returns:
        The value of the config variable, or null if it is not cached.
      • removeConfigurationVariableValue

        public void removeConfigurationVariableValue​(String configVariableName)
        Removes a cached value of a configuration variable (if present).
        Parameters:
        configVariableName - The name of the config variable.
      • clearAll

        public void clearAll()
        Clears all cached information
      • clearClassCache

        public void clearClassCache()
        Clears only the cached elements associated to the data model. Call it after performing any change in the class hierarchy of the property of the classes. Note that this method doesn't actually clears the main classIndex, only de dependencies, such as the possibleChildrenIndex, possibleSpecialChildrenIndex, subClassesIndex, subClassesNoRecursiveIndex and uniqueClassAttributesIndex
      • putCacheSlot

        public void putCacheSlot​(String cacheSlotName,
                                 Object content,
                                 int hoursOfValidity)