@ExperimentalApi
public interface PrioritySchemeManager
FieldConfigScheme
for managing priority schemes.
Example usage:
PrioritySchemeManager prioritySchemeManager; ProjectManager projectManager; //creates a new FieldConfigScheme with 3 priorities assigned FieldConfigScheme fieldConfigScheme = prioritySchemeManager.createWithDefaultMapping("Some name", "Some description", ImmutableList.of("1", "2", "3")); //options/priorities are assigned to a particular FieldConfig FieldConfig fieldConfig = prioritySchemeManager.getFieldConfigForDefaultMapping(fieldConfigScheme); //sets a priority with ID=1 as the default priority prioritySchemeManager.setDefaultOption(fieldConfig, "1"); //assigns a priority scheme to a "TEST" project Project project = projectManager.getProjectObjByKey("TEST"); prioritySchemeManager.assignProject(fieldConfigScheme, project); //retrieves all priorities for a given priority scheme Collection<Priority> priorities = prioritySchemeManager.getPrioritiesFromIds(prioritySchemeManager.getOptions(fieldConfig));
Modifier and Type | Method and Description |
---|---|
void |
addOptionToDefault(String optionId)
Adds the
optionId to the default priority scheme. |
void |
assignProject(FieldConfigScheme priorityFieldConfig,
Project project)
Associates a project with a priority scheme.
|
FieldConfigScheme |
createWithDefaultMapping(String name,
String description,
List<String> optionIds)
Creates a new
FieldConfigScheme with a default mapping to FieldConfig . |
void |
delete(FieldConfigScheme fieldConfigScheme)
Removes
FieldConfigScheme . |
Collection<FieldConfigScheme> |
getAllRelatedSchemes(String optionId)
Retrieves all schemes that have
optionId as part of its options. |
List<FieldConfigScheme> |
getAllSchemes()
Retrieves all priority schemes and sorts them.
|
String |
getDefaultOption(FieldConfig fieldConfig)
Returns the ID of the default
Priority for a given fieldConfig . |
String |
getDefaultOption(IssueContext issueContext)
Retrieves the ID of the default
Priority for FieldConfig relevant to a passed issueContext for a priority system field. |
FieldConfigScheme |
getDefaultScheme()
Retrieves the default global priority scheme which contains all priorities.
|
FieldConfig |
getFieldConfigForDefaultMapping(FieldConfigScheme fieldConfigScheme)
Retrieves
FieldConfig that is used for a default mapping for a passed fieldConfigScheme . |
List<String> |
getOptions(FieldConfig fieldConfig)
Retrieves a list of priority IDs configured for a passed
fieldConfig . |
List<String> |
getOptions(IssueContext issueContext)
Retrieves a list of priority IDs configured for a passed
issueContext . |
Collection<Priority> |
getPrioritiesFromIds(Collection<String> priorityIds)
Converts a collection of priority IDs to a collection of
Priority . |
Priority |
getPriority(String priorityId)
Converts
priorityId to Priority value. |
Set<Project> |
getProjectsWithScheme(FieldConfigScheme fieldConfigScheme)
Retrieves all projects associated with a scheme.
|
FieldConfigScheme |
getScheme(Long id)
Gets
FieldConfigScheme by id . |
FieldConfigScheme |
getScheme(Project project)
Gets
FieldConfigScheme for given project . |
boolean |
isDefaultScheme(FieldConfigScheme fieldConfigScheme)
Checks if a passed
fieldConfigScheme is the default priority scheme. |
void |
removeOptionFromAllSchemes(String optionId)
Removes a priority ID from all priority schemes that have the passed
optionId as part of its options. |
void |
setDefaultOption(FieldConfig fieldConfig,
String optionId)
Sets default priority ID for given
FieldConfigScheme . |
void |
setOptions(FieldConfig fieldConfig,
List<String> optionIds)
Sets priority IDs for
fieldConfig . |
void |
unassignProject(FieldConfigScheme scheme,
Project project)
Removes a project from a priority scheme.
|
FieldConfigScheme |
updateWithDefaultMapping(FieldConfigScheme fieldConfigScheme,
List<String> optionIds)
Updates
FieldConfigScheme with provided data and options (priority IDs). |
@Nonnull FieldConfigScheme createWithDefaultMapping(@Nonnull String name, @Nullable String description, @Nullable List<String> optionIds)
FieldConfigScheme
with a default mapping to FieldConfig
.
Also creates options in OPTION_CONFIGURATION
table.
Triggers PrioritySchemeCreatedEvent
.name
- Scheme namedescription
- Scheme descriptionoptionIds
- Collection of priority idsFieldConfigScheme updateWithDefaultMapping(@Nonnull FieldConfigScheme fieldConfigScheme, @Nullable List<String> optionIds)
FieldConfigScheme
with provided data and options (priority IDs).
Default FieldConfig
for FieldConfigScheme
is used.
Triggers PrioritySchemeUpdatedEvent
.fieldConfigScheme
- Field config scheme to updateoptionIds
- Collection of priority ids@Nullable FieldConfig getFieldConfigForDefaultMapping(@Nullable FieldConfigScheme fieldConfigScheme)
FieldConfig
that is used for a default mapping for a passed fieldConfigScheme
.fieldConfigScheme
- FieldConfig
for default mapping for fieldConfigScheme
void delete(@Nonnull FieldConfigScheme fieldConfigScheme)
FieldConfigScheme
.
Triggers PrioritySchemeDeletedEvent
.fieldConfigScheme
- FieldConfigScheme
to deleteFieldConfigScheme getScheme(@Nullable Project project)
FieldConfigScheme
for given project
.project
- ProjectFieldConfigScheme
associated with given project
@Nullable FieldConfigScheme getScheme(@Nonnull Long id)
FieldConfigScheme
by id
.id
- scheme idFieldConfigScheme
@Nonnull List<FieldConfigScheme> getAllSchemes()
boolean isDefaultScheme(@Nonnull FieldConfigScheme fieldConfigScheme)
fieldConfigScheme
is the default priority scheme.fieldConfigScheme
- Field config scheme in questionfieldConfigScheme
is default one, false otherwise.@Nullable FieldConfigScheme getDefaultScheme()
FieldConfigScheme
@Nullable String getDefaultOption(@Nonnull IssueContext issueContext)
Priority
for FieldConfig
relevant to a passed issueContext
for a priority system field.
If no default priority is defined for FieldConfig
then middle priority of all priorities assigned to that FieldConfig
is returned.issueContext
- IssueContext
to obtain default value forPriority
for issueContext
@Nullable String getDefaultOption(@Nullable FieldConfig fieldConfig)
Priority
for a given fieldConfig
.fieldConfig
- the field configuration scheme of interestPriority
for this fieldConfig
void setDefaultOption(@Nonnull FieldConfig fieldConfig, @Nullable String optionId)
FieldConfigScheme
.fieldConfig
- FieldConfig
for which set the default optionoptionId
- Priority id. Pass null
to remove default priority from fieldConfig
.List<String> getOptions(@Nullable IssueContext issueContext)
issueContext
.
If null
is passed for issueContext
then priority ids for default scheme are returned.issueContext
- Issue context eg. ProjectContext
issueContext
.@Nonnull List<String> getOptions(@Nullable FieldConfig fieldConfig)
fieldConfig
.
If null
is passed as fieldConfig
then empty list is returned.fieldConfig
- FieldConfig
to obtain list of priority id from.fieldConfig
void setOptions(@Nonnull FieldConfig fieldConfig, @Nullable List<String> optionIds)
fieldConfig
.fieldConfig
- FieldConfig
to set list of priority id for.optionIds
- List of priority ids.void addOptionToDefault(@Nonnull String optionId)
optionId
to the default priority scheme.optionId
- priority idvoid removeOptionFromAllSchemes(@Nonnull String optionId)
optionId
as part of its options.optionId
- Priority id to remove from all priority schemes.@Nonnull Collection<FieldConfigScheme> getAllRelatedSchemes(@Nonnull String optionId)
optionId
as part of its options.optionId
- Priority id being queriedFieldConfigScheme
objects@Nullable Priority getPriority(@Nonnull String priorityId)
priorityId
to Priority
value.@Nonnull Collection<Priority> getPrioritiesFromIds(@Nonnull Collection<String> priorityIds)
Priority
. Priorities not found by id are skipped.void assignProject(@Nonnull FieldConfigScheme priorityFieldConfig, @Nonnull Project project)
unassignProject(FieldConfigScheme, Project)
.
If this method is used on "default priority scheme" it will remove DB association that marks scheme as default thus it will break "default priority scheme".priorityFieldConfig
- the schemeproject
- the project@Nonnull Set<Project> getProjectsWithScheme(@Nonnull FieldConfigScheme fieldConfigScheme)
fieldConfigScheme
- the schemeProject
with the given scheme (possibly empty)void unassignProject(@Nonnull FieldConfigScheme scheme, @Nonnull Project project)
scheme
- the schemeproject
- the projectCopyright © 2002-2018 Atlassian. All Rights Reserved.