Class ProjectManager

    • Field Detail

      • PROJECT_FLUSH_DELAY

        protected static final Duration PROJECT_FLUSH_DELAY
      • QUICK_SAVE_MAX_TIME

        protected static final Duration QUICK_SAVE_MAX_TIME
      • _lookupCacheManager

        protected transient LookupCacheManager _lookupCacheManager
        What caches the lookups of projects (for the GREL cross function)
      • _facetCountCacheManager

        protected transient FacetCountCacheManager _facetCountCacheManager
        Caches the facet counts of projects (for the GREL facetCount function)
      • _projects

        protected transient Map<Long,​Project> _projects
        While each project's metadata is loaded completely at start-up, each project's raw data is loaded only when the project is accessed by the user. This is because project metadata is tiny compared to raw project data. This hash map from project ID to project is more like a last accessed-last out cache.
    • Constructor Detail

      • ProjectManager

        protected ProjectManager()
    • Method Detail

      • dispose

        public void dispose()
      • registerProject

        public void registerProject​(Project project,
                                    ProjectMetadata projectMetadata)
        Registers the project in the memory of the current session
      • getChangeDataStore

        public abstract ChangeDataStore getChangeDataStore​(long projectID)
        Return the change data store for a given project
      • getGridCache

        public abstract GridCache getGridCache​(long projectId)
        Return the cached grid store for a given project
      • loadProjectMetadata

        public abstract boolean loadProjectMetadata​(long projectID)
        Load project metadata from data storage
      • loadProject

        protected abstract Project loadProject​(long id)
                                        throws IOException
        Loads a project from the data store into memory
        Throws:
        IOException
      • importProject

        public abstract void importProject​(long projectID,
                                           InputStream inputStream,
                                           boolean gziped)
                                    throws IOException
        Import project from a Refine archive
        Throws:
        IOException
      • exportProject

        public abstract void exportProject​(long projectId,
                                           org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos)
                                    throws IOException
        Export project to a Refine archive
        Throws:
        IOException
      • ensureProjectSaved

        public void ensureProjectSaved​(long id,
                                       ProgressReporter progressReporter)
        Saves a project and its metadata to the data store
      • reloadProjectFromWorkspace

        public abstract void reloadProjectFromWorkspace​(long id,
                                                        ProgressReporter progressReporter)
                                                 throws IOException
        Ensures a project is saved in the workspace and its grids are read from there.
        Parameters:
        id - the project id to load
        progressReporter -
        Throws:
        IOException
      • saveMetadata

        public abstract void saveMetadata​(ProjectMetadata metadata,
                                          long projectId)
                                   throws Exception
        Save project metadata to the data store
        Throws:
        Exception
      • save

        public void save()
        Save workspace and all projects to data store
      • saveWorkspace

        protected abstract void saveWorkspace()
        Saves the workspace to the data store
      • saveProjects

        public void saveProjects()
        Saves all projects to the data store
      • disposeUnmodifiedProjects

        protected void disposeUnmodifiedProjects()
        Flush all unmodified projects from memory.
      • getLookupCacheManager

        public LookupCacheManager getLookupCacheManager()
        Gets the LookupCacheManager from memory
      • getProjectMetadata

        public ProjectMetadata getProjectMetadata​(long id)
        Gets the project metadata from memory Requires that the metadata has already been loaded from the data store
      • getProjectMetadata

        public ProjectMetadata getProjectMetadata​(String name)
        Gets the project metadata from memory Requires that the metadata has already been loaded from the data store
      • getProjectID

        public long getProjectID​(String name)
                          throws GetProjectIDException
        Tries to find the project id when given a project name Requires that all project metadata exists has been loaded to memory from the data store
        Parameters:
        name - The name of the project
        Returns:
        The id of the project
        Throws:
        GetProjectIDException - If no unique project is found with the given name
      • mergeEmptyUserMetadata

        public void mergeEmptyUserMetadata​(ProjectMetadata metadata)
      • getAllProjectMetadata

        public Map<Long,​ProjectMetadata> getAllProjectMetadata()
        Gets all the project Metadata currently held in memory.
      • getAllProjectTags

        public Map<String,​Integer> getAllProjectTags()
        Gets all the project tags currently held in memory
      • getProject

        public Project getProject​(long id)
        Gets the required project from the data store If project does not already exist in memory, it is loaded from the data store
        Parameters:
        id - the id of the project
        Returns:
        the project with the matching id, or null if it can't be found
      • getLoadedProject

        public Project getLoadedProject​(long id)
        Gets the required project, assuming it has already been leaded.
        Parameters:
        id - the id of the project
        Returns:
        null if the project is not loaded yet.
      • getPreferenceStore

        public PreferenceStore getPreferenceStore()
        Gets the preference store
      • getExpressions

        public List<String> getExpressions()
        Gets all expressions from the preference store
      • getHistoryEntryManager

        public abstract HistoryEntryManager getHistoryEntryManager()
        The history entry manager deals with changes
        Returns:
        manager for handling history
      • deleteProject

        public void deleteProject​(Project project)
        Remove the project from the data store
      • deleteProject

        public abstract void deleteProject​(long projectID)
        Remove project from data store
      • removeProject

        protected void removeProject​(long projectID)
        Removes project from memory
      • addLatestExpression

        public void addLatestExpression​(String s)
        Add the latest expression to the preference store
      • preparePreferenceStore

        protected static void preparePreferenceStore​(PreferenceStore ps)