Class ProjectManager

java.lang.Object
com.google.refine.ProjectManager
Direct Known Subclasses:
FileProjectManager

public abstract class ProjectManager extends Object
ProjectManager is responsible for loading and saving the workspace and projects.
  • Field Details

    • EXPRESSION_HISTORY_MAX

      public static final int EXPRESSION_HISTORY_MAX
      See Also:
    • PROJECT_FLUSH_DELAY

      protected static final int PROJECT_FLUSH_DELAY
      See Also:
    • QUICK_SAVE_MAX_TIME

      protected static final int QUICK_SAVE_MAX_TIME
      See Also:
    • _projectsMetadata

      protected Map<Long,ProjectMetadata> _projectsMetadata
    • _projectsTags

      protected Map<String,Integer> _projectsTags
    • _preferenceStore

      protected PreferenceStore _preferenceStore
    • _lookupCacheManager

      protected transient LookupCacheManager _lookupCacheManager
      What caches the lookups of projects.
    • _busy

      protected transient int _busy
      Flag for heavy operations like creating or importing projects. Workspace saves are skipped while it's set.
    • _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.
    • singleton

      public static ProjectManager singleton
  • Constructor Details

    • ProjectManager

      protected ProjectManager()
  • Method Details

    • dispose

      public void dispose()
    • registerProject

      public void registerProject(Project project, ProjectMetadata projectMetadata)
      Registers the project in the memory of the current session
      Parameters:
      project -
      projectMetadata -
    • loadProjectMetadata

      public abstract boolean loadProjectMetadata(long projectID)
      Load project metadata from data storage
      Parameters:
      projectID -
      Returns:
    • loadProject

      protected abstract Project loadProject(long id)
      Loads a project from the data store into memory
      Parameters:
      id -
      Returns:
    • importProject

      public abstract void importProject(long projectID, InputStream inputStream, boolean gziped) throws IOException
      Import project from a Refine archive
      Parameters:
      projectID -
      inputStream -
      gziped -
      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
      Parameters:
      projectId -
      tos -
      Throws:
      IOException
    • ensureProjectSaved

      public void ensureProjectSaved(long id)
      Saves a project and its metadata to the data store
      Parameters:
      id -
    • saveMetadata

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

      protected abstract void saveProject(Project project) throws IOException
      Save project to the data store
      Parameters:
      project -
      Throws:
      IOException
    • save

      public void save(boolean allModified)
      Save workspace and all projects to data store
      Parameters:
      allModified -
    • saveWorkspace

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

      protected void saveProjects(boolean allModified)
      Saves all projects to the data store
      Parameters:
      allModified -
    • 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
      Parameters:
      id -
      Returns:
    • getProjectMetadata

      public ProjectMetadata getProjectMetadata(String name)
      Gets the project metadata from memory Requires that the metadata has already been loaded from the data store
      Parameters:
      name -
      Returns:
    • 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.
      Returns:
    • getAllProjectTags

      public Map<String,Integer> getAllProjectTags()
      Gets all the project tags currently held in memory
      Returns:
    • 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
    • getPreferenceStore

      public PreferenceStore getPreferenceStore()
      Gets the preference store
      Returns:
    • getExpressions

      public List<String> getExpressions()
      Gets all expressions from the preference store
      Returns:
    • 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
      Parameters:
      project -
    • deleteProject

      public abstract void deleteProject(long projectID)
      Remove project from data store
      Parameters:
      projectID -
    • removeProject

      protected void removeProject(long projectID)
      Removes project from memory
      Parameters:
      projectID -
    • setBusy

      public void setBusy(boolean busy)
      Sets the flag for long running operations. This will prevent workspace saves from happening while it's set.
      Parameters:
      busy -
    • addLatestExpression

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

      protected static void preparePreferenceStore(PreferenceStore ps)
      Parameters:
      ps -