Class ContractManagerService
- java.lang.Object
-
- org.neotropic.kuwaiba.modules.commercial.contractman.ContractManagerService
-
@Service public class ContractManagerService extends Object
The service that provides the actual functionality exposed by this module.- Author:
- Mauricio Ruiz <mauricio.ruiz@kuwaiba.org>
-
-
Field Summary
Fields Modifier and Type Field Description static String
RELATIONSHIP_CONTRACTHAS
Relationship contract to object
-
Constructor Summary
Constructors Constructor Description ContractManagerService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
copyContractToPool(String poolId, String contractClass, String contractId, String userName)
Creates a copy of a contract.String
createContract(String poolId, String contractClass, HashMap<String,String> attributes, String userName)
Creates a contractString
createContractPool(String poolName, String poolDescription, String poolClass, String userName)
Creates a contract pool.void
deleteContract(String contractClass, String contractId, String userName)
Deletes a contract and delete its association with the related inventory objects.void
deleteContractPool(String poolId, String poolClass, String userName)
Deletes a contract pool.List<BusinessObjectLight>
getAllContracts(long page, long limit)
Get all contracts, without filters.BusinessObject
getContract(String contractClass, String contractId)
Get contract propertiesInventoryObjectPool
getContractPool(String poolId, String poolClass)
Gets the contract pools properties.List<InventoryObjectPool>
getContractPools()
Retrieves the contract pool list.List<BusinessObjectLight>
getContractResources(String contractClass, String contractId)
Gets the resources related to a contract.List<BusinessObjectLight>
getContractsInPool(String poolId, int limit)
Gets the contracts inside a contract pool.void
moveContractToPool(String poolId, String contractClass, String contractId, String userName)
Moves a contract from a pool to another pool.void
relateObjectsToContract(String contractClass, String contractId, String[] objectClass, String[] objectId, String userName)
Relates a set of objects to a contract.void
relateObjectToContract(String contractClass, String contractId, String objectClass, String objectId, String userName)
Relates an object to a contract.void
releaseObjectFromContract(String objectClass, String objectId, String contractClass, String contractId, String userName)
Releases an object from contract.void
updateContract(String contractClass, String contractId, HashMap<String,String> attributes, String userName)
Updates one or many contract attributes.void
updateContractPool(String poolId, String poolClass, String poolName, String poolDescription, String userName)
Updates the attributes of a contract pool.
-
-
-
Field Detail
-
RELATIONSHIP_CONTRACTHAS
public static String RELATIONSHIP_CONTRACTHAS
Relationship contract to object
-
-
Method Detail
-
createContractPool
public String createContractPool(String poolName, String poolDescription, String poolClass, String userName) throws MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Creates a contract pool.- Parameters:
poolName
- The pool name.poolDescription
- The pool description.poolClass
- The pool class. What kind of objects can this pool contain? Must be subclass of GenericContract.userName
- The user name of the session.- Returns:
- The id of the newly created contract pool.
- Throws:
MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericContract.ApplicationObjectNotFoundException
- If the pool activity log can't be found.
-
getContractPool
public InventoryObjectPool getContractPool(String poolId, String poolClass) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Gets the contract pools properties.- Parameters:
poolId
- The pool id.poolClass
- The pool class.- Returns:
- The pool properties.
- Throws:
ApplicationObjectNotFoundException
- If the pool can't be found.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericContract.
-
updateContractPool
public void updateContractPool(String poolId, String poolClass, String poolName, String poolDescription, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Updates the attributes of a contract pool.- Parameters:
poolId
- The id of the pool to be updated.poolClass
- The pool class.poolName
- The attribute value for pool name.poolDescription
- The attribute value for pool description.userName
- The user name of the session.- Throws:
ApplicationObjectNotFoundException
- If the pool can't be found.InvalidArgumentException
- If an unknown attribute name is provided.MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericContract.
-
deleteContractPool
public void deleteContractPool(String poolId, String poolClass, String userName) throws ApplicationObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException, InvalidArgumentException
Deletes a contract pool.- Parameters:
poolId
- The pool id.poolClass
- The pool class.userName
- The user name of the session.- Throws:
ApplicationObjectNotFoundException
- If the pool can't be found.OperationNotPermittedException
- If any of the objects in the pool can't be deleted because it's not a business related instance (it's more a security restriction).MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericContract.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.
-
getContractPools
public List<InventoryObjectPool> getContractPools() throws InvalidArgumentException
Retrieves the contract pool list.- Returns:
- The available contract pools.
- Throws:
InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.
-
createContract
public String createContract(String poolId, String contractClass, HashMap<String,String> attributes, String userName) throws MetadataObjectNotFoundException, ApplicationObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException
Creates a contract- Parameters:
poolId
- The contract pool id.contractClass
- The contract class. 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.- Returns:
- The id of the newly created contract.
- Throws:
MetadataObjectNotFoundException
- If the contract class can't be found.ApplicationObjectNotFoundException
- If the parent pool can't be found.InvalidArgumentException
- If any of the attributes or its type is invalid.BusinessObjectNotFoundException
- If the requested contract can't be found.
-
getContract
public BusinessObject getContract(String contractClass, String contractId) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException
Get contract properties- Parameters:
contractClass
- The contract class. Must be subclass of GenericContract.contractId
- The contract id.- Returns:
- The contract properties.
- Throws:
MetadataObjectNotFoundException
- If the contract class can't be found.InvalidArgumentException
- If the contract id can't be found.BusinessObjectNotFoundException
- If the requested contract can't be found.
-
updateContract
public void updateContract(String contractClass, String contractId, HashMap<String,String> attributes, String userName) throws MetadataObjectNotFoundException, BusinessObjectNotFoundException, OperationNotPermittedException, InvalidArgumentException, ApplicationObjectNotFoundException
Updates one or many contract attributes.- Parameters:
contractClass
- The contract class.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.- Throws:
BusinessObjectNotFoundException
- If the requested contract can't be found.OperationNotPermittedException
- If the update can't be performed due a business rule or because the contract is blocked.InvalidArgumentException
- If any of the initial attributes can't be mapped.MetadataObjectNotFoundException
- If the contract class can't be found.ApplicationObjectNotFoundException
- If the contract activity log can't be found.
-
deleteContract
public void deleteContract(String contractClass, String contractId, String userName) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, ApplicationObjectNotFoundException, OperationNotPermittedException
Deletes a contract and delete its association with the related inventory objects. These objects will remain untouched.- Parameters:
contractClass
- The contract class.contractId
- The contract id.userName
- The user name of the session.- Throws:
MetadataObjectNotFoundException
- If the contract class can't be found.InvalidArgumentException
- If the contract id can't be found.BusinessObjectNotFoundException
- If the requested contract can't be found.OperationNotPermittedException
- If the contract can't be deleted because there's some business rules that avoids it or it has incoming relationships.ApplicationObjectNotFoundException
- If the contract activity log can't be found.
-
getAllContracts
public List<BusinessObjectLight> getAllContracts(long page, long limit) throws InvalidArgumentException, MetadataObjectNotFoundException
Get all contracts, without filters.- 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.- Returns:
- The contracts list.
- Throws:
InvalidArgumentException
- If any contract node could not be mapped into a Java object.MetadataObjectNotFoundException
- If the provided class name doesn't exists.
-
getContractsInPool
public List<BusinessObjectLight> getContractsInPool(String poolId, int limit) throws ApplicationObjectNotFoundException, InvalidArgumentException
Gets the contracts inside a contract pool.- Parameters:
poolId
- The pool id.limit
- The results limit per page. Use -1 to retrieve all.- Returns:
- The contracts list.
- Throws:
ApplicationObjectNotFoundException
- If the pool can't be found.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.
-
relateObjectsToContract
public void relateObjectsToContract(String contractClass, String contractId, String[] objectClass, String[] objectId, String userName) throws InvalidArgumentException, ArraySizeMismatchException, BusinessObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Relates a set of objects to a contract.- Parameters:
contractClass
- The contract class.contractId
- The contract id.objectClass
- The objects class names.objectId
- The objects ids.userName
- The user name of the session.- Throws:
InvalidArgumentException
- If the contract is not subclass of GenericContract.ArraySizeMismatchException
- If array sizes of objectClass and objectId are not the same.BusinessObjectNotFoundException
- If any of the objects can't be found.OperationNotPermittedException
- If any of the objects involved can't be connected (i.e. if it's not an inventory object).MetadataObjectNotFoundException
- If any of the classes provided can't be found.ApplicationObjectNotFoundException
- If the object activity log can't be found.
-
relateObjectToContract
public void relateObjectToContract(String contractClass, String contractId, String objectClass, String objectId, String userName) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, OperationNotPermittedException, ApplicationObjectNotFoundException
Relates an object to a contract.- Parameters:
contractClass
- The contract class.contractId
- The contract id.objectClass
- The object class.objectId
- The object id.userName
- The user name of the session.- Throws:
MetadataObjectNotFoundException
- If the object class provided can't be found.InvalidArgumentException
- If the contract is not subclass of GenericContract.BusinessObjectNotFoundException
- If any of the objects can't be found.OperationNotPermittedException
- If any of the objects involved can't be connected (i.e. if it's not an inventory object).ApplicationObjectNotFoundException
- If the object activity log can't be found.
-
releaseObjectFromContract
public void releaseObjectFromContract(String objectClass, String objectId, String contractClass, String contractId, String userName) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, ApplicationObjectNotFoundException
Releases an object from contract.- Parameters:
objectClass
- The object class.objectId
- The object id.contractClass
- The contract class.contractId
- The contract id.userName
- The user name of the session.- Throws:
MetadataObjectNotFoundException
- If the object class provided can't be found.InvalidArgumentException
- If the contract is not subclass of GenericContract.BusinessObjectNotFoundException
- If any of the objects can't be found.ApplicationObjectNotFoundException
-
getContractResources
public List<BusinessObjectLight> getContractResources(String contractClass, String contractId) throws InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Gets the resources related to a contract.- Parameters:
contractClass
- The contract class.contractId
- The contract id.- Returns:
- The contract resources list.
- Throws:
InvalidArgumentException
- If the contract is not subclass of GenericContract.BusinessObjectNotFoundException
- If the contract can't be found.MetadataObjectNotFoundException
- If the contract class provided can't be found.
-
copyContractToPool
public String copyContractToPool(String poolId, String contractClass, String contractId, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Creates a copy of a contract.- Parameters:
poolId
- The pool id.contractClass
- The contract class.contractId
- The contract id.userName
- The user name of the session.- Returns:
- The newly created contract id.
- Throws:
ApplicationObjectNotFoundException
- If the pool node can not be found.InvalidArgumentException
- If the contract can not be copy to the selected pool.BusinessObjectNotFoundException
- If the contract can not be found.MetadataObjectNotFoundException
- If the contract class name can no be found.
-
moveContractToPool
public void moveContractToPool(String poolId, String contractClass, String contractId, String userName) throws MetadataObjectNotFoundException, InvalidArgumentException, ApplicationObjectNotFoundException, BusinessObjectNotFoundException
Moves a contract from a pool to another pool.- Parameters:
poolId
- The pool id.contractClass
- The contract class.contractId
- The contract id.userName
- The user name of the session.- Throws:
MetadataObjectNotFoundException
- If the contract class name can no be found.InvalidArgumentException
- If the contract can not be move to the selected pool.ApplicationObjectNotFoundException
- If the pool node can not be found.BusinessObjectNotFoundException
- If the contract can not be found.
-
-