Class PersistentCache

java.lang.Object
net.aifusion.metamodel.InMemoryCache
net.aifusion.metamodel.PersistentCache
All Implemented Interfaces:
Repository

public class PersistentCache extends InMemoryCache
Class to implement a persistent repository that supports multiple name spaces
Author:
Sharad Singhal
  • Constructor Details

    • PersistentCache

      public PersistentCache(String repositoryLocation)
      Create a persistent repository using the file system
      Parameters:
      repositoryLocation - - file system root of the repository i.e., /user/repository
  • Method Details

    • getNameSpaces

      public List<NameSpacePath> getNameSpaces()
      Description copied from interface: Repository
      Get a list of all name spaces known to this repository. Note that because implementations can add or remove name spaces as elements are added or deleted, this list may not be complete, and depends on the repository implementation
      Specified by:
      getNameSpaces in interface Repository
      Overrides:
      getNameSpaces in class InMemoryCache
      Returns:
      - list of name spaces
    • put

      public boolean put(NamedElement element)
      Description copied from interface: Repository
      Put a named element into the repository
      Specified by:
      put in interface Repository
      Overrides:
      put in class InMemoryCache
      Parameters:
      element - - element to be added
      Returns:
      - true if successfully added, false otherwise
    • get

      public NamedElement get(ObjectPath path)
      Description copied from interface: Repository
      Get a named element from the repository
      Specified by:
      get in interface Repository
      Overrides:
      get in class InMemoryCache
      Parameters:
      path - - object path corresponding to the named element
      Returns:
      - Named Element corresponding to the element. Null returned if no such element exists in the repository
    • contains

      public boolean contains(ObjectPath path)
      Description copied from interface: Repository
      Check if a named element exists in the repository
      Specified by:
      contains in interface Repository
      Overrides:
      contains in class InMemoryCache
      Parameters:
      path - - object path corresponding to the named element
      Returns:
      - true if the path exists in the repository, false otherwise
    • delete

      public boolean delete(ObjectPath path)
      Description copied from interface: Repository
      Delete a named element from the repository
      Specified by:
      delete in interface Repository
      Overrides:
      delete in class InMemoryCache
      Parameters:
      path - - object path corresponding to the named element
      Returns:
      - true if deletion succeeded, false otherwise
    • getElements

      public List<NamedElement> getElements(String elementTypes, String localNameSpaces, String elementNames, boolean locateSubTypes)
      Get elements from this repository. Note that depending on the size of the repository, this method can be very expensive in time and/or memory. This method directly accesses the persistent store, and does not cache the results in the in-memory cache
      Specified by:
      getElements in interface Repository
      Overrides:
      getElements in class InMemoryCache
      Parameters:
      elementTypes - - Optional comma separated list of element types to retrieve. Must be a NamedElement (Instance, Class, QualifierType, Structure, structurevalue, Interface or enumeration). Null will select all element types.
      localNameSpaces - - Optional comma separated list of local namespaces to search. A null will retrieve elements from all namespaces
      elementNames - - Optional comma-separated list of element names to retrieve. A null will retrieve all elements of the given type
      locateSubTypes - - if true, also retrieve subtypes of the requested element types
      Returns:
      list of elements that match the given criteria. An empty list is returned if no matching elements are found
      See Also: