import org.sonar.server.exceptions.NotFoundException;
import javax.annotation.CheckForNull;
+
import java.util.Collection;
import java.util.Collections;
import java.util.List;
private final Collection<String> resolutions;
private final Collection<String> components;
private final Collection<String> componentRoots;
+ private final Collection<String> projects;
private final Collection<RuleKey> rules;
private final Collection<String> actionPlans;
private final Collection<String> reporters;
this.resolutions = defaultCollection(builder.resolutions);
this.components = defaultCollection(builder.components);
this.componentRoots = defaultCollection(builder.componentRoots);
+ this.projects = defaultCollection(builder.projects);
this.rules = defaultCollection(builder.rules);
this.actionPlans = defaultCollection(builder.actionPlans);
this.reporters = defaultCollection(builder.reporters);
return componentRoots;
}
+ public Collection<String> projectUuids() {
+ return projects;
+ }
+
public Collection<RuleKey> rules() {
return rules;
}
private Collection<String> resolutions;
private Collection<String> components;
private Collection<String> componentRoots;
+ private Collection<String> projects;
private Collection<RuleKey> rules;
private Collection<String> actionPlans;
private Collection<String> reporters;
return this;
}
+ public Builder projectUuids(@Nullable Collection<String> l) {
+ this.projects = l;
+ return this;
+ }
+
public Builder rules(@Nullable Collection<RuleKey> rules) {
this.rules = rules;
return this;
.createdAt(RubyUtils.toDate(params.get(IssueFilterParameters.CREATED_AT)))
.createdAfter(RubyUtils.toDate(params.get(IssueFilterParameters.CREATED_AFTER)))
.createdBefore(RubyUtils.toDate(params.get(IssueFilterParameters.CREATED_BEFORE)));
+ addProjectUuids(builder, session,
+ RubyUtils.toStrings(params.get(IssueFilterParameters.PROJECT_UUIDS)), RubyUtils.toStrings(params.get(IssueFilterParameters.PROJECTS)));
addComponentUuids(builder, session,
RubyUtils.toStrings(params.get(IssueFilterParameters.COMPONENT_UUIDS)), RubyUtils.toStrings(params.get(IssueFilterParameters.COMPONENTS)));
addComponentRootUuids(builder, session,
.createdAt(request.paramAsDateTime(IssueFilterParameters.CREATED_AT))
.createdAfter(request.paramAsDateTime(IssueFilterParameters.CREATED_AFTER))
.createdBefore(request.paramAsDateTime(IssueFilterParameters.CREATED_BEFORE));
+ addProjectUuids(builder, session,
+ request.paramAsStrings(IssueFilterParameters.PROJECT_UUIDS), request.paramAsStrings(IssueFilterParameters.PROJECTS));
addComponentUuids(builder, session,
request.paramAsStrings(IssueFilterParameters.COMPONENT_UUIDS), request.paramAsStrings(IssueFilterParameters.COMPONENTS));
addComponentRootUuids(builder, session,
}
}
+ private void addProjectUuids(IssueQuery.Builder builder, DbSession session, @Nullable Collection<String> projectUuids, @Nullable Collection<String> projects) {
+ if (projectUuids != null) {
+ if (projects != null) {
+ throw new IllegalArgumentException("projects and projectUuids cannot be set simultaneously");
+ }
+ builder.projectUuids(projectUuids);
+ } else {
+ builder.projectUuids(componentUuids(session, projects));
+ }
+ }
+
private void addComponentUuids(IssueQuery.Builder builder, DbSession session, @Nullable Collection<String> componentUuids, @Nullable Collection<String> components) {
if (componentUuids != null) {
if (components != null) {
public static final String COMPONENT_UUIDS = "componentUuids";
public static final String COMPONENT_ROOTS = "componentRoots";
public static final String COMPONENT_ROOT_UUIDS = "componentRootUuids";
+ public static final String PROJECTS = "projects";
+ public static final String PROJECT_UUIDS = "projectUuids";
public static final String RULES = "rules";
public static final String ACTION_PLANS = "actionPlans";
public static final String REPORTERS = "reporters";
public static final String ASC = "asc";
public static final List<String> ALL = ImmutableList.of(ISSUES, SEVERITIES, STATUSES, RESOLUTIONS, RESOLVED, COMPONENTS, COMPONENT_ROOTS, RULES, ACTION_PLANS, REPORTERS,
- ASSIGNEES, LANGUAGES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, PAGE_SIZE, PAGE_INDEX, SORT, ASC, COMPONENT_UUIDS, COMPONENT_ROOT_UUIDS);
+ ASSIGNEES, LANGUAGES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, PAGE_SIZE, PAGE_INDEX, SORT, ASC, COMPONENT_UUIDS, COMPONENT_ROOT_UUIDS,
+ PROJECTS, PROJECT_UUIDS);
public static final List<String> ALL_WITHOUT_PAGINATION = newArrayList(Iterables.filter(ALL, new Predicate<String>() {
@Override
filters.put(IssueNormalizer.IssueField.ASSIGNEE.field(), matchFilter(IssueNormalizer.IssueField.ASSIGNEE, query.assignees()));
filters.put(IssueNormalizer.IssueField.MODULE_PATH.field(), matchFilter(IssueNormalizer.IssueField.MODULE_PATH, query.componentRootUuids()));
filters.put(IssueNormalizer.IssueField.COMPONENT.field(), matchFilter(IssueNormalizer.IssueField.COMPONENT, query.componentUuids()));
+ filters.put(IssueNormalizer.IssueField.PROJECT.field(), matchFilter(IssueNormalizer.IssueField.PROJECT, query.projectUuids()));
filters.put(IssueNormalizer.IssueField.LANGUAGE.field(), matchFilter(IssueNormalizer.IssueField.LANGUAGE, query.languages()));
filters.put(IssueNormalizer.IssueField.RESOLUTION.field(), matchFilter(IssueNormalizer.IssueField.RESOLUTION, query.resolutions()));
filters.put(IssueNormalizer.IssueField.REPORTER.field(), matchFilter(IssueNormalizer.IssueField.REPORTER, query.reporters()));
IssueFilterParameters.STATUSES, IssueNormalizer.IssueField.STATUS.field(), 0);
addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
IssueFilterParameters.ACTION_PLANS, IssueNormalizer.IssueField.ACTION_PLAN.field(), 1, query.actionPlans().toArray());
- addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
- IssueFilterParameters.COMPONENT_ROOT_UUIDS, IssueNormalizer.IssueField.MODULE_PATH.field(), 1, query.componentRootUuids().toArray());
addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
IssueFilterParameters.COMPONENT_UUIDS, IssueNormalizer.IssueField.COMPONENT.field(), 1, query.componentUuids().toArray());
+ addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
+ IssueFilterParameters.PROJECT_UUIDS, IssueNormalizer.IssueField.PROJECT.field(), 1, query.projectUuids().toArray());
addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
IssueFilterParameters.LANGUAGES, IssueNormalizer.IssueField.LANGUAGE.field(), 0, query.languages().toArray());
addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
"Issues associated to its sub-components (such as files, packages, etc.) are not retrieved. See also componentRoots. " +
"If this parameter is set, componentUuids must not be set.")
.setExampleValue("org.apache.struts:struts:org.apache.struts.Action");
+ action.createParam(IssueFilterParameters.PROJECTS)
+ .setDescription("To retrieve issues associated to a specific list of projects (comma-separated list of project keys). " +
+ "If this parameter is set, projectUuids must not be set.")
+ .setExampleValue("org.apache.struts:struts:org.apache.struts.Action");
action.createParam(IssueFilterParameters.COMPONENT_ROOTS)
.setDescription("To retrieve issues associated to a specific list of components and their sub-components (comma-separated list of component keys). " +
"Views are not supported. If this parameter is set, componentRootUuids must not be set.")
.setDescription("To retrieve issues associated to a specific list of components and their sub-components (comma-separated list of component UUIDs). " +
"Views are not supported. If this parameter is set, componentRoots must not be set.")
.setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92");
+ action.createParam(IssueFilterParameters.PROJECT_UUIDS)
+ .setDescription("To retrieve issues associated to a specific list of projects (comma-separated list of project UUIDs). " +
+ "Views are not supported. If this parameter is set, projects must not be set.")
+ .setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92");
action.createParam(IssueFilterParameters.RULES)
.setDescription("Comma-separated list of coding rule keys. Format is <repository>:<rule>")
.setExampleValue("squid:AvoidCycles");
IssueFilterParameters.STATUSES,
IssueFilterParameters.RESOLUTIONS,
IssueFilterParameters.ACTION_PLANS,
- IssueFilterParameters.COMPONENT_ROOT_UUIDS,
+ IssueFilterParameters.PROJECT_UUIDS,
IssueFilterParameters.RULES,
IssueFilterParameters.ASSIGNEES,
IssueFilterParameters.REPORTERS,
}
}
- collectFacetKeys(result, IssueFilterParameters.COMPONENT_ROOT_UUIDS, projectUuids);
+ collectFacetKeys(result, IssueFilterParameters.PROJECT_UUIDS, projectUuids);
collectFacetKeys(result, IssueFilterParameters.COMPONENT_UUIDS, componentUuids);
collectFacetKeys(result, IssueFilterParameters.ASSIGNEES, userLogins);
collectFacetKeys(result, IssueFilterParameters.REPORTERS, userLogins);
List<ComponentDto> fileDtos = dbClient.componentDao().getByUuids(session, componentUuids);
List<ComponentDto> subProjectDtos = dbClient.componentDao().findSubProjectsByComponentUuids(session, componentUuids);
- projectDtos = dbClient.componentDao().getByUuids(session, projectUuids);
componentDtos.addAll(fileDtos);
componentDtos.addAll(subProjectDtos);
- componentDtos.addAll(projectDtos);
+ for (ComponentDto component: componentDtos) {
+ projectUuids.add(component.projectUuid());
+ }
+
+ projectDtos = dbClient.componentDao().getByUuids(session, projectUuids);
+ componentDtos.addAll(projectDtos);
for (ComponentDto componentDto : componentDtos) {
componentsByUuid.put(componentDto.uuid(), componentDto);
}
throw new IllegalStateException("Component has no UUID: " + component.getKey());
}
if (!projectsByUuid.containsKey(component.projectUuid())) {
- throw new IllegalStateException("Project cannot be found for component: " + component.getKey());
+ throw new IllegalStateException("Project cannot be found for component: " + component.getKey() + " / " + component.uuid());
}
projectsByComponentUuid.put(component.uuid(), projectsByUuid.get(component.projectUuid()));
}
assertThat(show.isPost()).isFalse();
assertThat(show.isInternal()).isFalse();
assertThat(show.responseExampleAsString()).isNotEmpty();
- assertThat(show.params()).hasSize(28);
+ assertThat(show.params()).hasSize(30);
}
@Test
WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
.setParam("resolved", "false")
- .setParam(SearchAction.PARAM_FACETS, "statuses,severities,resolutions,componentRootUuids,rules,componentUuids,assignees,languages")
+ .setParam(SearchAction.PARAM_FACETS, "statuses,severities,resolutions,projectUuids,rules,componentUuids,assignees,languages")
.execute();
result.assertJson(this.getClass(), "display_facets.json", false);
}
]
},
{
- "property": "componentRootUuids",
+ "property": "projectUuids",
"values": [
{
- "val": "abcd",
+ "val": "ABCD",
"count": 1
}
]
$ = jQuery
EXTRA_FIELDS = 'actions,transitions,assigneeName,reporterName,actionPlanName'
PAGE_SIZE = 50
- ALL_FACETS = ['severities', 'statuses', 'resolutions', 'componentRootUuids', 'assignees', 'reporters', 'rules',
+ ALL_FACETS = ['severities', 'statuses', 'resolutions', 'projectUuids', 'assignees', 'reporters', 'rules',
'languages', 'actionPlans', 'componentUuids', 'creationDate']
FACET_DATA_FIELDS = ['components', 'projects', 'users', 'rules', 'actionPlans', 'languages']
- FACETS_FROM_SERVER = ['severities', 'statuses', 'resolutions', 'actionPlans', 'componentRootUuids', 'rules',
+ FACETS_FROM_SERVER = ['severities', 'statuses', 'resolutions', 'actionPlans', 'projectUuids', 'rules',
'assignees', 'reporters', 'componentUuids', 'languages']
when 'assignees' then AssigneeFacet
when 'resolutions' then ResolutionFacet
when 'creationDate' then CreationDateFacet
- when 'componentRootUuids' then ProjectFacet
+ when 'projectUuids' then ProjectFacet
when 'rules' then RuleFacet
when 'actionPlans' then ActionPlanFacet
when 'componentUuids' then ComponentFacet
enabledFacets = @collection.filter (model) -> model.get('enabled')
enabledFacetIds = enabledFacets.map (model) -> model.id
@options.app.state.set facets: enabledFacetIds
-
import org.sonar.core.component.ComponentDto;
import javax.annotation.CheckForNull;
+
import java.util.Collection;
import java.util.List;
#
#------------------------------------------------------------------------------
issues.facet.severities=Severity
-issues.facet.componentRootUuids=Project
+issues.facet.projectUuids=Project
issues.facet.statuses=Status
issues.facet.actionPlans=Action Plan
issues.facet.assignees=Assignee