diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-06-19 22:07:29 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-06-19 22:07:29 +0200 |
commit | 71a6a922a2d07ae8db9f13036a9653e772380762 (patch) | |
tree | d9c311d405aaec5b5cdedc321077246a8ef6ef3c /sonar-core/src | |
parent | b6e19bf7f6a145573804b5f64866723885aac1c5 (diff) | |
download | sonarqube-71a6a922a2d07ae8db9f13036a9653e772380762.tar.gz sonarqube-71a6a922a2d07ae8db9f13036a9653e772380762.zip |
SONAR-5329 - Consolidation of Migration with Batis
Diffstat (limited to 'sonar-core/src')
3 files changed, 156 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/ChangeLog.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/ChangeLog.java new file mode 100644 index 00000000000..915905b12ab --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/ChangeLog.java @@ -0,0 +1,118 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.persistence.migration.v44; + +import java.util.Date; + +/** + * SONAR-5329 + * Transition ActiveRuleChanges to ActivityLog + * <p/> + * Used in the Active Record Migration 548. + * + * @since 4.4 + */ +public class ChangeLog { + + private int id; + private Date createdAt; + private int severity; + private String paramKey; + private String paramValue; + private String userLogin; + private String ruleKey; + private String repository; + private String profileKey; + + public ChangeLog() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getSeverity() { + return severity; + } + + public void setSeverity(int severity) { + this.severity = severity; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public String getParamKey() { + return paramKey; + } + + public void setParamKey(String paramKey) { + this.paramKey = paramKey; + } + + public String getParamValue() { + return paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + public String getUserLogin() { + return userLogin; + } + + public void setUserLogin(String userLogin) { + this.userLogin = userLogin; + } + + public String getRuleKey() { + return ruleKey; + } + + public void setRuleKey(String ruleKey) { + this.ruleKey = ruleKey; + } + + public String getRepository() { + return repository; + } + + public void setRepository(String repository) { + this.repository = repository; + } + + public String getProfileKey() { + return profileKey; + } + + public void setProfileKey(String profileKey) { + this.profileKey = profileKey; + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java index 9016b016318..2a514ff2d54 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java @@ -36,4 +36,7 @@ public interface Migration44Mapper { // creation of columns RULES_PROFILES.CREATED_AT and UPDATED_AT @CheckForNull Date selectProfileCreatedAt(long profileId); @CheckForNull Date selectProfileUpdatedAt(long profileId); + + // migrate changeLog to Activities + List<ChangeLog> selectActiveRuleChange(@Param("enabled") Boolean enabled); } diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml b/sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml index a4ebc00c627..150df88078d 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml @@ -38,5 +38,40 @@ select min(change_date) from active_rule_changes where profile_id=#{id} </select> + + <select id="selectActiveRuleChange" parameterType="Boolean" + resultType="org.sonar.core.persistence.migration.v44.ChangeLog"> + select + rule_change.id as id, + rule_change.change_date as createdAt, + users.login as userLogin, + rule_def.plugin_name as ruleKey, + rule_def.plugin_rule_key as repository, + profile.kee as profileKey, + rule_change.new_severity as severity , + rule_def.name as ruleName, + rule_def_param.name as paramName, + rule_param_change.new_value as paramValue + from active_rule_changes rule_change + left join users on users.name = rule_change.username + left join rules rule_def on rule_def.id = rule_change.rule_id + left join rules_profiles profile on profile.id = rule_change.profile_id + left join active_rule_param_changes rule_param_change on rule_param_change.active_rule_change_id = rule_change.id + left join rules_parameters rule_def_param on rule_def_param.id = rule_param_change.rules_parameter_id + WHERE + <choose> + <when test="enabled != null"> + rule_change.enabled = #{enabled} + </when> + <otherwise> + rule_change.enabled is null + </otherwise> + </choose> + AND profile.name is not null + AND profile.language is not null + AND rule_def.plugin_name is not null + AND rule_def.plugin_name is not null + order by rule_change.id ASC + </select> </mapper> |