Class JiraAutomationConfigStore

java.lang.Object
com.codebarrel.jira.plugin.automation.store.JiraAutomationConfigStore
All Implemented Interfaces:
AutomationConfigStore, UpgradeableAutomationConfigStore

@Component public class JiraAutomationConfigStore extends Object implements AutomationConfigStore, UpgradeableAutomationConfigStore
  • Constructor Details

  • Method Details

    • getRules

      public List<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext context, Set<String> projectIds)
      Specified by:
      getRules in interface AutomationConfigStore
    • getProjectRules

      public List<com.codebarrel.automation.api.config.RuleConfigBean> getProjectRules(TenantContext context, String... projectIds)
      Description copied from interface: AutomationConfigStore
      Get rules restricted to the the given projects only, unlike getRules() rules without a project restriction will be ignored.
      Specified by:
      getProjectRules in interface AutomationConfigStore
    • getBillableRules

      public List<com.codebarrel.automation.api.config.RuleConfigBean> getBillableRules(TenantContext tenantContext)
      Description copied from interface: AutomationConfigStore
      Returns rules that are considered billable i.e. multi-project and global rules
      Specified by:
      getBillableRules in interface AutomationConfigStore
      Parameters:
      tenantContext - Tenant context
      Returns:
      List of billable automation rules for the tenant
    • getRules

      public List<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext context, String... projectIds)
      Description copied from interface: AutomationConfigStore
      Get all rules for the given projects, and also rules without a project restriction.
      Specified by:
      getRules in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      projectIds - The project ids to look up rules for
      Returns:
      List of automation rules in this project and tenant
    • getRule

      public Optional<com.codebarrel.automation.api.config.RuleConfigBean> getRule(TenantContext context, Long ruleId)
      Description copied from interface: AutomationConfigStore
      Retrieve a rule by id
      Specified by:
      getRule in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to retrieve
      Returns:
      the automation rule or empty if none exists.
    • getRuleNames

      public Map<Long,String> getRuleNames(List<Long> ruleIds)
      Description copied from interface: AutomationConfigStore
      Retrieve rule names by rule ids
      Specified by:
      getRuleNames in interface AutomationConfigStore
      Parameters:
      ruleIds - The ids of rules to retrieve
      Returns:
      Map of rule id to rule name
    • getRulesWithTagGlobally

      public List<TenantRuleId> getRulesWithTagGlobally(Environment environment, Tag tag, com.codebarrel.automation.api.config.RuleState state)
      Description copied from interface: AutomationConfigStore
      Returns all automation rules tagged with the provided tag irrelevant of tenant context

      Use with care! Generally you should use AutomationConfigStore.getRulesWithTag(TenantContext, Tag)!

      Specified by:
      getRulesWithTagGlobally in interface AutomationConfigStore
      Parameters:
      environment - The db environment to run this query in
      tag - The tag to search for
      state - Only retrieve rules matching this state. Maybe null for all states.
      Returns:
      List of matching ruleIds the tag
    • getRulesWithTag

      public List<com.codebarrel.automation.api.config.RuleConfigBean> getRulesWithTag(TenantContext context, Tag tag)
      Description copied from interface: AutomationConfigStore
      Returns all automation rules tagged with the provided tag.
      Specified by:
      getRulesWithTag in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      tag - The tag to search for
      Returns:
      List of rules matching the tag
    • createRule

      public com.codebarrel.automation.api.config.RuleConfigBean createRule(TenantContext context, com.codebarrel.automation.api.config.RuleConfigBean createRequestBean)
      Description copied from interface: AutomationConfigStore
      Creates a new rule.
      Specified by:
      createRule in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      createRequestBean - Data needed to create the new rule
      Returns:
      The newly created rule or an error collection
    • addLabel

      public void addLabel(TenantContext context, Long ruleId, Long labelId)
      Description copied from interface: AutomationConfigStore
      Adds a new rule label to rule
      Specified by:
      addLabel in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      ruleId - the id of the rule to update
    • removeLabel

      public void removeLabel(TenantContext context, Long ruleId, Long labelId)
      Description copied from interface: AutomationConfigStore
      Removes a rule label
      Specified by:
      removeLabel in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      ruleId - the id of the rule to update
    • createRuleFromConfig

      public RuleConfig createRuleFromConfig(TenantContext context, RuleConfig createRequest)
    • updateRule

      public com.codebarrel.automation.api.config.RuleConfigBean updateRule(TenantContext context, Long ruleId, com.codebarrel.automation.api.config.RuleConfigBean updateRequestBean)
      Description copied from interface: AutomationConfigStore
      Updates the rule with the provided configuration.
      Specified by:
      updateRule in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to udpate
      updateRequestBean - Data needed to update the rule
      Returns:
      The updated rule or an error collection
    • disableRule

      public void disableRule(TenantContext context, Long ruleId)
      Description copied from interface: AutomationConfigStore
      This is an 'internal' method to be called by the rule executor when an execution loop may have been detected.
      Specified by:
      disableRule in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to disable
    • delete

      public void delete(TenantContext context, Long ruleId)
      Description copied from interface: AutomationConfigStore
      Deletes the rule with the id provided.
      Specified by:
      delete in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to delete
    • deleteAssociatedRuleProjects

      public void deleteAssociatedRuleProjects(TenantContext context, Long ruleId, String... projectIds)
      Description copied from interface: AutomationConfigStore
      Deletes the associated project ids from a rule
      Specified by:
      deleteAssociatedRuleProjects in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to delete projects from
      projectIds - List of projects to remove from rule
    • getTotalRuleCount

      public long getTotalRuleCount(TenantContext context)
      Description copied from interface: AutomationConfigStore
      Returns a count of all the rules for tenant
      Specified by:
      getTotalRuleCount in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      Returns:
      Count of all rules
    • hasRulesInScope

      public boolean hasRulesInScope(TenantContext context, @Nullable Long projectId)
      Description copied from interface: AutomationConfigStore
      Whether there are any rule specifically in the given scope
      Specified by:
      hasRulesInScope in interface AutomationConfigStore
      Parameters:
      context - The tenant context
      projectId - The scope to retrieve rules for
    • getEnabledRuleCount

      public long getEnabledRuleCount(TenantContext context)
      Description copied from interface: AutomationConfigStore
      Counts enabled rules on a tenant.
      Specified by:
      getEnabledRuleCount in interface AutomationConfigStore
      Parameters:
      context - The tenant
      Returns:
      count of enabled rules
    • getComponentConfigsForUpgrade

      public List<Long> getComponentConfigsForUpgrade(TenantContext context, String moduleKey, int highestSchemaVersion)
      Description copied from interface: UpgradeableAutomationConfigStore
      Returns a list of config ids that match the moduleKey and currently have a schema version less than the schemaversion provided (therefore need to be upgraded).
      Specified by:
      getComponentConfigsForUpgrade in interface UpgradeableAutomationConfigStore
      Parameters:
      context - the tenant context
      moduleKey - the module key (component type) to upgrade)
      highestSchemaVersion - the highest schema version that we'll upgrade to as part of this upgrade run
      Returns:
      List of component ids that need to be upgraded.
    • getComponentConfigForUprade

      public Optional<com.codebarrel.automation.api.config.ComponentConfigBean> getComponentConfigForUprade(TenantContext context, long id)
      Description copied from interface: UpgradeableAutomationConfigStore
      Returns a component config that will be passed to the component upgrade task.

      This differs slightly from a normal lookup of component config, because it wont retrieve children/conditions of a component.

      Specified by:
      getComponentConfigForUprade in interface UpgradeableAutomationConfigStore
      Parameters:
      context - the tenant context
      id - the id of the config to lookup.
      Returns:
      The component config or empty.
    • storeUpgradedComponentConfig

      public com.codebarrel.automation.api.config.ComponentConfigBean storeUpgradedComponentConfig(TenantContext context, long configToUpgrade, int newSchemaVersion, com.codebarrel.automation.api.thirdparty.upgrade.ComponentUpgrade upgrades)
      Description copied from interface: UpgradeableAutomationConfigStore
      Performs the actual upgrade and returns the upgraded component config (so it can be used for subsequent upgrades)
      Specified by:
      storeUpgradedComponentConfig in interface UpgradeableAutomationConfigStore
      Parameters:
      context - the tenant context
      configToUpgrade - the id of the config to update
      newSchemaVersion - the new schema version to set
      upgrades - new values to store for the config
      Returns:
      the upgraded config