Class 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GreenhouseRepository

        public GreenhouseRepository​(java.lang.String repositoryPath,
                                    java.lang.String proxyUrl)
        Constructor.
        Parameters:
        repositoryPath - The repository path.
        proxyUrl - The URL of the proxy server.
    • 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.
      • 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.