aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/main
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-01-19 16:57:17 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-01-19 17:01:44 +0100
commitb978d17cc73d70e4a38baf902fb0be401fcf3004 (patch)
treeaf6e06262ba064d457a4acb324b9e9ed8382c546 /sonar-core/src/main
parent53247da2a46dfcec2c6af7f378540390b51df200 (diff)
downloadsonarqube-b978d17cc73d70e4a38baf902fb0be401fcf3004.tar.gz
sonarqube-b978d17cc73d70e4a38baf902fb0be401fcf3004.zip
SONAR-6012 Create WS /batch/issues
Diffstat (limited to 'sonar-core/src/main')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java135
-rw-r--r--sonar-core/src/main/java/org/sonar/core/permission/GlobalPermissions.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java76
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml44
5 files changed, 194 insertions, 70 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
index f5e887bde58..87f4799525e 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
@@ -20,6 +20,7 @@
package org.sonar.core.component;
import org.sonar.api.component.Component;
+import org.sonar.api.resources.Scopes;
import org.sonar.core.persistence.Dto;
import javax.annotation.CheckForNull;
@@ -223,6 +224,10 @@ public class ComponentDto extends Dto<String> implements Component {
return this;
}
+ public boolean isRootProject() {
+ return MODULE_UUID_PATH_SEP.equals(moduleUuidPath) && Scopes.PROJECT.equals(scope);
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java
new file mode 100644
index 00000000000..2f2343ed426
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java
@@ -0,0 +1,135 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 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.core.issue.db;
+
+public class BatchIssueDto {
+
+ private String kee;
+ private String message;
+ private Integer line;
+ private String status;
+ private String resolution;
+ private String checksum;
+ private String assigneeLogin;
+ private String assigneeName;
+ private String componentPath;
+ private String ruleKey;
+ private String ruleRepo;
+
+ public String getAssigneeLogin() {
+ return assigneeLogin;
+ }
+
+ public BatchIssueDto setAssigneeLogin(String assigneeLogin) {
+ this.assigneeLogin = assigneeLogin;
+ return this;
+ }
+
+ public String getAssigneeName() {
+ return assigneeName;
+ }
+
+ public BatchIssueDto setAssigneeName(String assigneeName) {
+ this.assigneeName = assigneeName;
+ return this;
+ }
+
+ public String getChecksum() {
+ return checksum;
+ }
+
+ public BatchIssueDto setChecksum(String checksum) {
+ this.checksum = checksum;
+ return this;
+ }
+
+ public String getComponentPath() {
+ return componentPath;
+ }
+
+ public BatchIssueDto setComponentPath(String componentPath) {
+ this.componentPath = componentPath;
+ return this;
+ }
+
+ public String getKey() {
+ return kee;
+ }
+
+ public BatchIssueDto setKey(String key) {
+ this.kee = key;
+ return this;
+ }
+
+ public Integer getLine() {
+ return line;
+ }
+
+ public BatchIssueDto setLine(Integer line) {
+ this.line = line;
+ return this;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public BatchIssueDto setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public String getResolution() {
+ return resolution;
+ }
+
+ public BatchIssueDto setResolution(String resolution) {
+ this.resolution = resolution;
+ return this;
+ }
+
+ public String getRuleKey() {
+ return ruleKey;
+ }
+
+ public BatchIssueDto setRuleKey(String ruleKey) {
+ this.ruleKey = ruleKey;
+ return this;
+ }
+
+ public String getRuleRepo() {
+ return ruleRepo;
+ }
+
+ public BatchIssueDto setRuleRepo(String ruleRepo) {
+ this.ruleRepo = ruleRepo;
+ return this;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public BatchIssueDto setStatus(String status) {
+ this.status = status;
+ return this;
+ }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/permission/GlobalPermissions.java b/sonar-core/src/main/java/org/sonar/core/permission/GlobalPermissions.java
index d8a8d5a5f95..b9893ad1c50 100644
--- a/sonar-core/src/main/java/org/sonar/core/permission/GlobalPermissions.java
+++ b/sonar-core/src/main/java/org/sonar/core/permission/GlobalPermissions.java
@@ -34,13 +34,13 @@ public final class GlobalPermissions {
public static final String QUALITY_PROFILE_ADMIN = "profileadmin";
public static final String DASHBOARD_SHARING = "shareDashboard";
public static final String SCAN_EXECUTION = "scan";
- public static final String DRY_RUN_EXECUTION = "dryRunScan";
+ public static final String PREVIEW_EXECUTION = "dryRunScan";
public static final String PROVISIONING = "provisioning";
/**
* All the global permissions values, ordered from {@link #SYSTEM_ADMIN} to {@link #PROVISIONING}.
*/
- public static final List<String> ALL = ImmutableList.of(SYSTEM_ADMIN, QUALITY_PROFILE_ADMIN, DASHBOARD_SHARING, SCAN_EXECUTION, DRY_RUN_EXECUTION, PROVISIONING);
+ public static final List<String> ALL = ImmutableList.of(SYSTEM_ADMIN, QUALITY_PROFILE_ADMIN, DASHBOARD_SHARING, SCAN_EXECUTION, PREVIEW_EXECUTION, PROVISIONING);
private GlobalPermissions() {
// only static methods
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
index 62e559e59fc..75f75cf9089 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -25,11 +25,7 @@ import com.google.common.io.Closeables;
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.mapping.Environment;
-import org.apache.ibatis.session.Configuration;
-import org.apache.ibatis.session.ExecutorType;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.apache.ibatis.session.SqlSessionFactoryBuilder;
+import org.apache.ibatis.session.*;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.ibatis.type.JdbcType;
import org.slf4j.LoggerFactory;
@@ -47,14 +43,7 @@ import org.sonar.core.component.db.SnapshotMapper;
import org.sonar.core.computation.db.AnalysisReportDto;
import org.sonar.core.computation.db.AnalysisReportMapper;
import org.sonar.core.config.Logback;
-import org.sonar.core.dashboard.ActiveDashboardDto;
-import org.sonar.core.dashboard.ActiveDashboardMapper;
-import org.sonar.core.dashboard.DashboardDto;
-import org.sonar.core.dashboard.DashboardMapper;
-import org.sonar.core.dashboard.WidgetDto;
-import org.sonar.core.dashboard.WidgetMapper;
-import org.sonar.core.dashboard.WidgetPropertyDto;
-import org.sonar.core.dashboard.WidgetPropertyMapper;
+import org.sonar.core.dashboard.*;
import org.sonar.core.dependency.DependencyDto;
import org.sonar.core.dependency.DependencyMapper;
import org.sonar.core.dependency.ResourceSnapshotDto;
@@ -63,32 +52,11 @@ import org.sonar.core.duplication.DuplicationMapper;
import org.sonar.core.duplication.DuplicationUnitDto;
import org.sonar.core.graph.jdbc.GraphDto;
import org.sonar.core.graph.jdbc.GraphDtoMapper;
-import org.sonar.core.issue.db.ActionPlanDto;
-import org.sonar.core.issue.db.ActionPlanMapper;
-import org.sonar.core.issue.db.ActionPlanStatsDto;
-import org.sonar.core.issue.db.ActionPlanStatsMapper;
-import org.sonar.core.issue.db.IssueChangeDto;
-import org.sonar.core.issue.db.IssueChangeMapper;
-import org.sonar.core.issue.db.IssueDto;
-import org.sonar.core.issue.db.IssueFilterDto;
-import org.sonar.core.issue.db.IssueFilterFavouriteDto;
-import org.sonar.core.issue.db.IssueFilterFavouriteMapper;
-import org.sonar.core.issue.db.IssueFilterMapper;
-import org.sonar.core.issue.db.IssueMapper;
-import org.sonar.core.measure.db.MeasureDto;
-import org.sonar.core.measure.db.MeasureFilterDto;
-import org.sonar.core.measure.db.MeasureFilterMapper;
-import org.sonar.core.measure.db.MeasureMapper;
-import org.sonar.core.measure.db.MetricDto;
-import org.sonar.core.measure.db.MetricMapper;
+import org.sonar.core.issue.db.*;
+import org.sonar.core.measure.db.*;
import org.sonar.core.notification.db.NotificationQueueDto;
import org.sonar.core.notification.db.NotificationQueueMapper;
-import org.sonar.core.permission.GroupWithPermissionDto;
-import org.sonar.core.permission.PermissionTemplateDto;
-import org.sonar.core.permission.PermissionTemplateGroupDto;
-import org.sonar.core.permission.PermissionTemplateMapper;
-import org.sonar.core.permission.PermissionTemplateUserDto;
-import org.sonar.core.permission.UserWithPermissionDto;
+import org.sonar.core.permission.*;
import org.sonar.core.persistence.dialect.Dialect;
import org.sonar.core.persistence.migration.v44.Migration44Mapper;
import org.sonar.core.persistence.migration.v45.Migration45Mapper;
@@ -98,22 +66,9 @@ import org.sonar.core.properties.PropertyDto;
import org.sonar.core.purge.IdUuidPair;
import org.sonar.core.purge.PurgeMapper;
import org.sonar.core.purge.PurgeableSnapshotDto;
-import org.sonar.core.qualitygate.db.ProjectQgateAssociationDto;
-import org.sonar.core.qualitygate.db.ProjectQgateAssociationMapper;
-import org.sonar.core.qualitygate.db.QualityGateConditionDto;
-import org.sonar.core.qualitygate.db.QualityGateConditionMapper;
-import org.sonar.core.qualitygate.db.QualityGateDto;
-import org.sonar.core.qualitygate.db.QualityGateMapper;
-import org.sonar.core.qualityprofile.db.ActiveRuleDto;
-import org.sonar.core.qualityprofile.db.ActiveRuleMapper;
-import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
-import org.sonar.core.qualityprofile.db.QualityProfileDto;
-import org.sonar.core.qualityprofile.db.QualityProfileMapper;
-import org.sonar.core.resource.ResourceDto;
-import org.sonar.core.resource.ResourceIndexDto;
-import org.sonar.core.resource.ResourceIndexerMapper;
-import org.sonar.core.resource.ResourceKeyUpdaterMapper;
-import org.sonar.core.resource.ResourceMapper;
+import org.sonar.core.qualitygate.db.*;
+import org.sonar.core.qualityprofile.db.*;
+import org.sonar.core.resource.*;
import org.sonar.core.rule.RuleDto;
import org.sonar.core.rule.RuleMapper;
import org.sonar.core.rule.RuleParamDto;
@@ -123,19 +78,7 @@ import org.sonar.core.technicaldebt.db.CharacteristicMapper;
import org.sonar.core.technicaldebt.db.RequirementMigrationDto;
import org.sonar.core.template.LoadedTemplateDto;
import org.sonar.core.template.LoadedTemplateMapper;
-import org.sonar.core.user.AuthorDto;
-import org.sonar.core.user.AuthorMapper;
-import org.sonar.core.user.GroupDto;
-import org.sonar.core.user.GroupMapper;
-import org.sonar.core.user.GroupMembershipDto;
-import org.sonar.core.user.GroupMembershipMapper;
-import org.sonar.core.user.GroupRoleDto;
-import org.sonar.core.user.RoleMapper;
-import org.sonar.core.user.UserDto;
-import org.sonar.core.user.UserGroupDto;
-import org.sonar.core.user.UserGroupMapper;
-import org.sonar.core.user.UserMapper;
-import org.sonar.core.user.UserRoleDto;
+import org.sonar.core.user.*;
import java.io.InputStream;
@@ -218,6 +161,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
loadAlias(conf, "Measure", MeasureDto.class);
loadAlias(conf, "Metric", MetricDto.class);
loadAlias(conf, "Issue", IssueDto.class);
+ loadAlias(conf, "BatchIssue", BatchIssueDto.class);
loadAlias(conf, "IssueChange", IssueChangeDto.class);
loadAlias(conf, "IssueFilter", IssueFilterDto.class);
loadAlias(conf, "IssueFilterFavourite", IssueFilterFavouriteDto.class);
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
index 7453e1afa1a..2156d2c6b74 100644
--- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
@@ -176,13 +176,53 @@
p.kee as componentKey,
root.kee as projectKey
from issues i
- inner join (select p.id,p.kee from projects p where (p.root_id=#{id} and p.qualifier &lt;&gt; 'BRC') or
- (p.id=#{id})) p on p.id=i.component_id
+ inner join (select p.id,p.kee from projects p where (p.root_id=#{id} and p.qualifier &lt;&gt; 'BRC') or (p.id=#{id})) p on p.id=i.component_id
inner join rules r on r.id=i.rule_id
left outer join projects root on root.id=i.root_component_id
where i.status &lt;&gt; 'CLOSED'
</select>
+ <select id="selectNonClosedIssuesByModuleUuid" parameterType="String" resultType="BatchIssue">
+ SELECT
+ i.kee as kee,
+ i.message as message,
+ i.line as line,
+ i.status as status,
+ i.resolution as resolution,
+ i.checksum as checksum,
+ r.plugin_rule_key as ruleKey,
+ r.plugin_name as ruleRepo,
+ component.path as componentPath,
+ i.assignee as assigneeLogin,
+ u.name as assigneeName
+ FROM issues i
+ INNER JOIN (SELECT p.id,p.path FROM projects p WHERE p.module_uuid=#{uuid} OR p.uuid=#{uuid}) component ON component.id=i.component_id
+ INNER JOIN rules r ON r.id=i.rule_id
+ LEFT OUTER JOIN users u ON u.login=i.assignee
+ WHERE i.status &lt;&gt; 'CLOSED'
+ </select>
+
+ <select id="selectNonClosedIssuesByProjectUuid" parameterType="String" resultType="BatchIssue">
+ SELECT
+ i.kee as kee,
+ i.message as message,
+ i.line as line,
+ i.status as status,
+ i.resolution as resolution,
+ i.checksum as checksum,
+ r.plugin_rule_key as ruleKey,
+ r.plugin_name as ruleRepo,
+ component.path as componentPath,
+ i.assignee as assigneeLogin,
+ u.name as assigneeName
+ FROM issues i
+ INNER JOIN projects component on component.id=i.component_id
+ INNER JOIN projects project on project.uuid=component.project_uuid AND project.uuid=#{uuid}
+ INNER JOIN rules r ON r.id=i.rule_id
+ LEFT OUTER JOIN users u ON u.login=i.assignee
+ WHERE i.status &lt;&gt; 'CLOSED'
+ </select>
+
<select id="selectByKeys" parameterType="map" resultType="Issue">
select
<include refid="issueColumns"/>