/** * Create a new ProjectComponent object associated with the project with the ID specified and with the values given. * * @param name name of component * @param description description of component * @param lead user name associated with component * @param projectId ID of project that component is associated with * @return new instance of ProjectComponent with the values specified */ public ProjectComponent create(String name, String description, String lead, long assigneeType, Long projectId) throws IllegalArgumentException { try { MutableProjectComponent component = new MutableProjectComponent(null, name, description, lead, assigneeType, projectId); ProjectComponent projectComponent = convertToProjectComponent(store.store(component)); eventPublisher.publish(new ProjectComponentCreatedEvent(projectComponent)); return projectComponent; } catch (EntityNotFoundException e) { // Insert should never cause this exception - so this return statement should never be reached return null; } }
/** * Convert the specified ProjectComponent to a MutableProjectComponent object and sets its project ID with the given * value. * * @param value ProjectComponent to be converted into a MutableProjectComponent. * @return new instance of MutableProjectComponent with same values as given in the parameter object and with * project ID set */ protected MutableProjectComponent convertToMutableProjectComponent(ProjectComponent value) { return new MutableProjectComponent(value.getId(), value.getName(), value.getDescription(), value.getLead(), value.getAssigneeType(), value.getProjectId()); }
/** * Copy given component * * @param c component to copy * @return new instance of MutableProjectComponent set with values of the given component */ public static MutableProjectComponent copy(final ProjectComponent c) { MutableProjectComponent mutableProjectComponent = new MutableProjectComponent(c.getId(), c.getName(), c.getDescription(), c.getLead(), c.getAssigneeType(), c.getProjectId()); mutableProjectComponent.setGenericValue(c.getGenericValue()); return mutableProjectComponent; }
/** * Convert the specified GenericValue representing a MutableProjectComponent object to a MutableProjectComponent * object. * * @param componentGV GenericValue object representing a MutableProjectComponent object to be converted to a * MutableProjectComponent object * @return new MutableProjectComponent object that represents the original GenericValue object */ public MutableProjectComponent convertToComponent(GenericValue componentGV) { Long id = componentGV.getLong(OfBizProjectComponentStore.FIELD_ID); String name = componentGV.getString(OfBizProjectComponentStore.FIELD_NAME); String description = componentGV.getString(OfBizProjectComponentStore.FIELD_DESCRIPTION); String lead = componentGV.getString(OfBizProjectComponentStore.FIELD_LEAD); Long projectId = componentGV.getLong(OfBizProjectComponentStore.FIELD_PROJECT); Long assigneeTypeLong = componentGV.getLong(OfBizProjectComponentStore.FIELD_ASSIGNEE_TYPE); long assigneeType; if (assigneeTypeLong != null) { assigneeType = assigneeTypeLong; } else { assigneeType = AssigneeTypes.PROJECT_DEFAULT; } MutableProjectComponent mutableProjectComponent = new MutableProjectComponent(id, name, description, lead, assigneeType, projectId); mutableProjectComponent.setGenericValue(componentGV); return mutableProjectComponent; }