diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-12-02 18:12:56 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-12-05 16:52:54 +0100 |
commit | 37494f41d3d07042fedb9bab93fb44587866db05 (patch) | |
tree | 88a381ec0813aa9fd8343fc4bc21b7d20d11aeb2 /server | |
parent | 19882feb2c947ed14cc90190a000d6fa0d3b39d0 (diff) | |
download | sonarqube-37494f41d3d07042fedb9bab93fb44587866db05.tar.gz sonarqube-37494f41d3d07042fedb9bab93fb44587866db05.zip |
SONAR-8464 Populate UUID column of table EVENTS
Diffstat (limited to 'server')
3 files changed, 38 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStep.java index 644263f9304..481bf7f0baf 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStep.java @@ -23,6 +23,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.StreamSupport; import org.sonar.api.utils.System2; +import org.sonar.core.util.UuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; @@ -44,14 +45,16 @@ public class PersistEventsStep implements ComputationStep { private final AnalysisMetadataHolder analysisMetadataHolder; private final TreeRootHolder treeRootHolder; private final EventRepository eventRepository; + private final UuidFactory uuidFactory; public PersistEventsStep(DbClient dbClient, System2 system2, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder, - EventRepository eventRepository) { + EventRepository eventRepository, UuidFactory uuidFactory) { this.dbClient = dbClient; this.system2 = system2; this.treeRootHolder = treeRootHolder; this.analysisMetadataHolder = analysisMetadataHolder; this.eventRepository = eventRepository; + this.uuidFactory = uuidFactory; } @Override @@ -120,6 +123,7 @@ public class PersistEventsStep implements ComputationStep { private EventDto newBaseEvent(Component component, Long analysisDate) { return new EventDto() + .setUuid(uuidFactory.create()) .setAnalysisUuid(analysisMetadataHolder.getUuid()) .setComponentUuid(component.getUuid()) .setCreatedAt(system2.now()) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStepTest.java index a3811228f2f..1fcc4a94234 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistEventsStepTest.java @@ -26,6 +26,8 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryImpl; import org.sonar.db.DbTester; import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule; import org.sonar.server.computation.task.projectanalysis.component.Component; @@ -75,6 +77,7 @@ public class PersistEventsStepTest extends BaseStepTest { private Date someDate = new Date(150000000L); private EventRepository eventRepository = mock(EventRepository.class); + private UuidFactory uuidFactory = UuidFactoryImpl.INSTANCE; private PersistEventsStep underTest; @@ -82,7 +85,7 @@ public class PersistEventsStepTest extends BaseStepTest { public void setup() { when(system2.now()).thenReturn(1225630680000L); analysisMetadataHolder.setAnalysisDate(someDate.getTime()).setUuid(ANALYSIS_UUID); - underTest = new PersistEventsStep(dbTester.getDbClient(), system2, treeRootHolder, analysisMetadataHolder, eventRepository); + underTest = new PersistEventsStep(dbTester.getDbClient(), system2, treeRootHolder, analysisMetadataHolder, eventRepository, uuidFactory); when(eventRepository.getEvents(any(Component.class))).thenReturn(Collections.<Event>emptyList()); } diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1501_populate_uuid_of_events.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1501_populate_uuid_of_events.rb new file mode 100644 index 00000000000..b155e253d79 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1501_populate_uuid_of_events.rb @@ -0,0 +1,29 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2016 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 6.3 +# +class PopulateUuidOfEvents < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.db.version.v63.PopulateUuidColumnOfEvents') + end +end |