aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java5
-rw-r--r--sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java34
-rw-r--r--sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java39
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/Platform.java3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb11
-rw-r--r--sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java49
10 files changed, 150 insertions, 8 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
index 1c3502154ad..c2af012c47a 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -582,7 +582,7 @@ issue_filter.criteria.date_format=year-month-day (2013-01-31)
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.
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
index 4901abda11c..e893f2970f8 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
@@ -154,6 +154,11 @@ public class ResourceDao {
}
}
+ 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();
diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
index 00102831f4e..458dd84f423 100644
--- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
@@ -259,4 +259,13 @@ public class ResourceDaoTest extends AbstractDaoTestCase {
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();
+ }
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java
new file mode 100644
index 00000000000..b110cce19e0
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java
@@ -0,0 +1,34 @@
+/*
+ * 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);
+
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java b/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java
new file mode 100644
index 00000000000..da913946555
--- /dev/null
+++ b/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java
@@ -0,0 +1,39 @@
+/*
+ * 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);
+ }
+
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
index aeba75ab896..eec7008c300 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
@@ -68,6 +68,7 @@ import org.sonar.jpa.session.DatabaseSessionProvider;
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;
@@ -253,6 +254,8 @@ public final class Platform {
servicesContainer.addSingleton(DefaultUserFinder.class);
servicesContainer.addSingleton(DefaultRubyUserService.class);
+ // components
+ servicesContainer.addSingleton(DefaultRubyComponentService.class);
// issues
servicesContainer.addSingleton(ServerIssueStorage.class);
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb
index 11241ff6379..fb037453079 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb
@@ -30,8 +30,6 @@ class IssuesController < ApplicationController
@filter = IssueFilter.new
@filter.criteria=criteria_params
@filter.execute
-
- @selected_project = @filter.issues_result.projects.first if @filter.issues && @filter.criteria('componentRoots')
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
index fc6cd765ab3..df3c18a1884 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
@@ -42,6 +42,10 @@ class Internal
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)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb
index 9a6a66ede1d..b726f192374 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb
@@ -9,8 +9,9 @@
</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',
@@ -18,9 +19,9 @@
-%>
</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">
@@ -37,13 +38,13 @@
</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>
diff --git a/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java b/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java
new file mode 100644
index 00000000000..d9911b33775
--- /dev/null
+++ b/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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);
+ }
+}