aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-03 17:27:29 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-03 17:28:54 +0100
commitf24695d415017ec78e7bc28676715fa136c0efa6 (patch)
tree8ef9ce30943b2d9281ab8d7ecd9a087e36db2ab7 /sonar-server/src/main
parent9590f2207c793dad39f14f8c516479fce8549958 (diff)
downloadsonarqube-f24695d415017ec78e7bc28676715fa136c0efa6.tar.gz
sonarqube-f24695d415017ec78e7bc28676715fa136c0efa6.zip
Update groupId to subProjectId and rootIt to projectId in issues WS
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java44
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb6
3 files changed, 33 insertions, 21 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java b/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java
index eb3263fcbe8..8d94f69b518 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java
@@ -206,7 +206,7 @@ public class DefaultIssueFinder implements IssueFinder {
return findComponents(newHashSet(Iterables.transform(components, new Function<Component, Long>() {
@Override
public Long apply(Component input) {
- return ((ComponentDto) input).groupId();
+ return ((ComponentDto) input).subProjectId();
}
})));
}
@@ -215,7 +215,7 @@ public class DefaultIssueFinder implements IssueFinder {
return findComponents(newHashSet(Iterables.transform(components, new Function<Component, Long>() {
@Override
public Long apply(Component input) {
- return ((ComponentDto) input).rootId();
+ return ((ComponentDto) input).projectId();
}
})));
}
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java b/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
index dcf82862e1d..f1971a4ad48 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
@@ -96,11 +96,6 @@ public class IssueShowWsHandler implements RequestHandler {
}
private void writeIssue(IssueQueryResult result, DefaultIssue issue, JsonWriter json) {
- // component, module and project can be null if they were removed
- ComponentDto component = (ComponentDto) result.component(issue);
- ComponentDto module = (ComponentDto) getModule(result, component);
- ComponentDto project = (ComponentDto) geProject(result, component);
-
String actionPlanKey = issue.actionPlanKey();
ActionPlan actionPlan = result.actionPlan(issue);
Long technicalDebt = issue.debt();
@@ -109,13 +104,6 @@ public class IssueShowWsHandler implements RequestHandler {
json
.prop("key", issue.key())
- .prop("component", issue.componentKey())
- .prop("componentLongName", component != null ? component.longName() : null)
- .prop("componentQualifier", component != null ? component.qualifier() : null)
- // Do not display module long name if module and project are the same
- .prop("moduleLongName", module != null && project != null && !module.getId().equals(project.getId()) ? module.longName() : null)
- .prop("project", issue.projectKey())
- .prop("projectLongName", project != null ? project.longName() : null)
.prop("rule", issue.ruleKey().toString())
.prop("ruleName", result.rule(issue).getName())
.prop("line", issue.line())
@@ -135,21 +123,45 @@ public class IssueShowWsHandler implements RequestHandler {
.prop("closeDate", closeDate != null ? DateUtils.formatDateTime(closeDate) : null)
.prop("fCloseDate", formatDate(issue.closeDate()));
+ addComponents(result, issue, json);
addUserWithLabel(result, issue.assignee(), "assignee", json);
addUserWithLabel(result, issue.reporter(), "reporter", json);
addCharacteristics(result, issue, json);
}
+ private void addComponents(IssueQueryResult result, DefaultIssue issue, JsonWriter json) {
+ // component, module and project can be null if they were removed
+ ComponentDto component = (ComponentDto) result.component(issue);
+ ComponentDto subProject = (ComponentDto) getSubProject(result, component);
+ ComponentDto project = (ComponentDto) geProject(result, component);
+
+ String projectName = project != null ? project.longName() != null ? project.longName() : project.name() : null;
+ // Do not display sub project long name if sub project and project are the same
+ String subProjectName = subProject != null && project != null && !subProject.getId().equals(project.getId()) ?
+ subProject.longName() != null ? subProject.longName() : subProject.name() :
+ null;
+
+ json
+ .prop("component", issue.componentKey())
+ .prop("componentLongName", component != null ? component.longName() : null)
+ .prop("componentQualifier", component != null ? component.qualifier() : null)
+ .prop("project", issue.projectKey())
+ .prop("projectName", projectName)
+ // Do not display sub project long name if sub project and project are the same
+ .prop("subProjectName", subProjectName)
+ ;
+ }
+
/**
* Can be null on project or on removed component
*/
@CheckForNull
- private Component getModule(IssueQueryResult result, @Nullable final ComponentDto component){
+ private Component getSubProject(IssueQueryResult result, @Nullable final ComponentDto component) {
if (component != null) {
return Iterables.find(result.components(), new Predicate<Component>() {
@Override
public boolean apply(Component input) {
- Long groupId = component.groupId();
+ Long groupId = component.subProjectId();
return groupId != null && groupId.equals(((ComponentDto) input).getId());
}
}, null);
@@ -161,12 +173,12 @@ public class IssueShowWsHandler implements RequestHandler {
* Can be null on removed component
*/
@CheckForNull
- private Component geProject(IssueQueryResult result, @Nullable final ComponentDto component){
+ private Component geProject(IssueQueryResult result, @Nullable final ComponentDto component) {
if (component != null) {
return Iterables.find(result.components(), new Predicate<Component>() {
@Override
public boolean apply(Component input) {
- return component.rootId().equals(((ComponentDto) input).getId());
+ return component.projectId().equals(((ComponentDto) input).getId());
}
}, null);
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb
index 2eae8b6625b..5e658dc7ba8 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb
@@ -344,9 +344,9 @@ class Api::IssuesController < Api::ApiController
hash[:name] = component.name if component.name
hash[:longName] = component.longName if component.longName
hash[:path] = component.path if component.path
- hash[:groupId] = component.groupId if component.groupId
- # On a root project, groupId is null but rootId is equal to itself, which make no sense.
- hash[:rootId] = component.rootId if component.groupId && component.rootId
+ # On a root project, subProjectId is null but projectId is equal to itself, which make no sense.
+ hash[:projectId] = component.projectId if component.subProjectId && component.projectId
+ hash[:subProjectId] = component.subProjectId if component.subProjectId
hash
end