Class ContractRestController

  • All Implemented Interfaces:
    ContractRestOpenApi

    @RestController
    @RequestMapping("/v2.1.1/contract-manager/")
    public class ContractRestController
    extends Object
    implements ContractRestOpenApi
    Contract Manager Rest Controller.
    Author:
    Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
    • Constructor Detail

      • ContractRestController

        public ContractRestController()
    • Method Detail

      • createContractPool

        @RequestMapping(method=POST,
                        value="createContractPool/{poolName}/{poolDescription}/{poolClassName}/{userName}/{sessionId}",
                        produces="application/json")
        public String createContractPool​(@PathVariable("poolName")
                                         String poolName,
                                         @PathVariable("poolDescription")
                                         String poolDescription,
                                         @PathVariable("poolClassName")
                                         String poolClassName,
                                         @PathVariable("userName")
                                         String userName,
                                         @PathVariable("sessionId")
                                         String sessionId)
        Creates a contract pool.
        Specified by:
        createContractPool in interface ContractRestOpenApi
        Parameters:
        poolName - The pool name.
        poolDescription - The pool description.
        poolClassName - The pool class. What kind of objects can this pool contain? Must be subclass of GenericContract.
        userName - The user name of the session.
        sessionId - The session token id.
        Returns:
        The id of the newly created contract pool.
      • updateContractPool

        @RequestMapping(method=PUT,
                        value="updateContractPool/{poolId}/{poolClassName}/{poolName}/{poolDescription}/{userName}/{sessionId}",
                        produces="application/json")
        public void updateContractPool​(@PathVariable("poolId")
                                       String poolId,
                                       @PathVariable("poolClassName")
                                       String poolClassName,
                                       @PathVariable("poolName")
                                       String poolName,
                                       @PathVariable("poolDescription")
                                       String poolDescription,
                                       @PathVariable("userName")
                                       String userName,
                                       @PathVariable("sessionId")
                                       String sessionId)
        Updates the attributes of a contract pool.
        Specified by:
        updateContractPool in interface ContractRestOpenApi
        Parameters:
        poolId - The id of the pool to be updated.
        poolClassName - The pool class name.
        poolName - The attribute value for pool name.
        poolDescription - The attribute value for pool description.
        userName - The user name of the session.
        sessionId - The session token id.
      • deleteContractPool

        @RequestMapping(method=DELETE,
                        value="deleteContractPool/{poolId}/{poolClassName}/{userName}/{sessionId}",
                        produces="application/json")
        public void deleteContractPool​(@PathVariable("poolId")
                                       String poolId,
                                       @PathVariable("poolClassName")
                                       String poolClassName,
                                       @PathVariable("userName")
                                       String userName,
                                       @PathVariable("sessionId")
                                       String sessionId)
        Deletes a contract pool.
        Specified by:
        deleteContractPool in interface ContractRestOpenApi
        Parameters:
        poolId - The pool id.
        poolClassName - The pool class name.
        userName - The user name of the session.
        sessionId - The session token id.
      • getContractPools

        @RequestMapping(method=GET,
                        value="getContractPools/{sessionId}",
                        produces="application/json")
        public List<InventoryObjectPool> getContractPools​(@PathVariable("sessionId")
                                                          String sessionId)
        Gets the contract pools properties.
        Specified by:
        getContractPools in interface ContractRestOpenApi
        Parameters:
        sessionId - The session token id.
        Returns:
        The pools properties.
      • getContractPool

        @RequestMapping(method=GET,
                        value="getContractPool/{poolId}/{poolClassName}/{sessionId}",
                        produces="application/json")
        public InventoryObjectPool getContractPool​(@PathVariable("poolId")
                                                   String poolId,
                                                   @PathVariable("poolClassName")
                                                   String poolClassName,
                                                   @PathVariable("sessionId")
                                                   String sessionId)
        Gets the contract pools properties.
        Specified by:
        getContractPool in interface ContractRestOpenApi
        Parameters:
        poolId - The pool id.
        poolClassName - The pool class name.
        sessionId - The session token id.
        Returns:
        The pool properties.
      • createContract

        @RequestMapping(method=POST,
                        value="createContract/{poolId}/{contractClassName}/{userName}/{sessionId}",
                        produces="application/json")
        public String createContract​(@PathVariable("poolId")
                                     String poolId,
                                     @PathVariable("contractClassName")
                                     String contractClassName,
                                     @RequestBody(required=false)
                                     HashMap<String,​String> attributes,
                                     @PathVariable("userName")
                                     String userName,
                                     @PathVariable("sessionId")
                                     String sessionId)
        Creates a contract.
        Specified by:
        createContract in interface ContractRestOpenApi
        Parameters:
        poolId - The contract pool id.
        contractClassName - The contract class name. Must be subclass of GenericContract.
        attributes - The set of initial attributes. If no attribute name is specified, an empty string will be used.
        userName - The user name of the session.
        sessionId - The session token id.
        Returns:
        The id of the newly created contract.
      • updateContract

        @RequestMapping(method=PUT,
                        value="updateContract/{contractClassName}/{contractId}/{userName}/{sessionId}",
                        produces="application/json")
        public void updateContract​(@PathVariable("contractClassName")
                                   String contractClassName,
                                   @PathVariable("contractId")
                                   String contractId,
                                   @RequestBody(required=false)
                                   HashMap<String,​String> attributes,
                                   @PathVariable("userName")
                                   String userName,
                                   @PathVariable("sessionId")
                                   String sessionId)
        Updates one or many contract attributes.
        Specified by:
        updateContract in interface ContractRestOpenApi
        Parameters:
        contractClassName - The contract class name.
        contractId - The contract id.
        attributes - The set of initial attributes. If no attribute name is specified, an empty string will be used.
        userName - The user name of the session.
        sessionId - The session token id.
      • deleteContract

        @RequestMapping(method=DELETE,
                        value="deleteContract/{contractClassName}/{contractId}/{userName}/{sessionId}",
                        produces="application/json")
        public void deleteContract​(@PathVariable("contractClassName")
                                   String contractClassName,
                                   @PathVariable("contractId")
                                   String contractId,
                                   @PathVariable("userName")
                                   String userName,
                                   @PathVariable("sessionId")
                                   String sessionId)
        Deletes a contract and delete its association with the related inventory objects. These objects will remain untouched.
        Specified by:
        deleteContract in interface ContractRestOpenApi
        Parameters:
        contractClassName - The contract class name.
        contractId - The contract id.
        userName - The user name of the session.
        sessionId - The session token id.
      • getAllContracts

        @RequestMapping(method=GET,
                        value="getAllContracts/{page}/{limit}/{sessionId}",
                        produces="application/json")
        public List<BusinessObjectLight> getAllContracts​(@PathVariable("page")
                                                         long page,
                                                         @PathVariable("limit")
                                                         long limit,
                                                         @PathVariable("sessionId")
                                                         String sessionId)
        Get all contracts, without filters.
        Specified by:
        getAllContracts in interface ContractRestOpenApi
        Parameters:
        page - Page number of results to skip. Use -1 to retrieve all.
        limit - Max number of results per page. Use -1 to retrieve all.
        sessionId - The session token id.
        Returns:
        The contracts list.
      • getContractsInPool

        @RequestMapping(method=GET,
                        value="getContractsInPool/{poolId}/{limit}/{sessionId}",
                        produces="application/json")
        public List<BusinessObjectLight> getContractsInPool​(@PathVariable("poolId")
                                                            String poolId,
                                                            @PathVariable("limit")
                                                            int limit,
                                                            @PathVariable("sessionId")
                                                            String sessionId)
        Gets the contracts inside a contract pool.
        Specified by:
        getContractsInPool in interface ContractRestOpenApi
        Parameters:
        poolId - The pool id.
        limit - The results limit per page. Use -1 to retrieve all.
        sessionId - The session token id.
        Returns:
        The contracts list.
      • getContract

        @RequestMapping(method=GET,
                        value="getContract/{contractClassName}/{contractId}/{sessionId}",
                        produces="application/json")
        public BusinessObject getContract​(@PathVariable("contractClassName")
                                          String contractClassName,
                                          @PathVariable("contractId")
                                          String contractId,
                                          @PathVariable("sessionId")
                                          String sessionId)
        Get contract properties.
        Specified by:
        getContract in interface ContractRestOpenApi
        Parameters:
        contractClassName - The contract class name. Must be subclass of GenericContract.
        contractId - The contract id.
        sessionId - The session token id.
        Returns:
        The contract properties.
      • relateObjectsToContract

        @RequestMapping(method=PUT,
                        value="relateObjectsToContract/{contractClassName}/{contractId}/{objectsClassNames}/{objectsIds}/{userName}/{sessionId}",
                        produces="application/json")
        public void relateObjectsToContract​(@PathVariable("contractClassName")
                                            String contractClassName,
                                            @PathVariable("contractId")
                                            String contractId,
                                            @PathVariable("objectsClassNames")
                                            String[] objectsClassNames,
                                            @PathVariable("objectsIds")
                                            String[] objectsIds,
                                            @PathVariable("userName")
                                            String userName,
                                            @PathVariable("sessionId")
                                            String sessionId)
        Relates a set of objects to a contract.
        Specified by:
        relateObjectsToContract in interface ContractRestOpenApi
        Parameters:
        contractClassName - The contract class name.
        contractId - The contract id.
        objectsClassNames - The objects class names.
        objectsIds - The objects ids.
        userName - The user name of the session.
        sessionId - The session token id.
      • relateObjectToContract

        @RequestMapping(method=PUT,
                        value="relateObjectToContract/{contractClassName}/{contractId}/{objectClassName}/{objectId}/{userName}/{sessionId}",
                        produces="application/json")
        public void relateObjectToContract​(@PathVariable("contractClassName")
                                           String contractClassName,
                                           @PathVariable("contractId")
                                           String contractId,
                                           @PathVariable("objectClassName")
                                           String objectClassName,
                                           @PathVariable("objectId")
                                           String objectId,
                                           @PathVariable("userName")
                                           String userName,
                                           @PathVariable("sessionId")
                                           String sessionId)
        Relates an object to a contract.
        Specified by:
        relateObjectToContract in interface ContractRestOpenApi
        Parameters:
        contractClassName - The contract class name.
        contractId - The contract id.
        objectClassName - The object class name.
        objectId - The object id.
        userName - The user name of the session.
        sessionId - The session token id.
      • releaseObjectFromContract

        @RequestMapping(method=PUT,
                        value="releaseObjectFromContract/{objectClassName}/{objectId}/{contractClassName}/{contractId}/{userName}/{sessionId}",
                        produces="application/json")
        public void releaseObjectFromContract​(@PathVariable("objectClassName")
                                              String objectClassName,
                                              @PathVariable("objectId")
                                              String objectId,
                                              @PathVariable("contractClassName")
                                              String contractClassName,
                                              @PathVariable("contractId")
                                              String contractId,
                                              @PathVariable("userName")
                                              String userName,
                                              @PathVariable("sessionId")
                                              String sessionId)
        Releases an object from contract.
        Specified by:
        releaseObjectFromContract in interface ContractRestOpenApi
        Parameters:
        objectClassName - The object class name.
        objectId - The object id.
        contractClassName - The contract class name.
        contractId - The contract id.
        userName - The user name of the session.
        sessionId - The session token id.
      • getContractResources

        @RequestMapping(method=GET,
                        value="getContractResources/{contractClassName}/{contractId}/{sessionId}",
                        produces="application/json")
        public List<BusinessObjectLight> getContractResources​(@PathVariable("contractClassName")
                                                              String contractClassName,
                                                              @PathVariable("contractId")
                                                              String contractId,
                                                              @PathVariable("sessionId")
                                                              String sessionId)
        Gets the resources related to a contract.
        Specified by:
        getContractResources in interface ContractRestOpenApi
        Parameters:
        contractClassName - The contract class name.
        contractId - The contract id.
        sessionId - The session token id.
        Returns:
        The contract resources list.
      • copyContractToPool

        @RequestMapping(method=PUT,
                        value="copyContractToPool/{poolId}/{contractClassName}/{contractId}/{userName}/{sessionId}",
                        produces="application/json")
        public String copyContractToPool​(@PathVariable("poolId")
                                         String poolId,
                                         @PathVariable("contractClassName")
                                         String contractClassName,
                                         @PathVariable("contractId")
                                         String contractId,
                                         @PathVariable("userName")
                                         String userName,
                                         @PathVariable("sessionId")
                                         String sessionId)
        Creates a copy of a contract.
        Specified by:
        copyContractToPool in interface ContractRestOpenApi
        Parameters:
        poolId - The pool id.
        contractClassName - The contract class name.
        contractId - The contract id.
        userName - The user name of the session.
        sessionId - The session token id.
        Returns:
        The newly created contract id.
      • moveContractToPool

        @RequestMapping(method=PUT,
                        value="moveContractToPool/{poolId}/{contractClassName}/{contractId}/{userName}/{sessionId}",
                        produces="application/json")
        public void moveContractToPool​(@PathVariable("poolId")
                                       String poolId,
                                       @PathVariable("contractClassName")
                                       String contractClassName,
                                       @PathVariable("contractId")
                                       String contractId,
                                       @PathVariable("userName")
                                       String userName,
                                       @PathVariable("sessionId")
                                       String sessionId)
        Moves a contract from a pool to another pool.
        Specified by:
        moveContractToPool in interface ContractRestOpenApi
        Parameters:
        poolId - The pool id.
        contractClassName - The contract class name.
        contractId - The contract id.
        userName - The user name of the session.
        sessionId - The session token id.