Class ProjectsService
- java.lang.Object
-
- com.neotropic.kuwaiba.modules.commercial.planning.projects.ProjectsService
-
@Service public class ProjectsService extends Object
The service that provides the actual functionality exposed by this module.- Author:
- Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>, Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
-
-
Field Summary
Fields Modifier and Type Field Description static String
RELATIONSHIP_PROJECTSPROJECTUSES
Relationship project to object
-
Constructor Summary
Constructors Constructor Description ProjectsService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
copyProjectToPool(String poolId, String projectClass, String projectId, String userName)
Creates a copy of a project.String
createActivity(String projectId, String projectClass, String activityClass, HashMap<String,String> attributes, String userName)
Creates an Activity inside a project.String
createProject(String projectPoolId, String projectClass, HashMap<String,String> attributes, String userName)
Create a projectString
createProjectPool(String poolName, String poolDescription, String poolClass, String userName)
Creates a project pool.void
deleteActivity(String activityClass, String activityId, boolean releaseRelationships, String userName)
Deletes an activity and delete its association with the related inventory objects.void
deleteProject(String projectClass, String projectId, String userName)
Deletes a project and delete its association with the related inventory objects.void
deleteProjectPool(String poolId, String poolClass, String userName)
Deletes a project pool.BusinessObject
getActivity(String activityClass, String activityId)
Get activity propertiesList<BusinessObjectLight>
getAllProjects(long page, long limit)
Get all projects, without filters.BusinessObject
getProject(String projectClass, String projectId)
Get project propertiesList<BusinessObjectLight>
getProjectActivities(String projectClass, String projectId)
Gets the activities inside a project.InventoryObjectPool
getProjectPool(String poolId, String poolClass)
Gets the project pools properties.List<InventoryObjectPool>
getProjectPools()
Retrieves the projects pool list.List<BusinessObjectLight>
getProjectResources(String projectClass, String projectId)
Gets the resources related to a project.List<BusinessObjectLight>
getProjectsInPool(String poolId, int limit)
Gets the projects inside a project poolList<BusinessObjectLight>
getProjectsRelatedToObject(String objectClass, String objectId)
Gets the projects related to an object.List<BusinessObjectLight>
getProjectsWithFilter(HashMap<String,String> filters, long page, long limit)
Get the projects according to the filter value.void
moveProjectToPool(String poolId, String projectClass, String projectId, String userName)
Moves a project from a pool to another pool.void
relateObjectsToProject(String projectClass, String projectId, String[] objectClass, String[] objectId, String userName)
Relates a set of objects to a project.void
relateObjectToProject(String projectClass, String projectId, String objectClass, String objectId, String userName)
Relates an object to a projectvoid
releaseObjectFromProject(String objectClass, String objectId, String projectClass, String projectId, String userName)
Releases an object from project.void
updateActivity(String activityClass, String activityId, HashMap<String,String> attributes, String userName)
Updates one or many activity attributes.void
updateProject(String projectClass, String projectId, HashMap<String,String> attributes, String userName)
Updates one or many project attributes.void
updateProjectPool(String poolId, String poolClass, String poolName, String poolDescription, String userName)
Updates the attributes of a project pool.
-
-
-
Field Detail
-
RELATIONSHIP_PROJECTSPROJECTUSES
public static String RELATIONSHIP_PROJECTSPROJECTUSES
Relationship project to object
-
-
Method Detail
-
createProject
public String createProject(String projectPoolId, String projectClass, HashMap<String,String> attributes, String userName) throws MetadataObjectNotFoundException, ApplicationObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException
Create a project- Parameters:
projectPoolId
- The project pool id.projectClass
- The project class. Must be subclass of GenericProject.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 project.
- Throws:
MetadataObjectNotFoundException
- If the project 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 project can't be found.
-
getProject
public BusinessObject getProject(String projectClass, String projectId) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException
Get project properties- Parameters:
projectClass
- The project class. Must be subclass of GenericProject.projectId
- The project id.- Returns:
- The project properties.
- Throws:
MetadataObjectNotFoundException
- If the project class can't be found.InvalidArgumentException
- If the project id can't be found.BusinessObjectNotFoundException
- If the requested project can't be found.
-
deleteProject
public void deleteProject(String projectClass, String projectId, String userName) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, ApplicationObjectNotFoundException, OperationNotPermittedException
Deletes a project and delete its association with the related inventory objects. These objects will remain untouched.- Parameters:
projectClass
- The project class.projectId
- The project id.userName
- The user name of the session.- Throws:
MetadataObjectNotFoundException
- If the project class can't be found.InvalidArgumentException
- If the project id can't be found.BusinessObjectNotFoundException
- If the requested project can't be found.OperationNotPermittedException
- If the project can't be deleted because there's some business rules that avoids it or it has incoming relationships.ApplicationObjectNotFoundException
- If the project activity log can't be found.
-
updateProject
public void updateProject(String projectClass, String projectId, HashMap<String,String> attributes, String userName) throws MetadataObjectNotFoundException, BusinessObjectNotFoundException, OperationNotPermittedException, InvalidArgumentException, ApplicationObjectNotFoundException
Updates one or many project attributes.- Parameters:
projectClass
- The project class.projectId
- The project 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 project can't be found.OperationNotPermittedException
- If the update can't be performed due a business rule or because the project is blocked.InvalidArgumentException
- If any of the initial attributes can't be mapped.MetadataObjectNotFoundException
- If the project class can't be found.ApplicationObjectNotFoundException
- If the project activity log can't be found.
-
createProjectPool
public String createProjectPool(String poolName, String poolDescription, String poolClass, String userName) throws MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Creates a project pool.- Parameters:
poolName
- The pool name.poolDescription
- The pool description.poolClass
- The pool class name. What kind of objects can this pool contain? Must be subclass of GenericProject.userName
- The user name of the session.- Returns:
- The id of the newly created project pool.
- Throws:
MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericProject.ApplicationObjectNotFoundException
- If the pool activity log can't be found.
-
getProjectPool
public InventoryObjectPool getProjectPool(String poolId, String poolClass) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Gets the project 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 GenericProject.
-
updateProjectPool
public void updateProjectPool(String poolId, String poolClass, String poolName, String poolDescription, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Updates the attributes of a project 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 GenericProject.
-
deleteProjectPool
public void deleteProjectPool(String poolId, String poolClass, String userName) throws ApplicationObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException, InvalidArgumentException
Deletes a project 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 GenericProject.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.
-
getProjectPools
public List<InventoryObjectPool> getProjectPools() throws InvalidArgumentException
Retrieves the projects pool list.- Returns:
- The available project pools.
- Throws:
InvalidArgumentException
- If the pool id is null or the result pool does not have uuid
-
getProjectsInPool
public List<BusinessObjectLight> getProjectsInPool(String poolId, int limit) throws ApplicationObjectNotFoundException, InvalidArgumentException
Gets the projects inside a project pool- Parameters:
poolId
- The pool id.limit
- The results limit per page. Use -1 to retrieve all- Returns:
- The projects 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.
-
getAllProjects
public List<BusinessObjectLight> getAllProjects(long page, long limit) throws InvalidArgumentException, MetadataObjectNotFoundException
Get all projects, without filters.- Parameters:
page
- Page number of results to skip. Use -1 to retrieve alllimit
- Max number of results per page. Use -1 to retrieve all- Returns:
- The projects list.
- Throws:
InvalidArgumentException
- If any project node could not be mapped into a Java object.MetadataObjectNotFoundException
- If the provided class name doesn't exists.
-
getProjectsWithFilter
public List<BusinessObjectLight> getProjectsWithFilter(HashMap<String,String> filters, long page, long limit) throws InvalidArgumentException, MetadataObjectNotFoundException
Get the projects according to the filter value.- Parameters:
filters
- Map of filters key: attribute name, value: attribute value.page
- Page or number of elements to skip.limit
- Max count of child per page.- Returns:
- The projects list.
- Throws:
InvalidArgumentException
- If any project node could not be mapped into a Java object.MetadataObjectNotFoundException
- If the provided class name doesn't exists.
-
relateObjectsToProject
public void relateObjectsToProject(String projectClass, String projectId, String[] objectClass, String[] objectId, String userName) throws InvalidArgumentException, ArraySizeMismatchException, BusinessObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Relates a set of objects to a project.- Parameters:
projectClass
- The project class.projectId
- The project id.objectClass
- The object class.objectId
- The object Id.userName
- The user name of the session.- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProject.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.
-
relateObjectToProject
public void relateObjectToProject(String projectClass, String projectId, String objectClass, String objectId, String userName) throws InvalidArgumentException, BusinessObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Relates an object to a project- Parameters:
projectClass
- The project class.projectId
- The project id.objectClass
- The object class.objectId
- The object Id.userName
- The user name of the session.- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProject.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 the object class provided can't be found.ApplicationObjectNotFoundException
- If the object activity log can't be found.
-
releaseObjectFromProject
public void releaseObjectFromProject(String objectClass, String objectId, String projectClass, String projectId, String userName) throws InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Releases an object from project.- Parameters:
objectClass
- The object class.objectId
- The object Id.projectClass
- The project class.projectId
- The project id.userName
- The user name of the session.- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProject.BusinessObjectNotFoundException
- If any of the objects can't be found.MetadataObjectNotFoundException
- If the object class provided can't be found.ApplicationObjectNotFoundException
- If the object activity log can't be found.
-
getProjectsRelatedToObject
public List<BusinessObjectLight> getProjectsRelatedToObject(String objectClass, String objectId) throws BusinessObjectNotFoundException, MetadataObjectNotFoundException, InvalidArgumentException
Gets the projects related to an object.- Parameters:
objectClass
- The object class.objectId
- The object Id.- Returns:
- The list projects related to an object.
- Throws:
BusinessObjectNotFoundException
- If the object can't be found.MetadataObjectNotFoundException
- If the object class provided can't be found.InvalidArgumentException
- If the object id is null or the result object does not have uuid.
-
getProjectResources
public List<BusinessObjectLight> getProjectResources(String projectClass, String projectId) throws InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Gets the resources related to a project.- Parameters:
projectClass
- Project class.projectId
- Project Id.- Returns:
- The project resources list.
- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProject.BusinessObjectNotFoundException
- If the project can't be found.MetadataObjectNotFoundException
- If the project class provided can't be found.
-
getProjectActivities
public List<BusinessObjectLight> getProjectActivities(String projectClass, String projectId) throws InvalidArgumentException, MetadataObjectNotFoundException, BusinessObjectNotFoundException
Gets the activities inside a project.- Parameters:
projectClass
- The project class.projectId
- The project Id.- Returns:
- The activities list.
- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProject.MetadataObjectNotFoundException
- If the project class provided can't be found.BusinessObjectNotFoundException
- If the project can't be found.
-
createActivity
public String createActivity(String projectId, String projectClass, String activityClass, HashMap<String,String> attributes, String userName) throws MetadataObjectNotFoundException, BusinessObjectNotFoundException, InvalidArgumentException, OperationNotPermittedException, ApplicationObjectNotFoundException
Creates an Activity inside a project.- Parameters:
projectId
- The project id.projectClass
- The project class.activityClass
- The activity class. Must be subclass of GenericActivity.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 activity.
- Throws:
MetadataObjectNotFoundException
- If any of the object classes can't be found.BusinessObjectNotFoundException
- If the project id can't be found.InvalidArgumentException
- If any of the attribute values has an invalid value or format.OperationNotPermittedException
- If the update can't be performed due to a format issue.ApplicationObjectNotFoundException
- If the specified template can't be found.
-
getActivity
public BusinessObject getActivity(String activityClass, String activityId) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException
Get activity properties- Parameters:
activityClass
- The activity class. Must be subclass of GenericActivity.activityId
- The activity id.- Returns:
- The activity properties.
- Throws:
MetadataObjectNotFoundException
- If the activity class can't be found.InvalidArgumentException
- If the activity id can't be found.BusinessObjectNotFoundException
- If the requested activity can't be found.
-
updateActivity
public void updateActivity(String activityClass, String activityId, HashMap<String,String> attributes, String userName) throws MetadataObjectNotFoundException, BusinessObjectNotFoundException, OperationNotPermittedException, InvalidArgumentException, ApplicationObjectNotFoundException
Updates one or many activity attributes.- Parameters:
activityClass
- The activity class. Must be subclass of GenericActivity.activityId
- The activity 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:
MetadataObjectNotFoundException
- If the activity class can't be found.InvalidArgumentException
- If the activity id can't be found.BusinessObjectNotFoundException
- If the requested activity can't be found.OperationNotPermittedException
- If the update can't be performed due a business rule or because the activity is blocked.ApplicationObjectNotFoundException
- If the object activity log can't be found.
-
deleteActivity
public void deleteActivity(String activityClass, String activityId, boolean releaseRelationships, String userName) throws BusinessObjectNotFoundException, MetadataObjectNotFoundException, OperationNotPermittedException, InvalidArgumentException, ApplicationObjectNotFoundException
Deletes an activity and delete its association with the related inventory objects. These objects will remain untouched.- Parameters:
activityClass
- The activity class. Must be subclass of GenericActivity.activityId
- The activity id.releaseRelationships
- Release of existing relationships.userName
- The user name of the session.- Throws:
BusinessObjectNotFoundException
- If the requested activity can't be found.MetadataObjectNotFoundException
- If the activity class can't be found.InvalidArgumentException
- If the activity id can't be found.OperationNotPermittedException
- If the activity could not be deleted because there's some business rules that avoids it or it has incoming relationships.ApplicationObjectNotFoundException
- If the object activity log can't be found.
-
copyProjectToPool
public String copyProjectToPool(String poolId, String projectClass, String projectId, String userName) throws ApplicationObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Creates a copy of a project.- Parameters:
poolId
- The pool id.projectClass
- The project class.projectId
- The project id.userName
- The user name of the session.- Returns:
- The newly created project id.
- Throws:
ApplicationObjectNotFoundException
- If the pool node can not be found.InvalidArgumentException
- If the project can not be copy to the selected pool.BusinessObjectNotFoundException
- If the project can not be found.MetadataObjectNotFoundException
- If the project class name can no be found.
-
moveProjectToPool
public void moveProjectToPool(String poolId, String projectClass, String projectId, String userName) throws MetadataObjectNotFoundException, InvalidArgumentException, ApplicationObjectNotFoundException, BusinessObjectNotFoundException
Moves a project from a pool to another pool.- Parameters:
poolId
- The pool id.projectClass
- The project class.projectId
- The project id.userName
- The user name of the session.- Throws:
MetadataObjectNotFoundException
- If the project class name can no be found.InvalidArgumentException
- If the project can not be move to the selected pool.ApplicationObjectNotFoundException
- If the pool node can not be found.BusinessObjectNotFoundException
- If the project can not be found.
-
-