protected ComponentConverter getComponentConverter() { return new ComponentConverter(); } }
/** * Convert the specified collection of GenericValues representing MutableProjectComponent object to a collection of * MutableProjectComponent objects. * * @param componentGVCollection collection of GenericValues - each GenericValue represents a ProjectComponent * @return collection of new MutableProjectComponent objects that represents the original collection of * GenericValues */ public Collection<MutableProjectComponent> convertToComponents(Collection<GenericValue> componentGVCollection) { Collection<MutableProjectComponent> components = new ArrayList<MutableProjectComponent>(componentGVCollection.size()); for (final GenericValue gv : componentGVCollection) { if (gv != null) { components.add(convertToComponent(gv)); } } return components; }
/** * Convert a collection of MutableProjectComponent objects to a collection of ProjectComponent objects. * * @param mutables collection of MutableProjectComponent objects to convert * @return collection of new ProjectComponent objects that represent objects in the given MutableProjectComponent * collection */ public Collection<ProjectComponent> convertToProjectComponents(Collection<MutableProjectComponent> mutables) { Collection<ProjectComponent> components = new ArrayList<ProjectComponent>(mutables.size()); for (final MutableProjectComponent mutable : mutables) { components.add(convertToProjectComponent(mutable)); } return components; }
/** * Retrieve a collection of components - where the lead of each component is the specified user. * * @param userKey the lead user's key * @return collection of components - where the lead of each component is the specified user */ public Collection findComponentsBylead(String userKey) { return getComponentConverter().convertToComponents(findComponentGVs(FIELD_LEAD, userKey)); }
/** * Convert a collection of MutableProjectComponent objects to a collection of ProjectComponent objects. * * @param mutables collection of MutableProjectComponent objects to convert * @return collection of new ProjectComponent objects that represent objects in the given MutableProjectComponent * collection */ private Collection<ProjectComponent> convertToProjectComponents(Collection<MutableProjectComponent> mutables) { return getComponentConverter().convertToProjectComponents(mutables); }
/** * Retrieve all components that are related to the project with given ID and sort by name. * * @param projectId project ID * @return a collection of ProjectComponent objects that are related to the project with given ID */ public Collection<MutableProjectComponent> findAllForProject(Long projectId) { return getComponentConverter().convertToComponents(findComponentGVs(FIELD_PROJECT, projectId,FIELD_NAME)); }
public Collection<MutableProjectComponent> findByComponentNameCaseInSensitive(String componentName) { if (componentName == null) { throw new IllegalArgumentException("Component Name is required, was null."); } final Collection<MutableProjectComponent> components = getComponentConverter().convertToComponents(delegator.findAll(OfBizDelegator.PROJECT_COMPONENT)); List<MutableProjectComponent> matched = new ArrayList<MutableProjectComponent>(); for (MutableProjectComponent component : components) { if (componentName.equalsIgnoreCase(component.getName())) { matched.add(component); } } return matched; }
public MutableProjectComponent findByComponentName(Long projectId, String componentName) throws IllegalArgumentException { if (projectId == null) { throw new IllegalArgumentException("Project ID is required, was null."); } if (componentName == null) { throw new IllegalArgumentException("Component Name is required, was null."); } List components = delegator.findByAnd(OfBizDelegator.PROJECT_COMPONENT, MapBuilder.<String, Object>newBuilder().add(FIELD_PROJECT, projectId).add(FIELD_NAME, componentName).toMap()); // should only be one or none since component name is unique per project if (components.size() == 1) { return getComponentConverter().convertToComponent((GenericValue) components.get(0)); } else if (components.size() == 0) { return null; } else { log.error("found " + components.size() + " components with name " + componentName + " in project with id " + projectId); return (MutableProjectComponent) components.get(0); } }
protected ComponentConverter getComponentConverter() { return new ComponentConverter(); }
/** * Convert the specified MutableProjectComponent to a ProjectComponent object. * * @param value MutableProjectComponent to be converted into a ProjectComponent. * @return new instance of ProjectComponent with same values as given in the parameter object */ protected ProjectComponent convertToProjectComponent(MutableProjectComponent value) { return getComponentConverter().convertToProjectComponent(value); }
/** * Retrieve all ProjectComponent objects stored and sort by name. * * @return all ProjectComponent objects stored */ public Collection findAll() { return getComponentConverter().convertToComponents(delegator.findAll(OfBizDelegator.PROJECT_COMPONENT, CollectionBuilder.list(FIELD_NAME))); }
/** * Retrieve the MutableProjectComponent with the specified ID. An EntityNotFoundException is thrown if the component * is not found. * * @param id component ID to search for * @return MutableProjectComponent component with the specified ID * @throws EntityNotFoundException if the component is not found */ public MutableProjectComponent find(Long id) throws EntityNotFoundException { validateId(id); GenericValue componentGV = findComponentGV(FIELD_ID, id); if (componentGV == null) { throw new EntityNotFoundException("Component with ID = '" + id + "' does not exist."); } else { return getComponentConverter().convertToComponent(componentGV); } }