--- /dev/null
+/*
+ * 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.server.computation.db;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import org.sonar.api.utils.System2;
+import org.sonar.core.computation.db.AnalysisReportDto;
+import org.sonar.core.computation.db.AnalysisReportMapper;
+import org.sonar.core.issue.db.IssueDto;
+import org.sonar.core.issue.db.IssueMapper;
+import org.sonar.core.persistence.DaoComponent;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.server.db.BaseDao;
+import org.sonar.server.search.IndexDefinition;
+
+import java.util.Date;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class AnalysisReportDao extends BaseDao<AnalysisReportMapper, AnalysisReportDto, String> implements DaoComponent {
+
+ public AnalysisReportDao() {
+ this(System2.INSTANCE);
+ }
+
+ @VisibleForTesting
+ public AnalysisReportDao(System2 system) {
+ super(AnalysisReportMapper.class, system);
+ }
+
+ @Override
+ protected AnalysisReportDto doGetNullableByKey(DbSession session, String key) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected AnalysisReportDto doUpdate(DbSession session, AnalysisReportDto issue) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected AnalysisReportDto doInsert(DbSession session, AnalysisReportDto report) {
+ checkNotNull(report.getProjectKey(), "Cannot insert Report with no project key!");
+ mapper(session).insert(report);
+ return report;
+ }
+
+ @Override
+ protected String getSynchronizationStatementName() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected Map getSynchronizationParams(Date date, Map<String, String> params) {
+ throw new UnsupportedOperationException();
+ }
+}
--- /dev/null
+/*
+ * 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.server.computation.db;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+<!--
+ ~ 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.
+ -->
+
+<dataset>
+ <issues
+ id="100"
+ project_key="sonarqube"
+ created_at="2013-05-21"
+ updated_at="2013-05-22"
+ version="123456789"
+ />
+</dataset>
--- /dev/null
+#
+# 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.
+#
+#
+# SonarQube 5.0
+# SONAR-5624
+#
+class CreateAnalysisReports < ActiveRecord::Migration
+
+ def self.up
+ create_table :analysis_reports do |t|
+ t.column :project_key, :string, :limit => 400, :null => false
+ t.column :report_status, :string, :limit => 20, :null => false
+ t.column :report_data, :text, :null => true
+ t.column :created_at, :datetime, :null => false
+ t.column :updated_at, :datetime, :null => false
+ end
+ add_index :analysis_reports, ['project_key'], :name => 'analysis_reports_project_key', :unique => true
+ end
+
+end
+
--- /dev/null
+/*
+ * 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.computation.db;
+
+import org.sonar.core.persistence.Dto;
+
+import javax.annotation.Nullable;
+
+/**
+ * since 5.0
+ */
+public class AnalysisReportDto extends Dto<String> {
+
+ private Long id;
+ private String projectKey;
+ private String status;
+ private String data;
+
+ public String getProjectKey() {
+ return projectKey;
+ }
+
+ public AnalysisReportDto setProjectKey(String projectKey) {
+ this.projectKey = projectKey;
+ return this;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public AnalysisReportDto setStatus(String status) {
+ this.status = status;
+ return this;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public AnalysisReportDto setData(@Nullable String data) {
+ this.data = data;
+ return this;
+ }
+
+
+ @Override
+ public String getKey() {
+ return getProjectKey();
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public AnalysisReportDto setId(Long id) {
+ this.id = id;
+ return this;
+ }
+}
--- /dev/null
+/*
+ * 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.computation.db;
+
+/**
+ * since 5.0
+ */
+public interface AnalysisReportMapper {
+ void insert(AnalysisReportDto report);
+}
--- /dev/null
+/*
+ * 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.computation.db;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+/*
+ * 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.computation;
+
+import javax.annotation.ParametersAreNonnullByDefault;
\ No newline at end of file
*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 701;
+ public static final int LAST_VERSION = 702;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
"active_rules",
"active_rule_parameters",
"activities",
+ "analysis_reports",
"authors",
"characteristics",
"dashboards",
import org.sonar.core.component.SnapshotDto;
import org.sonar.core.component.db.ComponentMapper;
import org.sonar.core.component.db.SnapshotMapper;
+import org.sonar.core.computation.db.AnalysisReportDto;
+import org.sonar.core.computation.db.AnalysisReportMapper;
import org.sonar.core.config.Logback;
import org.sonar.core.dashboard.*;
import org.sonar.core.dependency.DependencyDto;
loadAlias(conf, "ActiveRuleParam", ActiveRuleParamDto.class);
loadAlias(conf, "RequirementMigration", RequirementMigrationDto.class);
loadAlias(conf, "Activity", ActivityDto.class);
+ loadAlias(conf, "AnalysisReport", AnalysisReportDto.class);
// AuthorizationMapper has to be loaded before IssueMapper because this last one used it
loadMapper(conf, "org.sonar.core.user.AuthorizationMapper");
NotificationQueueMapper.class, CharacteristicMapper.class,
GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class,
MeasureMapper.class, MetricMapper.class, QualityGateMapper.class, QualityGateConditionMapper.class, ComponentMapper.class, SnapshotMapper.class,
- ProjectQgateAssociationMapper.class
+ ProjectQgateAssociationMapper.class,
+ AnalysisReportMapper.class
};
loadMappers(conf, mappers);
configureLogback(mappers);
--- /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.computation.db.AnalysisReportMapper">
+
+ <insert id="insert" parameterType="AnalysisReport" useGeneratedKeys="true" >
+ insert into activities
+ (project_key, report_status, report_data, created_at, updated_at)
+ values (#{projectKey}, #{status}, #{data}, #{createdAt}, #{updatedAt})
+ </insert>
+</mapper>
+
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('584');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('700');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('701');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('702');
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', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
"DATA_FIELD" CLOB(2147483647)
);
+CREATE TABLE "ANALYSIS_REPORTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PROJECT_KEY" VARCHAR(400) NOT NULL,
+ "REPORT_STATUS" VARCHAR(20) NOT NULL,
+ "REPORT_DATA" CLOB(2147483647),
+ "CREATED_AT" TIMESTAMP NOT NULL,
+ "UPDATED_AT" TIMESTAMP
+);
+
-- ----------------------------------------------
-- DDL Statements for indexes
-- ----------------------------------------------
CREATE INDEX "SNAPSHOT_DATA_RESOURCE_IDS" ON "SNAPSHOT_DATA" ("RESOURCE_ID");
-CREATE UNIQUE INDEX "QPROFILE_UNIQUE_KEY" ON "RULES_PROFILES" ("KEE");
+CREATE UNIQUE INDEX "PROFILE_UNIQUE_KEY" ON "RULES_PROFILES" ("KEE");
+
+CREATE UNIQUE INDEX "ANALYSIS_REPORTS_PROJECT_KEY" ON "ANALYSIS_REPORTS" ("PROJECT_KEY");