/** * Retrieves all ProjectComponents that have the given user as their lead. * Not synchronised, because findAll() returns a private copy of all components. * * @param userKey key of the lead user * @return possibly empty Collection of ProjectComponents. */ public Collection findComponentsBylead(String userKey) { Collection<ProjectComponent> leadComponents = new ArrayList<ProjectComponent>(); Collection components = findAll(); for (final Object component : components) { MutableProjectComponent projectComponent = (MutableProjectComponent) component; if (projectComponent != null && TextUtils.stringSet(projectComponent.getLead()) && projectComponent.getLead().equals(userKey)) { leadComponents.add(projectComponent); } } return leadComponents; }
@Override public ApplicationUser getComponentLead() { return ComponentAccessor.getUserManager().getUserByKey(getLead()); }
/** * 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()); }
@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); } } }
componentParams.put(FIELD_NAME, name); componentParams.put(FIELD_DESCRIPTION, component.getDescription()); componentParams.put(FIELD_LEAD, component.getLead()); componentParams.put(FIELD_PROJECT, component.getProjectId()); componentParams.put(FIELD_ASSIGNEE_TYPE, component.getAssigneeType()); componentGV.setString(FIELD_LEAD, component.getLead()); componentGV.set(FIELD_ASSIGNEE_TYPE, component.getAssigneeType()); try