Interface PrioritySchemeManager

All Known Implementing Classes:
PrioritySchemeManagerImpl

@ExperimentalApi public interface PrioritySchemeManager
Manager 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));
 
  • Method Details

    • createWithDefaultMapping

      @Nonnull FieldConfigScheme createWithDefaultMapping(@Nonnull String name, @Nullable String description, @Nullable List<String> optionIds)
      Creates a new FieldConfigScheme with a default mapping to FieldConfig. Also creates options in OPTION_CONFIGURATION table. Triggers PrioritySchemeCreatedEvent.
      Parameters:
      name - Scheme name
      description - Scheme description
      optionIds - Collection of priority ids
      Returns:
      created FieldConfigScheme
    • updateWithDefaultMapping

      FieldConfigScheme updateWithDefaultMapping(@Nonnull FieldConfigScheme fieldConfigScheme, @Nullable List<String> optionIds)
      Updates FieldConfigScheme with provided data and options (priority IDs). Default FieldConfig for FieldConfigScheme is used. Triggers PrioritySchemeUpdatedEvent.
      Parameters:
      fieldConfigScheme - Field config scheme to update
      optionIds - Collection of priority ids
      Returns:
      updated FieldConfigScheme
    • getFieldConfigForDefaultMapping

      @Nullable FieldConfig getFieldConfigForDefaultMapping(@Nullable FieldConfigScheme fieldConfigScheme)
      Retrieves FieldConfig that is used for a default mapping for a passed fieldConfigScheme.
      Parameters:
      fieldConfigScheme -
      Returns:
      FieldConfig for default mapping for fieldConfigScheme
    • delete

      void delete(@Nonnull FieldConfigScheme fieldConfigScheme)
      Parameters:
      fieldConfigScheme - FieldConfigScheme to delete
    • getScheme

      FieldConfigScheme getScheme(@Nullable Project project)
      Gets FieldConfigScheme for given project.
      Parameters:
      project - Project
      Returns:
      FieldConfigScheme associated with given project
    • getScheme

      @Nullable FieldConfigScheme getScheme(@Nonnull Long id)
      Gets FieldConfigScheme by id.
      Parameters:
      id - scheme id
      Returns:
      FieldConfigScheme
    • getAllSchemes

      @Nonnull List<FieldConfigScheme> getAllSchemes()
      Retrieves all priority schemes and sorts them. Schemes with the default scheme ID are first. Schemes with null names are second, the rest are sorted on name.
      Returns:
      all schemes sorted on name with default first
    • isDefaultScheme

      boolean isDefaultScheme(@Nonnull FieldConfigScheme fieldConfigScheme)
      Checks if a passed fieldConfigScheme is the default priority scheme.
      Parameters:
      fieldConfigScheme - Field config scheme in question
      Returns:
      true if fieldConfigScheme is default one, false otherwise.
    • getDefaultScheme

      @Nullable FieldConfigScheme getDefaultScheme()
      Retrieves the default global priority scheme which contains all priorities.
      Returns:
      default FieldConfigScheme
    • getDefaultOption

      @Nullable String getDefaultOption(@Nonnull IssueContext issueContext)
      Retrieves the ID of the default 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.
      Parameters:
      issueContext - IssueContext to obtain default value for
      Returns:
      Id of default Priority for issueContext
    • getDefaultOption

      @Nullable String getDefaultOption(@Nullable FieldConfig fieldConfig)
      Returns the ID of the default Priority for a given fieldConfig.
      Parameters:
      fieldConfig - the field configuration scheme of interest
      Returns:
      Id of default Priority for this fieldConfig
    • setDefaultOption

      void setDefaultOption(@Nonnull FieldConfig fieldConfig, @Nullable String optionId)
      Sets default priority ID for given FieldConfigScheme.
      Parameters:
      fieldConfig - FieldConfig for which set the default option
      optionId - Priority id. Pass null to remove default priority from fieldConfig.
    • getOptions

      List<String> getOptions(@Nullable IssueContext issueContext)
      Retrieves a list of priority IDs configured for a passed issueContext. If null is passed for issueContext then priority ids for default scheme are returned.
      Parameters:
      issueContext - Issue context eg. ProjectContext
      Returns:
      list of priorities configured for passed issueContext.
    • getOptions

      @Nonnull List<String> getOptions(@Nullable FieldConfig fieldConfig)
      Retrieves a list of priority IDs configured for a passed fieldConfig. If null is passed as fieldConfig then empty list is returned.
      Parameters:
      fieldConfig - FieldConfig to obtain list of priority id from.
      Returns:
      List of priority ids for fieldConfig
    • setOptions

      void setOptions(@Nonnull FieldConfig fieldConfig, @Nullable List<String> optionIds)
      Sets priority IDs for fieldConfig.
      Parameters:
      fieldConfig - FieldConfig to set list of priority id for.
      optionIds - List of priority ids.
    • addOptionToDefault

      void addOptionToDefault(@Nonnull String optionId)
      Adds the optionId to the default priority scheme.
      Parameters:
      optionId - priority id
    • removeOptionFromAllSchemes

      void removeOptionFromAllSchemes(@Nonnull String optionId)
      Removes a priority ID from all priority schemes that have the passed optionId as part of its options.
      Parameters:
      optionId - Priority id to remove from all priority schemes.
    • getAllRelatedSchemes

      @Nonnull Collection<FieldConfigScheme> getAllRelatedSchemes(@Nonnull String optionId)
      Retrieves all schemes that have optionId as part of its options.
      Parameters:
      optionId - Priority id being queried
      Returns:
      Collection of FieldConfigScheme objects
    • getPriority

      @Nullable Priority getPriority(@Nonnull String priorityId)
      Converts priorityId to Priority value.
      Parameters:
      priorityId - Id of Priority
      Returns:
      Priority object
    • getPrioritiesFromIds

      @Nonnull Collection<Priority> getPrioritiesFromIds(@Nonnull Collection<String> priorityIds)
      Converts a collection of priority IDs to a collection of Priority. Priorities not found by id are skipped.
      Parameters:
      priorityIds - Collection of ids for Priority
      Returns:
      Collection of Priority objects
    • assignProject

      void assignProject(@Nonnull FieldConfigScheme priorityFieldConfig, @Nonnull Project project)
      Associates a project with a priority scheme. To assign project to "default priority scheme" please unassign project from currently used priority scheme 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". When assigning multiple projects please use assignProjects(FieldConfigScheme, Set) instead of calling this method in a loop to achieve better performance.
      Parameters:
      priorityFieldConfig - the scheme
      project - the project
    • assignProjects

      void assignProjects(@Nonnull FieldConfigScheme priorityFieldConfig, @Nonnull Set<Project> projects)
      Associates multiple projects with a priority scheme. To assign project to "default priority scheme" please unassign project from currently used priority scheme 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".
      Parameters:
      priorityFieldConfig - the scheme
      projects - the projects
      Since:
      7.6.13, 7.13.3, 8.0.3, 8.1.0 (be careful when checking if this method can be used, as it was added in a bugfix release)
    • getProjectsWithScheme

      @Nonnull Set<Project> getProjectsWithScheme(@Nonnull FieldConfigScheme fieldConfigScheme)
      Retrieves all projects associated with a scheme.
      Parameters:
      fieldConfigScheme - the scheme
      Returns:
      List of Project with the given scheme (possibly empty)
    • unassignProject

      void unassignProject(@Nonnull FieldConfigScheme scheme, @Nonnull Project project)
      Removes a project from a priority scheme. It can also be used to assign project with "default priority scheme" - simply unassign project from currently used scheme and the project will start using default priority scheme. When unassigning multiple projects please use unassignProjects(FieldConfigScheme, Set) instead of calling this method in a loop to achieve better performance.
      Parameters:
      scheme - the scheme
      project - the project
    • unassignProjects

      void unassignProjects(@Nonnull FieldConfigScheme scheme, @Nonnull Set<Project> projects)
      Removes multiple projects from a priority scheme. It can also be used to assign projects with "default priority scheme" - simply unassign projects from currently used scheme and the projects will start using default priority scheme.
      Parameters:
      scheme - the scheme
      projects - the projects
      Since:
      7.6.13, 7.13.3, 8.0.3, 8.1.0 (be careful when checking if this method can be used, as it was added in a bugfix release)