java.lang.Object
de.turnertech.frederick.services.PersistanceProvider
de.turnertech.frederick.persistance.file.Database

public class Database extends PersistanceProvider
  • Constructor Details

    • Database

      public Database()
      The constructor initialises the data storage folder.
  • Method Details

    • getDeploymentFiles

      public List<File> 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 class PersistanceProvider
      Returns:
      Never null, empty list on exception.
    • getCurrentDeployment

      public Deployment getCurrentDeployment()
      Always returns a deployment! If no deployment is loaded, then it will load or create one.
      Specified by:
      getCurrentDeployment in class PersistanceProvider
      Returns:
      The active deployment.
    • saveCurrentDeployment

      public void saveCurrentDeployment()
      Specified by:
      saveCurrentDeployment in class PersistanceProvider
    • 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 class PersistanceProvider
    • getPathToDeployment

      public Optional<Path> getPathToDeployment(String name)
      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 class PersistanceProvider
      Parameters:
      name - The name of the deployment to get a path for.
      Returns:
      Optional.empty() on failure, or a valid theoretical Path .
    • getDeployment

      public Optional<Deployment> getDeployment(String name)
    • isDeploymentExists

      public boolean isDeploymentExists(String name)
      Simple check for if a deployment with the given name exists on disk.
      Specified by:
      isDeploymentExists in class PersistanceProvider
      Parameters:
      name - The name of a deployment to check for.
      Returns:
      Whether the deployment exists or not.
    • closeDeployment

      public void closeDeployment(String name)
      Specified by:
      closeDeployment in class PersistanceProvider
    • deleteDeployment

      public void deleteDeployment(String name)
      Specified by:
      deleteDeployment in class PersistanceProvider