/** * Find the component with the specified ID * * @param id component ID to search for * @return ProjectComponent with the specified ID * @throws EntityNotFoundException if the component is not found */ public ProjectComponent find(Long id) throws EntityNotFoundException { return convertToProjectComponent(store.find(id)); }
public ProjectComponent findByComponentName(Long projectId, String componentName) { MutableProjectComponent pc; try { pc = store.findByComponentName(projectId, componentName); return pc == null ? null : convertToProjectComponent(pc); } catch (EntityNotFoundException e) { return null; } }
/** * 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; } }
/** * Update the component specified with the values given. * * @param component component to be updated * @return ProjectComponent with updated values as specified * @throws EntityNotFoundException if component is not found */ public ProjectComponent update(MutableProjectComponent component) throws EntityNotFoundException { ProjectComponent oldProjectComponent = find(component.getId()); store.store(component); ProjectComponent projectComponent = convertToProjectComponent(component); eventPublisher.publish(new ProjectComponentUpdatedEvent(projectComponent, oldProjectComponent)); return projectComponent; }