import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
private final String sort;
private final Boolean asc;
private final Boolean ignorePaging;
- private final Boolean contextualized;
private final String userLogin;
private final Set<String> userGroups;
this.userLogin = builder.userLogin;
this.userGroups = builder.userGroups;
this.checkAuthorization = builder.checkAuthorization;
- this.contextualized = builder.contextualized;
}
public Collection<String> issueKeys() {
return checkAuthorization;
}
- @CheckForNull
- public Boolean isContextualized() {
- return contextualized;
- }
-
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
private String sort;
private Boolean asc = false;
private Boolean ignorePaging = false;
- private boolean contextualized;
private String userLogin = UserSession.get().login();
private Set<String> userGroups = UserSession.get().userGroups();
private boolean checkAuthorization = true;
return this;
}
- public Builder setContextualized(boolean b) {
- this.contextualized = b;
- return this;
- }
}
private static <T> Collection<T> defaultCollection(@Nullable Collection<T> c) {
builder.onComponentOnly(effectiveOnComponentOnly);
if (allComponentUuids.isEmpty()) {
- builder.setContextualized(false);
addComponentsBelowView(builder, session, authors, projects, projectUuids, moduleUuids, directories, fileUuids);
} else {
if (effectiveOnComponentOnly) {
- builder.setContextualized(false);
builder.componentUuids(allComponentUuids);
return;
}
- builder.setContextualized(true);
-
Set<String> qualifiers = componentService.getDistinctQualifiers(session, allComponentUuids);
if (qualifiers.isEmpty()) {
// Qualifier not found, defaulting to componentUuids (e.g <UNKNOWN>)
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static com.google.common.collect.Maps.newLinkedHashMap;
.userGroups(UserSession.get().userGroups())
.moduleRootUuids(Arrays.asList(componentUuid))
.onComponentOnly(false)
- .setContextualized(true)
.resolved(false)
.build();
return issueIndex.countTags(query, pageSize);
FilterBuilder directoryFilter = createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_DIRECTORY_PATH, query.directories());
FilterBuilder fileFilter = createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, query.fileUuids());
- if (BooleanUtils.isTrue(query.isContextualized())) {
- if (viewFilter != null) {
- filters.put(FILTER_COMPONENT_ROOT, viewFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID, projectFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_MODULE_UUID, moduleFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_DIRECTORY_PATH, directoryFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, fileFilter);
- } else if (projectFilter != null) {
- filters.put(FILTER_COMPONENT_ROOT, projectFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_MODULE_UUID, moduleFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_DIRECTORY_PATH, directoryFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, fileFilter);
- } else if (moduleRootFilter != null) {
- filters.put(FILTER_COMPONENT_ROOT, moduleRootFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_MODULE_UUID, moduleFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_DIRECTORY_PATH, directoryFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, fileFilter);
- } else if (directoryRootFilter != null) {
- filters.put(FILTER_COMPONENT_ROOT, directoryRootFilter);
- filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, fileFilter);
- } else if (fileFilter != null) {
- filters.put(FILTER_COMPONENT_ROOT, fileFilter);
- } else if (componentFilter != null) {
- // Last resort, when component type is unknown
- filters.put(FILTER_COMPONENT_ROOT, componentFilter);
- }
+ if (query.onComponentOnly()) {
+ filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, componentFilter);
} else {
- if (query.onComponentOnly()) {
- filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, componentFilter);
- } else {
- filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, fileFilter);
- }
+ filters.put("__view", viewFilter);
filters.put(IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID, projectFilter);
+ filters.put("__module", moduleRootFilter);
filters.put(IssueIndexDefinition.FIELD_ISSUE_MODULE_UUID, moduleFilter);
filters.put(IssueIndexDefinition.FIELD_ISSUE_DIRECTORY_PATH, directoryFilter);
- filters.put("view", viewFilter);
+ if (fileFilter != null) {
+ filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, fileFilter);
+ } else {
+ filters.put(IssueIndexDefinition.FIELD_ISSUE_COMPONENT_UUID, componentFilter);
+ }
}
}
IssueTesting.newDoc("ISSUE5", subModule),
IssueTesting.newDoc("ISSUE6", file3));
- assertThat(index.search(IssueQuery.builder().setContextualized(true).fileUuids(newArrayList(file1.uuid(), file2.uuid(), file3.uuid())).build(), new SearchOptions())
+ assertThat(index.search(IssueQuery.builder().fileUuids(newArrayList(file1.uuid(), file2.uuid(), file3.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(3);
- assertThat(index.search(IssueQuery.builder().setContextualized(true).fileUuids(newArrayList(file1.uuid())).build(), new SearchOptions())
+ assertThat(index.search(IssueQuery.builder().fileUuids(newArrayList(file1.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder().setContextualized(true).moduleRootUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
+ assertThat(index.search(IssueQuery.builder().moduleRootUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder().setContextualized(true).moduleRootUuids(newArrayList(module.uuid())).build(), new SearchOptions())
+ assertThat(index.search(IssueQuery.builder().moduleRootUuids(newArrayList(module.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(4);
- assertThat(index.search(IssueQuery.builder().setContextualized(true).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions())
+ assertThat(index.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(6);
- assertThat(index.search(IssueQuery.builder().setContextualized(true).viewUuids(newArrayList(view)).build(), new SearchOptions())
+ assertThat(index.search(IssueQuery.builder().viewUuids(newArrayList(view)).build(), new SearchOptions())
.getDocs()).hasSize(6);
- assertThat(index.search(IssueQuery.builder().setContextualized(true).projectUuids(newArrayList("unknown")).build(), new SearchOptions())
+ assertThat(index.search(IssueQuery.builder().projectUuids(newArrayList("unknown")).build(), new SearchOptions())
.getDocs()).isEmpty();
}
}
@Test
- public void project_facet_is_sticky_when_non_contextualized() throws Exception {
+ public void project_facet_is_sticky() throws Exception {
ComponentDto project1 = insertComponent(ComponentTesting.newProjectDto("ABCD").setKey("MyProject1"));
ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto("BCDE").setKey("MyProject2"));
ComponentDto project3 = insertComponent(ComponentTesting.newProjectDto("CDEF").setKey("MyProject3"));
.setParam(WebService.Param.FACETS, "projectUuids")
.execute()
.assertJson(this.getClass(), "display_sticky_project_facet.json", false);
-
- wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
- .setParam(IssueFilterParameters.COMPONENT_UUIDS, project1.uuid())
- .setParam(WebService.Param.FACETS, "projectUuids")
- .execute()
- .assertJson(this.getClass(), "display_non_sticky_project_facet.json", false);
}
@Test