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 Summary
ConstructorsConstructorDescriptionJiraAutomationConfigStore(DbConnectionManager dbConnectionManager, JiraRuleUserResolver userResolver, RuleComponentProvider ruleComponentProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLabel(TenantContext context, Long ruleId, Long labelId) Adds a new rule label to rulecom.codebarrel.automation.api.config.RuleConfigBeancreateRule(TenantContext context, com.codebarrel.automation.api.config.RuleConfigBean createRequestBean) Creates a new rule.createRuleFromConfig(TenantContext context, RuleConfig createRequest) voiddelete(TenantContext context, Long ruleId) Deletes the rule with the id provided.voiddeleteAssociatedRuleProjects(TenantContext context, Long ruleId, String... projectIds) Deletes the associated project ids from a rulevoiddisableRule(TenantContext context, Long ruleId) This is an 'internal' method to be called by the rule executor when an execution loop may have been detected.List<com.codebarrel.automation.api.config.RuleConfigBean> getBillableRules(TenantContext tenantContext) Returns rules that are considered billable i.e.Optional<com.codebarrel.automation.api.config.ComponentConfigBean> getComponentConfigForUprade(TenantContext context, long id) Returns a component config that will be passed to the component upgrade task.getComponentConfigsForUpgrade(TenantContext context, String moduleKey, int highestSchemaVersion) 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).longgetEnabledRuleCount(TenantContext context) Counts enabled rules on a tenant.List<com.codebarrel.automation.api.config.RuleConfigBean> getProjectRules(TenantContext context, String... projectIds) Get rules restricted to the the given projects only, unlike getRules() rules without a project restriction will be ignored.Optional<com.codebarrel.automation.api.config.RuleConfigBean> getRule(TenantContext context, Long ruleId) Retrieve a rule by idgetRuleNames(List<Long> ruleIds) Retrieve rule names by rule idsList<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext context, String... projectIds) Get all rules for the given projects, and also rules without a project restriction.List<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext context, Set<String> projectIds) List<com.codebarrel.automation.api.config.RuleConfigBean> getRulesWithTag(TenantContext context, Tag tag) Returns all automation rules tagged with the provided tag.getRulesWithTagGlobally(Environment environment, Tag tag, com.codebarrel.automation.api.config.RuleState state) Returns all automation rules tagged with the provided tag irrelevant of tenant contextlonggetTotalRuleCount(TenantContext context) Returns a count of all the rules for tenantbooleanhasRulesInScope(TenantContext context, Long projectId) Whether there are any rule specifically in the given scopevoidremoveLabel(TenantContext context, Long ruleId, Long labelId) Removes a rule labelcom.codebarrel.automation.api.config.ComponentConfigBeanstoreUpgradedComponentConfig(TenantContext context, long configToUpgrade, int newSchemaVersion, com.codebarrel.automation.api.thirdparty.upgrade.ComponentUpgrade upgrades) Performs the actual upgrade and returns the upgraded component config (so it can be used for subsequent upgrades)com.codebarrel.automation.api.config.RuleConfigBeanupdateRule(TenantContext context, Long ruleId, com.codebarrel.automation.api.config.RuleConfigBean updateRequestBean) Updates the rule with the provided configuration.
-
Constructor Details
-
JiraAutomationConfigStore
@Inject public JiraAutomationConfigStore(DbConnectionManager dbConnectionManager, JiraRuleUserResolver userResolver, RuleComponentProvider ruleComponentProvider)
-
-
Method Details
-
getRules
public List<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext context, Set<String> projectIds) - Specified by:
getRulesin interfaceAutomationConfigStore
-
getProjectRules
public List<com.codebarrel.automation.api.config.RuleConfigBean> getProjectRules(TenantContext context, String... projectIds) Description copied from interface:AutomationConfigStoreGet rules restricted to the the given projects only, unlike getRules() rules without a project restriction will be ignored.- Specified by:
getProjectRulesin interfaceAutomationConfigStore
-
getBillableRules
public List<com.codebarrel.automation.api.config.RuleConfigBean> getBillableRules(TenantContext tenantContext) Description copied from interface:AutomationConfigStoreReturns rules that are considered billable i.e. multi-project and global rules- Specified by:
getBillableRulesin interfaceAutomationConfigStore- 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:AutomationConfigStoreGet all rules for the given projects, and also rules without a project restriction.- Specified by:
getRulesin interfaceAutomationConfigStore- Parameters:
context- The tenant contextprojectIds- 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:AutomationConfigStoreRetrieve a rule by id- Specified by:
getRulein interfaceAutomationConfigStore- Parameters:
context- The tenant contextruleId- The id of the rule to retrieve- Returns:
- the automation rule or empty if none exists.
-
getRuleNames
Description copied from interface:AutomationConfigStoreRetrieve rule names by rule ids- Specified by:
getRuleNamesin interfaceAutomationConfigStore- 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:AutomationConfigStoreReturns all automation rules tagged with the provided tag irrelevant of tenant contextUse with care! Generally you should use
AutomationConfigStore.getRulesWithTag(TenantContext, Tag)!- Specified by:
getRulesWithTagGloballyin interfaceAutomationConfigStore- Parameters:
environment- The db environment to run this query intag- The tag to search forstate- 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:AutomationConfigStoreReturns all automation rules tagged with the provided tag.- Specified by:
getRulesWithTagin interfaceAutomationConfigStore- Parameters:
context- The tenant contexttag- 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:AutomationConfigStoreCreates a new rule.- Specified by:
createRulein interfaceAutomationConfigStore- Parameters:
context- The tenant contextcreateRequestBean- Data needed to create the new rule- Returns:
- The newly created rule or an error collection
-
addLabel
Description copied from interface:AutomationConfigStoreAdds a new rule label to rule- Specified by:
addLabelin interfaceAutomationConfigStore- Parameters:
context- The tenant contextruleId- the id of the rule to update
-
removeLabel
Description copied from interface:AutomationConfigStoreRemoves a rule label- Specified by:
removeLabelin interfaceAutomationConfigStore- Parameters:
context- The tenant contextruleId- the id of the rule to update
-
createRuleFromConfig
-
updateRule
public com.codebarrel.automation.api.config.RuleConfigBean updateRule(TenantContext context, Long ruleId, com.codebarrel.automation.api.config.RuleConfigBean updateRequestBean) Description copied from interface:AutomationConfigStoreUpdates the rule with the provided configuration.- Specified by:
updateRulein interfaceAutomationConfigStore- Parameters:
context- The tenant contextruleId- The id of the rule to udpateupdateRequestBean- Data needed to update the rule- Returns:
- The updated rule or an error collection
-
disableRule
Description copied from interface:AutomationConfigStoreThis is an 'internal' method to be called by the rule executor when an execution loop may have been detected.- Specified by:
disableRulein interfaceAutomationConfigStore- Parameters:
context- The tenant contextruleId- The id of the rule to disable
-
delete
Description copied from interface:AutomationConfigStoreDeletes the rule with the id provided.- Specified by:
deletein interfaceAutomationConfigStore- Parameters:
context- The tenant contextruleId- The id of the rule to delete
-
deleteAssociatedRuleProjects
Description copied from interface:AutomationConfigStoreDeletes the associated project ids from a rule- Specified by:
deleteAssociatedRuleProjectsin interfaceAutomationConfigStore- Parameters:
context- The tenant contextruleId- The id of the rule to delete projects fromprojectIds- List of projects to remove from rule
-
getTotalRuleCount
Description copied from interface:AutomationConfigStoreReturns a count of all the rules for tenant- Specified by:
getTotalRuleCountin interfaceAutomationConfigStore- Parameters:
context- The tenant context- Returns:
- Count of all rules
-
hasRulesInScope
Description copied from interface:AutomationConfigStoreWhether there are any rule specifically in the given scope- Specified by:
hasRulesInScopein interfaceAutomationConfigStore- Parameters:
context- The tenant contextprojectId- The scope to retrieve rules for
-
getEnabledRuleCount
Description copied from interface:AutomationConfigStoreCounts enabled rules on a tenant.- Specified by:
getEnabledRuleCountin interfaceAutomationConfigStore- Parameters:
context- The tenant- Returns:
- count of enabled rules
-
getComponentConfigsForUpgrade
public List<Long> getComponentConfigsForUpgrade(TenantContext context, String moduleKey, int highestSchemaVersion) Description copied from interface:UpgradeableAutomationConfigStoreReturns 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:
getComponentConfigsForUpgradein interfaceUpgradeableAutomationConfigStore- Parameters:
context- the tenant contextmoduleKey- 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:UpgradeableAutomationConfigStoreReturns 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:
getComponentConfigForUpradein interfaceUpgradeableAutomationConfigStore- Parameters:
context- the tenant contextid- 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:UpgradeableAutomationConfigStorePerforms the actual upgrade and returns the upgraded component config (so it can be used for subsequent upgrades)- Specified by:
storeUpgradedComponentConfigin interfaceUpgradeableAutomationConfigStore- Parameters:
context- the tenant contextconfigToUpgrade- the id of the config to updatenewSchemaVersion- the new schema version to setupgrades- new values to store for the config- Returns:
- the upgraded config
-