/** * Looks up all components that are related to the project with given ID. * * @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) { Collection<ProjectComponent> components = projectIdToComponentsMap.get(projectId); return MutableProjectComponent.copy(components); }
/** * Copy given collection of components * * @param c collection of components to copy * @return new instance collection of MutableProjectComponent objects set with values of the given components */ public static Collection<MutableProjectComponent> copy(final Collection<ProjectComponent> c) { if (c != null && !c.isEmpty()) { final List copyList = Lists.newArrayListWithCapacity(c.size()); for (final Object aC : c) { copyList.add(MutableProjectComponent.copy((ProjectComponent) aC)); } return copyList; } else { return Collections.EMPTY_LIST; } }
public ErrorCollection execute(ApplicationUser user) throws GenericEntityException { ErrorCollection errorCollection = new SimpleErrorCollection(); final Set<Map.Entry<ProjectComponent, Long>> componentEntries = componentAssigneeTypes.entrySet(); for (final Map.Entry<ProjectComponent, Long> entry : componentEntries) { final Long assigneeType = entry.getValue(); final Long componentId = entry.getKey().getId(); MutableProjectComponent projectComponent = MutableProjectComponent.copy(projectComponentService.find(user, errorCollection, componentId)); projectComponent.setAssigneeType(assigneeType); projectComponentService.update(user, errorCollection, projectComponent); } return errorCollection; }
/** * Persist the component. If component has no ID (null) it is inserted to the database and added to the cache, * otherwise an update operation is performed on both cache and database. * * @param component component to persist * @throws EntityNotFoundException in case of update if the component does not exist (maybe was deleted :-) * @throws com.atlassian.jira.exception.DataAccessException if cannot persist the component */ public MutableProjectComponent store(MutableProjectComponent component) throws EntityNotFoundException, DataAccessException { MutableProjectComponent copy = MutableProjectComponent.copy(component); MutableProjectComponent newComponent; if (copy.getId() == null) { newComponent = insert(copy); } else { newComponent = update(copy); } return newComponent; }
/** * Looks up the project component by the given ID and returns it. If not found, throws the EntityNotFoundException, * it never returns null. * * @param id project component ID * @return project component found by a given ID * @throws EntityNotFoundException if the component not found */ public MutableProjectComponent find(Long id) throws EntityNotFoundException { Assertions.notNull("id", id); ProjectComponent component = componentIdToComponentMap.get(id).getValue(); if (component == null) { throw new EntityNotFoundException("The component with id '" + id + "' does not exist."); } return MutableProjectComponent.copy(component); }
private void removeComponentLeadsForUser(final ApplicationUser user) { for (final ProjectComponent component : getComponentsUserLeads(user)) { MutableProjectComponent newProjectComponent = MutableProjectComponent.copy(component); newProjectComponent.setLead(null); if (component.getAssigneeType() == AssigneeTypes.COMPONENT_LEAD) { newProjectComponent.setAssigneeType(AssigneeTypes.PROJECT_DEFAULT); } try { componentManager.update(newProjectComponent); } catch (EntityNotFoundException e) { // We only just fetched this component, but perhaps someone deleted it concurrently ... } } }
MutableProjectComponent mutableComponent = MutableProjectComponent.copy(currentComponent); update(bean, mutableComponent, errorCollection); final ProjectComponent projectComponent = projectComponentService.update(authContext.getUser(), errorCollection, mutableComponent);
return MutableProjectComponent.copy(component);