aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-19 19:22:32 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-20 11:02:53 +0200
commitaac5b47155d3f4de3191951f8c2edb6eb415d385 (patch)
tree0fc82826729d31ac9c6a605818d60e0fc9c6b6e3 /sonar-core
parentb691c1bfbbc7f0d398e46d7377bae26c5ad1725f (diff)
downloadsonarqube-aac5b47155d3f4de3191951f8c2edb6eb415d385.tar.gz
sonarqube-aac5b47155d3f4de3191951f8c2edb6eb415d385.zip
SONAR-6418 delete table GRAPHS
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/SnapshotPerspectives.java88
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/SubGraph.java82
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java53
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDto.java103
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDtoMapper.java30
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/jdbc/package-info.java23
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java22
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java20
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java4
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/graph/jdbc/GraphDtoMapper.xml29
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql1
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl15
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml14
-rw-r--r--sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java118
-rw-r--r--sonar-core/src/test/java/org/sonar/core/graph/jdbc/GraphDaoTest.java79
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/graph/jdbc/GraphDaoTest/shared.xml9
18 files changed, 17 insertions, 681 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/component/SnapshotPerspectives.java b/sonar-core/src/main/java/org/sonar/core/component/SnapshotPerspectives.java
deleted file mode 100644
index 03a1e2c30f7..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/component/SnapshotPerspectives.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import com.google.common.collect.Maps;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.sonar.api.ServerSide;
-import org.sonar.api.component.Perspective;
-import org.sonar.core.graph.graphson.GraphsonReader;
-import org.sonar.core.graph.jdbc.GraphDao;
-import org.sonar.core.graph.jdbc.GraphDto;
-
-import javax.annotation.CheckForNull;
-
-import java.io.StringReader;
-import java.util.Map;
-
-@ServerSide
-public class SnapshotPerspectives {
-
- private final GraphDao dao;
- private final Map<Class<?>, GraphPerspectiveLoader<?>> loaders = Maps.newHashMap();
-
- public SnapshotPerspectives(GraphDao dao, GraphPerspectiveLoader[] loaders) {
- this.dao = dao;
- for (GraphPerspectiveLoader loader : loaders) {
- // TODO check duplications
- this.loaders.put(loader.getPerspectiveClass(), loader);
- }
- }
-
- @CheckForNull
- public <T extends Perspective> T as(Class<T> perspectiveClass, String componentKey) {
- GraphPerspectiveLoader<T> builder = (GraphPerspectiveLoader<T>) loaders.get(perspectiveClass);
- if (builder == null) {
- throw new IllegalStateException();
- }
- GraphDto graphDto = dao.selectByComponent(builder.getPerspectiveKey(), componentKey);
- return doAs(builder, graphDto);
- }
-
- @CheckForNull
- public <T extends Perspective> T as(Class<T> perspectiveClass, long snapshotId) {
- GraphPerspectiveLoader<T> builder = (GraphPerspectiveLoader<T>) loaders.get(perspectiveClass);
- if (builder == null) {
- throw new IllegalStateException();
- }
- GraphDto graphDto = dao.selectBySnapshot(builder.getPerspectiveKey(), snapshotId);
- return doAs(builder, graphDto);
- }
-
- private <T extends Perspective> T doAs(GraphPerspectiveLoader<T> loader, GraphDto graphDto) {
- T result = null;
- if (graphDto != null) {
- SnapshotGraph graph = read(graphDto.getData(), graphDto.getRootVertexId());
- result = loader.load(graph.wrap(graph.getComponentRoot(), ComponentVertex.class));
- }
- return result;
- }
-
- private SnapshotGraph read(String data, String rootVertexId) {
- StringReader input = new StringReader(data);
- try {
- TinkerGraph graph = new TinkerGraph();
- new GraphsonReader().read(input, graph);
- return new SnapshotGraph(graph, rootVertexId);
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/SubGraph.java b/sonar-core/src/main/java/org/sonar/core/graph/SubGraph.java
deleted file mode 100644
index 34bb34bb2e1..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/graph/SubGraph.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.google.common.collect.Sets;
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import com.tinkerpop.blueprints.util.ElementHelper;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Not thread-safe
- */
-public class SubGraph {
-
- private TinkerGraph sub = new TinkerGraph();
- private Set<Edge> edgesToCopy = Sets.newHashSet();
-
- private SubGraph() {
- }
-
- public static Graph extract(Vertex start, EdgePath edgePath) {
- return new SubGraph().process(start, edgePath);
- }
-
- private Graph process(Vertex start, EdgePath edgePath) {
- copy(start);
- browse(start, 0, edgePath.getElements());
- for (Edge edge : edgesToCopy) {
- Vertex from = edge.getVertex(Direction.OUT);
- Vertex to = edge.getVertex(Direction.IN);
- Edge copyEdge = sub.addEdge(edge.getId(), sub.getVertex(from.getId()), sub.getVertex(to.getId()), edge.getLabel());
- ElementHelper.copyProperties(edge, copyEdge);
- }
- return sub;
- }
-
- private void browse(Vertex from, int cursor, List<Object> edgePath) {
- if (from != null && cursor < edgePath.size()) {
- Direction edgeDirection = (Direction) edgePath.get(cursor);
- String edgeLabel = (String) edgePath.get(cursor + 1);
- Iterable<Edge> edges = from.getEdges(edgeDirection, edgeLabel);
- for (Edge edge : edges) {
- edgesToCopy.add(edge);
- Vertex tail = edge.getVertex(edgeDirection.opposite());
- copy(tail);
- browse(tail, cursor + 2, edgePath);
- }
- }
- }
-
- private Vertex copy(Vertex v) {
- Vertex to = sub.getVertex(v.getId());
- if (to == null) {
- to = sub.addVertex(v.getId());
- ElementHelper.copyProperties(v, to);
- }
- return to;
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java
deleted file mode 100644
index 40b1740c9f3..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.graph.jdbc;
-
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.MyBatis;
-
-public class GraphDao {
- private final MyBatis mybatis;
-
- public GraphDao(MyBatis mybatis) {
- this.mybatis = mybatis;
- }
-
- public GraphDto selectBySnapshot(String perspectiveKey, long snapshotId) {
- DbSession session = mybatis.openSession(true);
- try {
- GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
- return mapper.selectBySnapshot(perspectiveKey, snapshotId);
-
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public GraphDto selectByComponent(String perspectiveKey, String componentKey) {
- DbSession session = mybatis.openSession(true);
- try {
- GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
- return mapper.selectByComponent(perspectiveKey, componentKey);
-
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDto.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDto.java
deleted file mode 100644
index 7e36c786ede..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDto.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.graph.jdbc;
-
-public class GraphDto {
- private long id;
- private long resourceId;
- private long snapshotId;
- private String format;
- private String perspective;
- private int version;
- private String rootVertexId;
- private String data;
-
- public long getId() {
- return id;
- }
-
- public GraphDto setId(long id) {
- this.id = id;
- return this;
- }
-
- public long getResourceId() {
- return resourceId;
- }
-
- public GraphDto setResourceId(long resourceId) {
- this.resourceId = resourceId;
- return this;
- }
-
- public long getSnapshotId() {
- return snapshotId;
- }
-
- public GraphDto setSnapshotId(long snapshotId) {
- this.snapshotId = snapshotId;
- return this;
- }
-
- public String getPerspective() {
- return perspective;
- }
-
- public GraphDto setPerspective(String perspective) {
- this.perspective = perspective;
- return this;
- }
-
- public String getFormat() {
- return format;
- }
-
- public GraphDto setFormat(String format) {
- this.format = format;
- return this;
- }
-
- public int getVersion() {
- return version;
- }
-
- public GraphDto setVersion(int version) {
- this.version = version;
- return this;
- }
-
- public String getRootVertexId() {
- return rootVertexId;
- }
-
- public GraphDto setRootVertexId(String rootVertexId) {
- this.rootVertexId = rootVertexId;
- return this;
- }
-
- public String getData() {
- return data;
- }
-
- public GraphDto setData(String data) {
- this.data = data;
- return this;
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDtoMapper.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDtoMapper.java
deleted file mode 100644
index 23bb6437f66..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDtoMapper.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.graph.jdbc;
-
-import org.apache.ibatis.annotations.Param;
-
-public interface GraphDtoMapper {
- void insert(GraphDto graph);
-
- GraphDto selectBySnapshot(@Param("perspective") String perspectiveKey, @Param("sid") long snapshotId);
-
- GraphDto selectByComponent(@Param("perspective") String perspectiveKey, @Param("key") String componentKey);
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/package-info.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/package-info.java
deleted file mode 100644
index 148e4e943c0..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.core.graph.jdbc;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java
index 052120c913b..935bc122b29 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java
@@ -22,11 +22,18 @@ package org.sonar.core.persistence;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
import org.sonar.core.dashboard.ActiveDashboardDao;
import org.sonar.core.dashboard.DashboardDao;
import org.sonar.core.duplication.DuplicationDao;
-import org.sonar.core.graph.jdbc.GraphDao;
-import org.sonar.core.issue.db.*;
+import org.sonar.core.issue.db.ActionPlanDao;
+import org.sonar.core.issue.db.ActionPlanStatsDao;
+import org.sonar.core.issue.db.IssueChangeDao;
+import org.sonar.core.issue.db.IssueDao;
+import org.sonar.core.issue.db.IssueFilterDao;
+import org.sonar.core.issue.db.IssueFilterFavouriteDao;
import org.sonar.core.notification.db.NotificationQueueDao;
import org.sonar.core.permission.PermissionDao;
import org.sonar.core.permission.PermissionTemplateDao;
@@ -40,11 +47,11 @@ import org.sonar.core.resource.ResourceKeyUpdaterDao;
import org.sonar.core.rule.RuleDao;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
import org.sonar.core.template.LoadedTemplateDao;
-import org.sonar.core.user.*;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import org.sonar.core.user.AuthorDao;
+import org.sonar.core.user.AuthorizationDao;
+import org.sonar.core.user.GroupMembershipDao;
+import org.sonar.core.user.RoleDao;
+import org.sonar.core.user.UserDao;
import static com.google.common.collect.Lists.newArrayList;
@@ -67,7 +74,6 @@ public final class DaoUtils {
AuthorizationDao.class,
DashboardDao.class,
DuplicationDao.class,
- GraphDao.class,
GroupMembershipDao.class,
IssueDao.class,
IssueChangeDao.class,
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
index 334245aa769..17fa55201f7 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
@@ -35,7 +35,7 @@ import java.util.List;
@ServerSide
public class DatabaseVersion {
- public static final int LAST_VERSION = 914;
+ public static final int LAST_VERSION = 915;
/**
* List of all the tables.n
@@ -56,7 +56,6 @@ public class DatabaseVersion {
"duplications_index",
"events",
"file_sources",
- "graphs",
"groups",
"groups_users",
"group_roles",
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
index 35d49d5a0d4..7480d60edbe 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -66,8 +66,6 @@ import org.sonar.core.duplication.DuplicationMapper;
import org.sonar.core.duplication.DuplicationUnitDto;
import org.sonar.core.event.EventDto;
import org.sonar.core.event.db.EventMapper;
-import org.sonar.core.graph.jdbc.GraphDto;
-import org.sonar.core.graph.jdbc.GraphDtoMapper;
import org.sonar.core.issue.db.ActionPlanDto;
import org.sonar.core.issue.db.ActionPlanMapper;
import org.sonar.core.issue.db.ActionPlanStatsDto;
@@ -197,7 +195,6 @@ public class MyBatis {
loadAlias(conf, "ComponentLink", ComponentLinkDto.class);
loadAlias(conf, "Dashboard", DashboardDto.class);
loadAlias(conf, "DuplicationUnit", DuplicationUnitDto.class);
- loadAlias(conf, "Graph", GraphDto.class);
loadAlias(conf, "Group", GroupDto.class);
loadAlias(conf, "GroupRole", GroupRoleDto.class);
loadAlias(conf, "GroupMembership", GroupMembershipDto.class);
@@ -253,7 +250,7 @@ public class MyBatis {
loadMapper(conf, "org.sonar.core.permission.PermissionMapper");
Class<?>[] mappers = {ActivityMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class,
- FileDependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class,
+ FileDependencyMapper.class, DuplicationMapper.class,
IssueMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class,
IsAliveMapper.class,
LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class,
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
index 438f416177c..b8c9c49edd5 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
@@ -132,13 +132,6 @@ class PurgeCommands {
session.commit();
profiler.stop();
- profiler.start("deleteResourceGraphs (graphs)");
- for (List<Long> partResourceIds : componentIdPartitions) {
- purgeMapper.deleteResourceGraphs(partResourceIds);
- }
- session.commit();
- profiler.stop();
-
profiler.start("deleteResource (projects)");
for (List<Long> partResourceIds : componentIdPartitions) {
purgeMapper.deleteResource(partResourceIds);
@@ -181,8 +174,6 @@ class PurgeCommands {
session.commit();
profiler.stop();
- deleteSnapshotGraphs(snapshotIdsPartition);
-
profiler.start("deleteSnapshot (snapshots)");
for (List<Long> partSnapshotIds : snapshotIdsPartition) {
purgeMapper.deleteSnapshot(partSnapshotIds);
@@ -204,8 +195,6 @@ class PurgeCommands {
deleteSnapshotDuplications(snapshotIdsPartition);
- deleteSnapshotGraphs(snapshotIdsPartition);
-
profiler.start("deleteSnapshotWastedMeasures (project_measures)");
List<Long> metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData();
for (List<Long> partSnapshotIds : snapshotIdsPartition) {
@@ -222,15 +211,6 @@ class PurgeCommands {
profiler.stop();
}
- private void deleteSnapshotGraphs(final List<List<Long>> snapshotIdsPartition) {
- profiler.start("deleteSnapshotGraphs (graphs)");
- for (List<Long> partSnapshotIds : snapshotIdsPartition) {
- purgeMapper.deleteSnapshotGraphs(partSnapshotIds);
- }
- session.commit();
- profiler.stop();
- }
-
private void deleteSnapshotDuplications(final List<List<Long>> snapshotIdsPartition) {
profiler.start("deleteSnapshotDuplications (duplications_index)");
for (List<Long> partSnapshotIds : snapshotIdsPartition) {
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
index 2dda5e52837..3c5e7131463 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
@@ -49,8 +49,6 @@ public interface PurgeMapper {
void deleteSnapshotMeasures(@Param("snapshotIds") List<Long> snapshotIds);
- void deleteSnapshotGraphs(@Param("snapshotIds") List<Long> snapshotIds);
-
List<Long> selectMetricIdsWithoutHistoricalData();
void deleteSnapshotWastedMeasures(@Param("snapshotIds") List<Long> snapshotIds, @Param("mids") List<Long> metricIds);
@@ -83,8 +81,6 @@ public interface PurgeMapper {
void deleteResourceActionPlans(@Param("resourceIds") List<Long> resourceIds);
- void deleteResourceGraphs(@Param("resourceIds") List<Long> resourceIds);
-
void deleteAuthors(@Param("resourceIds") List<Long> resourceIds);
List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithEvents(long resourceId);
diff --git a/sonar-core/src/main/resources/org/sonar/core/graph/jdbc/GraphDtoMapper.xml b/sonar-core/src/main/resources/org/sonar/core/graph/jdbc/GraphDtoMapper.xml
deleted file mode 100644
index 704090274f5..00000000000
--- a/sonar-core/src/main/resources/org/sonar/core/graph/jdbc/GraphDtoMapper.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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.graph.jdbc.GraphDtoMapper">
-
- <select id="selectBySnapshot" parameterType="map" resultType="Graph" >
- SELECT id, resource_id as resourceId, snapshot_id as snapshotId, format, version, perspective, root_vertex_id as rootVertexId, data
- FROM graphs
- WHERE snapshot_id = #{sid} AND perspective = #{perspective}
- </select>
-
- <select id="selectByComponent" parameterType="map" resultType="Graph" >
- SELECT g.id, g.resource_id as resourceId, g.snapshot_id as snapshotId, g.format, g.version, g.perspective, g.root_vertex_id as rootVertexId, g.data
- FROM graphs g, snapshots s
- WHERE g.perspective = #{perspective} AND g.snapshot_id=s.id AND s.islast=${_true} and s.project_id=(
- select id from projects where enabled=${_true} and kee=#{key} and person_id is null and copy_resource_id is null
- )
- </select>
-
- <insert id="insert" parameterType="Graph" useGeneratedKeys="false" >
- insert into graphs
- (resource_id, snapshot_id, format, version, perspective, root_vertex_id, data, created_at, updated_at)
- values (
- #{resourceId}, #{snapshotId}, #{format}, #{version}, #{perspective}, #{rootVertexId},
- #{data}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
- </insert>
-
-</mapper>
-
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
index 92a6baa5be6..a985006dde7 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
@@ -338,6 +338,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('911');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('912');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('913');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('914');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('915');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
index ff932e6131e..f1b4b16c6c4 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
@@ -437,19 +437,6 @@ CREATE TABLE "MEASURE_FILTER_FAVOURITES" (
"CREATED_AT" TIMESTAMP
);
-CREATE TABLE "GRAPHS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "RESOURCE_ID" INTEGER NOT NULL,
- "SNAPSHOT_ID" INTEGER NOT NULL,
- "FORMAT" VARCHAR(20),
- "PERSPECTIVE" VARCHAR(30),
- "VERSION" VARCHAR(20),
- "ROOT_VERTEX_ID" VARCHAR(30),
- "DATA" CLOB(2147483647),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
CREATE TABLE "ISSUES" (
"ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"KEE" VARCHAR(50) UNIQUE NOT NULL,
@@ -665,8 +652,6 @@ CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME");
CREATE INDEX "MEASURE_FILTER_FAVS_USERID" ON "MEASURE_FILTER_FAVOURITES" ("USER_ID");
-CREATE UNIQUE INDEX "GRAPHS_PERSPECTIVES" ON "GRAPHS" ("SNAPSHOT_ID", "PERSPECTIVE");
-
CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE");
CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID");
diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
index 6ba17308f50..454cebefd32 100644
--- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
@@ -103,13 +103,6 @@
</foreach>
</delete>
- <delete id="deleteSnapshotGraphs" parameterType="map">
- delete from graphs where snapshot_id in
- <foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
- #{snapshotId}
- </foreach>
- </delete>
-
<delete id="deleteSnapshotDependenciesFromSnapshotId" parameterType="map">
delete from dependencies where from_snapshot_id in
<foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
@@ -252,13 +245,6 @@
</foreach>
</delete>
- <delete id="deleteResourceGraphs" parameterType="map">
- delete from graphs where resource_id in
- <foreach collection="resourceIds" open="(" close=")" item="resourceId" separator=",">
- #{resourceId}
- </foreach>
- </delete>
-
<delete id="deleteAuthors" parameterType="map">
delete from authors where person_id in
<foreach collection="resourceIds" open="(" close=")" item="resourceId" separator=",">
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java b/sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java
deleted file mode 100644
index 9323c28e6d2..00000000000
--- a/sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import com.tinkerpop.blueprints.util.GraphHelper;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SubGraphTest {
-
- @Test
- public void should_extract_graph() {
- TinkerGraph graph = new TinkerGraph();
- Vertex a = GraphHelper.addVertex(graph, null, "key", "a");
- Vertex b = GraphHelper.addVertex(graph, null, "key", "b");
- Vertex c = GraphHelper.addVertex(graph, null, "key", "c");
- Vertex d = GraphHelper.addVertex(graph, null, "key", "d");
- Vertex e = GraphHelper.addVertex(graph, null, "key", "e");
-
- Edge ab = GraphHelper.addEdge(graph, null, a, b, "uses");
- Edge bc = GraphHelper.addEdge(graph, null, b, c, "inherits");
- Edge ad = GraphHelper.addEdge(graph, null, a, d, "uses");
- Edge de = GraphHelper.addEdge(graph, null, d, e, "implements");
-
- // a -uses-> b -inherits -> c
- // a -uses-> d -implements-> e
-
- Graph sub = SubGraph.extract(a, EdgePath.create(Direction.OUT, "uses", Direction.OUT, "implements"));
-
- // a -uses-> b
- // a -uses-> d -implements-> e
- assertThat(sub.getVertices()).hasSize(4);
- assertThat(sub.getVertex(a.getId()).getProperty("key")).isEqualTo("a");
- assertThat(sub.getVertex(b.getId()).getProperty("key")).isEqualTo("b");
- assertThat(sub.getVertex(c.getId())).isNull();
- assertThat(sub.getVertex(d.getId()).getProperty("key")).isEqualTo("d");
- assertThat(sub.getVertex(e.getId()).getProperty("key")).isEqualTo("e");
-
- assertThat(sub.getEdges()).hasSize(3);
- assertThat(sub.getEdge(ab.getId()).getLabel()).isEqualTo("uses");
- assertThat(sub.getEdge(ab.getId()).toString()).isEqualTo(ab.toString());
- assertThat(sub.getEdge(bc.getId())).isNull();
- assertThat(sub.getEdge(ad.getId()).toString()).isEqualTo(ad.toString());
- assertThat(sub.getEdge(de.getId()).toString()).isEqualTo(de.toString());
- }
-
- @Test
- public void should_extract_cyclic_graph() {
- TinkerGraph graph = new TinkerGraph();
- Vertex a = GraphHelper.addVertex(graph, null, "key", "a");
- Vertex b = GraphHelper.addVertex(graph, null, "key", "b");
- Vertex c = GraphHelper.addVertex(graph, null, "key", "c");
- Vertex d = GraphHelper.addVertex(graph, null, "key", "d");
- Vertex e = GraphHelper.addVertex(graph, null, "key", "e");
-
- Edge ab = GraphHelper.addEdge(graph, null, a, b, "uses");
- Edge bc = GraphHelper.addEdge(graph, null, b, c, "implements");
- Edge ce = GraphHelper.addEdge(graph, null, c, e, "package");
- Edge ad = GraphHelper.addEdge(graph, null, a, d, "uses");
- Edge dc = GraphHelper.addEdge(graph, null, d, c, "implements");
-
- // a -uses-> b -implements-> c -package-> e
- // a -uses-> d -implements-> c -package-> e
-
- Graph sub = SubGraph.extract(a, EdgePath.create(Direction.OUT, "uses", Direction.OUT, "implements", Direction.OUT, "package"));
-
- // same graph
- assertThat(sub.getVertices()).hasSize(5);
- assertThat(sub.getEdges()).hasSize(5);
- }
-
- @Test
- public void should_check_edge_direction() {
- TinkerGraph graph = new TinkerGraph();
- Vertex a = GraphHelper.addVertex(graph, null, "key", "a");
- Vertex b = GraphHelper.addVertex(graph, null, "key", "b");
- Vertex c = GraphHelper.addVertex(graph, null, "key", "c");
- Vertex d = GraphHelper.addVertex(graph, null, "key", "d");
- Vertex e = GraphHelper.addVertex(graph, null, "key", "e");
-
- Edge ab = GraphHelper.addEdge(graph, null, a, b, "uses");
- Edge bc = GraphHelper.addEdge(graph, null, b, c, "inherits");
- Edge ad = GraphHelper.addEdge(graph, null, a, d, "uses");
- Edge de = GraphHelper.addEdge(graph, null, d, e, "implements");
-
- // a -uses-> b -inherits -> c
- // a -uses-> d -implements-> e
-
- Graph sub = SubGraph.extract(a, EdgePath.create(Direction.IN /* instead of out */, "uses", Direction.OUT, "implements"));
-
- assertThat(sub.getVertices()).hasSize(1);
- assertThat(sub.getVertex(a.getId())).isNotNull();
- assertThat(sub.getEdges()).isEmpty();
- }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/jdbc/GraphDaoTest.java b/sonar-core/src/test/java/org/sonar/core/graph/jdbc/GraphDaoTest.java
deleted file mode 100644
index 4b84ef03c87..00000000000
--- a/sonar-core/src/test/java/org/sonar/core/graph/jdbc/GraphDaoTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.graph.jdbc;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.core.persistence.AbstractDaoTestCase;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GraphDaoTest extends AbstractDaoTestCase {
- private GraphDao dao;
-
- @Before
- public void createDao() {
- dao = new GraphDao(getMyBatis());
- setupData("shared");
- }
-
- @Test
- public void select_graph_by_snapshot() {
- GraphDto testPlan = dao.selectBySnapshot("testplan", 11L);
-
- assertThat(testPlan.getId()).isEqualTo(101L);
- assertThat(testPlan.getResourceId()).isEqualTo(1L);
- assertThat(testPlan.getSnapshotId()).isEqualTo(11L);
- assertThat(testPlan.getFormat()).isEqualTo("graphson");
- assertThat(testPlan.getVersion()).isEqualTo(1);
- assertThat(testPlan.getPerspective()).isEqualTo("testplan");
- assertThat(testPlan.getRootVertexId()).isEqualTo("3456");
- assertThat(testPlan.getData()).isEqualTo("{testplan of snapshot 123}");
- }
-
- @Test
- public void select_by_snapshot_and_missing_perspective() {
- assertThat(dao.selectBySnapshot("duplicable", 123L)).isNull();
- }
-
- @Test
- public void select_by_missing_snapshot() {
- assertThat(dao.selectBySnapshot("duplicable", 7777L)).isNull();
- }
-
- @Test
- public void select_by_component() {
- GraphDto testPlan = dao.selectByComponent("testplan", "org.apache.struts:struts");
-
- assertThat(testPlan.getId()).isEqualTo(101L);
- assertThat(testPlan.getResourceId()).isEqualTo(1L);
- assertThat(testPlan.getSnapshotId()).isEqualTo(11L);
- assertThat(testPlan.getFormat()).isEqualTo("graphson");
- assertThat(testPlan.getVersion()).isEqualTo(1);
- assertThat(testPlan.getPerspective()).isEqualTo("testplan");
- assertThat(testPlan.getRootVertexId()).isEqualTo("3456");
- assertThat(testPlan.getData()).isEqualTo("{testplan of snapshot 123}");
- }
-
- @Test
- public void select_by_missing_component() {
- assertThat(dao.selectByComponent("testplan", "org.other:unknown")).isNull();
- }
-}
diff --git a/sonar-core/src/test/resources/org/sonar/core/graph/jdbc/GraphDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/graph/jdbc/GraphDaoTest/shared.xml
deleted file mode 100644
index 9345cfcf402..00000000000
--- a/sonar-core/src/test/resources/org/sonar/core/graph/jdbc/GraphDaoTest/shared.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
- <projects id="1" kee="org.apache.struts:struts" enabled="[true]"/>
-
- <snapshots id="10" project_id="1" islast="[false]" />
- <snapshots id="11" project_id="1" islast="[true]" />
-
- <graphs id="100" resource_id="1" snapshot_id="11" format="graphson" version="1" perspective="testable" root_vertex_id="7890" data="{testable of snapshot 123}"/>
- <graphs id="101" resource_id="1" snapshot_id="11" format="graphson" version="1" perspective="testplan" root_vertex_id="3456" data="{testplan of snapshot 123}"/>
-</dataset> \ No newline at end of file