Package org.openrefine
Class ProjectManager
- java.lang.Object
-
- org.openrefine.ProjectManager
-
- Direct Known Subclasses:
FileProjectManager,ProjectManagerStub
public abstract class ProjectManager extends Object
ProjectManager is responsible for loading and saving the workspace and projects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classProjectManager.SaveRecordA utility class to prioritize projects for saving, depending on how long ago they have been changed but have not been saved.
-
Field Summary
Fields Modifier and Type Field Description protected FacetCountCacheManager_facetCountCacheManagerCaches the facet counts of projects (for the GREL facetCount function)protected LookupCacheManager_lookupCacheManagerWhat caches the lookups of projects (for the GRELÂ cross function)protected PreferenceStore_preferenceStoreprotected Map<Long,Project>_projectsWhile 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.protected Map<Long,ProjectMetadata>_projectsMetadataprotected Map<String,Integer>_projectsTagsstatic intEXPRESSION_HISTORY_MAXprotected static DurationPROJECT_FLUSH_DELAYprotected static DurationQUICK_SAVE_MAX_TIMEstatic ProjectManagersingleton
-
Constructor Summary
Constructors Modifier Constructor Description protectedProjectManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddLatestExpression(String s)Add the latest expression to the preference storeabstract voiddeleteProject(long projectID)Remove project from data storevoiddeleteProject(Project project)Remove the project from the data storevoiddispose()protected voiddisposeUnmodifiedProjects()Flush all unmodified projects from memory.voidensureProjectSaved(long id, ProgressReporter progressReporter)Saves a project and its metadata to the data storeabstract voidexportProject(long projectId, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos)Export project to a Refine archiveMap<Long,ProjectMetadata>getAllProjectMetadata()Gets all the project Metadata currently held in memory.Map<String,Integer>getAllProjectTags()Gets all the project tags currently held in memoryabstract ChangeDataStoregetChangeDataStore(long projectID)Return the change data store for a given projectList<String>getExpressions()Gets all expressions from the preference storeFacetCountCacheManagergetFacetCountCache()abstract GridCachegetGridCache(long projectId)Return the cached grid store for a given projectabstract HistoryEntryManagergetHistoryEntryManager()The history entry manager deals with changesProjectgetLoadedProject(long id)Gets the required project, assuming it has already been leaded.LookupCacheManagergetLookupCacheManager()Gets the LookupCacheManager from memoryPreferenceStoregetPreferenceStore()Gets the preference storeProjectgetProject(long id)Gets the required project from the data store If project does not already exist in memory, it is loaded from the data storelonggetProjectID(String name)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 storeProjectMetadatagetProjectMetadata(long id)Gets the project metadata from memory Requires that the metadata has already been loaded from the data storeProjectMetadatagetProjectMetadata(String name)Gets the project metadata from memory Requires that the metadata has already been loaded from the data storeabstract voidimportProject(long projectID, InputStream inputStream, boolean gziped)Import project from a Refine archiveprotected abstract ProjectloadProject(long id)Loads a project from the data store into memoryabstract booleanloadProjectMetadata(long projectID)Load project metadata from data storagevoidmergeEmptyUserMetadata(ProjectMetadata metadata)protected static voidpreparePreferenceStore(PreferenceStore ps)voidregisterProject(Project project, ProjectMetadata projectMetadata)Registers the project in the memory of the current sessionabstract voidreloadProjectFromWorkspace(long id, ProgressReporter progressReporter)Ensures a project is saved in the workspace and its grids are read from there.protected voidremoveProject(long projectID)Removes project from memoryvoidsave()Save workspace and all projects to data storeabstract voidsaveMetadata(ProjectMetadata metadata, long projectId)Save project metadata to the data storeabstract voidsaveProject(Project project, ProgressReporter progressReporter)Save project to the data storevoidsaveProjects()Saves all projects to the data storeprotected abstract voidsaveWorkspace()Saves the workspace to the data store
-
-
-
Field Detail
-
EXPRESSION_HISTORY_MAX
public static final int EXPRESSION_HISTORY_MAX
- See Also:
- Constant Field Values
-
PROJECT_FLUSH_DELAY
protected static final Duration PROJECT_FLUSH_DELAY
-
QUICK_SAVE_MAX_TIME
protected static final Duration QUICK_SAVE_MAX_TIME
-
_projectsMetadata
protected Map<Long,ProjectMetadata> _projectsMetadata
-
_preferenceStore
protected PreferenceStore _preferenceStore
-
_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.
-
singleton
public static ProjectManager singleton
-
-
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 IOExceptionImport project from a Refine archive- Throws:
IOException
-
exportProject
public abstract void exportProject(long projectId, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos) throws IOExceptionExport 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 IOExceptionEnsures a project is saved in the workspace and its grids are read from there.- Parameters:
id- the project id to loadprogressReporter-- Throws:
IOException
-
saveMetadata
public abstract void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception
Save project metadata to the data store- Throws:
Exception
-
saveProject
public abstract void saveProject(Project project, ProgressReporter progressReporter) throws IOException
Save project to the data store- Throws:
IOException
-
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
-
getFacetCountCache
public FacetCountCacheManager getFacetCountCache()
-
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
-
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)
-
-