SearchResponse esResults = issueIndex.search(query, options);
// Extend the content of the resultSet to make an actual IssueResponse
- IssueResult results = new IssueResult(issueIndex, esResults);
- results.setPaging(Paging.create(
+ IssueResult result = new IssueResult(issueIndex, esResults);
+ result.setPaging(Paging.create(
options.getLimit(),
(options.getOffset() * options.getLimit()) + 1,
new Long(esResults.getHits().getTotalHits()).intValue()));
- return results;
+ // TODO Optimise
+ // Insert the projects and component name;
+ DbSession session = dbClient.openSession(false);
+ try {
+ for (Issue issue : result.getHits()) {
+ result.addProject(issue.key(),
+ dbClient.componentDao().getByKey(session, issue.projectKey()));
+ result.addComponent(issue.key(),
+ dbClient.componentDao().getByKey(session, issue.componentKey()));
+ }
+ } finally {
+ session.close();
+ }
+
+ return result;
}
}
import org.sonar.api.rules.Rule;
import org.sonar.api.user.User;
import org.sonar.api.utils.Paging;
+import org.sonar.core.component.ComponentDto;
import org.sonar.server.search.BaseIndex;
import org.sonar.server.search.Result;
public boolean maxResultsReached() {
return false;
}
+
+ public void addProject(String key, ComponentDto project) {
+ this.projects.put(key, project);
+ }
+
+ public void addComponent(String key, ComponentDto project) {
+ this.components.put(key, project);
+ }
}