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>
-
-
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
addActivity(String parentId, String parentClassName, String className, String[] attributeNames, String[] attributeValues)
Adds an Activity.void
associateObjectsToProject(String projectClass, String projectId, String[] objectClass, String[] objectId)
Associates objects to a Projectvoid
associateObjectToProject(String projectClass, String projectId, String objectClass, String objectId)
Associates an object to a ProjectString
createProject(String projectPoolId, String projectClass, HashMap<String,String> attributes)
Create a projectString
createProjectPool(String name, String description, String instancesOfClass)
Create a project poolvoid
deleteActivity(String className, String oid, boolean releaseRelationships)
Deletes an activityvoid
deleteProject(String projectClass, String projectId)
Deletes a project and delete its association with the related inventory objects.void
deleteProjetcPool(String projectPoolId)
Deletes a proxy pool.List<Project>
getAllProjects()
Gets all the projects in the database.Project
getProject(String projectClass, String projectId)
Get project propertiesList<BusinessObjectLight>
getProjectActivities(String projectClass, String projectId)
Gets the activities associates to an ProjectInventoryObjectPool
getProjectPool(String poolId)
Get properties poolList<InventoryObjectPool>
getProjectPools()
Retrieves the list of pools of projects.List<BusinessObjectLight>
getProjectResources(String projectClass, String projectId)
Gets the resources associates with an ProjectList<BusinessObjectLight>
getProjectsAssociateToObject(String objectClass, String objectId)
Gets the project associate to an objectList<Project>
getProjectsInPool(String projectPoolId)
Gets the list of projects in a given pool.List<BusinessObjectLight>
getProjectsInProjectPool(String poolId, int limit)
Gets the project in a Project poolvoid
releaseObjectFromProject(String objectClass, String objectId, String projectClass, String projectId)
Releases an object from Projectvoid
updateProject(String projectClass, String projectId, HashMap<String,String> attributes)
Updates one or many project attributes.void
updateProjectPool(String projectPoolId, String attributeName, String attributeValue)
Updates an attribute 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) throws MetadataObjectNotFoundException, ApplicationObjectNotFoundException, InvalidArgumentException
Create a project- Parameters:
projectPoolId
- The parent 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.- Returns:
- The id of the newly created project.
- Throws:
MetadataObjectNotFoundException
ApplicationObjectNotFoundException
InvalidArgumentException
-
getProject
public Project getProject(String projectClass, String projectId) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException, ApplicationObjectNotFoundException
Get project properties- Parameters:
projectClass
- The project class. Must be subclass of GenericProject.projectId
- The project id.- Returns:
- project properties
- Throws:
MetadataObjectNotFoundException
InvalidArgumentException
BusinessObjectNotFoundException
ApplicationObjectNotFoundException
-
deleteProject
public void deleteProject(String projectClass, String projectId) throws MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Deletes a project and delete its association with the related inventory objects. These objects will remain untouched.- Parameters:
projectClass
- The class of the projectprojectId
- The id of the project- Throws:
ApplicationObjectNotFoundException
MetadataObjectNotFoundException
-
updateProject
public void updateProject(String projectClass, String projectId, HashMap<String,String> attributes) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Updates one or many project attributes.- Parameters:
projectClass
- The class of the projectprojectId
- The id of the projectattributes
- The set of initial attributes. If no attribute name is specified, an empty string will be used.- Throws:
ApplicationObjectNotFoundException
- If the parent pool could not be found.InvalidArgumentException
- If any of the initial attributes could not be mapped.MetadataObjectNotFoundException
- If the project class could not be found.
-
createProjectPool
public String createProjectPool(String name, String description, String instancesOfClass) throws MetadataObjectNotFoundException
Create a project pool- Parameters:
name
- The name of the pool.description
- The description of the pool.instancesOfClass
- What kind of objects can this pool contain?- Returns:
- The id of the newly created project.
- Throws:
MetadataObjectNotFoundException
-
getProjectPool
public InventoryObjectPool getProjectPool(String poolId) throws ApplicationObjectNotFoundException, InvalidArgumentException
Get properties pool- Parameters:
poolId
- The pool id.- Returns:
- The pool properties.
- Throws:
ApplicationObjectNotFoundException
InvalidArgumentException
-
updateProjectPool
public void updateProjectPool(String projectPoolId, String attributeName, String attributeValue) throws ApplicationObjectNotFoundException, InvalidArgumentException
Updates an attribute of a project pool.- Parameters:
projectPoolId
- The id of the pool to be updated.attributeName
- The name of the pool attribute to be updated. Valid values are "name" and "description"attributeValue
- The value of the attribute. Null values will be ignored.- Throws:
ApplicationObjectNotFoundException
- If the pool could not be found.InvalidArgumentException
- If an unknown attribute name is provided.
-
deleteProjetcPool
public void deleteProjetcPool(String projectPoolId) throws ApplicationObjectNotFoundException
Deletes a proxy pool.- Parameters:
projectPoolId
- The id of the pool.- Throws:
ApplicationObjectNotFoundException
- If the pool could not be found.
-
getProjectPools
public List<InventoryObjectPool> getProjectPools()
Retrieves the list of pools of projects.- Returns:
- The available pools of projects.
-
getProjectsInPool
public List<Project> getProjectsInPool(String projectPoolId) throws ApplicationObjectNotFoundException, InvalidArgumentException
Gets the list of projects in a given pool.- Parameters:
projectPoolId
- The id of the parent pool.- Returns:
- The projects
- Throws:
ApplicationObjectNotFoundException
- If the parent pool could not be found.InvalidArgumentException
- If the object in the database can not be mapped into an Project instance.
-
getProjectsInProjectPool
public List<BusinessObjectLight> getProjectsInProjectPool(String poolId, int limit) throws ApplicationObjectNotFoundException, InvalidArgumentException
Gets the project in a Project pool- Parameters:
poolId
- Project pool idlimit
- Max result number, -1 without limit- Returns:
- The list of projects
- Throws:
ApplicationObjectNotFoundException
- If the Project pool is not foundInvalidArgumentException
- If the pool does not have uuid
-
getAllProjects
public List<Project> getAllProjects() throws InvalidArgumentException
Gets all the projects in the database.- Returns:
- The list of projects
- Throws:
InvalidArgumentException
- If any project node could not be mapped into a Java object.
-
associateObjectsToProject
public void associateObjectsToProject(String projectClass, String projectId, String[] objectClass, String[] objectId) throws InvalidArgumentException, ArraySizeMismatchException, BusinessObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException
Associates objects to a Project- Parameters:
projectClass
- Project classprojectId
- Project IdobjectClass
- Object classobjectId
- Object Id- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProjectArraySizeMismatchException
- if array sizes of objectClass and objectId are not the sameBusinessObjectNotFoundException
OperationNotPermittedException
MetadataObjectNotFoundException
-
associateObjectToProject
public void associateObjectToProject(String projectClass, String projectId, String objectClass, String objectId) throws InvalidArgumentException, BusinessObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException
Associates an object to a Project- Parameters:
projectClass
- Project classprojectId
- Project IdobjectClass
- Object classobjectId
- Object id- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProjectBusinessObjectNotFoundException
OperationNotPermittedException
MetadataObjectNotFoundException
-
releaseObjectFromProject
public void releaseObjectFromProject(String objectClass, String objectId, String projectClass, String projectId) throws InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Releases an object from Project- Parameters:
objectClass
- Object classobjectId
- Object idprojectClass
- Project classprojectId
- Project id- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProjectBusinessObjectNotFoundException
MetadataObjectNotFoundException
-
getProjectsAssociateToObject
public List<BusinessObjectLight> getProjectsAssociateToObject(String objectClass, String objectId) throws BusinessObjectNotFoundException, MetadataObjectNotFoundException, InvalidArgumentException
Gets the project associate to an object- Parameters:
objectClass
- Object classobjectId
- Object Id- Returns:
- The list of projects
- Throws:
BusinessObjectNotFoundException
- If the project is no foundMetadataObjectNotFoundException
- If the project class is no foundInvalidArgumentException
- If the object does not have uuid
-
getProjectResources
public List<BusinessObjectLight> getProjectResources(String projectClass, String projectId) throws InvalidArgumentException, BusinessObjectNotFoundException, MetadataObjectNotFoundException
Gets the resources associates with an Project- Parameters:
projectClass
- Project classprojectId
- Project Id- Returns:
- The list of project resources
- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProjectBusinessObjectNotFoundException
MetadataObjectNotFoundException
-
getProjectActivities
public List<BusinessObjectLight> getProjectActivities(String projectClass, String projectId) throws InvalidArgumentException, MetadataObjectNotFoundException, BusinessObjectNotFoundException
Gets the activities associates to an Project- Parameters:
projectClass
- Project classprojectId
- Project Id- Returns:
- The list of Activities
- Throws:
InvalidArgumentException
- If the project is not subclass of GenericProjectMetadataObjectNotFoundException
- If the project class is not foundBusinessObjectNotFoundException
- If the project is not found
-
addActivity
public String addActivity(String parentId, String parentClassName, String className, String[] attributeNames, String[] attributeValues) throws MetadataObjectNotFoundException, BusinessObjectNotFoundException, InvalidArgumentException, OperationNotPermittedException, ApplicationObjectNotFoundException, ArraySizeMismatchException
Adds an Activity.- Parameters:
parentId
- Parent IdparentClassName
- Parent class nameclassName
- Class nameattributeNames
- Attribute namesattributeValues
- Attribute values- Returns:
- The Activity id
- Throws:
MetadataObjectNotFoundException
- If the object's class can't be foundBusinessObjectNotFoundException
- If the parent id is not foundInvalidArgumentException
- If any of the attribute values has an invalid value or formatOperationNotPermittedException
- If the update can't be performed due to a format issueApplicationObjectNotFoundException
- If the specified template could not be foundArraySizeMismatchException
- If attributeNames and attributeValues have different sizes.
-
deleteActivity
public void deleteActivity(String className, String oid, boolean releaseRelationships) throws BusinessObjectNotFoundException, MetadataObjectNotFoundException, OperationNotPermittedException, InvalidArgumentException
Deletes an activity- Parameters:
className
- Class nameoid
- Object idreleaseRelationships
- Release relationships- Throws:
BusinessObjectNotFoundException
- If the object couldn't be foundMetadataObjectNotFoundException
- If the class 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 activity does not have uuid
-
-