private Long id;
private String kee;
+ private String path;
private String name;
private String longName;
private String qualifier;
return this;
}
+ @Override
+ public String path() {
+ return path;
+ }
+
+ public ComponentDto setPath(String path) {
+ this.path = path;
+ return this;
+ }
+
@Override
public String name() {
return name;
return longName;
}
-
public ComponentDto setLongName(String longName) {
this.longName = longName;
return this;
return (String) getProperty("key");
}
+ public String path() {
+ return (String) getProperty("path");
+ }
+
public String name() {
return (String) getProperty("name");
}
void copyFrom(Component component) {
setProperty("key", component.key());
+ setProperty("path", component.path());
setProperty("name", component.name());
setProperty("longName", component.longName());
setProperty("qualifier", component.qualifier());
public class ResourceComponent implements Component {
private String key;
+ private String path;
private String name;
private String longName;
private String qualifier;
public ResourceComponent(Resource resource, @Nullable Snapshot snapshot) {
this.key = resource.getEffectiveKey();
+ this.path = resource.getPath();
if (Strings.isNullOrEmpty(key)) {
throw new IllegalArgumentException("Missing component key");
}
return key;
}
+ @Override
+ public String path() {
+ return path;
+ }
+
public String name() {
return name;
}
return longName;
}
-
public String qualifier() {
return qualifier;
}
return new ComponentDto()
.setId(resourceDto.getId())
.setKey(resourceDto.getKey())
+ .setPath(resourceDto.getPath())
.setLongName(resourceDto.getLongName())
.setName(resourceDto.getName())
.setQualifier(resourceDto.getQualifier());
<sql id="resourceColumns">
p.id,
p.kee as key,
+ p.path as path,
p.deprecated_kee as deprecatedKey,
p.name as name,
p.long_name as longName,
public void should_copy() {
BeanGraph beanGraph = new BeanGraph(new TinkerGraph());
ComponentVertex vertex = beanGraph.createVertex(ComponentVertex.class);
- Component file = MockSourceFile.createMain("myproject:org/Foo.java").setName("Foo.java").setQualifier(Qualifiers.FILE);
+ Component file = MockSourceFile.createMain("myproject:org/Foo.java").setName("Foo.java").setQualifier(Qualifiers.FILE)
+ .setPath("src/org/Foo.java");
vertex.copyFrom(file);
assertThat(vertex.key()).isEqualTo("myproject:org/Foo.java");
assertThat(vertex.name()).isEqualTo("Foo.java");
assertThat(vertex.qualifier()).isEqualTo(Qualifiers.FILE);
+ assertThat(vertex.path()).isEqualTo("src/org/Foo.java");
}
@Test
ResourceDto resource = dao.getResource(1L);
+ assertThat(resource.getPath()).isNull();
assertThat(resource.getName()).isEqualTo("Struts");
assertThat(resource.getLongName()).isEqualTo("Apache Struts");
assertThat(resource.getScope()).isEqualTo("PRJ");
setupData("fixture");
assertThat(dao.findByKey("org.struts:struts")).isNotNull();
- assertThat(dao.findByKey("org.struts:struts:org.struts.RequestContext")).isNotNull();
+ Component<?> component = dao.findByKey("org.struts:struts:org.struts.RequestContext");
+ assertThat(component).isNotNull();
+ assertThat(component.path()).isEqualTo("src/main/java/RequestContext.java");
assertThat(dao.findByKey("unknown")).isNull();
}
<!-- root project -->
<projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
description="the description" long_name="Apache Struts"
- enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+ enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]"/>
<snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
status="P" islast="[true]" purge_status="[null]"
period1_mode="[null]" period1_param="[null]" period1_date="[null]"
version="[null]" path="1.2."/>
<!-- file -->
- <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.struts:struts:org.struts.RequestContext"
+ <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.RequestContext"
name="RequestContext" root_id="1"
description="[null]"
- enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+ enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/main/java/RequestContext.java"/>
<snapshots id="4" project_id="4" parent_snapshot_id="3" root_project_id="1" root_snapshot_id="1"
status="P" islast="[true]" purge_status="[null]"
public interface Component<C extends Component> {
String key();
+ /**
+ * @since 4.2
+ */
+ String path();
+
String name();
String longName();
public class MockSourceFile implements SourceFile {
private String key;
+ private String path;
private String qualifier;
private String language;
private String name;
return this;
}
+ @Override
+ public String path() {
+ return path;
+ }
+
+ public MockSourceFile setPath(String path) {
+ this.path = path;
+ return this;
+ }
+
public String qualifier() {
return qualifier;
}
return getName();
}
+ @Override
+ public String path() {
+ return getPath();
+ }
+
@Override
public String longName() {
return getLongName();
}
hash[:name] = component.name if component.name
hash[:longName] = component.longName if component.longName
+ hash[:path] = component.path if component.path
hash
end
import org.sonar.wsclient.unmarshallers.JsonUtils;
import javax.annotation.CheckForNull;
+
import java.util.Map;
public class Component {
return JsonUtils.getString(json, "key");
}
+ /**
+ * @since 4.2
+ */
+ @CheckForNull
+ public String path() {
+ return JsonUtils.getString(json, "path");
+ }
+
public String name() {
return JsonUtils.getString(json, "name");
}