public class

DefaultProjectComponentManager

extends Object
implements ProjectComponentManager
java.lang.Object
   ↳ com.atlassian.jira.bc.project.component.DefaultProjectComponentManager

Class Overview

Validates project component values and provides methods for accessing and persisting project components.

Summary

Constants
String FIELD_LEAD lead field name
String FIELD_NAME name field name
String FIELD_PROJECT_ID project ID field name
[Expand]
Inherited Constants
From interface com.atlassian.jira.bc.project.component.ProjectComponentManager
Fields
protected final EventPublisher eventPublisher
Public Constructors
DefaultProjectComponentManager(ProjectComponentStore store, IssueManager issueManager, EventPublisher eventPublisher, UserManager userManager, NodeAssociationStore nodeAssociationStore, DbConnectionManager dbConnectionManager)
Creates a new instance of this class and sets the store that will be used for persistence.
Public Methods
boolean containsName(String name, Long projectId)
Check whether component with specified name is stored.
GenericValue convertToGenericValue(ProjectComponent projectComponent)
Converts the ProjectComponent to GenericValue form, provided as a transitional measure until GenericValue is eradicated from the front end.
Collection<GenericValue> convertToGenericValues(Collection<ProjectComponent> projectComponents)
Temporary method to allow conversion of a collection of ProjectComponent objects to a collection of GenericValues representing a project component.
ProjectComponent create(String name, String description, String lead, long assigneeType, Long projectId)
Create a new ProjectComponent object associated with the project with the ID specified and with the values given.
void delete(Long componentId)
Delete the component.
void deleteAllComponents(Long projectId)
Deletes all components in given project.
ProjectComponent find(Long id)
Find the component with the specified ID
Collection<ProjectComponent> findAll()
Implement this method to find all components.
Collection<ProjectComponent> findAllForProject(Long projectId)
Find all components associated with the project with the ID specified
Collection<String> findAllUniqueNamesForProjectObjects(Collection<Project> projects)
Returns all unique names of the components that belong to the passed projects.
Collection<String> findAllUniqueNamesForProjects(Collection<Long> projectIds)
Returns all unique names of components associated with all the projects with the ID-s specified.
ProjectComponent findByComponentName(Long projectId, String componentName)
Finds the ProjectComponent with the given name in the project with the given id.
Collection<ProjectComponent> findByComponentNameCaseInSensitive(String componentName)
Finds all ProjectComponents with the given name with comparisons case insenstive.
Collection<ProjectComponent> findComponentsByIssue(Issue issue)
Collection<GenericValue> findComponentsByIssueGV(Issue issue)
This code used to live directly in the IssueImpl but it has been refactored into the ProjectComponentManager to make things a little cleaner.
Collection<ProjectComponent> findComponentsByLead(String userName)
Retrieve a collection of components - where the lead of each component is the specified user.
Long findProjectIdForComponent(Long id)
Implement this method to look up the project ID for the given component ID.
List<ProjectComponent> getComponents(List<Long> ids)
Creates a list of ProjectComponent objects from the given list of IDs.
@Nonnull Collection<Long> getIssueIdsWithComponent(ProjectComponent component)
Returns a list of all Issue IDs with the given component.
ProjectComponent getProjectComponent(Long projectComponentId)
Returns the component with the given ID or null if not found.
ProjectComponent update(MutableProjectComponent component)
Update the component specified with the values given.
List<ChangeItemBean> updateIssueProjectComponents(Issue issue, Collection<ProjectComponent> newValue)
Updates the list of components in issue
Protected Methods
MutableProjectComponent convertToMutableProjectComponent(ProjectComponent value)
Convert the specified ProjectComponent to a MutableProjectComponent object and sets its project ID with the given value.
ProjectComponent convertToProjectComponent(MutableProjectComponent value)
Convert the specified MutableProjectComponent to a ProjectComponent object.
ComponentConverter getComponentConverter()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.bc.project.component.ProjectComponentManager

Constants

protected static final String FIELD_LEAD

lead field name

Constant Value: "lead"

protected static final String FIELD_NAME

name field name

Constant Value: "name"

protected static final String FIELD_PROJECT_ID

project ID field name

Constant Value: "projectId"

Fields

protected final EventPublisher eventPublisher

Public Constructors

public DefaultProjectComponentManager (ProjectComponentStore store, IssueManager issueManager, EventPublisher eventPublisher, UserManager userManager, NodeAssociationStore nodeAssociationStore, DbConnectionManager dbConnectionManager)

Creates a new instance of this class and sets the store that will be used for persistence.

Parameters
store persistent store

Public Methods

public boolean containsName (String name, Long projectId)

Check whether component with specified name is stored.

Parameters
name component name, null will cause IllegalArgumentException
projectId project ID
Returns
  • true if new name is stored

public GenericValue convertToGenericValue (ProjectComponent projectComponent)

Converts the ProjectComponent to GenericValue form, provided as a transitional measure until GenericValue is eradicated from the front end.

Parameters
projectComponent project component
Returns
  • the ProjectComponent as a GenericValue.

public Collection<GenericValue> convertToGenericValues (Collection<ProjectComponent> projectComponents)

Temporary method to allow conversion of a collection of ProjectComponent objects to a collection of GenericValues representing a project component.

Parameters
projectComponents a collection of project components
Returns
  • Collection of GenericValues representing the collection of ProjectComponent objects passed in

public ProjectComponent create (String name, String description, String lead, long assigneeType, Long projectId)

Create a new ProjectComponent object associated with the project with the ID specified and with the values given.

Parameters
name name of component
description description of component
lead user name associated with component
assigneeType assignee type
projectId ID of project that component is associated with
Returns
  • new instance of ProjectComponent with the values specified

public void delete (Long componentId)

Delete the component.

Parameters
componentId component id
Throws
EntityNotFoundException if the component is not found

public void deleteAllComponents (Long projectId)

Deletes all components in given project. Note that this method will not fire a ProjectComponentDeleted upon deletion of a component.

Parameters
projectId id of the project in which components will be deleted.

public ProjectComponent find (Long id)

Find the component with the specified ID

Parameters
id component ID to search for
Returns
  • ProjectComponent with the specified ID
Throws
EntityNotFoundException if the component is not found

public Collection<ProjectComponent> findAll ()

Implement this method to find all components.

Returns
  • collection of all ProjectComponent objects

public Collection<ProjectComponent> findAllForProject (Long projectId)

Find all components associated with the project with the ID specified

Parameters
projectId ID of project to search for
Returns
  • collection of ProjectComponent objects associated with the project with the ID specified

public Collection<String> findAllUniqueNamesForProjectObjects (Collection<Project> projects)

Returns all unique names of the components that belong to the passed projects.

Parameters
projects projects to search in
Returns
  • collection of unique names of all components.

public Collection<String> findAllUniqueNamesForProjects (Collection<Long> projectIds)

Returns all unique names of components associated with all the projects with the ID-s specified.

Parameters
projectIds ID-s of project to search for
Returns
  • collection of unique names of components associated with all the projects with the ID-s specified.

public ProjectComponent findByComponentName (Long projectId, String componentName)

Finds the ProjectComponent with the given name in the project with the given id.

Parameters
projectId id of the project.
componentName name of the component.
Returns
  • the ProjectComponent or null if there is no such ProjectComponent.

public Collection<ProjectComponent> findByComponentNameCaseInSensitive (String componentName)

Finds all ProjectComponents with the given name with comparisons case insenstive.

Parameters
componentName name of the component.
Returns
  • all ProjectComponents with the given name or an empty collection if there is no such ProjectComponent.

public Collection<ProjectComponent> findComponentsByIssue (Issue issue)

public Collection<GenericValue> findComponentsByIssueGV (Issue issue)

This code used to live directly in the IssueImpl but it has been refactored into the ProjectComponentManager to make things a little cleaner. That's why it is "new in 4.2" but immediately marked as deprecated

Parameters
issue find components for this issue
Returns
  • collection of generic values representing the components assigned to the issue

public Collection<ProjectComponent> findComponentsByLead (String userName)

Retrieve a collection of components - where the lead of each component is the specified user.

Parameters
userName the lead user name
Returns
  • collection of components - where the lead of each component is the specified user

public Long findProjectIdForComponent (Long id)

Implement this method to look up the project ID for the given component ID. If project is not found, throws EntityNotFoundException.

Parameters
id component ID
Returns
  • project ID

public List<ProjectComponent> getComponents (List<Long> ids)

Creates a list of ProjectComponent objects from the given list of IDs.

Parameters
ids The List of ProjectComponent IDs.
Returns
  • a list of ProjectComponent objects from the given list of IDs.

@Nonnull public Collection<Long> getIssueIdsWithComponent (ProjectComponent component)

Returns a list of all Issue IDs with the given component.

Parameters
component the component
Returns
  • a not null list of all Issue IDs with the given component.

public ProjectComponent getProjectComponent (Long projectComponentId)

Returns the component with the given ID or null if not found.

Parameters
projectComponentId component ID
Returns
  • the component with the given ID or null if not found.

public ProjectComponent update (MutableProjectComponent component)

Update the component specified with the values given.

Parameters
component component to be updated
Returns
  • ProjectComponent with updated values as specified
Throws
EntityNotFoundException if component is not found

public List<ChangeItemBean> updateIssueProjectComponents (Issue issue, Collection<ProjectComponent> newValue)

Updates the list of components in issue

Parameters
issue updated issue
newValue list of components
Returns
  • list of ChangeItemBean

Protected Methods

protected MutableProjectComponent convertToMutableProjectComponent (ProjectComponent value)

Convert the specified ProjectComponent to a MutableProjectComponent object and sets its project ID with the given value.

Parameters
value ProjectComponent to be converted into a MutableProjectComponent.
Returns
  • new instance of MutableProjectComponent with same values as given in the parameter object and with project ID set

protected ProjectComponent convertToProjectComponent (MutableProjectComponent value)

Convert the specified MutableProjectComponent to a ProjectComponent object.

Parameters
value MutableProjectComponent to be converted into a ProjectComponent.
Returns
  • new instance of ProjectComponent with same values as given in the parameter object

protected ComponentConverter getComponentConverter ()