/** * Validates that the name is not null * * @param component component to validate * @throws IllegalArgumentException if name is null */ private void validateName(MutableProjectComponent component) throws IllegalArgumentException { if (component.getName() == null) { throw new IllegalArgumentException("Name is required, was null."); } }
@Override public Collection<String> findAllUniqueNamesForProjects(Collection<Long> projectIds) { Set<String> uniqueNames = Sets.newTreeSet(ProjectComponentComparator.COMPONENT_NAME_COMPARATOR); for (Long projectId : projectIds) { Collection<MutableProjectComponent> projectComponents = store.findAllForProject(projectId); if (projectComponents != null) { for (MutableProjectComponent component : projectComponents) { uniqueNames.add(component.getName()); } } } return uniqueNames; }
/** * Finds one or more ProjectComponent with a given name. * * @param componentName the name of the component to find. * @return a Collection of Components with the given name. */ public Collection<MutableProjectComponent> findByComponentNameCaseInSensitive(String componentName) { Collection<MutableProjectComponent> components = findAll(); Collection<MutableProjectComponent> matchingComponents = new ArrayList<MutableProjectComponent>(); for (final MutableProjectComponent component : components) { if (component.getName().equalsIgnoreCase(componentName)) { matchingComponents.add(component); } } return matchingComponents; }
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; }
@Override @SuppressWarnings("unchecked") public Collection<String> findAllUniqueNamesForProjectObjects(Collection<Project> projects) { Set<String> uniqueNames = Sets.newTreeSet(ProjectComponentComparator.COMPONENT_NAME_COMPARATOR); for (Project project : projects) { Collection<MutableProjectComponent> projectComponents = store.findAllForProject(project.getId()); if (projectComponents != null) { for (MutableProjectComponent component : projectComponents) { uniqueNames.add(component.getName()); } } } return uniqueNames; }
/** * Looks up the component with the given name in the project with the given id. * * @param projectId id of the project. * @param componentName name of the component. * @return the component. * @throws EntityNotFoundException if no such component can be found. */ public MutableProjectComponent findByComponentName(Long projectId, String componentName) throws EntityNotFoundException { Collection<MutableProjectComponent> components = findAllForProject(projectId); for (MutableProjectComponent c : components) { if (c.getName().equals(componentName)) { return c; } } throw new EntityNotFoundException("The project with id '" + projectId + "' is not associated with a component with the name '" + componentName + "'."); }
@Override void validateData() { // validate lead validateLead(this, component.getLead()); // validate name Long id = component.getId(); try { ProjectComponent oldComponent = projectComponentManager.find(id); String oldName = oldComponent.getName(); if (!oldName.equalsIgnoreCase(component.getName())) { validateName(this, oldName, component.getName(), oldComponent.getProjectId()); } } catch (EntityNotFoundException e) { if (id != null) { addErrorKey(KEY_NO_SUCH_COMPONENT_WITH_ID, id.toString(), ErrorCollection.Reason.VALIDATION_FAILED); } else { addErrorKey(KEY_NO_SUCH_COMPONENT, null, ErrorCollection.Reason.VALIDATION_FAILED); } } }
/** * 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 */ public ProjectComponent convertToProjectComponent(MutableProjectComponent value) { return new ProjectComponentImpl(value.getId(), value.getName(), value.getDescription(), value.getLead(), value.getAssigneeType(), value.getProjectId(), value.getGenericValue()); }
try final String name = component.getName(); if (containsName(name, component.getProjectId()))