issue_filter.criteria.project=Project
issue_filter.criteria.reporter=Reporter
issue_filter.criteria.resolution=Resolution
-issue_filter.criteria.severities=Severities
+issue_filter.criteria.severity=Severity
issue_filter.criteria.status=Status
issue_filter.max_results_reached=Only the first {0} issues matching the search criteria have been retrieved. Add some additional criteria to get fewer results to be able to sort this list.
issue_filter.no_result=No matching issues found.
}
}
+ public Component findByKey(String key) {
+ ResourceDto resourceDto = getResource(ResourceQuery.create().setKey(key));
+ return resourceDto != null ? toComponent(resourceDto) : null;
+ }
+
public List<Integer> findChildrenComponentIds(Collection<String> componentRootKeys){
if (componentRootKeys.isEmpty()) {
return Collections.emptyList();
assertThat(dao.findChildrenComponentIds(newArrayList("unknown"))).isEmpty();
assertThat(dao.findChildrenComponentIds(Collections.<String>emptyList())).isEmpty();
}
+
+ @Test
+ public void should_find_component_by_key(){
+ setupData("fixture");
+
+ assertThat(dao.findByKey("org.struts:struts")).isNotNull();
+ assertThat(dao.findByKey("org.struts:struts:org.struts.RequestContext")).isNotNull();
+ assertThat(dao.findByKey("unknown")).isNull();
+ }
}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.component;
+
+import org.sonar.api.ServerComponent;
+
+import javax.annotation.CheckForNull;
+
+/**
+ * @since 3.6
+ */
+public interface RubyComponentService extends ServerComponent {
+
+ @CheckForNull
+ Component findByKey(String key);
+
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.component;
+
+import org.sonar.api.component.Component;
+import org.sonar.api.component.RubyComponentService;
+import org.sonar.core.resource.ResourceDao;
+
+public class DefaultRubyComponentService implements RubyComponentService {
+
+ private final ResourceDao resourceDao;
+
+ public DefaultRubyComponentService(ResourceDao resourceDao) {
+ this.resourceDao = resourceDao;
+ }
+
+ @Override
+ public Component findByKey(String key) {
+ return resourceDao.findByKey(key);
+ }
+
+}
import org.sonar.jpa.session.DefaultDatabaseConnector;
import org.sonar.jpa.session.ThreadLocalDatabaseSessionFactory;
import org.sonar.server.charts.ChartFactory;
+import org.sonar.server.component.DefaultRubyComponentService;
import org.sonar.server.configuration.Backup;
import org.sonar.server.configuration.ProfilesManager;
import org.sonar.server.database.EmbeddedDatabaseFactory;
servicesContainer.addSingleton(DefaultUserFinder.class);
servicesContainer.addSingleton(DefaultRubyUserService.class);
+ // components
+ servicesContainer.addSingleton(DefaultRubyComponentService.class);
// issues
servicesContainer.addSingleton(ServerIssueStorage.class);
@filter = IssueFilter.new
@filter.criteria=criteria_params
@filter.execute
-
- @selected_project = @filter.issues_result.projects.first if @filter.issues && @filter.criteria('componentRoots')
end
component(Java::OrgSonarApiUser::RubyUserService.java_class)
end
+ def self.component_api
+ component(Java::OrgSonarApiComponent::RubyComponentService.java_class)
+ end
+
private
def self.component(component_java_class)
Java::OrgSonarServerPlatform::Platform.component(component_java_class)
</li>
<li id="criteria-project" class="marginbottom5">
<%= message 'issue_filter.criteria.project' -%>:
+ <% selected_componentRoot = Internal.component_api.findByKey(@filter.criteria('componentRoots')) %>
<%= component_select_tag 'componentRoots', :resource_type_property => 'supportsGlobalDashboards', :width => '100%',
- :selected_resource => @selected_project,
+ :selected_resource => selected_componentRoot,
:display_key => true,
:placeholder => message('issue_filter.criteria.project'),
:html_id => 'select-project',
-%>
</li>
<li id="criteria-severity" class="marginbottom5">
- <%= message 'issue_filter.criteria.severities' -%>:
+ <%= message 'issue_filter.criteria.severity' -%>:
<%= dropdown_tag 'severities[]', options_for_select(RulesConfigurationController::RULE_PRIORITIES, @filter.criteria('severities')),
- {:width => '100%', :placeholder => message('issue_filter.criteria.severities')},
+ {:width => '100%', :placeholder => message('issue_filter.criteria.severity')},
{:id => 'select-severities', :multiple => true}-%>
</li>
<li id="criteria-status" class="marginbottom5">
</li>
<li>
<%= message 'issue_filter.criteria.assignee' -%>:
- <% selected_assignee = @filter.issues_result.user(@filter.criteria('assignees')) if @filter.issues_result %>
+ <% selected_assignee = Api.users.findByLogin(@filter.criteria('assignees')) %>
<%= user_select_tag('assignees', {:selected_user => selected_assignee, :width => '100%', :placeholder => message('issue_filter.criteria.assignee'),
:html_id => 'select-assignee', :open => false, :allow_clear => true}) -%>
</li>
<li>
<%= message 'issue_filter.criteria.reporter' -%>:
- <% selected_reporter = @filter.issues_result.user(@filter.criteria('reporters')) if @filter.issues_result %>
+ <% selected_reporter = Api.users.findByLogin(@filter.criteria('reporters')) %>
<%= user_select_tag('reporters', {:selected_user => selected_reporter, :width => '100%', :placeholder => message('issue_filter.criteria.reporter'),
:html_id => 'select-reporter', :open => false, :allow_clear => true}) -%>
</li>
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.component;
+
+import org.junit.Before;
+import org.sonar.api.component.Component;
+import org.sonar.core.resource.ResourceDao;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class DefaultRubyComponentServiceTest {
+
+ private ResourceDao resourceDao;
+ private DefaultRubyComponentService componentService;
+
+ @Before
+ public void before(){
+ resourceDao = mock(ResourceDao.class);
+ componentService = new DefaultRubyComponentService(resourceDao);
+ }
+
+ @Before
+ public void should_find_by_key() {
+ Component component = mock(Component.class);
+ when(resourceDao.findByKey("struts")).thenReturn(component);
+
+ assertThat(componentService.findByKey("struts")).isEqualTo(component);
+ }
+}