Package evo.search.io.service
Class ProjectService
- java.lang.Object
-
- evo.search.io.service.ProjectService
-
public class ProjectService extends Object
Project utility service. Handles current project and the global project registry.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROJECT_LEVEL_HIDDEN
Hidden folder name for local project level.
-
Constructor Summary
Constructors Constructor Description ProjectService()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addProjectEntry(Project project)
Add a new project to the services index entries.static boolean
containsHidden(Path file)
Check, if the directory contains the hidden ".evo" folder.static Project
getCurrentProject()
Currently opened project.static List<IndexEntry>
getIndexEntries()
List of registered projects.static List<Path>
getSavedEvolutions()
Scan the current projects directory for .evolution files.static boolean
isProjectRegistered(Project project)
Check if the given project is registered in the services list.static boolean
isSetUp()
Check, if the global register is set up.static Workspace
loadCurrentWorkspace()
Load the workspace for the current project.static Project
loadProjectFromDirectory(Path projectDirectory)
Load a project from a given directory.static Evolution
readEvolution(Path evolutionFile)
Read an evolution file and the configuration.static void
readProjectIndex()
Read all globally registered projects into the services index entries.static void
saveConfigurations(Path projectFolder, List<Configuration> configurations)
Save a list of configurations to a project folder.static void
saveProjectWorkspace(Workspace workspace)
Save a workspace to the currently opened project.static void
saveRegistered()
Save the services index entries into the global register.static void
setCurrentProject(Project currentProject)
Currently opened project.static void
setupNewProject(Path folder, Project project)
Set up a new project with configs folder and basic project config files.static void
setupService()
Set up the global register with no project.static Path
writeEvolution(Evolution evolution, String prefix)
Save the evolution to a .evolution file and back up the configuration to an xml file with the same number.static void
writeProjectIndex(List<IndexEntry> projects)
Write the given index entries into the global register.
-
-
-
Field Detail
-
PROJECT_LEVEL_HIDDEN
public static final String PROJECT_LEVEL_HIDDEN
Hidden folder name for local project level.- See Also:
- Constant Field Values
-
-
Method Detail
-
addProjectEntry
public static void addProjectEntry(Project project)
Add a new project to the services index entries.- Parameters:
project
- project to add
-
setupNewProject
public static void setupNewProject(Path folder, Project project)
Set up a new project with configs folder and basic project config files.- Parameters:
folder
- folder to create the projects files inproject
- project to save
-
isSetUp
public static boolean isSetUp()
Check, if the global register is set up.- Returns:
- true, if the ".evoSearch" folder exist in user root, false otherwise
-
loadProjectFromDirectory
public static Project loadProjectFromDirectory(Path projectDirectory)
Load a project from a given directory. Checks are performed to ensure, that the directory contains a project.- Parameters:
projectDirectory
- directory with project- Returns:
- loaded project if it exists, null otherwise
-
saveConfigurations
public static void saveConfigurations(Path projectFolder, List<Configuration> configurations)
Save a list of configurations to a project folder. Ensures a project is set up in the provided directory and overwrites the old configurations.- Parameters:
projectFolder
- directory containing a projectconfigurations
- configurations to save in the directory
-
saveProjectWorkspace
public static void saveProjectWorkspace(Workspace workspace)
Save a workspace to the currently opened project.- Parameters:
workspace
- workspace to save
-
loadCurrentWorkspace
public static Workspace loadCurrentWorkspace()
Load the workspace for the current project.- Returns:
- workspace of the current project, empty workspace if there is no current project
-
isProjectRegistered
public static boolean isProjectRegistered(Project project)
Check if the given project is registered in the services list. Checks by equality of paths.- Parameters:
project
- project to check- Returns:
- true if the project's directory exists in the services list, false otherwise
-
containsHidden
public static boolean containsHidden(Path file)
Check, if the directory contains the hidden ".evo" folder.- Parameters:
file
- directory to check- Returns:
- true if the hidden folder is in the given directory, false otherwise
-
setupService
public static void setupService()
Set up the global register with no project.
-
readProjectIndex
public static void readProjectIndex()
Read all globally registered projects into the services index entries.
-
writeProjectIndex
public static void writeProjectIndex(List<IndexEntry> projects)
Write the given index entries into the global register.- Parameters:
projects
- projects entries to save
-
saveRegistered
public static void saveRegistered()
Save the services index entries into the global register.- See Also:
writeProjectIndex(List)
-
writeEvolution
public static Path writeEvolution(Evolution evolution, String prefix)
Save the evolution to a .evolution file and back up the configuration to an xml file with the same number.- Parameters:
evolution
- evolution to writeprefix
- file name prefix- Returns:
- path to the saved evolution
-
readEvolution
public static Evolution readEvolution(Path evolutionFile)
Read an evolution file and the configuration.- Parameters:
evolutionFile
- .evolution file path- Returns:
- evolution with backed up configuration, if something fails, null
-
getSavedEvolutions
public static List<Path> getSavedEvolutions()
Scan the current projects directory for .evolution files.- Returns:
- list of evolution file paths
-
getIndexEntries
public static List<IndexEntry> getIndexEntries()
List of registered projects.
-
setCurrentProject
public static void setCurrentProject(Project currentProject)
Currently opened project.
-
getCurrentProject
public static Project getCurrentProject()
Currently opened project.
-
-