Class Database
java.lang.Object
de.turnertech.frederick.services.PersistanceProvider
de.turnertech.frederick.persistance.file.Database
-
Field Summary
Fields inherited from class de.turnertech.frederick.services.PersistanceProvider
CURRENT_DEPLOYMENT_FILE_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
closeDeployment
(String name) void
deleteDeployment
(String name) Always returns a deployment! If no deployment is loaded, then it will load or create one.getDeployment
(String name) Return the sorted set of files stored in the deployments folder of the data store.getPathToDeployment
(String name) Returns the path to a deployment with the specified name.boolean
isDeploymentExists
(String name) Simple check for if a deployment with the given name exists on disk.void
void
Manages a save timer which triggers in 5 seconds.Methods inherited from class de.turnertech.frederick.services.PersistanceProvider
getInstance
-
Constructor Details
-
Database
public Database()The constructor initialises the data storage folder.
-
-
Method Details
-
getDeploymentFiles
Return the sorted set of files stored in the deployments folder of the data store. This will not cause the files to be loaded into memory.- Specified by:
getDeploymentFiles
in classPersistanceProvider
- Returns:
- Never null, empty list on exception.
-
getCurrentDeployment
Always returns a deployment! If no deployment is loaded, then it will load or create one.- Specified by:
getCurrentDeployment
in classPersistanceProvider
- Returns:
- The active deployment.
-
saveCurrentDeployment
public void saveCurrentDeployment()- Specified by:
saveCurrentDeployment
in classPersistanceProvider
-
saveCurrentDeploymentInFiveSeconds
public void saveCurrentDeploymentInFiveSeconds()Manages a save timer which triggers in 5 seconds. Every call to this function resets the timer. This is usefull for enabling autosave functionality for example when saving after text bodies are entered.- Specified by:
saveCurrentDeploymentInFiveSeconds
in classPersistanceProvider
-
getPathToDeployment
Returns the path to a deployment with the specified name. Note, that the deployment does not need to exist! This function is rather a helper function for concatenating the desired deployment name to the store root folder path.- Specified by:
getPathToDeployment
in classPersistanceProvider
- Parameters:
name
- The name of the deployment to get a path for.- Returns:
Optional.empty()
on failure, or a valid theoreticalPath
.
-
getDeployment
-
isDeploymentExists
Simple check for if a deployment with the given name exists on disk.- Specified by:
isDeploymentExists
in classPersistanceProvider
- Parameters:
name
- The name of a deployment to check for.- Returns:
- Whether the deployment exists or not.
-
closeDeployment
- Specified by:
closeDeployment
in classPersistanceProvider
-
deleteDeployment
- Specified by:
deleteDeployment
in classPersistanceProvider
-