]> source.dussan.org Git - sonarqube.git/commitdiff
fixed synchronization
authorStephane Gamard <stephane.gamard@searchbox.com>
Wed, 20 Aug 2014 15:05:23 +0000 (17:05 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Wed, 20 Aug 2014 16:18:39 +0000 (18:18 +0200)
server/sonar-server/src/main/java/org/sonar/server/activity/db/ActivityDao.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java
sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java
sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml

index df395320c09943afb44e63860c14bc03c83fe3c1..27fff1d30f6e841b911beb3ced7a2bf5c4c3a729 100644 (file)
@@ -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<ActivityMapper, ActivityDto, String> {
 
   @Override
   protected Iterable<ActivityDto> findAfterDate(DbSession session, Date date) {
-    //    for (ActivityDto activity : this.findAll(session)) {
-//      session.enqueue(new DtoIndexAction<ActivityDto>(this.getIndexType(), IndexAction.Method.UPSERT, activity));
-//    }
-//    session.commit();
-    return Collections.EMPTY_LIST;
+    return mapper(session).selectAll();
   }
 
   public List<ActivityDto> findAll(DbSession session) {
index 682ed69f7620799f5a840eb6a75cabe572c7d319..1cd5966e5fb8af377bac2e64a27797c189198cf3 100644 (file)
@@ -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<ActiveRuleMapper, ActiveRuleDto, Acti
 
   @Override
   protected Iterable<ActiveRuleDto> 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<String, Object> fields = (Map<String, Object>) 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<ActiveRuleKey>(getIndexType(), IndexAction.Method.UPSERT, key));
-//        }
-//      });
-//      session.commit();
-//    }
-    return Collections.EMPTY_LIST;
+    return mapper(session).selectAfterDate(new Timestamp(date.getTime()));
   }
 
   /**
index 4c3c0773eb5d6ff5090bb2b689baa29b5b71d48f..86a117841aebb510bd3ae595c8ca99aec5a23552 100644 (file)
@@ -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<ActiveRuleParamDto> 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<ActiveRuleParamDto> selectAllParams();
 
+  List<ActiveRuleDto> selectAfterDate(Timestamp date);
+
 }
index 63c868f209701bfbad6b14b6ff9e2fdd72e69d76..b0cbe0057b99aff5bc86fb2493c6c42a2a9e9645 100644 (file)
     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
   </sql>
 
-  <select id="selectAllKeysAfterTimestamp" parameterType="Date" resultType="map">
-    SELECT
-    r.plugin_rule_key as "rulefield",
-    r.plugin_name as "repository",
-    qp.kee as "profileKey"
-    FROM active_rules a
+  <select id="selectAfterDate" parameterType="Date" resultType="ActiveRule" resultSetType="FORWARD_ONLY">
+    select
+    <include refid="activeRuleKeyColumns"/>
+    from active_rules a
     <include refid="activeRuleKeyJoin"/>
     <where>
       a.updated_at IS NULL or a.updated_at &gt;= #{id}