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 void
addGreenhouse(java.lang.String name, java.lang.String description, java.lang.String userToken)
Register a new greenhouse to the API.Greenhouse
getGreenhouse()
Get the locally saved greenhouse.boolean
initializeRepository()
Initialize an empty repository.void
load()
Load the greenhouse from the repository.
-
-
-
Method Detail
-
initializeRepository
public boolean initializeRepository() throws RepositoryLoadException
Initialize 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 RepositoryLoadException
Load the greenhouse from the repository.- Specified by:
load
in 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, RepositoryLoadException
Register 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.
-
-