summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-23 16:38:19 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-23 16:38:27 +0200
commit6bb743abfa39e8a65355bc2f2125c5d6d28fcb79 (patch)
treec6a75c522ce48ef9cc213e218b13a5e55a85b568 /sonar-server/src/main
parentba4737bcacc686404e8bd163ac50c98e1017eef9 (diff)
downloadsonarqube-6bb743abfa39e8a65355bc2f2125c5d6d28fcb79.tar.gz
sonarqube-6bb743abfa39e8a65355bc2f2125c5d6d28fcb79.zip
SONAR-5007 update the column RULES_PROFILES.RULES_UPDATED_AT on rule change
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java17
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java6
2 files changed, 19 insertions, 4 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
index 35b37348a80..605e45ae7d2 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
@@ -66,8 +66,8 @@ public class RuleActivator implements ServerComponent {
private final ActivityService log;
public RuleActivator(DbClient db, IndexClient index,
- RuleActivatorContextFactory contextFactory, TypeValidations typeValidations,
- PreviewCache previewCache, ActivityService log) {
+ RuleActivatorContextFactory contextFactory, TypeValidations typeValidations,
+ PreviewCache previewCache, ActivityService log) {
this.db = db;
this.index = index;
this.contextFactory = contextFactory;
@@ -136,12 +136,18 @@ public class RuleActivator implements ServerComponent {
}
if (!changes.isEmpty()) {
+ updateProfileDate(dbSession, context);
log.write(dbSession, Activity.Type.QPROFILE, changes);
previewCache.reportGlobalModification(dbSession);
}
return changes;
}
+ private void updateProfileDate(DbSession dbSession, RuleActivatorContext context) {
+ context.profile().setRulesUpdatedAt(context.getInitDate());
+ db.qualityProfileDao().update(dbSession, context.profile());
+ }
+
/**
* Severity and parameter values are :
* 1. defined by end-user
@@ -196,7 +202,8 @@ public class RuleActivator implements ServerComponent {
}
private ActiveRuleDto doInsert(ActiveRuleChange change, RuleActivatorContext context, DbSession dbSession) {
- ActiveRuleDto activeRule;ActiveRuleDao dao = db.activeRuleDao();
+ ActiveRuleDto activeRule;
+ ActiveRuleDao dao = db.activeRuleDao();
activeRule = ActiveRuleDto.createFor(context.profile(), context.rule());
activeRule.setSeverity(change.getSeverity());
if (change.getInheritance() != null) {
@@ -214,7 +221,8 @@ public class RuleActivator implements ServerComponent {
}
private ActiveRuleDto doUpdate(ActiveRuleChange change, RuleActivatorContext context, DbSession dbSession) {
- ActiveRuleDto activeRule;ActiveRuleDao dao = db.activeRuleDao();
+ ActiveRuleDto activeRule;
+ ActiveRuleDao dao = db.activeRuleDao();
activeRule = context.activeRule();
activeRule.setSeverity(change.getSeverity());
if (change.getInheritance() != null) {
@@ -307,6 +315,7 @@ public class RuleActivator implements ServerComponent {
}
if (!changes.isEmpty()) {
+ updateProfileDate(dbSession, context);
log.write(dbSession, Activity.Type.QPROFILE, changes);
previewCache.reportGlobalModification(dbSession);
}
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java
index 333da232bab..002551e16e5 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java
@@ -34,10 +34,12 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.util.Collection;
+import java.util.Date;
import java.util.Map;
class RuleActivatorContext {
+ private final Date initDate = new Date();
private RuleDto rule;
private final Map<String, RuleParamDto> ruleParams = Maps.newHashMap();
private QualityProfileDto profile;
@@ -60,6 +62,10 @@ class RuleActivatorContext {
return this;
}
+ Date getInitDate() {
+ return initDate;
+ }
+
Map<String, RuleParamDto> ruleParamsByKeys() {
return ruleParams;
}