From: Julien HENRY Date: Fri, 21 Feb 2014 18:32:40 +0000 (+0100) Subject: SONAR-926 Add module key information on components for IntelliJ X-Git-Tag: 4.2~63 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ebf7643e81af44e8fd06ac0d7a8cf1175946dba7;p=sonarqube.git SONAR-926 Add module key information on components for IntelliJ --- 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 1c6bcf86732..fc9cdf829b3 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 @@ -26,6 +26,7 @@ public class ComponentDto implements Component { private Long id; private String kee; private String path; + private String moduleKey; private String name; private String longName; private String qualifier; @@ -59,6 +60,16 @@ public class ComponentDto implements Component { return this; } + @Override + public String moduleKey() { + return moduleKey; + } + + public ComponentDto setModuleKey(String moduleKey) { + this.moduleKey = moduleKey; + return this; + } + @Override public String name() { return name; diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentVertex.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentVertex.java index 8297c081968..89403dce4ac 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/ComponentVertex.java +++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentVertex.java @@ -32,6 +32,10 @@ public class ComponentVertex extends BeanVertex implements Component { return (String) getProperty("path"); } + public String moduleKey() { + return (String) getProperty("moduleKey"); + } + public String name() { return (String) getProperty("name"); } @@ -47,6 +51,7 @@ public class ComponentVertex extends BeanVertex implements Component { void copyFrom(Component component) { setProperty("key", component.key()); setProperty("path", component.path()); + setProperty("moduleKey", component.moduleKey()); setProperty("name", component.name()); setProperty("longName", component.longName()); setProperty("qualifier", component.qualifier()); diff --git a/sonar-core/src/main/java/org/sonar/core/component/ResourceComponent.java b/sonar-core/src/main/java/org/sonar/core/component/ResourceComponent.java index 7a1ea538773..d50eceddbff 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/ResourceComponent.java +++ b/sonar-core/src/main/java/org/sonar/core/component/ResourceComponent.java @@ -20,6 +20,7 @@ package org.sonar.core.component; import com.google.common.base.Strings; +import org.apache.commons.lang.StringUtils; import org.sonar.api.component.Component; import org.sonar.api.database.model.Snapshot; import org.sonar.api.resources.Resource; @@ -29,6 +30,7 @@ import javax.annotation.Nullable; public class ResourceComponent implements Component { private String key; private String path; + private String moduleKey; private String name; private String longName; private String qualifier; @@ -39,6 +41,8 @@ public class ResourceComponent implements Component { public ResourceComponent(Resource resource, @Nullable Snapshot snapshot) { this.key = resource.getEffectiveKey(); this.path = resource.getPath(); + // Kind of a hack as it depends on format of resource effective key + this.moduleKey = StringUtils.removeEnd(resource.getEffectiveKey(), ":" + resource.getKey()); if (Strings.isNullOrEmpty(key)) { throw new IllegalArgumentException("Missing component key"); } @@ -65,6 +69,11 @@ public class ResourceComponent implements Component { return path; } + @Override + public String moduleKey() { + return moduleKey; + } + public String name() { return name; } 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 34f0cac01be..1f46ddfa250 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 @@ -307,6 +307,7 @@ public class ResourceDao { return new ComponentDto() .setId(resourceDto.getId()) .setKey(resourceDto.getKey()) + .setModuleKey(resourceDto.getModuleKey()) .setPath(resourceDto.getPath()) .setLongName(resourceDto.getLongName()) .setName(resourceDto.getName()) diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java index e7c062b86f6..c821fee9018 100644 --- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java +++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java @@ -29,6 +29,7 @@ public class ResourceDto { private String name; private String longName; private Long rootId; + private String moduleKey; private String path; private String scope; private String qualifier; @@ -93,6 +94,15 @@ public class ResourceDto { return this; } + public String getModuleKey() { + return moduleKey; + } + + public ResourceDto setModuleKey(String s) { + this.moduleKey = s; + return this; + } + public String getLongName() { return longName; } diff --git a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml index a9ba7ad6b0e..2855efc4dda 100644 --- a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml @@ -44,6 +44,7 @@ + @@ -58,8 +59,8 @@