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
_historyEntryManager
protected Runner
_runner
protected File
_workspaceDir
protected static String
PROJECT_DIR_SUFFIX
protected static boolean
projectRemoved
-
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 protected
FileProjectManager(File dir, Runner runner)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
copyFile(File file, OutputStream os)
protected static void
deleteDir(File dir)
void
deleteProject(long projectID)
Remove project from data storevoid
exportProject(long projectId, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos)
Export project to a Refine archiveChangeDataStore
getChangeDataStore(long projectID)
Return the change data store for a given projectGridCache
getGridCache(long projectId)
Return the cached grid store for a given projectHistoryEntryManager
getHistoryEntryManager()
The history entry manager deals with changesprotected List<Long>
getModifiedProjectIds()
File
getProjectDir(long projectID)
static File
getProjectDir(File workspaceDir, long projectID)
Set<Long>
getProjectIds()
File
getWorkspaceDir()
static void
gzipTarToOutputStream(Project project, OutputStream os)
void
importProject(long projectID, InputStream inputStream, boolean gziped)
Import project from a Refine archivestatic void
initialize(File dir)
Initializes the project manager to store its workspace in a specific directory, without a default runner.static void
initialize(Runner runner, File dir)
Initializes the project manager to store its workspace in a specific directory, and provide a default runner.protected void
load()
protected boolean
loadFromFile(File file)
Project
loadProject(long id)
Loads a project from the data store into memoryboolean
loadProjectMetadata(long projectID)
Import an external project that has been received as a .tar file, expanded, and copied into our workspace directory.protected void
loadProjects(List<Long> projectIDs)
protected void
recover()
void
reloadProjectFromWorkspace(long id, ProgressReporter progressReporter)
Ensures a project is saved in the workspace and its grids are read from there.void
saveMetadata(ProjectMetadata metadata, long projectId)
Save project metadata to the data storevoid
saveProject(Project project, ProgressReporter progressReporter)
Save project to the data storeprotected void
saveProjectMetadata(List<Long> modified)
protected boolean
saveToFile(File file)
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.protected void
setExpressions(TopList newExpressions)
protected void
setPreferences(PreferenceStore preferences)
protected static void
tarDir(String relative, File dir, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream tos)
protected void
untar(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:
loadProjectMetadata
in classProjectManager
-
importProject
public void importProject(long projectID, InputStream inputStream, boolean gziped) throws IOException
Description copied from class:ProjectManager
Import project from a Refine archive- Specified by:
importProject
in 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 IOException
Description copied from class:ProjectManager
Export project to a Refine archive- Specified by:
exportProject
in 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:ProjectManager
Save project metadata to the data store- Specified by:
saveMetadata
in classProjectManager
- Throws:
Exception
-
saveProject
public void saveProject(Project project, ProgressReporter progressReporter) throws IOException
Description copied from class:ProjectManager
Save project to the data store- Specified by:
saveProject
in classProjectManager
- Throws:
IOException
-
loadProject
public Project loadProject(long id) throws IOException
Description copied from class:ProjectManager
Loads a project from the data store into memory- Specified by:
loadProject
in 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:
saveWorkspace
in 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:ProjectManager
Remove project from data store- Specified by:
deleteProject
in 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:ProjectManager
The history entry manager deals with changes- Specified by:
getHistoryEntryManager
in 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:ProjectManager
Return the change data store for a given project- Specified by:
getChangeDataStore
in classProjectManager
-
getGridCache
public GridCache getGridCache(long projectId)
Description copied from class:ProjectManager
Return the cached grid store for a given project- Specified by:
getGridCache
in classProjectManager
-
reloadProjectFromWorkspace
public void reloadProjectFromWorkspace(long id, ProgressReporter progressReporter) throws IOException
Description copied from class:ProjectManager
Ensures a project is saved in the workspace and its grids are read from there.- Specified by:
reloadProjectFromWorkspace
in classProjectManager
- Parameters:
id
- the project id to load- Throws:
IOException
-
-