import org.sonar.server.es.SearchOptions;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.issue.index.IssueDoc;
+import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.issue.notification.IssueChangeNotification;
import org.sonar.server.notification.NotificationManager;
import org.sonar.server.rule.DefaultRuleFinder;
private static final Logger LOG = Loggers.get(IssueBulkChangeService.class);
private final DbClient dbClient;
- private final IssueService issueService;
+ private final IssueIndex issueIndex;
private final IssueStorage issueStorage;
private final DefaultRuleFinder ruleFinder;
private final NotificationManager notificationService;
private final List<Action> actions;
private final UserSession userSession;
- public IssueBulkChangeService(DbClient dbClient, IssueService issueService, IssueStorage issueStorage, DefaultRuleFinder ruleFinder,
+ public IssueBulkChangeService(DbClient dbClient, IssueIndex issueIndex, IssueStorage issueStorage, DefaultRuleFinder ruleFinder,
NotificationManager notificationService, List<Action> actions, UserSession userSession) {
this.dbClient = dbClient;
- this.issueService = issueService;
+ this.issueIndex = issueIndex;
this.issueStorage = issueStorage;
this.ruleFinder = ruleFinder;
this.notificationService = notificationService;
// Load from index to check permission
SearchOptions options = new SearchOptions().setLimit(SearchOptions.MAX_LIMIT);
// TODO restrict fields to issue key, in order to not load all other fields;
- List<IssueDoc> authorizedIssues = issueService.search(IssueQuery.builder(userSession).issueKeys(issueKeys).build(), options).getDocs();
+ List<IssueDoc> authorizedIssues = issueIndex.search(IssueQuery.builder(userSession).issueKeys(issueKeys).build(), options).getDocs();
Collection<String> authorizedKeys = Collections2.transform(authorizedIssues, new Function<IssueDoc, String>() {
@Override
public String apply(IssueDoc input) {
import org.sonar.db.issue.IssueDto;
import org.sonar.db.protobuf.DbFileSources;
import org.sonar.db.rule.RuleDto;
-import org.sonar.server.es.SearchOptions;
-import org.sonar.server.es.SearchResult;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.issue.actionplan.ActionPlanService;
-import org.sonar.server.issue.index.IssueDoc;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.issue.notification.IssueChangeNotification;
import org.sonar.server.issue.workflow.IssueWorkflow;
}
}
- public SearchResult<IssueDoc> search(IssueQuery query, SearchOptions options) {
- return issueIndex.search(query, options);
- }
-
/**
* Search for all tags, whatever issue resolution or user access rights
*/
import org.sonar.server.es.SearchResult;
import org.sonar.server.issue.IssueQuery;
import org.sonar.server.issue.IssueQueryService;
-import org.sonar.server.issue.IssueService;
import org.sonar.server.issue.index.IssueDoc;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.rule.RuleKeyFunctions;
public static final String SEARCH_ACTION = "search";
private final UserSession userSession;
- private final IssueService service;
+ private final IssueIndex issueIndex;
private final IssueQueryService issueQueryService;
private final SearchResponseLoader searchResponseLoader;
private final SearchResponseFormat searchResponseFormat;
- public SearchAction(UserSession userSession, IssueService service, IssueQueryService issueQueryService,
+ public SearchAction(UserSession userSession, IssueIndex issueIndex, IssueQueryService issueQueryService,
SearchResponseLoader searchResponseLoader, SearchResponseFormat searchResponseFormat) {
this.userSession = userSession;
- this.service = service;
+ this.issueIndex = issueIndex;
this.issueQueryService = issueQueryService;
this.searchResponseLoader = searchResponseLoader;
this.searchResponseFormat = searchResponseFormat;
IssueQuery query = issueQueryService.createFromRequest(request);
// execute request
- SearchResult<IssueDoc> result = service.search(query, options);
+ SearchResult<IssueDoc> result = issueIndex.search(query, options);
List<String> issueKeys = from(result.getDocs()).transform(IssueDocToKey.INSTANCE).toList();
// load the additional information to be returned in response
import org.sonar.db.user.GroupDao;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.es.SearchOptions;
-import org.sonar.server.es.SearchResult;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.issue.index.IssueDoc;
import org.sonar.server.issue.index.IssueIndex;
-import org.sonar.server.issue.index.IssueIndexDefinition;
import org.sonar.server.issue.index.IssueIndexer;
import org.sonar.server.issue.workflow.Transition;
import org.sonar.server.permission.PermissionChange;
assertThat(service.getByKey(issue.getKey())).isNotNull();
}
- @Test
- public void can_facet() {
- RuleDto rule = newRule();
- ComponentDto project = newProject();
- ComponentDto file = newFile(project);
-
- saveIssue(IssueTesting.newDto(rule, file, project).setActionPlanKey("P1"));
- saveIssue(IssueTesting.newDto(rule, file, project).setActionPlanKey("P2").setResolution("NONE"));
-
- SearchResult<IssueDoc> result = service.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions());
- assertThat(result.getDocs()).hasSize(2);
- assertThat(result.getFacets().getNames()).isEmpty();
-
- result = service.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets("actionPlans", "assignees"));
- assertThat(result.getFacets().getNames()).hasSize(2);
- assertThat(result.getFacets().get("actionPlans")).hasSize(2);
- assertThat(result.getFacets().get("assignees")).hasSize(1);
- }
-
@Test
public void list_status() {
assertThat(service.listStatus()).containsExactly("OPEN", "CONFIRMED", "REOPENED", "RESOLVED", "CLOSED");
service.createManualIssue(file.key(), rule.getKey(), 10, "Fix it", null);
}
- @Test
- public void search_issues() {
- RuleDto rule = newRule();
- ComponentDto project = newProject();
- ComponentDto file = newFile(project);
- saveIssue(IssueTesting.newDto(rule, file, project));
-
- List<IssueDoc> result = service.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFields(IssueIndexDefinition.FIELD_ISSUE_KEY)).getDocs();
- assertThat(result).hasSize(1);
- }
-
@Test
public void list_tags() {
RuleDto rule = newRule();