]> source.dussan.org Git - sonarqube.git/commitdiff
Load dependency versions
authorDavid Gageot <david@gageot.net>
Mon, 25 Jun 2012 15:12:38 +0000 (17:12 +0200)
committerDavid Gageot <david@gageot.net>
Mon, 25 Jun 2012 15:12:38 +0000 (17:12 +0200)
sonar-core/src/main/java/org/sonar/core/dependency/DependencyDto.java
sonar-core/src/main/resources/org/sonar/core/dependency/DependencyMapper.xml
sonar-core/src/test/java/org/sonar/core/dependency/DependencyMapperTest.java
sonar-core/src/test/resources/org/sonar/core/dependency/DependencyMapperTest/fixture.xml

index 0a61133942bf332a32c54dd77bcc914edfe40b4b..00599da2344ff6eb3063e5c4ff56c075f9e9c3e4 100644 (file)
@@ -22,7 +22,9 @@ package org.sonar.core.dependency;
 public final class DependencyDto {
   private Long id;
   private Long fromResourceId;
+  private String fromVersion;
   private Long toResourceId;
+  private String toVersion;
   private String usage;
   private Integer weight;
 
@@ -44,6 +46,15 @@ public final class DependencyDto {
     return this;
   }
 
+  public String getFromVersion() {
+    return fromVersion;
+  }
+
+  public DependencyDto setFromVersion(String fromVersion) {
+    this.fromVersion = fromVersion;
+    return this;
+  }
+
   public Long getToResourceId() {
     return toResourceId;
   }
@@ -53,6 +64,15 @@ public final class DependencyDto {
     return this;
   }
 
+  public String getToVersion() {
+    return toVersion;
+  }
+
+  public DependencyDto setToVersion(String toVersion) {
+    this.toVersion = toVersion;
+    return this;
+  }
+
   public String getUsage() {
     return usage;
   }
index 53ab9f500cf0b6f90fdde0af7f7820ce77d41b10..8f864c313fb13df6580d1e6fe01022a3fa4c52b4 100644 (file)
@@ -4,8 +4,10 @@
 <mapper namespace="org.sonar.core.dependency.DependencyMapper">
 
   <select id="selectAll" resultType="dependency">
-    select id, from_resource_id as fromResourceId, to_resource_id as toResourceId, dep_usage as usage, dep_weight as weight from dependencies
+    SELECT dependencies.id as id, from_resource_id as fromResourceId, sLeft.version as fromVersion, to_resource_id as toResourceId, sRight.version as toVersion, dep_usage as usage, dep_weight as weight
+    FROM dependencies
+    JOIN snapshots as sLeft ON dependencies.from_snapshot_id = sLeft.id
+    JOIN snapshots as sRight ON dependencies.to_snapshot_id = sRight.id
   </select>
 
 </mapper>
-
index 11699e567dbce749f3a3ae366844e4610a3427dc..4dd1307dcb9904c0ae17a5a76feb94a9b3218def 100644 (file)
@@ -43,13 +43,13 @@ public class DependencyMapperTest extends DaoTestCase {
       DependencyDto dep = dependencies.get(0);
       assertThat(dep.getUsage()).isEqualTo("compile");
       assertThat(dep.getFromResourceId()).isEqualTo(100L);
+      assertThat(dep.getFromVersion()).isEqualTo("1.0");
       assertThat(dep.getToResourceId()).isEqualTo(101L);
+      assertThat(dep.getToVersion()).isEqualTo("3.0");
       assertThat(dep.getId()).isEqualTo(1L);
     } finally {
       MyBatis.closeQuietly(session);
     }
   }
-
-
 }
 
index 7e8a8e9f677dcca2e235391b329a3384799e2fbd..b6cc818679b49d3acfb00cabde1e0dc5859fb7f3 100644 (file)
@@ -1,4 +1,8 @@
 <dataset>
   <dependencies id="1" from_resource_id="100" to_resource_id="101" from_snapshot_id="1000" to_snapshot_id="1001" dep_usage="compile" dep_weight="1" />
   <dependencies id="2" from_resource_id="200" to_resource_id="201" from_snapshot_id="2000" to_snapshot_id="2001" dep_usage="provided" dep_weight="1" />
+  <snapshots id="1000" version="1.0" project_id="1" />
+  <snapshots id="2000" version="2.0" project_id="1" />
+  <snapshots id="1001" version="3.0" project_id="1" />
+  <snapshots id="2001" version="4.0" project_id="1" />
 </dataset>
\ No newline at end of file