Class WarehousesService
- java.lang.Object
 - 
- com.neotropic.kuwaiba.modules.commercial.whman.persistence.WarehousesService
 
 
- 
@Service public class WarehousesService extends Object
Service to manage warehouses- Author:
 - Johny Andres Ortega Ruiz <johny.ortega@kuwaiba.org>, Mauricio Ruiz Beltran <mauricio.ruiz@kuwaiba.org>
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static StringRELATIONSHIP_WAREHOUSE_HASRelationship used to assign a Warehouse or VirtualWarehouse to a GenericLocation 
- 
Constructor Summary
Constructors Constructor Description WarehousesService() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyObjectToWarehouse(String poolId, String objectClass, String ObjectId, boolean recursive, String userName)Creates a copy of an object in a warehouse.StringcreatePoolInWarehouse(String warehouseClass, String warehouseId, String poolName, String poolDescription, String instancesOfClass, String userName)Creates a pool inside a warehouseStringcreateSparePart(String poolId, String className, HashMap<String,String> attributes, String templateId, String userName)Creates a spare part inside a poolStringcreateWarehouse(String poolId, String poolClass, HashMap<String,String> attributes, String templateId, String userName)Creates a warehouse inside a poolvoiddeleteSparePool(String poolId, String poolClass, String userName)Deletes a spare pool.voiddeleteWarehouse(String warehouseClass, String warehouseId, String userName)Deletes a warehouse and delete its association with the related inventory objects.List<BusinessObjectLight>getObjectsInSparePool(String poolId, int limit)Get the objects of a poolList<InventoryObjectPool>getPoolsInWarehouse(String objectClassName, String objectId)Get the pools of a warehousesList<InventoryObjectPool>getWarehouseRootPools()Gets the Warehouse Module Root PoolsList<BusinessObjectLight>getWarehousesInPool(String poolId, int limit)Get the warehouses of a poolvoidinit()voidmoveObjectToWarehouse(String poolId, String objectClass, String ObjectId, String userName)Moves an object from a warehouse to another warehouse. 
 - 
 
- 
- 
Field Detail
- 
RELATIONSHIP_WAREHOUSE_HAS
public static final String RELATIONSHIP_WAREHOUSE_HAS
Relationship used to assign a Warehouse or VirtualWarehouse to a GenericLocation- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
init
@PostConstruct public void init()
 
- 
getWarehouseRootPools
public List<InventoryObjectPool> getWarehouseRootPools() throws MetadataObjectNotFoundException, InvalidArgumentException
Gets the Warehouse Module Root Pools- Returns:
 - A list of root pools
 - Throws:
 MetadataObjectNotFoundException- If the classes Warehouse or VirtualWarehouse could not be found.InvalidArgumentException- If any pool does not have uuid
 
- 
getWarehousesInPool
public List<BusinessObjectLight> getWarehousesInPool(String poolId, int limit) throws ApplicationObjectNotFoundException, InvalidArgumentException
Get the warehouses of a pool- Parameters:
 poolId- Root pool idlimit- Result limit. -1 To return all- Returns:
 - List of warehouses
 - Throws:
 ApplicationObjectNotFoundException- If the pool id provided is not validInvalidArgumentException- If any warehouse does not have uuid
 
- 
getPoolsInWarehouse
public List<InventoryObjectPool> getPoolsInWarehouse(String objectClassName, String objectId) throws BusinessObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Get the pools of a warehouses- Parameters:
 objectClassName- Warehouse class nameobjectId- Warehouse id- Returns:
 - List of spare pools
 - Throws:
 BusinessObjectNotFoundException- If the parent object can not be foundInvalidArgumentException- If pool warehouse does not have uuiMetadataObjectNotFoundException- If the classes could not be found.
 
- 
getObjectsInSparePool
public List<BusinessObjectLight> getObjectsInSparePool(String poolId, int limit) throws ApplicationObjectNotFoundException, InvalidArgumentException
Get the objects of a pool- Parameters:
 poolId- Root pool idlimit- Result limit. -1 To return all- Returns:
 - List of objects
 - Throws:
 ApplicationObjectNotFoundException- If the pool id provided is not validInvalidArgumentException- If any object does not have uuid
 
- 
createWarehouse
public String createWarehouse(String poolId, String poolClass, HashMap<String,String> attributes, String templateId, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Creates a warehouse inside a pool- Parameters:
 poolId- Parent pool idpoolClass- Class this warehouse is going to be instance ofattributes- The list of attributes to be set initially. The values are serialized objects.templateId- The id of the template to be used to create this object. This id was probably retrieved by {@link ApplicationEntityManager.getTemplatesForClass(String)} before. Use a null or empty string to not use a template.userName- The user name of the session.- Returns:
 - the id of the newly created warehouse
 - Throws:
 ApplicationObjectNotFoundException- If the parent pool can't be foundInvalidArgumentException- If any of the attributes or its type is invalidMetadataObjectNotFoundException- If the class name could not be found
 
- 
deleteWarehouse
public void deleteWarehouse(String warehouseClass, String warehouseId, String userName) throws ApplicationObjectNotFoundException, MetadataObjectNotFoundException, BusinessObjectNotFoundException, OperationNotPermittedException, InvalidArgumentException
Deletes a warehouse and delete its association with the related inventory objects. These objects will remain untouched- Parameters:
 warehouseClass- The class of the warehousewarehouseId- The id of the warehouseuserName- The user name of the session- Throws:
 ApplicationObjectNotFoundException- If the log root node could not be foundMetadataObjectNotFoundException- If the warehouse class could not be foundBusinessObjectNotFoundException- If the warehouse could not be foundOperationNotPermittedException- If the object could not be deleted because there's some business rules that avoids it or it has incoming relationshipsInvalidArgumentException- If the id is null
 
- 
createPoolInWarehouse
public String createPoolInWarehouse(String warehouseClass, String warehouseId, String poolName, String poolDescription, String instancesOfClass, String userName) throws MetadataObjectNotFoundException, BusinessObjectNotFoundException, ApplicationObjectNotFoundException
Creates a pool inside a warehouse- Parameters:
 warehouseClass- Class name of the parent warehousewarehouseId- Id of the parent objectpoolName- Pool namepoolDescription- Pool descriptioninstancesOfClass- What kind of objects can this pool contain?userName- The user name of the session- Returns:
 - The id of the new pool
 - Throws:
 MetadataObjectNotFoundException- If instancesOfClass is not a valid subclass of InventoryObjectBusinessObjectNotFoundException- If the parent object can not be foundApplicationObjectNotFoundException- If the log root node could not be found
 
- 
deleteSparePool
public void deleteSparePool(String poolId, String poolClass, String userName) throws ApplicationObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException
Deletes a spare pool.- Parameters:
 poolId- The spare pool id.poolClass- The spare pool class.userName- The user name of the session.- Throws:
 ApplicationObjectNotFoundException- If the pools to be deleted couldn't be found.OperationNotPermittedException- If any of the objects in the pool can not be deleted because it's not a business related instance (it's more a security restriction).MetadataObjectNotFoundException- If spare pool class name is null
 
- 
createSparePart
public String createSparePart(String poolId, String className, HashMap<String,String> attributes, String templateId, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Creates a spare part inside a pool- Parameters:
 poolId- Spare pool idclassName- Class this spare part is going to be instance ofattributes- The list of attributes to be set initially. The values are serialized objects.templateId- The id of the template to be used to create this object. This id was probably retrieved by {@link ApplicationEntityManager.getTemplatesForClass(String)} before. Use a null or empty string to not use a template.userName- The user name of the session.- Returns:
 - the id of the newly created spare part
 - Throws:
 ApplicationObjectNotFoundException- If the parent pool can't be foundInvalidArgumentException- If any of the attributes or its type is invalidMetadataObjectNotFoundException- If the class name could not be found
 
- 
copyObjectToWarehouse
public void copyObjectToWarehouse(String poolId, String objectClass, String ObjectId, boolean recursive, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Creates a copy of an object in a warehouse. And optionally its children objects.- Parameters:
 poolId- The spare pool id.objectClass- The object class name.ObjectId- The object id.recursive- If this operation should also copy the children objects recursively.userName- The user name of the session.- Throws:
 ApplicationObjectNotFoundException- If the spare pool can not be found.InvalidArgumentException- If the object can not be copy to the selected pool.BusinessObjectNotFoundException- If the object can not be found.MetadataObjectNotFoundException- If the object class name can no be found.
 
- 
moveObjectToWarehouse
public void moveObjectToWarehouse(String poolId, String objectClass, String ObjectId, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Moves an object from a warehouse to another warehouse.- Parameters:
 poolId- The spare pool id.objectClass- The object class name.ObjectId- The object id.userName- The user name of the session.- Throws:
 ApplicationObjectNotFoundException- If the spare pool can not be found.InvalidArgumentException- If the object can not be move to the selected pool.BusinessObjectNotFoundException- If the object can not be found.MetadataObjectNotFoundException- If the object class name can no be found.
 
 - 
 
 -