Class CachingAutomationConfigStore

java.lang.Object
com.codebarrel.jira.plugin.automation.store.CachingAutomationConfigStore
All Implemented Interfaces:
AutomationConfigStore

public class CachingAutomationConfigStore extends Object implements AutomationConfigStore
  • Constructor Details

    • CachingAutomationConfigStore

      public CachingAutomationConfigStore(AutomationConfigStore delegateStore, com.atlassian.cache.CacheManager cacheManager)
  • Method Details

    • getRules

      public List<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext tenantContext, 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:
      tenantContext - The tenant context
      projectIds - The project ids to look up rules for
      Returns:
      List of automation rules in this project and tenant
    • getRules

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

      public List<com.codebarrel.automation.api.config.RuleConfigBean> getProjectRules(TenantContext tenantContext, 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
    • getRule

      public Optional<com.codebarrel.automation.api.config.RuleConfigBean> getRule(TenantContext tenantContext, Long ruleId)
      Description copied from interface: AutomationConfigStore
      Retrieve a rule by id
      Specified by:
      getRule in interface AutomationConfigStore
      Parameters:
      tenantContext - The tenant context
      ruleId - The id of the rule to retrieve
      Returns:
      the automation rule or empty if none exists.
    • 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 tenantContext, Tag tag)
      Description copied from interface: AutomationConfigStore
      Returns all automation rules tagged with the provided tag.
      Specified by:
      getRulesWithTag in interface AutomationConfigStore
      Parameters:
      tenantContext - 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 tenantContext, com.codebarrel.automation.api.config.RuleConfigBean ruleConfigBean)
      Description copied from interface: AutomationConfigStore
      Creates a new rule.
      Specified by:
      createRule in interface AutomationConfigStore
      Parameters:
      tenantContext - The tenant context
      ruleConfigBean - Data needed to create the new rule
      Returns:
      The newly created rule or an error collection
    • addLabel

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

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

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

      public void disableRule(TenantContext tenantContext, 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:
      tenantContext - The tenant context
      ruleId - The id of the rule to disable
    • delete

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

      public void deleteAssociatedRuleProjects(TenantContext tenantContext, Long ruleId, String... projectIds)
      Description copied from interface: AutomationConfigStore
      Deletes the associated project ids from a rule
      Specified by:
      deleteAssociatedRuleProjects in interface AutomationConfigStore
      Parameters:
      tenantContext - 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 tenantContext)
      Description copied from interface: AutomationConfigStore
      Returns a count of all the rules for tenant
      Specified by:
      getTotalRuleCount in interface AutomationConfigStore
      Parameters:
      tenantContext - The tenant context
      Returns:
      Count of all rules
    • hasRulesInScope

      public boolean hasRulesInScope(TenantContext tenantContext, @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:
      tenantContext - The tenant context
      projectId - The scope to retrieve rules for
    • getEnabledRuleCount

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