Package com.google.refine
Class ProjectManager
java.lang.Object
com.google.refine.ProjectManager
- Direct Known Subclasses:
FileProjectManager
ProjectManager is responsible for loading and saving the workspace and projects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA utility class to prioritize projects for saving, depending on how long ago they have been changed but have not been saved. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intFlag for heavy operations like creating or importing projects.protected LookupCacheManagerWhat caches the lookups of projects.protected PreferenceStoreWhile 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> static final intprotected static final intprotected static final intstatic ProjectManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd 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 voidFlush all unmodified projects from memory.voidensureProjectSaved(long id) 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 archiveGets all the project Metadata currently held in memory.Gets all the project tags currently held in memoryGets all expressions from the preference storeabstract HistoryEntryManagerThe history entry manager deals with changesGets the LookupCacheManager from memoryGets the preference storegetProject(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 storegetProjectMetadata(long id) Gets the project metadata from memory Requires that the metadata has already been loaded from the data storegetProjectMetadata(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 voidvoidregisterProject(Project project, ProjectMetadata projectMetadata) Registers the project in the memory of the current sessionprotected voidremoveProject(long projectID) Removes project from memoryvoidsave(boolean allModified) Save workspace and all projects to data storeabstract voidsaveMetadata(ProjectMetadata metadata, long projectId) Save project metadata to the data storeprotected abstract voidsaveProject(Project project) Save project to the data storeprotected voidsaveProjects(boolean allModified) Saves all projects to the data storeprotected abstract voidSaves the workspace to the data storevoidsetBusy(boolean busy) Sets the flag for long running operations.
-
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
-
_projectsTags
-
_preferenceStore
-
_lookupCacheManager
What caches the lookups of projects. -
_busy
protected transient int _busyFlag for heavy operations like creating or importing projects. Workspace saves are skipped while it's set. -
_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
-
-
Constructor Details
-
ProjectManager
protected ProjectManager()
-
-
Method Details
-
dispose
public void dispose() -
registerProject
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
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
Save project metadata to the data store- Parameters:
metadata-projectId-- Throws:
Exception
-
saveProject
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
Gets the LookupCacheManager from memory -
getProjectMetadata
Gets the project metadata from memory Requires that the metadata has already been loaded from the data store- Parameters:
id-- Returns:
-
getProjectMetadata
Gets the project metadata from memory Requires that the metadata has already been loaded from the data store- Parameters:
name-- Returns:
-
getProjectID
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
-
getAllProjectMetadata
Gets all the project Metadata currently held in memory.- Returns:
-
getAllProjectTags
Gets all the project tags currently held in memory- Returns:
-
getProject
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
Gets the preference store- Returns:
-
getExpressions
Gets all expressions from the preference store- Returns:
-
getHistoryEntryManager
The history entry manager deals with changes- Returns:
- manager for handling history
-
deleteProject
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
Add the latest expression to the preference store- Parameters:
s-
-
preparePreferenceStore
- Parameters:
ps-
-