import org.sonar.server.db.BaseDao;
import org.sonar.server.search.IndexDefinition;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
@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) {
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;
@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()));
}
/**
import org.apache.ibatis.annotations.Param;
import javax.annotation.CheckForNull;
+import java.sql.Timestamp;
import java.util.List;
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);
+
}
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 >= #{id}