Class GreenhouseRepository
- java.lang.Object
-
- com.inhousegreenhouse.ch.backend.repository.GreenhouseRepository
-
- All Implemented Interfaces:
IRepository
public class GreenhouseRepository extends java.lang.Object implements IRepository
A GreenhouseRepository is a repository that manage data related to the current Greenhouse.
-
-
Constructor Summary
Constructors Constructor Description GreenhouseRepository(java.lang.String repositoryPath, java.lang.String proxyUrl)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGreenhouse(java.lang.String name, java.lang.String description, java.lang.String userToken)Register a new greenhouse to the API.GreenhousegetGreenhouse()Get the locally saved greenhouse.booleaninitializeRepository()Initialize an empty repository.voidload()Load the greenhouse from the repository.
-
-
-
Method Detail
-
initializeRepository
public boolean initializeRepository() throws RepositoryLoadExceptionInitialize an empty repository.- Returns:
- True if the repository was initialized, false otherwise.
- Throws:
RepositoryLoadException- If the repository cannot be initialized.
-
load
public void load() throws RepositoryLoadExceptionLoad the greenhouse from the repository.- Specified by:
loadin interfaceIRepository- Throws:
RepositoryLoadException- If the repository cannot be loaded.
-
addGreenhouse
public void addGreenhouse(java.lang.String name, java.lang.String description, java.lang.String userToken) throws ProxyRequestFailException, RepositoryLoadExceptionRegister a new greenhouse to the API.- Parameters:
name- The name of the greenhouse.description- The description of the greenhouse.userToken- The user token.- Throws:
ProxyRequestFailException- If the request to the API fails.RepositoryLoadException- If the repository is not initialized.
-
getGreenhouse
public Greenhouse getGreenhouse()
Get the locally saved greenhouse.- Returns:
- The locally saved greenhouse.
-
-