From: Stephane Gamard Date: Wed, 20 Aug 2014 15:05:23 +0000 (+0200) Subject: fixed synchronization X-Git-Tag: 4.5-RC1~135 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e72b7db9c0983eace302e0bb0fe2c83ade0d1106;p=sonarqube.git fixed synchronization --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java b/server/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java index df395320c09..27fff1d30f6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java @@ -26,7 +26,6 @@ import org.sonar.core.persistence.DbSession; import org.sonar.server.db.BaseDao; import org.sonar.server.search.IndexDefinition; -import java.util.Collections; import java.util.Date; import java.util.List; @@ -62,11 +61,7 @@ public class ActivityDao extends BaseDao { @Override protected Iterable findAfterDate(DbSession session, Date date) { - // for (ActivityDto activity : this.findAll(session)) { -// session.enqueue(new DtoIndexAction(this.getIndexType(), IndexAction.Method.UPSERT, activity)); -// } -// session.commit(); - return Collections.EMPTY_LIST; + return mapper(session).selectAll(); } public List findAll(DbSession session) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java index 682ed69f762..1cd5966e5fb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java @@ -36,7 +36,7 @@ import org.sonar.server.rule.db.RuleDao; import org.sonar.server.search.IndexDefinition; import javax.annotation.CheckForNull; -import java.util.Collections; +import java.sql.Timestamp; import java.util.Date; import java.util.List; @@ -119,22 +119,7 @@ public class ActiveRuleDao extends BaseDao findAfterDate(DbSession session, Date date) { -// @Override -// public void synchronizeAfter(final DbSession session, Date date) { -// session.select("selectAllKeysAfterTimestamp", new Timestamp(date.getTime()), new ResultHandler() { -// @Override -// public void handleResult(ResultContext context) { -// Map fields = (Map) context.getResultObject(); -// // "rule" is a reserved keyword in SQLServer, so "rulefield" is used -// ActiveRuleKey key = ActiveRuleKey.of( -// (String) fields.get("profileKey"), -// RuleKey.of((String) fields.get("repository"), (String) fields.get("rulefield"))); -// session.enqueue(new KeyIndexAction(getIndexType(), IndexAction.Method.UPSERT, key)); -// } -// }); -// session.commit(); -// } - return Collections.EMPTY_LIST; + return mapper(session).selectAfterDate(new Timestamp(date.getTime())); } /** diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java index 4c3c0773eb5..86a117841ae 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java @@ -23,6 +23,7 @@ package org.sonar.core.qualityprofile.db; import org.apache.ibatis.annotations.Param; import javax.annotation.CheckForNull; +import java.sql.Timestamp; import java.util.List; public interface ActiveRuleMapper { @@ -58,8 +59,10 @@ public interface ActiveRuleMapper { List selectParamsByProfileKey(String profileKey); ActiveRuleDto selectByKey(@Param("profileKey") String profileKey, - @Param("repository") String repository, @Param("rule") String rule ); + @Param("repository") String repository, @Param("rule") String rule); List selectAllParams(); + List selectAfterDate(Timestamp date); + } diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml index 63c868f2097..b0cbe0057b9 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml @@ -39,12 +39,10 @@ LEFT JOIN active_rules active_rule_parent ON active_rule_parent.profile_id=profile_parent.id AND a.rule_id=active_rule_parent.rule_id - + select + + from active_rules a a.updated_at IS NULL or a.updated_at >= #{id}