Package org.openrefine.io
Class FileProjectManager
- java.lang.Object
-
- org.openrefine.ProjectManager
-
- org.openrefine.io.FileProjectManager
-
public class FileProjectManager extends ProjectManager
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openrefine.ProjectManager
ProjectManager.SaveRecord
-
-
Field Summary
Fields Modifier and Type Field Description protected HistoryEntryManager_historyEntryManagerprotected Runner_runnerprotected File_workspaceDirprotected static StringPROJECT_DIR_SUFFIXprotected static booleanprojectRemoved-
Fields inherited from class org.openrefine.ProjectManager
_facetCountCacheManager, _lookupCacheManager, _preferenceStore, _projects, _projectsMetadata, _projectsTags, EXPRESSION_HISTORY_MAX, PROJECT_FLUSH_DELAY, QUICK_SAVE_MAX_TIME, singleton
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileProjectManager(File dir, Runner runner)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidcopyFile(File file, OutputStream os)protected static voiddeleteDir(File dir)voiddeleteProject(long projectID)Remove project from data storevoidexportProject(long projectId, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos)Export project to a Refine archiveChangeDataStoregetChangeDataStore(long projectID)Return the change data store for a given projectGridCachegetGridCache(long projectId)Return the cached grid store for a given projectHistoryEntryManagergetHistoryEntryManager()The history entry manager deals with changesprotected List<Long>getModifiedProjectIds()FilegetProjectDir(long projectID)static FilegetProjectDir(File workspaceDir, long projectID)Set<Long>getProjectIds()FilegetWorkspaceDir()static voidgzipTarToOutputStream(Project project, OutputStream os)voidimportProject(long projectID, InputStream inputStream, boolean gziped)Import project from a Refine archivestatic voidinitialize(File dir)Initializes the project manager to store its workspace in a specific directory, without a default runner.static voidinitialize(Runner runner, File dir)Initializes the project manager to store its workspace in a specific directory, and provide a default runner.protected voidload()protected booleanloadFromFile(File file)ProjectloadProject(long id)Loads a project from the data store into memorybooleanloadProjectMetadata(long projectID)Import an external project that has been received as a .tar file, expanded, and copied into our workspace directory.protected voidloadProjects(List<Long> projectIDs)protected voidrecover()voidreloadProjectFromWorkspace(long id, ProgressReporter progressReporter)Ensures a project is saved in the workspace and its grids are read from there.voidsaveMetadata(ProjectMetadata metadata, long projectId)Save project metadata to the data storevoidsaveProject(Project project, ProgressReporter progressReporter)Save project to the data storeprotected voidsaveProjectMetadata(List<Long> modified)protected booleansaveToFile(File file)protected voidsaveWorkspace()Save the workspace's data out to file in a safe way: save to a temporary file first and rename it to the real file.protected voidsetExpressions(TopList newExpressions)protected voidsetPreferences(PreferenceStore preferences)protected static voidtarDir(String relative, File dir, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos)protected voiduntar(File destDir, InputStream inputStream)-
Methods inherited from class org.openrefine.ProjectManager
addLatestExpression, deleteProject, dispose, disposeUnmodifiedProjects, ensureProjectSaved, getAllProjectMetadata, getAllProjectTags, getExpressions, getFacetCountCache, getLoadedProject, getLookupCacheManager, getPreferenceStore, getProject, getProjectID, getProjectMetadata, getProjectMetadata, mergeEmptyUserMetadata, preparePreferenceStore, registerProject, removeProject, save, saveProjects
-
-
-
-
Field Detail
-
PROJECT_DIR_SUFFIX
protected static final String PROJECT_DIR_SUFFIX
- See Also:
- Constant Field Values
-
_workspaceDir
protected File _workspaceDir
-
_runner
protected Runner _runner
-
_historyEntryManager
protected HistoryEntryManager _historyEntryManager
-
projectRemoved
protected static boolean projectRemoved
-
-
Method Detail
-
initialize
public static void initialize(Runner runner, File dir)
Initializes the project manager to store its workspace in a specific directory, and provide a default runner.
-
initialize
public static void initialize(File dir)
Initializes the project manager to store its workspace in a specific directory, without a default runner.
-
getWorkspaceDir
public File getWorkspaceDir()
-
getProjectDir
public File getProjectDir(long projectID)
-
loadProjectMetadata
public boolean loadProjectMetadata(long projectID)
Import an external project that has been received as a .tar file, expanded, and copied into our workspace directory.- Specified by:
loadProjectMetadatain classProjectManager
-
importProject
public void importProject(long projectID, InputStream inputStream, boolean gziped) throws IOExceptionDescription copied from class:ProjectManagerImport project from a Refine archive- Specified by:
importProjectin classProjectManager- Throws:
IOException
-
untar
protected void untar(File destDir, InputStream inputStream) throws IOException
- Throws:
IOException
-
exportProject
public void exportProject(long projectId, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos) throws IOExceptionDescription copied from class:ProjectManagerExport project to a Refine archive- Specified by:
exportProjectin classProjectManager- Throws:
IOException
-
tarDir
protected static void tarDir(String relative, File dir, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos) throws IOException
- Throws:
IOException
-
copyFile
protected static void copyFile(File file, OutputStream os) throws IOException
- Throws:
IOException
-
saveMetadata
public void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception
Description copied from class:ProjectManagerSave project metadata to the data store- Specified by:
saveMetadatain classProjectManager- Throws:
Exception
-
saveProject
public void saveProject(Project project, ProgressReporter progressReporter) throws IOException
Description copied from class:ProjectManagerSave project to the data store- Specified by:
saveProjectin classProjectManager- Throws:
IOException
-
loadProject
public Project loadProject(long id) throws IOException
Description copied from class:ProjectManagerLoads a project from the data store into memory- Specified by:
loadProjectin classProjectManager- Throws:
IOException
-
saveWorkspace
protected void saveWorkspace()
Save the workspace's data out to file in a safe way: save to a temporary file first and rename it to the real file.- Specified by:
saveWorkspacein classProjectManager
-
saveProjectMetadata
protected void saveProjectMetadata(List<Long> modified) throws IOException
- Throws:
IOException
-
saveToFile
protected boolean saveToFile(File file) throws IOException
- Throws:
IOException
-
deleteProject
public void deleteProject(long projectID)
Description copied from class:ProjectManagerRemove project from data store- Specified by:
deleteProjectin classProjectManager
-
deleteDir
protected static void deleteDir(File dir)
-
load
protected void load()
-
loadFromFile
protected boolean loadFromFile(File file)
-
recover
protected void recover()
-
getHistoryEntryManager
public HistoryEntryManager getHistoryEntryManager()
Description copied from class:ProjectManagerThe history entry manager deals with changes- Specified by:
getHistoryEntryManagerin classProjectManager- Returns:
- manager for handling history
-
gzipTarToOutputStream
public static void gzipTarToOutputStream(Project project, OutputStream os) throws IOException
- Throws:
IOException
-
setPreferences
protected void setPreferences(PreferenceStore preferences)
-
setExpressions
protected void setExpressions(TopList newExpressions)
-
getChangeDataStore
public ChangeDataStore getChangeDataStore(long projectID)
Description copied from class:ProjectManagerReturn the change data store for a given project- Specified by:
getChangeDataStorein classProjectManager
-
getGridCache
public GridCache getGridCache(long projectId)
Description copied from class:ProjectManagerReturn the cached grid store for a given project- Specified by:
getGridCachein classProjectManager
-
reloadProjectFromWorkspace
public void reloadProjectFromWorkspace(long id, ProgressReporter progressReporter) throws IOExceptionDescription copied from class:ProjectManagerEnsures a project is saved in the workspace and its grids are read from there.- Specified by:
reloadProjectFromWorkspacein classProjectManager- Parameters:
id- the project id to load- Throws:
IOException
-
-