import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
public void setModuleUuidPath(@Nullable String s) {
setField(IssueIndexDefinition.FIELD_ISSUE_MODULE_PATH, s);
}
+
+ @CheckForNull
+ public Collection<String> tags() {
+ return getNullableField(IssueIndexDefinition.FIELD_ISSUE_TAGS);
+ }
+
+ public void setTags(@Nullable Collection<String> tags) {
+ setField(IssueIndexDefinition.FIELD_ISSUE_TAGS, tags);
+ }
}
public static final String FIELD_ISSUE_SEVERITY = "severity";
public static final String FIELD_ISSUE_SEVERITY_VALUE = "severityValue";
public static final String FIELD_ISSUE_STATUS = "status";
+ public static final String FIELD_ISSUE_TAGS = "tags";
/**
* Technical date
*/
issueMapping.stringFieldBuilder(FIELD_ISSUE_SEVERITY).build();
issueMapping.createByteField(FIELD_ISSUE_SEVERITY_VALUE);
issueMapping.stringFieldBuilder(FIELD_ISSUE_STATUS).enableSorting().build();
+ issueMapping.stringFieldBuilder(FIELD_ISSUE_TAGS).build();
issueMapping.createDateTimeField(FIELD_ISSUE_TECHNICAL_UPDATED_AT);
}
}
*/
package org.sonar.server.issue.index;
-import com.google.common.collect.Maps;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Date;
+
import org.apache.commons.lang.StringUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.server.db.DbClient;
import org.sonar.server.db.ResultSetIterator;
import org.sonar.server.db.migrations.SqlUtil;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Date;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
/**
* Scrolls over table ISSUES and reads documents to populate
"p.uuid",
"p.module_uuid",
"p.module_uuid_path",
- "p.path"
+ "p.path",
+ "i.tags"
};
private static final String SQL_ALL = "select " + StringUtils.join(FIELDS, ",") + " from issues i " +
private static final String SQL_AFTER_DATE = SQL_ALL + " where i.updated_at>?";
+ private static final Splitter TAGS_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings();
+
static IssueResultSetIterator create(DbClient dbClient, Connection connection, long afterDate) {
try {
String sql = afterDate > 0L ? SQL_AFTER_DATE : SQL_ALL;
doc.setModuleUuid(rs.getString(23));
doc.setModuleUuidPath(rs.getString(24));
doc.setFilePath(rs.getString(25));
+ String tags = rs.getString(26);
+ doc.setTags(ImmutableList.copyOf(TAGS_SPLITTER.split(tags == null ? "" : tags)));
return doc;
}
}
assertThat(issue.assignee()).isNotEmpty();
assertThat(issue.componentUuid()).isNotEmpty();
assertThat(issue.projectUuid()).isNotEmpty();
+ assertThat(issue.tags()).containsOnly("tag1", "tag2", "tag3");
assertThat(issue.debt().toMinutes()).isGreaterThan(0L);
assertThat(it.hasNext()).isTrue();
assertThat(issue.assignee()).isNotEmpty();
assertThat(issue.componentUuid()).isNotEmpty();
assertThat(issue.projectUuid()).isNotEmpty();
+ assertThat(issue.tags()).isEmpty();
assertThat(issue.debt().toMinutes()).isGreaterThan(0L);
assertThat(it.hasNext()).isFalse();
reporter="[null]"
issue_attributes="JIRA=http://jira.com"
action_plan_key="PLAN1"
+ tags="tag1,tag2,tag3"
created_at="1400000000000"
updated_at="1400000000000"
issue_creation_date="2005-05-12 00:00:00.0"
reporter="[null]"
issue_attributes="JIRA=http://jira.com"
action_plan_key="PLAN2"
+ tags="[null]"
created_at="1400000000000"
updated_at="1450000000000"
issue_creation_date="2005-05-12 00:00:00.0"