<packaging>pom</packaging>
<version>3.2-SNAPSHOT</version>
<name>Sonar</name>
- <url>http://www.sonarsource.org</url>
+ <url>http://www.sonarsource.org/</url>
<description>Open source platform for continuous inspection of code quality</description>
<modules>
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.dependency;
+
+public final class DependencyDto {
+ private Long id;
+ private Long fromResourceId;
+ private Long toResourceId;
+ private String usage;
+ private Integer weight;
+
+ public Long getId() {
+ return id;
+ }
+
+ public DependencyDto setId(Long id) {
+ this.id = id;
+ return this;
+ }
+
+ public Long getFromResourceId() {
+ return fromResourceId;
+ }
+
+ public DependencyDto setFromResourceId(Long fromResourceId) {
+ this.fromResourceId = fromResourceId;
+ return this;
+ }
+
+ public Long getToResourceId() {
+ return toResourceId;
+ }
+
+ public DependencyDto setToResourceId(Long toResourceId) {
+ this.toResourceId = toResourceId;
+ return this;
+ }
+
+ public String getUsage() {
+ return usage;
+ }
+
+ public DependencyDto setUsage(String usage) {
+ this.usage = usage;
+ return this;
+ }
+
+ public Integer getWeight() {
+ return weight;
+ }
+
+ public DependencyDto setWeight(Integer weight) {
+ this.weight = weight;
+ return this;
+ }
+}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.dependency;
+
+import java.util.List;
+
+public interface DependencyMapper {
+ List<DependencyDto> selectAll();
+}
import org.sonar.core.dashboard.WidgetMapper;
import org.sonar.core.dashboard.WidgetPropertyDto;
import org.sonar.core.dashboard.WidgetPropertyMapper;
+import org.sonar.core.dependency.DependencyDto;
+import org.sonar.core.dependency.DependencyMapper;
import org.sonar.core.duplication.DuplicationMapper;
import org.sonar.core.duplication.DuplicationUnitDto;
import org.sonar.core.filter.CriterionDto;
loadAlias(conf, "Criterion", CriterionDto.class);
loadAlias(conf, "FilterColumn", FilterColumnDto.class);
loadAlias(conf, "Dashboard", DashboardDto.class);
+ loadAlias(conf, "Dependency", DependencyDto.class);
loadAlias(conf, "DuplicationUnit", DuplicationUnitDto.class);
loadAlias(conf, "LoadedTemplate", LoadedTemplateDto.class);
loadAlias(conf, "Property", PropertyDto.class);
loadMapper(conf, CriterionMapper.class);
loadMapper(conf, FilterColumnMapper.class);
loadMapper(conf, DashboardMapper.class);
+ loadMapper(conf, DependencyMapper.class);
loadMapper(conf, DuplicationMapper.class);
loadMapper(conf, LoadedTemplateMapper.class);
loadMapper(conf, PropertiesMapper.class);
public final class ResourceDto {
private Long id;
+ private String key;
private String name;
private String longName;
private Integer rootId;
return this;
}
+ public String getKey() {
+ return key;
+ }
+
+ public ResourceDto setKey(String s) {
+ this.key = s;
+ return this;
+ }
+
public Integer getRootId() {
return rootId;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<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>
+
+</mapper>
+
<resultMap id="resourceResultMap" type="Resource">
<id property="id" column="id"/>
+ <result property="key" column="kee"/>
<result property="name" column="name"/>
<result property="longName" column="long_name"/>
<result property="rootId" column="root_id"/>
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.dependency;
+
+import org.apache.ibatis.session.SqlSession;
+import org.junit.Test;
+import org.sonar.core.persistence.DaoTestCase;
+import org.sonar.core.persistence.MyBatis;
+
+import java.util.List;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DependencyMapperTest extends DaoTestCase {
+
+ @Test
+ public void testDescendantProjects_do_not_include_self() {
+ setupData("fixture");
+
+ SqlSession session = getMyBatis().openSession();
+ try {
+ List<DependencyDto> dependencies = session.getMapper(DependencyMapper.class).selectAll();
+
+ assertThat(dependencies).hasSize(2);
+
+ DependencyDto dep = dependencies.get(0);
+ assertThat(dep.getUsage()).isEqualTo("compile");
+ assertThat(dep.getFromResourceId()).isEqualTo(100L);
+ assertThat(dep.getToResourceId()).isEqualTo(101L);
+ assertThat(dep.getId()).isEqualTo(1L);
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
+
+}
+
--- /dev/null
+<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" />
+</dataset>
\ No newline at end of file