Class ProjectAPI

  • All Implemented Interfaces:
    IAPI<Project>

    public class ProjectAPI
    extends java.lang.Object
    implements IAPI<Project>
    The project service handles the API requests for projects
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<Challenge> children​(long identifier, int limit, int page)
      Retrieve the children of the Project
      Project create​(Project project)
      Creates an object in MapRoulette.
      boolean delete​(long identifier)
      Deletes an object in MapRoulette based on the provided identifier
      java.util.List<Project> find​(java.lang.String matcher, long parent, int limit, int page)
      Finds a list of elements
      boolean forceDelete​(long identifier)
      By default MapRoulette will not actually delete any object, but rather flag the object for deletion.
      java.util.Optional<Project> get​(long identifier)
      Gets the object type associated with the service.
      java.util.Optional<Project> get​(long parentIdentifier, java.lang.String name)
      Gets the object type associated with the service based on the object name
      java.util.Optional<Project> get​(java.lang.String name)
      Projects have no parents, so we create a function that will ignore the value
      Project update​(Project project)
      Updates an object in MapRoulette.
      • Methods inherited from class java.lang.Object

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

      • get

        public java.util.Optional<Project> get​(java.lang.String name)
                                        throws MapRouletteException
        Projects have no parents, so we create a function that will ignore the value
        Parameters:
        name - The name of the project to retrieve
        Returns:
        An optional Project if found by name
        Throws:
        MapRouletteException - If any exceptions occur while retrieving the project
      • get

        public java.util.Optional<Project> get​(long parentIdentifier,
                                               java.lang.String name)
                                        throws MapRouletteException
        Description copied from interface: IAPI
        Gets the object type associated with the service based on the object name
        Specified by:
        get in interface IAPI<Project>
        Parameters:
        parentIdentifier - The identifier of parent of the object
        name - The name of the object
        Returns:
        The object of Optional if not found
        Throws:
        MapRouletteException - If there are any exceptions while retrieving the object
      • get

        public java.util.Optional<Project> get​(long identifier)
                                        throws MapRouletteException
        Description copied from interface: IAPI
        Gets the object type associated with the service.
        Specified by:
        get in interface IAPI<Project>
        Parameters:
        identifier - The identifier of the object
        Returns:
        The object or Optional if not found
        Throws:
        MapRouletteException - If there are any exceptions while retrieving the object
      • find

        public java.util.List<Project> find​(java.lang.String matcher,
                                            long parent,
                                            int limit,
                                            int page)
                                     throws MapRouletteException
        Description copied from interface: IAPI
        Finds a list of elements
        Specified by:
        find in interface IAPI<Project>
        Parameters:
        matcher - A string query to match based on names
        parent - The parent identifier, use -1 if want to ignore it.
        limit - How many elements to limit the results by
        page - For paging the limited results
        Returns:
        A list of elements
        Throws:
        MapRouletteException - Any API exceptions
      • children

        public java.util.List<Challenge> children​(long identifier,
                                                  int limit,
                                                  int page)
                                           throws MapRouletteException
        Retrieve the children of the Project
        Parameters:
        identifier - The identifier of the project
        limit - To limit the amount of returned tasks
        page - For paging
        Returns:
        A list of Challenges that belong to the provided challenge
        Throws:
        MapRouletteException - If any exceptions occur during API Restful request
      • create

        public Project create​(Project project)
                       throws MapRouletteException
        Description copied from interface: IAPI
        Creates an object in MapRoulette. For creation if the object is in the cache it will just respond with the cached object.
        Specified by:
        create in interface IAPI<Project>
        Parameters:
        project - The object to create of type T
        Returns:
        The newly created identifier of the object
        Throws:
        MapRouletteException - If there are any exceptions while creating/updating or retrieving the objects
      • update

        public Project update​(Project project)
                       throws MapRouletteException
        Description copied from interface: IAPI
        Updates an object in MapRoulette.
        Specified by:
        update in interface IAPI<Project>
        Parameters:
        project - The object to update of type T
        Returns:
        Whether the update succeeded or not
        Throws:
        MapRouletteException - If there are any exceptions while creating/updating or retrieving the objects
      • delete

        public boolean delete​(long identifier)
                       throws MapRouletteException
        Description copied from interface: IAPI
        Deletes an object in MapRoulette based on the provided identifier
        Specified by:
        delete in interface IAPI<Project>
        Parameters:
        identifier - The identifier for the object to delete
        Returns:
        true if object was deleted
        Throws:
        MapRouletteException - If there are any exceptions while deleting the object
      • forceDelete

        public boolean forceDelete​(long identifier)
                            throws MapRouletteException
        Description copied from interface: IAPI
        By default MapRoulette will not actually delete any object, but rather flag the object for deletion. This function will add a flag to the URI that will force the deletion of an object.
        Specified by:
        forceDelete in interface IAPI<Project>
        Parameters:
        identifier - The identifier for the object to delete
        Returns:
        true if object was deleted
        Throws:
        MapRouletteException - if there are any exceptions while deleting the object