]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7690 support EVENTS.ANALYSIS_UUID in code 1061/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 22 Jun 2016 09:16:09 +0000 (11:16 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 27 Jun 2016 09:06:51 +0000 (11:06 +0200)
55 files changed:
it/it-tests/src/test/resources/measureHistory/HistoryUiTest/history-timeline-widget/should-display-even-if-one-missing-metric.html
server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java
server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/timeline.html.erb
server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistEventsStepTest.java
server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_deleted.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistEventsStepTest/add_version_event-result.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistEventsStepTest/keep_one_event_by_version-result.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistEventsStepTest/keep_one_event_by_version.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistEventsStepTest/nothing_to_do_when_no_events_in_report.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistEventsStepTest/persist_report_events_with_component_children-result.xml
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
server/sonar-web/src/main/webapp/WEB-INF/app/models/event.rb
server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb
server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb
server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/_versions.html.erb
server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb
sonar-db/src/main/java/org/sonar/db/MyBatis.java
sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java
sonar-db/src/main/java/org/sonar/db/event/EventDto.java
sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java
sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java
sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java
sonar-db/src/main/java/org/sonar/db/purge/PurgeableAnalysisDto.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/purge/PurgeableSnapshotDto.java [deleted file]
sonar-db/src/main/java/org/sonar/db/purge/period/DefaultPeriodCleaner.java
sonar-db/src/main/java/org/sonar/db/purge/period/DeleteAllFilter.java
sonar-db/src/main/java/org/sonar/db/purge/period/Filter.java
sonar-db/src/main/java/org/sonar/db/purge/period/Interval.java
sonar-db/src/main/java/org/sonar/db/purge/period/KeepOneFilter.java
sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
sonar-db/src/main/resources/org/sonar/db/event/EventMapper.xml
sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
sonar-db/src/test/java/org/sonar/db/event/EventDaoTest.java
sonar-db/src/test/java/org/sonar/db/event/EventDtoTest.java
sonar-db/src/test/java/org/sonar/db/purge/DbCleanerTestUtils.java
sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
sonar-db/src/test/java/org/sonar/db/purge/PurgeableAnalysisDtoTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/purge/PurgeableSnapshotDtoTest.java [deleted file]
sonar-db/src/test/java/org/sonar/db/purge/period/DefaultPeriodCleanerTest.java
sonar-db/src/test/java/org/sonar/db/purge/period/DeleteAllFilterTest.java
sonar-db/src/test/java/org/sonar/db/purge/period/IntervalTest.java
sonar-db/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java
sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/select_previous_version_snapshots.xml
sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/delete.xml
sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/insert-result.xml
sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/shared.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteResource.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldSelectPurgeableSnapshots.xml

index 44615acc4623aebf7efa37f59777a66c2b85c334..81030e5045595ecbb50efd47ed63dab1eab84eac 100644 (file)
 <thead>
 <tr><td rowspan="1" colspan="3">timeline</td></tr>
 </thead><tbody>
-       <tr>
+<tr>
        <td>open</td>
-        <td>/widget?id=timeline&amp;resource=sample&amp;metric1=complexity&amp;metric2=commits</td>
-        <td></td>
+       <td>/widget?id=timeline&amp;resource=sample&amp;metric1=complexity&amp;metric2=commits</td>
+       <td></td>
 </tr>
 <tr>
        <td>assertElementPresent</td>
index 0a952701b9dfb1f3ee7466b7d183fd5fd09dfc40..08eca3e5205b86d05ebb37d4d71b93be0b48a85f 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.server.computation.analysis.AnalysisMetadataHolder;
 import org.sonar.server.computation.component.Component;
 import org.sonar.server.computation.component.ComponentVisitor;
 import org.sonar.server.computation.component.CrawlerDepthLimit;
-import org.sonar.server.computation.component.DbIdsRepository;
 import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
 import org.sonar.server.computation.component.TreeRootHolder;
 import org.sonar.server.computation.component.TypeAwareVisitorAdapter;
@@ -45,16 +44,14 @@ public class PersistEventsStep implements ComputationStep {
   private final AnalysisMetadataHolder analysisMetadataHolder;
   private final TreeRootHolder treeRootHolder;
   private final EventRepository eventRepository;
-  private final DbIdsRepository dbIdsRepository;
 
   public PersistEventsStep(DbClient dbClient, System2 system2, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder,
-    EventRepository eventRepository, DbIdsRepository dbIdsRepository) {
+    EventRepository eventRepository) {
     this.dbClient = dbClient;
     this.system2 = system2;
     this.treeRootHolder = treeRootHolder;
     this.analysisMetadataHolder = analysisMetadataHolder;
     this.eventRepository = eventRepository;
-    this.dbIdsRepository = dbIdsRepository;
   }
 
   @Override
@@ -102,8 +99,8 @@ public class PersistEventsStep implements ComputationStep {
 
   private EventDto newBaseEvent(Component component, Long analysisDate) {
     return new EventDto()
+      .setAnalysisUuid(analysisMetadataHolder.getUuid())
       .setComponentUuid(component.getUuid())
-      .setSnapshotId(dbIdsRepository.getSnapshotId(component))
       .setCreatedAt(system2.now())
       .setDate(analysisDate);
   }
index f9755436f66e2b2977ca8fb0fbc22cdc041cec6d..e50edc58436db8b04c0296cd1ed93f0c93751e61 100644 (file)
            from_date = first_date if !from_date || from_date > first_date
          end
        end
-       Event.find(:all, :conditions => ["component_uuid=? AND event_date>=?", @resource.uuid, from_date.to_i*1000], :order => 'event_date').each() do |event|
+       Event.find(:all, :conditions => ["component_uuid=? AND event_date>=?", @resource.uuid, from_date.to_i*1000], :order => 'event_date', :include => 'snapshot').each() do |event|
          if events[event.event_date]
            events[event.event_date] << event
          else
        events.keys().sort.each() do |e_date|
          e_details = events[e_date]
          js_events += "{sid:"
-         js_events += e_details[0].snapshot_id.to_s
+         js_events += e_details[0].snapshot.id.to_s
          js_events += ",d:d("
          js_events += e_date.year.to_s
          js_events += ","
index 89cd11586d83241283454d9305122a3b164d49df..ce26f3c8075e273f6464e6fa09514d8432595fbc 100644 (file)
@@ -30,7 +30,6 @@ import org.sonar.db.DbTester;
 import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule;
 import org.sonar.server.computation.batch.TreeRootHolderRule;
 import org.sonar.server.computation.component.Component;
-import org.sonar.server.computation.component.DbIdsRepositoryImpl;
 import org.sonar.server.computation.component.ReportComponent;
 import org.sonar.server.computation.event.Event;
 import org.sonar.server.computation.event.EventRepository;
@@ -61,6 +60,7 @@ public class PersistEventsStepTest extends BaseStepTest {
             .build())
         .build())
     .build();
+  private static final String ANALYSIS_UUID = "uuid_1";
 
   System2 system2 = mock(System2.class);
 
@@ -73,16 +73,14 @@ public class PersistEventsStepTest extends BaseStepTest {
 
   private Date someDate = new Date(150000000L);
 
-  DbIdsRepositoryImpl dbIdsRepository = new DbIdsRepositoryImpl();
-
   EventRepository eventRepository = mock(EventRepository.class);
   PersistEventsStep step;
 
   @Before
   public void setup() {
     when(system2.now()).thenReturn(1225630680000L);
-    analysisMetadataHolder.setAnalysisDate(someDate.getTime());
-    step = new PersistEventsStep(dbTester.getDbClient(), system2, treeRootHolder, analysisMetadataHolder, eventRepository, dbIdsRepository);
+    analysisMetadataHolder.setAnalysisDate(someDate.getTime()).setUuid(ANALYSIS_UUID);
+    step = new PersistEventsStep(dbTester.getDbClient(), system2, treeRootHolder, analysisMetadataHolder, eventRepository);
     when(eventRepository.getEvents(any(Component.class))).thenReturn(Collections.<Event>emptyList());
   }
 
@@ -108,8 +106,6 @@ public class PersistEventsStepTest extends BaseStepTest {
 
     treeRootHolder.setRoot(ROOT);
 
-    dbIdsRepository.setSnapshotId(ROOT, 1000L);
-
     when(eventRepository.getEvents(ROOT)).thenReturn(ImmutableList.of(Event.createAlert("Red (was Orange)", null, "Open issues > 0")));
 
     treeRootHolder.setRoot(ROOT);
@@ -139,7 +135,6 @@ public class PersistEventsStepTest extends BaseStepTest {
           .build())
       .build();
     treeRootHolder.setRoot(project);
-    dbIdsRepository.setSnapshotId(ROOT, 1000L);
 
     step.execute();
 
@@ -167,7 +162,6 @@ public class PersistEventsStepTest extends BaseStepTest {
           .build())
       .build();
     treeRootHolder.setRoot(project);
-    dbIdsRepository.setSnapshotId(ROOT, 1001L);
 
     step.execute();
 
index b623941536535ae288219c79642a6cd34f9b80a4..73af5e041c080c2b3c5355793fe621e143bb52c0 100644 (file)
 <dataset>
 
-  <projects id="1" kee="ROOT_KEY" uuid="ABCD" root_uuid="ABCD"/>
+  <projects id="1"
+            kee="ROOT_KEY"
+            uuid="ABCD"
+            root_uuid="ABCD"/>
 
   <!-- 2008-11-11 -->
   <!-- Version 0.9 -->
   <snapshots id="1000"
              uuid="u1000"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1226379600000" build_date="1226379600000" version="0.9" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1226379600000"
+             build_date="1226379600000"
+             version="0.9"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- 2008-11-12 -->
   <!-- Version 1.0 -->
   <snapshots id="1001"
              uuid="u1001"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]" component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1226494680000" build_date="1226494680000" version="1.0" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1226494680000"
+             build_date="1226494680000"
+             version="1.0"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- 2008-11-20 -->
   <!-- version 1.1 -->
   <snapshots id="1002"
              uuid="u1002"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1227157200000" build_date="1227157200000" version="1.1" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1227157200000"
+             build_date="1227157200000"
+             version="1.1"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
 
-  <events id="1" name="0.9" component_uuid="ABCD" snapshot_id="1000" category="Version" event_date="1226379600000" created_at="1226379600000" description="" event_data="[null]"/>
+  <events id="1"
+          analysis_uuid="u1000"
+          component_uuid="ABCD"
+          name="0.9"
+          category="Version"
+          event_date="1226379600000"
+          created_at="1226379600000"
+          description=""
+          event_data="[null]"/>
   <!-- The "1.0" version was deleted from the history :  -->
   <!--<events id="2" name="1.0" component_uuid="ABCD" snapshot_id="1001" category="Version" event_date="1226494680000" created_at="1226494680000" description="" event_data="[null]"/>-->
-  <events id="3" name="1.1" component_uuid="ABCD" snapshot_id="1004" category="Version" event_date="1227934800000" created_at="1227934800000" description="" event_data="[null]"/>
+  <events id="3"
+          analysis_uuid="u1004"
+          component_uuid="ABCD"
+          name="1.1"
+          category="Version"
+          event_date="1227934800000"
+          created_at="1227934800000"
+          description=""
+          event_data="[null]"/>
 
 </dataset>
index 0484c25b2b76ec5248d787ca9a989ab2877d4e57..ceaa347646833f5130ec45d9f3a70d8e1e09b4a5 100644 (file)
 <dataset>
 
-  <projects id="1" kee="ROOT_KEY" name="project" uuid="ABCD" root_uuid="ABCD"/>
+  <projects id="1"
+            kee="ROOT_KEY"
+            name="project"
+            uuid="ABCD"
+            root_uuid="ABCD"/>
 
   <!-- 2008-11-11 -->
   <!-- Version 0.9 -->
   <snapshots id="1000"
              uuid="u1000"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1226379600000" build_date="1226379600000" version="0.9" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1226379600000"
+             build_date="1226379600000"
+             version="0.9"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- 2008-11-12 -->
   <!-- Version 1.0 -->
   <snapshots id="1001"
              uuid="u1001"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]" component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1226494680000" build_date="1226494680000" version="1.0" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1226494680000"
+             build_date="1226494680000"
+             version="1.0"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- 2008-11-20 -->
   <!-- First version 1.1 -->
   <snapshots id="1002"
              uuid="u1002"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1227157200000" build_date="1227157200000" version="1.1" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1227157200000"
+             build_date="1227157200000"
+             version="1.1"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- 2008-11-22 -->
   <snapshots id="1003"
              uuid="u1003"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1227358680000" build_date="1227358680000" version="1.1" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1227358680000"
+             build_date="1227358680000"
+             version="1.1"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- 2008-11-29 -->
   <!-- Last version 1.1 -->
   <snapshots id="1004"
              uuid="u1004"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]" component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1227934800000" build_date="1227934800000" version="1.1" path=""
-             status="P" islast="[true]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1227934800000"
+             build_date="1227934800000"
+             version="1.1"
+             path=""
+             status="P"
+             islast="[true]"
+             depth="0"/>
 
 
-  <events id="1" name="0.9" component_uuid="ABCD" snapshot_id="1000" category="Version" event_date="1226379600000" created_at="1226379600000" description="" event_data="[null]"/>
-  <events id="2" name="1.0" component_uuid="ABCD" snapshot_id="1001" category="Version" event_date="1226494680000" created_at="1226494680000" description="" event_data="[null]"/>
-  <events id="3" name="1.1" component_uuid="ABCD" snapshot_id="1004" category="Version" event_date="1227934800000" created_at="1227934800000" description="" event_data="[null]"/>
+  <events id="1"
+          analysis_uuid="u1000"
+          component_uuid="ABCD"
+          name="0.9"
+          category="Version"
+          event_date="1226379600000"
+          created_at="1226379600000"
+          description=""
+          event_data="[null]"/>
+  <events id="2"
+          analysis_uuid="u1001"
+          component_uuid="ABCD"
+          name="1.0"
+          category="Version"
+          event_date="1226494680000"
+          created_at="1226494680000"
+          description=""
+          event_data="[null]"/>
+  <events id="3"
+          analysis_uuid="u1004"
+          component_uuid="ABCD"
+          name="1.1"
+          category="Version"
+          event_date="1227934800000"
+          created_at="1227934800000"
+          description=""
+          event_data="[null]"/>
 
 </dataset>
index 1b72b63d5e7097dd97004ba8c954a975214ca871..08c70eb07cb42a1f7f1706c3dc206d21e7924d8c 100644 (file)
@@ -1,13 +1,13 @@
 <dataset>
 
   <events id="1"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="1.0"
           category="Version"
           description="[null]"
           event_data="[null]"
           event_date="150000000"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="1225630680000"/>
 
 </dataset>
index 2a56e0c7203108d01bdf168d23097c2705da5b18..7b1e1b13577cbed93462ed5c0780c8624eb8f16f 100644 (file)
@@ -1,14 +1,35 @@
 <dataset>
 
-  <events id="1" name="1.3-SNAPSHOT" category="Version" description="[null]" event_data="[null]" event_date="120000000"
-          component_uuid="ABCD" snapshot_id="1000" created_at="120000000" />
-  <events id="2" name="1.4" category="Version" description="[null]" event_data="[null]" event_date="130000000"
-          component_uuid="ABCD" snapshot_id="1000" created_at="130000000" />
+  <events id="1"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
+          name="1.3-SNAPSHOT"
+          category="Version"
+          description="[null]"
+          event_data="[null]"
+          event_date="120000000"
+          created_at="120000000"/>
+  <events id="2"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
+          name="1.4"
+          category="Version"
+          description="[null]"
+          event_data="[null]"
+          event_date="130000000"
+          created_at="130000000"/>
   <!-- Has been removed -->
   <!--<events id="3" name="1.5-SNAPSHOT" category="Version" description="[null]" event_data="[null]" event_date="140000000"-->
-          <!--component_uuid="ABCD" snapshot_id="1000" created_at="140000000" />-->
+  <!--component_uuid="ABCD" analysis_uuid="uuid_1" created_at="140000000" />-->
 
-  <events id="4" name="1.5-SNAPSHOT" category="Version" description="[null]" event_data="[null]" event_date="150000000"
-          component_uuid="ABCD" snapshot_id="1001" created_at="1225630680000" />
+  <events id="4"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
+          name="1.5-SNAPSHOT"
+          category="Version"
+          description="[null]"
+          event_data="[null]"
+          event_date="150000000"
+          created_at="1225630680000"/>
 
 </dataset>
index 93bfc6001b85fb3e24c6a2c0b3fccbc761e52306..e49dd98d343bb1789e4e8871bac0ce201437fa86 100644 (file)
@@ -1,31 +1,31 @@
 <dataset>
 
   <events id="1"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="1.3-SNAPSHOT"
           category="Version"
           description="[null]"
           event_data="[null]"
           event_date="120000000"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="120000000"/>
   <events id="2"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="1.4"
           category="Version"
           description="[null]"
           event_data="[null]"
           event_date="130000000"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="130000000"/>
   <events id="3"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="1.5-SNAPSHOT"
           category="Version"
           description="[null]"
           event_data="[null]"
           event_date="140000000"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="140000000"/>
 
 </dataset>
index 0d9badce82dc5639dd21d3914b691ea92947c396..df246ef8e1a2918c0c8df521cadee287d254ed1f 100644 (file)
@@ -1,41 +1,41 @@
 <dataset>
 
   <events id="1"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="1.0"
           category="Version"
           description="Version 1.0"
           event_data="some data"
           event_date="1413407091086"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="1225630680000"/>
   <events id="2"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="Red (was Orange)"
           category="Alert"
           description="Critical issues variation > 0 since previous version (1.0 - 2015 Feb 09), Open issues > 0"
           event_data="[null]"
           event_date="1413407091086"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="1225630680000"/>
   <events id="3"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="Changes in 'Default' (Java)"
           category="Profile"
           description="Version 1.0"
           event_data="from=2014-10-12T08:36:25+0000;key=java-default;to=2014-10-12T10:36:25+0000"
           event_date="1413407091086"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="1225630680000"/>
 
   <events id="4"
+          analysis_uuid="uuid_1"
+          component_uuid="BCDE"
           name="1.0"
           category="Version"
           description="Version 1.0"
           event_data="some data"
           event_date="1413407091086"
-          component_uuid="BCDE"
-          snapshot_id="1000"
           created_at="1225630680000"/>
 
 </dataset>
index 9eba6a21ee8c375de1fa4c7391c420a2a1f1691d..efbe7119b968246378ce2e538542bf9c406fccbc 100644 (file)
@@ -1,13 +1,13 @@
 <dataset>
 
   <events id="1"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
           name="Red (was Orange)"
           category="Alert"
           description="Open issues > 0"
           event_data="[null]"
           event_date="150000000"
-          component_uuid="ABCD"
-          snapshot_id="1000"
           created_at="1225630680000"/>
 
 </dataset>
index 7900407f2199513a0fbb6934b8e99e190e95198b..4269dee6bb5f3af069a41aef48c4e2669442246c 100644 (file)
@@ -190,11 +190,9 @@ class Api::EventsController < Api::ApiController
       events = []
       name = event.name
       category = event.category
-      snapshots = Snapshot.find(:all, :include => 'events', :conditions => ["(root_snapshot_id = ? OR id = ?) AND scope = 'PRJ'", event.snapshot_id, event.snapshot_id])
-      snapshots.each do |snapshot|
-        snapshot.events.reject {|e| e.name!=name || e.category!=category}.each do |event|
-          events << event
-        end
+      snapshot = Snapshot.find(:first, :include => 'events', :conditions => ["uuid = ? AND scope = 'PRJ'", event.analysis_uuid])
+      snapshot.events.reject {|e| e.name!=name || e.category!=category}.each do |event|
+        events << event
       end
 
       Event.transaction do
index 8966df0f57a9b2b9ef463cc2145a6d47d929e687..f95fba9e7ee2ba36b0565c5ff2d6f27450775811 100644 (file)
@@ -39,13 +39,13 @@ class ComparisonController < ApplicationController
       end
     else
       # the request comes from the comparison page: let's compare the given snapshots
-      sids = get_params_as_array(:sids)
-      unless sids.empty?
-        selected_snapshots = Snapshot.all(:conditions => ['id in (?)', sids])
-        # next loop is required to keep the order that was decided by the user and which comes from the "sids" parameter
-        sids.each do |id|
+      suuids = get_params_as_array(:suuids)
+      unless suuids.empty?
+        selected_snapshots = Snapshot.all(:conditions => ['uuid in (?)', suuids])
+        # next loop is required to keep the order that was decided by the user and which comes from the "suuids" parameter
+        suuids.each do |uuid|
           selected_snapshots.each do |s|
-            snapshots << s if id==s.id.to_s
+            snapshots << s if uuid==s.uuid.to_s
           end
         end
       end
@@ -69,20 +69,20 @@ class ComparisonController < ApplicationController
   end
 
   def versions
-    key = params[:resource]
-    sids = get_params_as_array(:sids)
+    id = params[:id]
+    suuids = get_params_as_array(:suuids)
 
-    unless key.blank?
-      resource = Project.by_key(params[:resource])
+    unless id.blank?
+      project = Project.by_key(id)
 
       # we look for the events that are versions and that are not linked to snapshots already displayed on the page
-      @versions = resource.events.select { |event| !event.snapshot_id.nil? && event.category==EventCategory::KEY_VERSION && !sids.include?(event.snapshot_id.to_s) }
+      @versions = project.events.select { |event| event.category==EventCategory::KEY_VERSION && !suuids.include?(event.analysis_uuid.to_s) }
 
       # check if the latest snapshot if suggested or not (and if not, suggest it as "LATEST" => this is used for views or developers which do not have events)
-      latest_snapshot_id = resource.last_snapshot.id
-      current_and_suggested_sids = sids + @versions.map {|e| e.snapshot_id.to_s}
-      unless current_and_suggested_sids.include?(latest_snapshot_id.to_s)
-        @versions.unshift Event.new(:name => Api::Utils.message('comparison.version.latest'), :snapshot_id => latest_snapshot_id)
+      latest_snapshot_uuid = project.last_snapshot.uuid
+      current_and_suggested_suuids = suuids + @versions.map {|e| e.analysis_uuid.to_s}
+      unless current_and_suggested_suuids.include?(latest_snapshot_uuid.to_s)
+        @versions.unshift Event.new(:name => Api::Utils.message('comparison.version.latest'), :analysis_uuid => latest_snapshot_uuid)
       end
     end
 
index 0e020368855503b9c3030ab7ab737089dd02b4dc..6a8028e977f1f6e8ef353f78dd5ba8b4f91ff156 100644 (file)
@@ -301,7 +301,7 @@ class ProjectController < ApplicationController
         if snapshot.event(EventCategory::KEY_VERSION)
           # This is an update: we update the event
           Event.update_all({:name => params[:version_name]},
-                           ["category = ? AND snapshot_id = ?", EventCategory::KEY_VERSION, snapshot.id])
+                           ["category = ? AND analysis_uuid = ?", EventCategory::KEY_VERSION, snapshot.uuid])
           flash[:notice] = message('project_history.version_updated', :params => h(params[:version_name]))
         else
           # We create an event on the snapshot
@@ -323,11 +323,8 @@ class ProjectController < ApplicationController
 
     # We update all the related snapshots to have the same version as the next snapshot
     next_snapshot = Snapshot.find(:first, :conditions => ['created_at>? and component_uuid=?', parent_snapshot.created_at.to_i*1000, parent_snapshot.component_uuid], :order => 'created_at asc')
-    snapshots = find_project_snapshots(parent_snapshot.id)
-    snapshots.each do |snapshot|
-      snapshot.version = next_snapshot.version
-      snapshot.save!
-    end
+    parent_snapshot.version = next_snapshot.version
+    parent_snapshot.save!
 
     # and we delete the events
     event = parent_snapshot.event(EventCategory::KEY_VERSION)
@@ -352,15 +349,12 @@ class ProjectController < ApplicationController
     if Event.already_exists(snapshot.component_uuid, params[:event_name], EventCategory::KEY_OTHER)
       flash[:error] = message('project_history.event_already_exists', :params => h(params[:event_name]))
     else
-      snapshots = find_project_snapshots(snapshot.id)
-      snapshots.each do |s|
-        e = Event.new({:name => params[:event_name],
-                       :category => EventCategory::KEY_OTHER,
-                       :snapshot => s,
-                       :component_uuid => s.project.uuid,
-                       :event_date => s.created_at})
-        e.save!
-      end
+      e = Event.new({:name => params[:event_name],
+                     :category => EventCategory::KEY_OTHER,
+                     :snapshot => snapshot,
+                     :component_uuid => snapshot.project.uuid,
+                     :event_date => snapshot.created_at})
+      e.save!
       flash[:notice] = message('project_history.event_created', :params => h(params[:event_name]))
     end
 
@@ -413,20 +407,13 @@ class ProjectController < ApplicationController
     project
   end
 
-  def find_project_snapshots(root_snapshot_id)
-    Snapshot.find(:all, :include => ['events', 'project'], :conditions => ["(root_snapshot_id = ? OR id = ?) AND scope = 'PRJ'", root_snapshot_id, root_snapshot_id])
-  end
-
-  # Returns all an array that contains the given event + all the events that are the same, but which are attached on the submodules
+  # Returns all an array that contains the given event + all the events that are the same
   def find_events(event)
     events = []
     name = event.name
     category = event.category
-    snapshots = find_project_snapshots(event.snapshot_id)
-    snapshots.each do |snapshot|
-      snapshot.events.reject { |e| e.name!=name || e.category!=category }.each do |event|
-        events << event
-      end
+    event.snapshot.events.reject { |e| e.name!=name || e.category!=category }.each do |event|
+      events << event
     end
     events
   end
index be3aa2eafa2b20d666ec47476a16ff767d0805ac..998a86db2edabe455d953f2926e35e279501fa0f 100644 (file)
@@ -24,7 +24,7 @@ class Event < ActiveRecord::Base
   validates_length_of      :category, :within => 1..50
 
   belongs_to :resource, :class_name => 'Project', :foreign_key => 'component_uuid', :primary_key => 'uuid'
-  belongs_to :snapshot
+  belongs_to :snapshot, :class_name => 'Snapshot', :foreign_key => 'analysis_uuid', :primary_key => 'uuid'
 
   before_save :populate_snapshot
   
index 90d1931ef848bf7c3fd9d9bc4e017860e6837ea0..1f008742a8e26eb4e10a5ef2126740fc9cb51a60 100644 (file)
@@ -116,10 +116,6 @@ class Project < ActiveRecord::Base
       end
   end
 
-  def events_with_snapshot
-    events.select { |event| !event.snapshot_id.nil? }
-  end
-
   def key
     kee
   end
index 535bc0e40b8ed800e63d0e97747cf180511d9983..879ed2c648b1a1bb66ba00427afb7a985ad55b26 100644 (file)
@@ -29,7 +29,7 @@ class Snapshot < ActiveRecord::Base
   has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'person_id IS NULL'
   has_many :person_measures, :class_name => 'ProjectMeasure', :conditions => 'person_id IS NOT NULL'
 
-  has_many :events, :dependent => :destroy, :order => 'event_date DESC'
+  has_many :events, :class_name => 'Event', :foreign_key => 'analysis_uuid', :primary_key => 'uuid', :dependent => :destroy, :order => 'event_date DESC'
 
   STATUS_UNPROCESSED = 'U'
   STATUS_PROCESSED = 'P'
@@ -75,7 +75,7 @@ class Snapshot < ActiveRecord::Base
     #   2. project B, which depends on A 1.0, is analyzed -> new snapshot A 1.0 with qualifier LIB.
     #   3. project A has 2 snapshots : the first one with qualifier=TRK has measures, the second one with qualifier LIB has no measures. Its version must not be used in time machine
     # That's why the 2 following SQL requests check the qualifiers (and optionally scopes, just to be sure)
-    snapshots=Snapshot.find(:all, :conditions => ["snapshots.component_uuid=? AND events.snapshot_id=snapshots.id AND snapshots.status=? AND snapshots.scope=? AND snapshots.qualifier=?", resource.uuid, STATUS_PROCESSED, resource.scope, resource.qualifier],
+    snapshots=Snapshot.find(:all, :conditions => ["snapshots.component_uuid=? AND events.analysis_uuid=snapshots.uuid AND snapshots.status=? AND snapshots.scope=? AND snapshots.qualifier=?", resource.uuid, STATUS_PROCESSED, resource.scope, resource.qualifier],
                             :include => 'events',
                             :order => 'snapshots.created_at ASC')
 
@@ -112,7 +112,7 @@ class Snapshot < ActiveRecord::Base
     # Look for the number_of_columns-2 last snapshots to display  (they must have 'Version' events)
     version_snapshots = []
     if number_of_columns > 2
-      snapshot_conditions[0] += " AND events.snapshot_id=snapshots.id AND events.category='Version' AND snapshots.id NOT IN (?)"
+      snapshot_conditions[0] += " AND events.analysis_uuid=snapshots.uuid AND events.category='Version' AND snapshots.id NOT IN (?)"
       snapshot_conditions << [first_snapshot.id, last_snapshot.id]
       version_snapshots=Snapshot.find(:all, :conditions => snapshot_conditions, :include => 'events', :order => 'snapshots.created_at ASC').last(number_of_columns-2)
     end
@@ -153,7 +153,7 @@ class Snapshot < ActiveRecord::Base
   def user_events
     categories=EventCategory.categories(true)
     category_names=categories.map { |cat| cat.name }
-    Event.find(:all, :conditions => ["snapshot_id=? AND category IS NOT NULL", id], :order => 'event_date desc').select do |event|
+    Event.find(:all, :conditions => ["analysis_uuid=? AND category IS NOT NULL", uuid], :order => 'event_date desc').select do |event|
       category_names.include?(event.category)
     end
   end
index f2a3be5c321dfa9d8abb24c5f5eb8fa1c7d6498d..7a5d7c80be5f02f68fd0d5049b8a789d55ec1223 100644 (file)
@@ -2,7 +2,7 @@
 
   <option value=""></option>
   <% @versions.each do |version| %>
-    <option value="<%= version.snapshot_id -%>"><%= h version.name -%></option>
+    <option value="<%= version.analysis_uuid -%>"><%= h version.name -%></option>
   <% end %>
   
-<% end %>
\ No newline at end of file
+<% end %>
index da6e94ccba4751d3f58dbc700d0cf485ff4c5d6b..dd67957720d2eae543b261db9b9e02189e31220d 100644 (file)
     }
 
     function moveLeft(index) {
-      sids = $j('#sids').val().split(',');
-      idToLeft = sids[index];
-      idToRight = sids[index - 1];
-      sids.splice(index - 1, 2, [idToLeft, idToRight]);
-      $j('#sids').val(sids.join(','));
+      suuids = $j('#suuids').val().split(',');
+      idToLeft = suuids[index];
+      idToRight = suuids[index - 1];
+      suuids.splice(index - 1, 2, [idToLeft, idToRight]);
+      $j('#suuids').val(suuids.join(','));
       submitForm();
     }
 
     function moveRight(index) {
-      sids = $j('#sids').val().split(',');
-      idToRight = sids[index];
-      idToLeft = sids[index + 1];
-      sids.splice(index, 2, [idToLeft, idToRight]);
-      $j('#sids').val(sids.join(','));
+      suuids = $j('#suuids').val().split(',');
+      idToRight = suuids[index];
+      idToLeft = suuids[index + 1];
+      suuids.splice(index, 2, [idToLeft, idToRight]);
+      $j('#suuids').val(suuids.join(','));
       submitForm();
     }
 
@@ -70,7 +70,7 @@
       <h1 class="page-title"><%= h message('comparison.page') -%></h1>
     </header>
     <form method="GET" id="compare-form" action="<%= ApplicationController.root_context -%>/comparison/index">
-      <input type="hidden" name="sids" id="sids" value="<%= @snapshots.map { |s| s.id.to_s }.join(',') -%>">
+      <input type="hidden" name="suuids" id="suuids" value="<%= @snapshots.map { |s| s.uuid.to_s }.join(',') -%>">
       <input type="hidden" name="metrics" id="metrics" value="<%= @metrics.map { |m| m.key }.join(',') -%>">
 
          <div style="margin-bottom: 4px">
                   $j('#version_loading').show();
                   $j.ajax({
                     type:'GET',
-                    url:'<%= ApplicationController.root_context -%>/comparison/versions?resource='
-                      + id + '&sids='
-                      + $j('#sids').val(),
+                    url:'<%= ApplicationController.root_context -%>/comparison/versions?id='
+                      + id + '&suuids='
+                      + $j('#suuids').val(),
                     success:function (data) {
                       $j('#new_version').html(data);
                       $j('#new_version').select2({
             </select>
             <script>
               $j('#new_version').change(function (event) {
-                var id = event.target.value;
-                if (id != null) {
-                  var currentSnapshotIds = $j('#sids').val();
-                  if (currentSnapshotIds.length > 0) {
-                    currentSnapshotIds += ',';
+                var uuid = event.target.value;
+                if (uuid != null) {
+                  var currentSnapshotUuids = $j('#suuids').val();
+                  if (currentSnapshotUuids.length > 0) {
+                    currentSnapshotUuids += ',';
                   }
-                  currentSnapshotIds += id;
-                  $j('#sids').val(currentSnapshotIds);
+                  currentSnapshotUuids += uuid;
+                  $j('#suuids').val(currentSnapshotUuids);
                   $j('#compare-form').submit();
                 }
               });
                   </td>
                   <td style="text-align: center; min-width: 100px">
                     <div style="width: 100%; text-align: center;">
-                      <a class="icon-delete" href="#" onclick="removeFromList(<%= index -%>, $j('#sids'))" id="del-r-<%= index -%>" title="<%= message('comparison.suppress_column') -%>"></a>
+                      <a class="icon-delete" href="#" onclick="removeFromList(<%= index -%>, $j('#suuids'))" id="del-r-<%= index -%>" title="<%= message('comparison.suppress_column') -%>"></a>
                     </div>
                   </td>
                   <td style="vertical-align: bottom;">
index 73593e1b4c7e46ca215d18f05d5b1be852bb7290..99a53c3601d48f8956dc7bae4f5b51e1304f37ec 100644 (file)
@@ -94,7 +94,7 @@ import org.sonar.db.property.PropertiesMapper;
 import org.sonar.db.property.PropertyDto;
 import org.sonar.db.purge.IdUuidPair;
 import org.sonar.db.purge.PurgeMapper;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 import org.sonar.db.qualitygate.ProjectQgateAssociationDto;
 import org.sonar.db.qualitygate.ProjectQgateAssociationMapper;
 import org.sonar.db.qualitygate.QualityGateConditionDto;
@@ -173,7 +173,7 @@ public class MyBatis {
     confBuilder.loadAlias("MeasureFilterFavourite", MeasureFilterFavouriteDto.class);
     confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class);
     confBuilder.loadAlias("Property", PropertyDto.class);
-    confBuilder.loadAlias("PurgeableSnapshot", PurgeableSnapshotDto.class);
+    confBuilder.loadAlias("PurgeableAnalysis", PurgeableAnalysisDto.class);
     confBuilder.loadAlias("QualityGate", QualityGateDto.class);
     confBuilder.loadAlias("QualityGateCondition", QualityGateConditionDto.class);
     confBuilder.loadAlias("ProjectQgateAssociation", ProjectQgateAssociationDto.class);
index e11efb849488f17d373e39dbc545a06eaf43d13d..a66173d2df0ae94bf85ef3d82dd299595646faa7 100644 (file)
@@ -95,6 +95,9 @@ public class SnapshotDao implements Dao {
     return snapshotDtos.get(0);
   }
 
+  /**
+   * Since this relies on tables EVENTS, this can return results only for root components (PROJECT, VIEW or DEVELOPER).
+   */
   public List<SnapshotDto> selectPreviousVersionSnapshots(DbSession session, String componentUuid, String lastVersion) {
     return mapper(session).selectPreviousVersionSnapshots(componentUuid, lastVersion);
   }
index 07bc636ba88d248b0122eb79c41f2009482a838d..5e377af9261bfecf36275cbf9d7c476886e48db3 100644 (file)
@@ -29,23 +29,15 @@ public class EventDto {
   public static final String CATEGORY_PROFILE = "Profile";
 
   private Long id;
-
+  private String analysisUuid;
+  private String componentUuid;
   private String name;
-
   private String description;
-
   private String category;
-
   private Long date;
-
   private Long createdAt;
-
   private String data;
 
-  private Long snapshotId;
-
-  private String componentUuid;
-
   public Long getId() {
     return id;
   }
@@ -55,12 +47,12 @@ public class EventDto {
     return this;
   }
 
-  public String getCategory() {
-    return category;
+  public String getAnalysisUuid() {
+    return analysisUuid;
   }
 
-  public EventDto setCategory(String category) {
-    this.category = category;
+  public EventDto setAnalysisUuid(String analysisUuid) {
+    this.analysisUuid = analysisUuid;
     return this;
   }
 
@@ -73,6 +65,24 @@ public class EventDto {
     return this;
   }
 
+  public String getName() {
+    return name;
+  }
+
+  public EventDto setName(String name) {
+    this.name = name;
+    return this;
+  }
+
+  public String getCategory() {
+    return category;
+  }
+
+  public EventDto setCategory(String category) {
+    this.category = category;
+    return this;
+  }
+
   public Long getCreatedAt() {
     return createdAt;
   }
@@ -111,21 +121,4 @@ public class EventDto {
     return this;
   }
 
-  public String getName() {
-    return name;
-  }
-
-  public EventDto setName(String name) {
-    this.name = name;
-    return this;
-  }
-
-  public Long getSnapshotId() {
-    return snapshotId;
-  }
-
-  public EventDto setSnapshotId(Long snapshotId) {
-    this.snapshotId = snapshotId;
-    return this;
-  }
 }
index 91a0300a5370d5cb183bbb13eede0d52adb6abac..5df77a2f3089740e20b8d7bc1e63bad4d5373d97 100644 (file)
@@ -160,8 +160,8 @@ class PurgeCommands {
     deleteSnapshotDuplications(snapshotUuidsPartition);
 
     profiler.start("deleteSnapshotEvents (events)");
-    for (List<Long> partSnapshotIds : snapshotIdsPartition) {
-      purgeMapper.deleteSnapshotEvents(partSnapshotIds);
+    for (List<String> partSnapshotUuids : snapshotUuidsPartition) {
+      purgeMapper.deleteSnapshotEvents(partSnapshotUuids);
     }
     session.commit();
     profiler.stop();
index 6e77444075a09c86dac6222c140500b56cb0d5d6..37e1918d5698bb224a99d9a69df07858fa0ba87d 100644 (file)
@@ -148,7 +148,7 @@ public class PurgeDao implements Dao {
     session.commit();
   }
 
-  public List<PurgeableSnapshotDto> selectPurgeableSnapshots(String componentUuid) {
+  public List<PurgeableAnalysisDto> selectPurgeableSnapshots(String componentUuid) {
     DbSession session = mybatis.openSession(true);
     try {
       return selectPurgeableSnapshots(componentUuid, session);
@@ -157,10 +157,10 @@ public class PurgeDao implements Dao {
     }
   }
 
-  public List<PurgeableSnapshotDto> selectPurgeableSnapshots(String componentUuid, DbSession session) {
-    List<PurgeableSnapshotDto> result = Lists.newArrayList();
-    result.addAll(mapper(session).selectPurgeableSnapshotsWithEvents(componentUuid));
-    result.addAll(mapper(session).selectPurgeableSnapshotsWithoutEvents(componentUuid));
+  public List<PurgeableAnalysisDto> selectPurgeableSnapshots(String componentUuid, DbSession session) {
+    List<PurgeableAnalysisDto> result = Lists.newArrayList();
+    result.addAll(mapper(session).selectPurgeableAnalysesWithEvents(componentUuid));
+    result.addAll(mapper(session).selectPurgeableAnalysesWithoutEvents(componentUuid));
     // sort by date
     Collections.sort(result);
     return result;
index 7c237d06ba8ee2d765d14a8ec30f1b2cf4ae36be..d0888709c089c2e22cd57f74efdad923ba819429 100644 (file)
@@ -38,7 +38,7 @@ public interface PurgeMapper {
 
   void deleteSnapshotDuplications(@Param("analysisUuids") List<String> analysisUuids);
 
-  void deleteSnapshotEvents(@Param("snapshotIds") List<Long> snapshotIds);
+  void deleteSnapshotEvents(@Param("analysisUuids") List<String> analysisUuids);
 
   void deleteSnapshotMeasures(@Param("snapshotIds") List<Long> snapshotIds);
 
@@ -74,9 +74,9 @@ public interface PurgeMapper {
 
   void deleteAuthors(@Param("resourceIds") List<Long> resourceIds);
 
-  List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithEvents(@Param("componentUuid") String componentUuid);
+  List<PurgeableAnalysisDto> selectPurgeableAnalysesWithEvents(@Param("componentUuid") String componentUuid);
 
-  List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithoutEvents(@Param("componentUuid") String componentUuid);
+  List<PurgeableAnalysisDto> selectPurgeableAnalysesWithoutEvents(@Param("componentUuid") String componentUuid);
 
   void deleteComponentIssueChanges(@Param("componentUuids") List<String> componentUuids);
 
diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeableAnalysisDto.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeableAnalysisDto.java
new file mode 100644 (file)
index 0000000..28a7da4
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.db.purge;
+
+import java.util.Date;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+public class PurgeableAnalysisDto implements Comparable<PurgeableAnalysisDto> {
+  private Date date;
+  // FIXME this property will be useless once we refactor table SNAPSHOTS into ANALYSES
+  private long analysisId;
+  private String analysisUuid;
+  private boolean hasEvents;
+  private boolean isLast;
+
+  public Date getDate() {
+    return date;
+  }
+
+  public PurgeableAnalysisDto setDate(Long aLong) {
+    this.date = new Date(aLong);
+    return this;
+  }
+
+  public long getAnalysisId() {
+    return analysisId;
+  }
+
+  public PurgeableAnalysisDto setAnalysisId(long analysisId) {
+    this.analysisId = analysisId;
+    return this;
+  }
+
+  public String getAnalysisUuid() {
+    return analysisUuid;
+  }
+
+  public PurgeableAnalysisDto setAnalysisUuid(String analysisUuid) {
+    this.analysisUuid = analysisUuid;
+    return this;
+  }
+
+  public boolean hasEvents() {
+    return hasEvents;
+  }
+
+  public PurgeableAnalysisDto setHasEvents(boolean b) {
+    this.hasEvents = b;
+    return this;
+  }
+
+  public boolean isLast() {
+    return isLast;
+  }
+
+  public PurgeableAnalysisDto setLast(boolean last) {
+    isLast = last;
+    return this;
+  }
+
+  @Override
+  public int compareTo(PurgeableAnalysisDto other) {
+    return date.compareTo(other.date);
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    PurgeableAnalysisDto that = (PurgeableAnalysisDto) o;
+    return analysisId == that.analysisId;
+  }
+
+  @Override
+  public int hashCode() {
+    return (int) analysisId;
+  }
+
+  @Override
+  public String toString() {
+    return new ReflectionToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).toString();
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeableSnapshotDto.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeableSnapshotDto.java
deleted file mode 100644 (file)
index 452c934..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.db.purge;
-
-import java.util.Date;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-public class PurgeableSnapshotDto implements Comparable<PurgeableSnapshotDto> {
-  private Date date;
-  private long snapshotId;
-  private boolean hasEvents;
-  private boolean isLast;
-
-  public Date getDate() {
-    return date;
-  }
-
-  public long getSnapshotId() {
-    return snapshotId;
-  }
-
-  public boolean hasEvents() {
-    return hasEvents;
-  }
-
-  public boolean isLast() {
-    return isLast;
-  }
-
-  public PurgeableSnapshotDto setDate(Long aLong) {
-    this.date = new Date(aLong);
-    return this;
-  }
-
-  public PurgeableSnapshotDto setSnapshotId(long snapshotId) {
-    this.snapshotId = snapshotId;
-    return this;
-  }
-
-  public PurgeableSnapshotDto setHasEvents(boolean b) {
-    this.hasEvents = b;
-    return this;
-  }
-
-  public PurgeableSnapshotDto setLast(boolean last) {
-    isLast = last;
-    return this;
-  }
-
-  @Override
-  public int compareTo(PurgeableSnapshotDto other) {
-    return date.compareTo(other.date);
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-    PurgeableSnapshotDto that = (PurgeableSnapshotDto) o;
-    return snapshotId == that.snapshotId;
-  }
-
-  @Override
-  public int hashCode() {
-    return (int) snapshotId;
-  }
-
-  @Override
-  public String toString() {
-    return new ReflectionToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).toString();
-  }
-}
index 26de4acd9020d4be11546b1838fd1b51c35ed535..cbd55b67bdbcb44b11c5a09536a02a9ffde9a14b 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.purge.PurgeDao;
 import org.sonar.db.purge.PurgeProfiler;
 import org.sonar.db.purge.PurgeSnapshotQuery;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 public class DefaultPeriodCleaner {
 
@@ -48,24 +48,24 @@ public class DefaultPeriodCleaner {
 
   @VisibleForTesting
   void doClean(String componentUuid, List<Filter> filters, DbSession session) {
-    List<PurgeableSnapshotDto> history = selectProjectSnapshots(componentUuid, session);
+    List<PurgeableAnalysisDto> history = selectProjectSnapshots(componentUuid, session);
     for (Filter filter : filters) {
       filter.log();
       delete(filter.filter(history), session);
     }
   }
 
-  private void delete(List<PurgeableSnapshotDto> snapshots, DbSession session) {
-    for (PurgeableSnapshotDto snapshot : snapshots) {
-      LOG.debug("<- Delete snapshot: {} [{}]", DateUtils.formatDateTime(snapshot.getDate()), snapshot.getSnapshotId());
+  private void delete(List<PurgeableAnalysisDto> snapshots, DbSession session) {
+    for (PurgeableAnalysisDto snapshot : snapshots) {
+      LOG.debug("<- Delete snapshot: {} [{}]", DateUtils.formatDateTime(snapshot.getDate()), snapshot.getAnalysisUuid());
       purgeDao.deleteSnapshots(
         session, profiler,
-        PurgeSnapshotQuery.create().setRootSnapshotId(snapshot.getSnapshotId()),
-        PurgeSnapshotQuery.create().setId(snapshot.getSnapshotId()));
+        PurgeSnapshotQuery.create().setRootSnapshotId(snapshot.getAnalysisId()),
+        PurgeSnapshotQuery.create().setId(snapshot.getAnalysisId()));
     }
   }
 
-  private List<PurgeableSnapshotDto> selectProjectSnapshots(String componentUuid, DbSession session) {
+  private List<PurgeableAnalysisDto> selectProjectSnapshots(String componentUuid, DbSession session) {
     return purgeDao.selectPurgeableSnapshots(componentUuid, session);
   }
 }
index 3c33df80dc4fee2ef4715f01292350520b0ab791..c70c3340e25e114d29d1d23a6904ac65c7e5aa4c 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Date;
 import java.util.List;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.log.Loggers;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 class DeleteAllFilter implements Filter {
   private final Date before;
@@ -34,9 +34,9 @@ class DeleteAllFilter implements Filter {
   }
 
   @Override
-  public List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> history) {
-    List<PurgeableSnapshotDto> result = Lists.newArrayList();
-    for (PurgeableSnapshotDto snapshot : history) {
+  public List<PurgeableAnalysisDto> filter(List<PurgeableAnalysisDto> history) {
+    List<PurgeableAnalysisDto> result = Lists.newArrayList();
+    for (PurgeableAnalysisDto snapshot : history) {
       if (snapshot.getDate().before(before)) {
         result.add(snapshot);
       }
index 82c79064a81db1fe75875912111b75389ec04ad7..916775f305821f8eee25803cf3f23591b64bbeb0 100644 (file)
 package org.sonar.db.purge.period;
 
 import java.util.List;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 interface Filter {
-  List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> snapshots);
+  List<PurgeableAnalysisDto> filter(List<PurgeableAnalysisDto> snapshots);
 
   void log();
 }
index 4359afdaf242c33fb501d808bdb07345998ac61a..a3cf6c0448b89d89af67ce3dedc079a5fa34f235 100644 (file)
@@ -25,16 +25,16 @@ import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
 import org.apache.commons.lang.time.DateUtils;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 final class Interval {
-  List<PurgeableSnapshotDto> snapshots = Lists.newArrayList();
+  List<PurgeableAnalysisDto> snapshots = Lists.newArrayList();
 
-  void add(PurgeableSnapshotDto snapshot) {
+  void add(PurgeableAnalysisDto snapshot) {
     snapshots.add(snapshot);
   }
 
-  List<PurgeableSnapshotDto> get() {
+  List<PurgeableAnalysisDto> get() {
     return snapshots;
   }
 
@@ -42,7 +42,7 @@ final class Interval {
     return snapshots.size();
   }
 
-  static List<Interval> group(List<PurgeableSnapshotDto> snapshots, Date start, Date end, int calendarField) {
+  static List<Interval> group(List<PurgeableAnalysisDto> snapshots, Date start, Date end, int calendarField) {
     List<Interval> intervals = Lists.newArrayList();
 
     GregorianCalendar calendar = new GregorianCalendar();
@@ -50,7 +50,7 @@ final class Interval {
     int lastFieldValue = -1;
     Interval currentInterval = null;
 
-    for (PurgeableSnapshotDto snapshot : snapshots) {
+    for (PurgeableAnalysisDto snapshot : snapshots) {
       if (!DateUtils.isSameDay(start, snapshot.getDate()) && snapshot.getDate().after(start) &&
         (snapshot.getDate().before(end) || DateUtils.isSameDay(end, snapshot.getDate()))) {
         calendar.setTime(snapshot.getDate());
index 7bb554ffab2388812b2a2cda3419f9688da822b6..37443c5f8924bb5e466f1ddbbb1b0dfe7a36d2cd 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Date;
 import java.util.List;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.log.Loggers;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 class KeepOneFilter implements Filter {
 
@@ -42,9 +42,9 @@ class KeepOneFilter implements Filter {
   }
 
   @Override
-  public List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> history) {
+  public List<PurgeableAnalysisDto> filter(List<PurgeableAnalysisDto> history) {
     List<Interval> intervals = Interval.group(history, start, end, dateField);
-    List<PurgeableSnapshotDto> result = Lists.newArrayList();
+    List<PurgeableAnalysisDto> result = Lists.newArrayList();
     for (Interval interval : intervals) {
       appendSnapshotsToDelete(interval, result);
     }
@@ -57,11 +57,11 @@ class KeepOneFilter implements Filter {
     Loggers.get(getClass()).debug("-> Keep one snapshot per {} between {} and {}", label, DateUtils.formatDate(start), DateUtils.formatDate(end));
   }
 
-  private void appendSnapshotsToDelete(Interval interval, List<PurgeableSnapshotDto> toDelete) {
+  private void appendSnapshotsToDelete(Interval interval, List<PurgeableAnalysisDto> toDelete) {
     if (interval.count() > 1) {
-      List<PurgeableSnapshotDto> deletables = Lists.newArrayList();
-      List<PurgeableSnapshotDto> toKeep = Lists.newArrayList();
-      for (PurgeableSnapshotDto snapshot : interval.get()) {
+      List<PurgeableAnalysisDto> deletables = Lists.newArrayList();
+      List<PurgeableAnalysisDto> toKeep = Lists.newArrayList();
+      for (PurgeableAnalysisDto snapshot : interval.get()) {
         if (isDeletable(snapshot)) {
           deletables.add(snapshot);
         } else {
@@ -80,7 +80,7 @@ class KeepOneFilter implements Filter {
   }
 
   @VisibleForTesting
-  static boolean isDeletable(PurgeableSnapshotDto snapshot) {
+  static boolean isDeletable(PurgeableAnalysisDto snapshot) {
     return !snapshot.isLast() && !snapshot.hasEvents();
   }
 
index 2a7af53a22ff56243a706615c53701434f250646..1290068f1f5c566a5f721b93403166b093b35470 100644 (file)
     SELECT
     <include refid="snapshotColumns" />
     FROM snapshots s
-    INNER JOIN events e ON s.id = e.snapshot_id AND e.name &lt;&gt; #{lastVersion} AND e.category='Version'
+    INNER JOIN events e ON s.uuid = e.analysis_uuid AND e.name &lt;&gt; #{lastVersion} AND e.category='Version'
     <where>
       s.component_uuid=#{componentUuid}
     </where>
index e0ad60d0927e5f7ca5cd74169b3689808c73ef33..cdac080c37ef125f7d487eab9a35b6763e5746d5 100644 (file)
@@ -4,13 +4,13 @@
 
   <sql id="eventColumns">
     e.id,
+    e.analysis_uuid as "analysisUuid",
+    e.component_uuid as "componentUuid",
     e.name,
     e.category,
     e.description,
     e.event_data as "data",
     e.event_date as "date",
-    e.component_uuid as "componentUuid",
-    e.snapshot_id as "snapshotId",
     e.created_at as "createdAt"
   </sql>
 
@@ -24,8 +24,8 @@
   </select>
 
   <insert id="insert" parameterType="Event" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
-    INSERT INTO events (name, category, description, event_data, event_date, component_uuid, snapshot_id, created_at)
-    VALUES (#{name}, #{category}, #{description}, #{data}, #{date}, #{componentUuid}, #{snapshotId}, #{createdAt})
+    INSERT INTO events (analysis_uuid, component_uuid, name, category, description, event_data, event_date, created_at)
+    VALUES (#{analysisUuid}, #{componentUuid}, #{name}, #{category}, #{description}, #{data}, #{date}, #{createdAt})
   </insert>
 
   <delete id="delete">
index 8ed0439ca7c890a791e86f58a72aa12113d9c06a..7aa9ed81d57190189d9391389a0b2882e2c1cc1f 100644 (file)
     </where>
   </select>
 
-  <select id="selectPurgeableSnapshotsWithEvents" parameterType="String" resultType="PurgeableSnapshot">
-    select s.id as "snapshotId", s.created_at as "date", ${_true} as "hasEvents", islast as "isLast" from
+  <select id="selectPurgeableAnalysesWithEvents" parameterType="String" resultType="PurgeableAnalysis">
+    select s.id as "analysisId", s.uuid as "analysisUuid", s.created_at as "date", ${_true} as "hasEvents", islast as "isLast" from
     snapshots s where
     s.component_uuid=#{componentUuid} and s.status='P' and s.qualifier &lt;&gt; 'LIB' and
-    exists(select e.id from events e where e.snapshot_id=s.id)
+    exists(select e.id from events e where e.analysis_uuid=s.uuid)
   </select>
 
-  <select id="selectPurgeableSnapshotsWithoutEvents" parameterType="String" resultType="PurgeableSnapshot">
-    select s.id as "snapshotId", s.created_at as "date", ${_false} as "hasEvents", islast as "isLast" from
+  <select id="selectPurgeableAnalysesWithoutEvents" parameterType="String" resultType="PurgeableAnalysis">
+    select s.id as "analysisId", s.uuid as "analysisUuid", s.created_at as "date", ${_false} as "hasEvents", islast as "isLast" from
     snapshots s where
     s.component_uuid=#{componentUuid} and s.status='P' and s.qualifier &lt;&gt; 'LIB' and
-    not exists(select e.id from events e where e.snapshot_id=s.id)
+    not exists(select e.id from events e where e.analysis_uuid=s.uuid)
   </select>
 
   <select id="selectComponentIdUuidsToDisable" resultType="org.sonar.db.purge.IdUuidPair" parameterType="String">
   </delete>
 
   <delete id="deleteSnapshotEvents" parameterType="map">
-    delete from events where snapshot_id in
-    <foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
-      #{snapshotId}
+    delete from events where analysis_uuid in
+    <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=",">
+      #{analysisUuid}
     </foreach>
   </delete>
 
index 649b941006afd3a2be510384d05c0d184b82e510..d3203cc41f55d5b9a19753e5bb1b4ffe522961be 100644 (file)
@@ -27,7 +27,6 @@ import org.sonar.db.DbTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-
 public class EventDaoTest {
 
   @Rule
@@ -47,8 +46,8 @@ public class EventDaoTest {
 
     EventDto dto = dtos.get(0);
     assertThat(dto.getId()).isEqualTo(4L);
+    assertThat(dto.getAnalysisUuid()).isEqualTo("uuid_1");
     assertThat(dto.getComponentUuid()).isEqualTo("BCDE");
-    assertThat(dto.getSnapshotId()).isEqualTo(1000L);
     assertThat(dto.getName()).isEqualTo("1.0");
     assertThat(dto.getCategory()).isEqualTo("Version");
     assertThat(dto.getDescription()).isEqualTo("Version 1.0");
@@ -70,15 +69,14 @@ public class EventDaoTest {
     dbTester.prepareDbUnit(getClass(), "empty.xml");
 
     dao.insert(dbTester.getSession(), new EventDto()
+      .setAnalysisUuid("uuid_1")
+      .setComponentUuid("ABCD")
       .setName("1.0")
       .setCategory(EventDto.CATEGORY_VERSION)
       .setDescription("Version 1.0")
       .setData("some data")
       .setDate(1413407091086L)
-      .setComponentUuid("ABCD")
-      .setSnapshotId(1000L)
-      .setCreatedAt(1225630680000L)
-      );
+      .setCreatedAt(1225630680000L));
     dbTester.getSession().commit();
 
     dbTester.assertDbUnit(getClass(), "insert-result.xml", new String[] {"id"}, "events");
index ac3839deb5f4b3f39923d2c473043191a383f79b..b2e199b9458bec324b604ff9a3eb49e7374b7821 100644 (file)
@@ -29,22 +29,22 @@ public class EventDtoTest {
   public void test_getters_and_setters() throws Exception {
     EventDto dto = new EventDto()
       .setId(1L)
+      .setAnalysisUuid("uuid_1")
+      .setComponentUuid("ABCD")
       .setName("1.0")
       .setCategory("Version")
       .setDescription("Version 1.0")
       .setData("some data")
       .setDate(1413407091086L)
-      .setComponentUuid("ABCD")
-      .setSnapshotId(1000L)
       .setCreatedAt(1225630680000L);
 
     assertThat(dto.getId()).isEqualTo(1L);
+    assertThat(dto.getAnalysisUuid()).isEqualTo("uuid_1");
+    assertThat(dto.getComponentUuid()).isEqualTo("ABCD");
     assertThat(dto.getName()).isEqualTo("1.0");
     assertThat(dto.getCategory()).isEqualTo("Version");
     assertThat(dto.getDescription()).isEqualTo("Version 1.0");
     assertThat(dto.getData()).isEqualTo("some data");
-    assertThat(dto.getComponentUuid()).isEqualTo("ABCD");
-    assertThat(dto.getSnapshotId()).isEqualTo(1000L);
     assertThat(dto.getCreatedAt()).isEqualTo(1225630680000L);
   }
 
index 0419b67df2219504298c6d7bace244e95ee59aa3..7dd36679600e85bd08ed1d485d125f6ecba6c965 100644 (file)
@@ -26,16 +26,16 @@ public final class DbCleanerTestUtils {
   private DbCleanerTestUtils() {
   }
 
-  public static PurgeableSnapshotDto createSnapshotWithDate(long snapshotId, String date) {
-    PurgeableSnapshotDto snapshot = new PurgeableSnapshotDto();
-    snapshot.setSnapshotId(snapshotId);
+  public static PurgeableAnalysisDto createSnapshotWithDate(long snapshotId, String date) {
+    PurgeableAnalysisDto snapshot = new PurgeableAnalysisDto();
+    snapshot.setAnalysisId(snapshotId);
     snapshot.setDate(DateUtils.parseDate(date).getTime());
     return snapshot;
   }
 
-  public static PurgeableSnapshotDto createSnapshotWithDateTime(long snapshotId, String datetime) {
-    PurgeableSnapshotDto snapshot = new PurgeableSnapshotDto();
-    snapshot.setSnapshotId(snapshotId);
+  public static PurgeableAnalysisDto createSnapshotWithDateTime(long snapshotId, String datetime) {
+    PurgeableAnalysisDto snapshot = new PurgeableAnalysisDto();
+    snapshot.setAnalysisId(snapshotId);
     snapshot.setDate(DateUtils.parseDateTime(datetime).getTime());
     return snapshot;
   }
index 0cba06d947c2e4cd3a9636a0bcaf3c0682d42d7d..4a0120bf96485f6d6ad93781c37eafaaf608e330 100644 (file)
@@ -105,7 +105,7 @@ public class PurgeDaoTest {
   @Test
   public void shouldSelectPurgeableSnapshots() {
     dbTester.prepareDbUnit(getClass(), "shouldSelectPurgeableSnapshots.xml");
-    List<PurgeableSnapshotDto> snapshots = underTest.selectPurgeableSnapshots(THE_PROJECT_UUID);
+    List<PurgeableAnalysisDto> snapshots = underTest.selectPurgeableSnapshots(THE_PROJECT_UUID);
 
     assertThat(snapshots).hasSize(3);
     assertThat(getById(snapshots, THE_PROJECT_ID).isLast()).isTrue();
@@ -217,9 +217,9 @@ public class PurgeDaoTest {
     return dto;
   }
 
-  private static PurgeableSnapshotDto getById(List<PurgeableSnapshotDto> snapshots, long id) {
-    for (PurgeableSnapshotDto snapshot : snapshots) {
-      if (snapshot.getSnapshotId() == id) {
+  private static PurgeableAnalysisDto getById(List<PurgeableAnalysisDto> snapshots, long id) {
+    for (PurgeableAnalysisDto snapshot : snapshots) {
+      if (snapshot.getAnalysisId() == id) {
         return snapshot;
       }
     }
diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeableAnalysisDtoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeableAnalysisDtoTest.java
new file mode 100644 (file)
index 0000000..231dd36
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.db.purge;
+
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+public class PurgeableAnalysisDtoTest {
+  @Test
+  public void testEquals() {
+    PurgeableAnalysisDto dto1 = new PurgeableAnalysisDto().setAnalysisId(3L);
+    PurgeableAnalysisDto dto2 = new PurgeableAnalysisDto().setAnalysisId(4L);
+    assertThat(dto1.equals(dto2), is(false));
+    assertThat(dto2.equals(dto1), is(false));
+    assertThat(dto1.equals(dto1), is(true));
+    assertThat(dto1.equals(new PurgeableAnalysisDto().setAnalysisId(3L)), is(true));
+    assertThat(dto1.equals("bi_bop_a_lou_la"), is(false));
+    assertThat(dto1.equals(null), is(false));
+  }
+
+  @Test
+  public void testHasCode() {
+    PurgeableAnalysisDto dto = new PurgeableAnalysisDto().setAnalysisId(3L);
+    assertThat(dto.hashCode(), is(dto.hashCode()));
+
+    // no id
+    dto = new PurgeableAnalysisDto();
+    assertThat(dto.hashCode(), is(dto.hashCode()));
+  }
+
+  @Test
+  public void testToString() {
+    PurgeableAnalysisDto dto = new PurgeableAnalysisDto().setAnalysisId(3L);
+    assertThat(dto.toString().length(), greaterThan(0));
+  }
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeableSnapshotDtoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeableSnapshotDtoTest.java
deleted file mode 100644 (file)
index 6cb62a6..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.db.purge;
-
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class PurgeableSnapshotDtoTest {
-  @Test
-  public void testEquals() {
-    PurgeableSnapshotDto dto1 = new PurgeableSnapshotDto().setSnapshotId(3L);
-    PurgeableSnapshotDto dto2 = new PurgeableSnapshotDto().setSnapshotId(4L);
-    assertThat(dto1.equals(dto2), is(false));
-    assertThat(dto2.equals(dto1), is(false));
-    assertThat(dto1.equals(dto1), is(true));
-    assertThat(dto1.equals(new PurgeableSnapshotDto().setSnapshotId(3L)), is(true));
-    assertThat(dto1.equals("bi_bop_a_lou_la"), is(false));
-    assertThat(dto1.equals(null), is(false));
-  }
-
-  @Test
-  public void testHasCode() {
-    PurgeableSnapshotDto dto = new PurgeableSnapshotDto().setSnapshotId(3L);
-    assertThat(dto.hashCode(), is(dto.hashCode()));
-
-    // no id
-    dto = new PurgeableSnapshotDto();
-    assertThat(dto.hashCode(), is(dto.hashCode()));
-  }
-
-  @Test
-  public void testToString() {
-    PurgeableSnapshotDto dto = new PurgeableSnapshotDto().setSnapshotId(3L);
-    assertThat(dto.toString().length(), greaterThan(0));
-  }
-}
index fc8ff9502b2d4be05b8e53181976e7799198d177..874969873d8e168fed697ed003d8cd111400a0ab 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.purge.PurgeDao;
 import org.sonar.db.purge.PurgeProfiler;
 import org.sonar.db.purge.PurgeSnapshotQuery;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.anyListOf;
@@ -49,7 +49,7 @@ public class DefaultPeriodCleanerTest {
     PurgeDao dao = mock(PurgeDao.class);
     DbSession session = mock(DbSession.class);
     when(dao.selectPurgeableSnapshots("uuid_123", session)).thenReturn(Arrays.asList(
-      new PurgeableSnapshotDto().setSnapshotId(999L).setDate(System2.INSTANCE.now())));
+      new PurgeableAnalysisDto().setAnalysisId(999L).setDate(System2.INSTANCE.now())));
     Filter filter1 = newLazyFilter();
     Filter filter2 = newLazyFilter();
 
@@ -83,7 +83,7 @@ public class DefaultPeriodCleanerTest {
 
   private Filter newLazyFilter() {
     Filter filter1 = mock(Filter.class);
-    when(filter1.filter(anyListOf(PurgeableSnapshotDto.class))).thenAnswer(new Answer<Object>() {
+    when(filter1.filter(anyListOf(PurgeableAnalysisDto.class))).thenAnswer(new Answer<Object>() {
       public Object answer(InvocationOnMock invocation) throws Throwable {
         return invocation.getArguments()[0];
       }
index 904bbdb56ee93df1392bf6440a5a7f1f859391fa..b18da7010d2a841c1197251120707fc6e7c9ddc6 100644 (file)
@@ -24,7 +24,7 @@ import java.util.List;
 import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.db.purge.DbCleanerTestUtils;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -34,12 +34,12 @@ public class DeleteAllFilterTest {
   public void shouldDeleteAllSnapshotsPriorToDate() {
     Filter filter = new DeleteAllFilter(DateUtils.parseDate("2011-12-25"));
 
-    List<PurgeableSnapshotDto> toDelete = filter.filter(Arrays.asList(
+    List<PurgeableAnalysisDto> toDelete = filter.filter(Arrays.asList(
       DbCleanerTestUtils.createSnapshotWithDate(1L, "2010-01-01"),
       DbCleanerTestUtils.createSnapshotWithDate(2L, "2010-12-25"),
       DbCleanerTestUtils.createSnapshotWithDate(3L, "2012-01-01")
       ));
 
-    assertThat(toDelete).extracting("snapshotId").containsOnly(1L, 2L);
+    assertThat(toDelete).extracting("analysisId").containsOnly(1L, 2L);
   }
 }
index 565b8a8491f20f1b692497ff6e3566eaa98f3859..74df21a49ac92e67b5973dfdd5eba1671af1f92e 100644 (file)
@@ -26,10 +26,9 @@ import java.util.List;
 import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.db.purge.DbCleanerTestUtils;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class IntervalTest {
   static int calendarField(Interval interval, int field) {
@@ -37,7 +36,7 @@ public class IntervalTest {
       return -1;
     }
 
-    PurgeableSnapshotDto first = interval.get().iterator().next();
+    PurgeableAnalysisDto first = interval.get().iterator().next();
     GregorianCalendar cal = new GregorianCalendar();
     cal.setTime(first.getDate());
     return cal.get(field);
@@ -45,7 +44,7 @@ public class IntervalTest {
 
   @Test
   public void shouldGroupByIntervals() {
-    List<PurgeableSnapshotDto> snapshots = Arrays.asList(
+    List<PurgeableAnalysisDto> snapshots = Arrays.asList(
       DbCleanerTestUtils.createSnapshotWithDate(1L, "2011-04-03"),
 
       DbCleanerTestUtils.createSnapshotWithDate(2L, "2011-05-01"),
@@ -58,41 +57,41 @@ public class IntervalTest {
       );
 
     List<Interval> intervals = Interval.group(snapshots, DateUtils.parseDate("2010-01-01"), DateUtils.parseDate("2011-12-31"), Calendar.MONTH);
-    assertThat(intervals.size(), is(3));
+    assertThat(intervals.size()).isEqualTo(3);
 
-    assertThat(intervals.get(0).count(), is(1));
-    assertThat(calendarField(intervals.get(0), Calendar.MONTH), is(Calendar.APRIL));
+    assertThat(intervals.get(0).count()).isEqualTo(1);
+    assertThat(calendarField(intervals.get(0), Calendar.MONTH)).isEqualTo((Calendar.APRIL));
 
-    assertThat(intervals.get(1).count(), is(2));
-    assertThat(calendarField(intervals.get(1), Calendar.MONTH), is(Calendar.MAY));
+    assertThat(intervals.get(1).count()).isEqualTo(2);
+    assertThat(calendarField(intervals.get(1), Calendar.MONTH)).isEqualTo((Calendar.MAY));
 
-    assertThat(intervals.get(2).count(), is(2));
-    assertThat(calendarField(intervals.get(2), Calendar.MONTH), is(Calendar.JUNE));
+    assertThat(intervals.get(2).count()).isEqualTo(2);
+    assertThat(calendarField(intervals.get(2), Calendar.MONTH)).isEqualTo((Calendar.JUNE));
   }
 
   @Test
   public void shouldNotJoinMonthsOfDifferentYears() {
-    List<PurgeableSnapshotDto> snapshots = Arrays.asList(
+    List<PurgeableAnalysisDto> snapshots = Arrays.asList(
       DbCleanerTestUtils.createSnapshotWithDate(1L, "2010-04-03"),
       DbCleanerTestUtils.createSnapshotWithDate(2L, "2011-04-13")
       );
 
     List<Interval> intervals = Interval.group(snapshots,
       DateUtils.parseDateTime("2010-01-01T00:00:00+0100"), DateUtils.parseDateTime("2011-12-31T00:00:00+0100"), Calendar.MONTH);
-    assertThat(intervals.size(), is(2));
+    assertThat(intervals.size()).isEqualTo(2);
 
-    assertThat(intervals.get(0).count(), is(1));
-    assertThat(calendarField(intervals.get(0), Calendar.MONTH), is(Calendar.APRIL));
-    assertThat(calendarField(intervals.get(0), Calendar.YEAR), is(2010));
+    assertThat(intervals.get(0).count()).isEqualTo(1);
+    assertThat(calendarField(intervals.get(0), Calendar.MONTH)).isEqualTo((Calendar.APRIL));
+    assertThat(calendarField(intervals.get(0), Calendar.YEAR)).isEqualTo((2010));
 
-    assertThat(intervals.get(1).count(), is(1));
-    assertThat(calendarField(intervals.get(1), Calendar.MONTH), is(Calendar.APRIL));
-    assertThat(calendarField(intervals.get(1), Calendar.YEAR), is(2011));
+    assertThat(intervals.get(1).count()).isEqualTo(1);
+    assertThat(calendarField(intervals.get(1), Calendar.MONTH)).isEqualTo((Calendar.APRIL));
+    assertThat(calendarField(intervals.get(1), Calendar.YEAR)).isEqualTo((2011));
   }
 
   @Test
   public void shouldIgnoreTimeWhenGroupingByIntervals() {
-    List<PurgeableSnapshotDto> snapshots = Arrays.asList(
+    List<PurgeableAnalysisDto> snapshots = Arrays.asList(
       DbCleanerTestUtils.createSnapshotWithDateTime(1L, "2011-05-25T00:16:48+0100"),
       DbCleanerTestUtils.createSnapshotWithDateTime(2L, "2012-01-26T00:16:48+0100"),
       DbCleanerTestUtils.createSnapshotWithDateTime(3L, "2012-01-27T00:16:48+0100")
@@ -101,8 +100,8 @@ public class IntervalTest {
     List<Interval> intervals = Interval.group(snapshots,
       DateUtils.parseDateTime("2011-05-25T00:00:00+0100"),
       DateUtils.parseDateTime("2012-01-26T00:00:00+0100"), Calendar.MONTH);
-    assertThat(intervals.size(), is(1));
-    assertThat(intervals.get(0).count(), is(1));
-    assertThat(intervals.get(0).get().get(0).getSnapshotId(), is(2L));
+    assertThat(intervals.size()).isEqualTo(1);
+    assertThat(intervals.get(0).count()).isEqualTo(1);
+    assertThat(intervals.get(0).get().get(0).getAnalysisId()).isEqualTo((2L));
   }
 }
index b7f20b5f86612468af5bae57f41811df7b6e8627..2f6b2820f366ba936455f789df8b0c9b6598020e 100644 (file)
  */
 package org.sonar.db.purge.period;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.List;
-import javax.annotation.Nullable;
 import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.db.purge.DbCleanerTestUtils;
-import org.sonar.db.purge.PurgeableSnapshotDto;
+import org.sonar.db.purge.PurgeableAnalysisDto;
 
 import static com.google.common.collect.Lists.newArrayList;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class KeepOneFilterTest {
 
-  private static List<Long> snapshotIds(List<PurgeableSnapshotDto> snapshotDtos) {
-    return newArrayList(Iterables.transform(snapshotDtos, new Function<PurgeableSnapshotDto, Long>() {
-      @Override
-      public Long apply(@Nullable PurgeableSnapshotDto input) {
-        return input != null ? input.getSnapshotId() : null;
-      }
-    }));
+  private static List<Long> snapshotIds(List<PurgeableAnalysisDto> snapshotDtos) {
+    return newArrayList(Iterables.transform(snapshotDtos, input -> input == null ? null : input.getAnalysisId()));
   }
 
   @Test
   public void shouldOnlyOneSnapshotPerInterval() {
     Filter filter = new KeepOneFilter(DateUtils.parseDate("2011-03-25"), DateUtils.parseDate("2011-08-25"), Calendar.MONTH, "month");
 
-    List<PurgeableSnapshotDto> toDelete = filter.filter(Arrays.<PurgeableSnapshotDto>asList(
+    List<PurgeableAnalysisDto> toDelete = filter.filter(Arrays.<PurgeableAnalysisDto>asList(
       DbCleanerTestUtils.createSnapshotWithDate(1L, "2010-01-01"), // out of scope -> keep
       DbCleanerTestUtils.createSnapshotWithDate(2L, "2011-05-01"), // may -> keep
       DbCleanerTestUtils.createSnapshotWithDate(3L, "2011-05-02"), // may -> to be deleted
@@ -67,7 +60,7 @@ public class KeepOneFilterTest {
   public void shouldKeepNonDeletableSnapshots() {
     Filter filter = new KeepOneFilter(DateUtils.parseDate("2011-03-25"), DateUtils.parseDate("2011-08-25"), Calendar.MONTH, "month");
 
-    List<PurgeableSnapshotDto> toDelete = filter.filter(Arrays.<PurgeableSnapshotDto>asList(
+    List<PurgeableAnalysisDto> toDelete = filter.filter(Arrays.<PurgeableAnalysisDto>asList(
       DbCleanerTestUtils.createSnapshotWithDate(1L, "2011-05-01"), // to be deleted
       DbCleanerTestUtils.createSnapshotWithDate(2L, "2011-05-02").setLast(true),
       DbCleanerTestUtils.createSnapshotWithDate(3L, "2011-05-19").setHasEvents(true).setLast(false),
index 09070b3b182ba37f25b3cefa0dbb8fe447f555fb..5dd22487230da284bb9c8e60b18fea841259c260 100644 (file)
 <dataset>
 
-  <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            root_uuid="ABCD" uuid="ABCD"
+  <projects long_name="[null]"
+            id="1"
+            scope="PRJ"
+            qualifier="TRK"
+            kee="project"
+            name="project"
+            root_uuid="ABCD"
+            uuid="ABCD"
             description="[null]"
-            enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]"/>
+            enabled="[true]"
+            language="java"
+            copy_component_uuid="[null]"
+            developer_uuid="[null]"/>
 
   <!-- version 1.0 -->
   <snapshots id="1000"
              uuid="u1000"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1225630680000" build_date="1225630680000" version="1.0" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1225630680000"
+             build_date="1225630680000"
+             version="1.0"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- version 1.1 -->
   <snapshots id="1001"
              uuid="u1001"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1225803480000" build_date="1225803480000" version="1.1" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1225803480000"
+             build_date="1225803480000"
+             version="1.1"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- version 1.2-SNAPSHOT -->
   <snapshots id="1002"
              uuid="u1002"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1225976280000" build_date="1225976280000" version="1.2-SNAPSHOT" path=""
-             status="P" islast="[false]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1225976280000"
+             build_date="1225976280000"
+             version="1.2-SNAPSHOT"
+             path=""
+             status="P"
+             islast="[false]"
+             depth="0"/>
 
   <!-- version 1.2-SNAPSHOT, current analysis -->
   <snapshots id="1003"
              uuid="u1003"
-             purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]"
-             period5_param="[null]" period5_date="[null]"
-             component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]"
-             scope="PRJ" qualifier="TRK" created_at="1226235480000" build_date="1226235480000" version="1.2-SNAPSHOT" path=""
-             status="U" islast="[true]" depth="0"/>
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             component_uuid="ABCD"
+             parent_snapshot_id="[null]"
+             root_component_uuid="ABCD"
+             root_snapshot_id="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1226235480000"
+             build_date="1226235480000"
+             version="1.2-SNAPSHOT"
+             path=""
+             status="U"
+             islast="[true]"
+             depth="0"/>
 
-  <events id="1" name="1.0" component_uuid="ABCD" snapshot_id="1000" category="Version" event_date="1225630680000" created_at="1225630680000" description="" event_data="[null]"/>
-  <events id="2" name="Foo" component_uuid="ABCD" snapshot_id="1000" category="Other" event_date="1225717080000" created_at="1225717080000" description="" event_data="[null]"/>
-  <events id="3" name="1.1" component_uuid="ABCD" snapshot_id="1001" category="Version" event_date="1225803480000" created_at="1225803480000" description="" event_data="[null]"/>
-  <events id="4" name="Bar" component_uuid="ABCD" snapshot_id="1001" category="Other" event_date="1225889880000" created_at="1225889880000" description="" event_data="[null]"/>
-  <events id="5" name="Uhh" component_uuid="ABCD" snapshot_id="1002" category="Other" event_date="1226062680000" created_at="1226062680000" description="" event_data="[null]"/>
-  <events id="6" name="1.2-SNAPSHOT" component_uuid="ABCD" snapshot_id="1003" category="Version" event_date="1226235480000" created_at="1226235480000" description=""
+  <events id="1"
+          analysis_uuid="u1000"
+          component_uuid="ABCD"
+          name="1.0"
+          category="Version"
+          event_date="1225630680000"
+          created_at="1225630680000"
+          description=""
+          event_data="[null]"/>
+  <events id="2"
+          analysis_uuid="u1000"
+          component_uuid="ABCD"
+          name="Foo"
+          category="Other"
+          event_date="1225717080000"
+          created_at="1225717080000"
+          description=""
+          event_data="[null]"/>
+  <events id="3"
+          analysis_uuid="u1001"
+          component_uuid="ABCD"
+          name="1.1"
+          category="Version"
+          event_date="1225803480000"
+          created_at="1225803480000"
+          description=""
+          event_data="[null]"/>
+  <events id="4"
+          analysis_uuid="u1001"
+          component_uuid="ABCD"
+          name="Bar"
+          category="Other"
+          event_date="1225889880000"
+          created_at="1225889880000"
+          description=""
+          event_data="[null]"/>
+  <events id="5"
+          analysis_uuid="u1002"
+          component_uuid="ABCD"
+          name="Uhh"
+          category="Other"
+          event_date="1226062680000"
+          created_at="1226062680000"
+          description=""
+          event_data="[null]"/>
+  <events id="6"
+          analysis_uuid="u1003"
+          component_uuid="ABCD"
+          name="1.2-SNAPSHOT"
+          category="Version"
+          event_date="1226235480000"
+          created_at="1226235480000"
+          description=""
           event_data="[null]"/>
 
 </dataset>
index c22a68ed8e0c1ead21953336c5d6adc7694c7c97..d04de02ea4fc535728107d2780f013644d0af884 100644 (file)
@@ -1,6 +1,13 @@
 <dataset>
 
-  <events id="1" name="1.0" category="Version" description="Version 1.0" event_data="some data" event_date="1225630680000"
-          component_uuid="ABCD" snapshot_id="1000" created_at="1225630680000" />
+  <events id="1"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
+          name="1.0"
+          category="Version"
+          description="Version 1.0"
+          event_data="some data"
+          event_date="1225630680000"
+          created_at="1225630680000"/>
 
 </dataset>
index 27a2a24e080fdeac402504eb4ffcc1069fd14b97..e70d018d0d1beffd0acb848630910ef13158088e 100644 (file)
@@ -1,6 +1,13 @@
 <dataset>
 
-  <events id="1" name="1.0" category="Version" description="Version 1.0" event_data="some data" event_date="1413407091086"
-          component_uuid="ABCD" snapshot_id="1000" created_at="1225630680000" />
+  <events id="1"
+          analysis_uuid="uuid_1"
+          component_uuid="ABCD"
+          name="1.0"
+          category="Version"
+          description="Version 1.0"
+          event_data="some data"
+          event_date="1413407091086"
+          created_at="1225630680000"/>
 
 </dataset>
index 0002deec3c29e1b1459e751dbf306f1d2f2d70ff..3e7e6173481a215767181c8800cf33f6dc5876fd 100644 (file)
@@ -1,13 +1,40 @@
 <dataset>
 
-  <events id="1" name="1.0" category="Version" description="Version 1.0" event_data="some data" event_date="1413407091086"
-          component_uuid="ABCD" snapshot_id="1000" created_at="1225630680000" />
-  <events id="2" name="Red (was Orange)" category="Alert" description="Critical issues variation > 0 since previous version (1.0 - 2015 Feb 09), Open issues > 0"
-          event_data="[null]" event_date="1413407091086" component_uuid="ABCD" snapshot_id="1000" created_at="1225630680000" />
-  <events id="3" name="Changes in 'Default' (Java)" category="Profile" description="Version 1.0" event_data="from=2014-10-12T08:36:25+0000;key=java-default;to=2014-10-12T10:36:25+0000"
-          event_date="1413407091086" component_uuid="ABCD" snapshot_id="1000" created_at="1225630680000" />
-
-  <events id="4" name="1.0" category="Version" description="Version 1.0" event_data="some data" event_date="1413407091086"
-          component_uuid="BCDE" snapshot_id="1000" created_at="1225630680000" />
+  <events id="1"
+          name="1.0"
+          category="Version"
+          description="Version 1.0"
+          event_data="some data"
+          event_date="1413407091086"
+          component_uuid="ABCD"
+          analysis_uuid="uuid_1"
+          created_at="1225630680000"/>
+  <events id="2"
+          name="Red (was Orange)"
+          category="Alert"
+          description="Critical issues variation > 0 since previous version (1.0 - 2015 Feb 09), Open issues > 0"
+          event_data="[null]"
+          event_date="1413407091086"
+          component_uuid="ABCD"
+          analysis_uuid="uuid_1"
+          created_at="1225630680000"/>
+  <events id="3"
+          name="Changes in 'Default' (Java)"
+          category="Profile"
+          description="Version 1.0"
+          event_data="from=2014-10-12T08:36:25+0000;key=java-default;to=2014-10-12T10:36:25+0000"
+          event_date="1413407091086"
+          component_uuid="ABCD"
+          analysis_uuid="uuid_1"
+          created_at="1225630680000"/>
+  <events id="4"
+          name="1.0"
+          category="Version"
+          description="Version 1.0"
+          event_data="some data"
+          event_date="1413407091086"
+          component_uuid="BCDE"
+          analysis_uuid="uuid_1"
+          created_at="1225630680000"/>
 
 </dataset>
index eaea6445456f3cea3ba5efb5d9075231f7b823b0..57686c91d82578db33f9f9cf5166a6dbc940b8ae 100644 (file)
@@ -1,41 +1,97 @@
 <dataset>
 
-  <projects id="1" uuid="uuid_1" enabled="[true]" root_uuid="uuid_1"
-            long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_component_uuid="[null]" developer_uuid="[null]"/>
+  <projects id="1"
+            uuid="uuid_1"
+            enabled="[true]"
+            root_uuid="uuid_1"
+            long_name="[null]"
+            scope="PRJ"
+            qualifier="TRK"
+            kee="project"
+            name="project"
+            description="[null]"
+            language="java"
+            copy_component_uuid="[null]"
+            developer_uuid="[null]"/>
 
   <snapshots id="1"
              uuid="u1"
              component_uuid="uuid_1"
-             parent_snapshot_id="[null]" root_component_uuid="uuid_1" root_snapshot_id="[null]"
-             status="P" islast="[false]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
+             parent_snapshot_id="[null]"
+             root_component_uuid="uuid_1"
+             root_snapshot_id="[null]"
+             status="P"
+             islast="[false]"
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
              build_date="1228222680000"
-             version="[null]" path="[null]"/>
+             version="[null]"
+             path="[null]"/>
 
-  <events id="1" name="Version 1.0" component_uuid="uuid_1" snapshot_id="1" category="VERSION" description="[null]"
-          event_date="1228222680000" created_at="1228222680000" event_data="[null]"/>
+  <events id="1"
+          analysis_uuid="u1"
+          component_uuid="uuid_1"
+          name="Version 1.0"
+          category="VERSION"
+          description="[null]"
+          event_date="1228222680000"
+          created_at="1228222680000"
+          event_data="[null]"/>
 
-  <issues id="1" kee="ABCDE" component_uuid="uuid_1" project_uuid="1" status="CLOSED" resolution="[null]" line="200"
+  <issues id="1"
+          kee="ABCDE"
+          component_uuid="uuid_1"
+          project_uuid="1"
+          status="CLOSED"
+          resolution="[null]"
+          line="200"
           severity="BLOCKER"
-          reporter="[null]" assignee="arthur" rule_id="500"
+          reporter="[null]"
+          assignee="arthur"
+          rule_id="500"
           manual_severity="[false]"
           message="[null]"
           issue_creation_date="1366063200000"
           issue_update_date="1366063200000"
           issue_close_date="1366063200000"
           created_at="[null]"
-          updated_at="[null]"
-    />
+          updated_at="[null]"/>
 
-  <issue_changes id="1" kee="ABDA" issue_key="ABCDE" created_at="[null]" updated_at="[null]" user_login="admin"
-                 change_type="comment" change_data="this is a comment"/>
+  <issue_changes id="1"
+                 kee="ABDA"
+                 issue_key="ABCDE"
+                 created_at="[null]"
+                 updated_at="[null]"
+                 user_login="admin"
+                 change_type="comment"
+                 change_data="this is a comment"/>
 
-  <authors id="1" person_id="1" login="tartanpion" created_at="[null]" updated_at="[null]"/>
-  <authors id="2" person_id="1" login="fanfoue" created_at="[null]" updated_at="[null]"/>
+  <authors id="1"
+           person_id="1"
+           login="tartanpion"
+           created_at="[null]"
+           updated_at="[null]"/>
+  <authors id="2"
+           person_id="1"
+           login="fanfoue"
+           created_at="[null]"
+           updated_at="[null]"/>
 </dataset>
index c1ed4d97196a2c39c08594e26042f70b403e01cd..ed1010681e73e2fbc6689646087ac1ad3225c049 100644 (file)
@@ -50,9 +50,9 @@
                     description="[null]"
                     measure_data="[null]"/>
   <events id="1"
-          name="Version 1.0"
+          analysis_uuid="u1"
           component_uuid="1"
-          snapshot_id="1"
+          name="Version 1.0"
           category="VERSION"
           description="[null]"
           event_date="1228222680000"
index a388208c88427ea858cdca897b3345f6f0cbc335..7749f05166803c1e9e596935aa62073ff754d8e9 100644 (file)
@@ -50,9 +50,9 @@
                     description="[null]"
                     measure_data="[null]"/>
   <events id="1"
-          name="Version 1.0"
+          analysis_uuid="u1"
           component_uuid="1"
-          snapshot_id="1"
+          name="Version 1.0"
           category="VERSION"
           description="[null]"
           event_date="1228222680000"
                     description="[null]"
                     measure_data="[null]"/>
   <events id="2"
-          name="Version 1.0"
+          analysis_uuid="u5"
           component_uuid="5"
-          snapshot_id="5"
+          name="Version 1.0"
           category="VERSION"
           description="[null]"
           event_date="1228222680000"
index 1e8f1ef1c1c637335265b3ceb9708456715f73ef..25a719d851a3fb9f27928724dcdcfb8cd97a1179 100644 (file)
@@ -63,8 +63,8 @@ Note that measures, events and reviews are not deleted.
                     measure_data="[null]"/>
 
   <events id="1"
+          analysis_uuid="u1"
           component_uuid="1"
-          snapshot_id="1"
           category="VERSION"
           description="[null]"
           name="Version 1.0"
@@ -128,8 +128,8 @@ Note that measures, events and reviews are not deleted.
                     measure_data="[null]"/>
 
   <events id="2"
+          analysis_uuid="u2"
           component_uuid="2"
-          snapshot_id="2"
           category="VERSION"
           description="[null]"
           name="Version 1.0"
index b218a1369b76e1ee5ad10fbfcdae786692a7cdca..a77b0c19077f829b2f2d56cf3ba92da564bb8727 100644 (file)
@@ -50,8 +50,8 @@
                     measure_data="[null]"/>
 
   <events id="1"
+          analysis_uuid="u1"
           component_uuid="1"
-          snapshot_id="1"
           category="VERSION"
           description="[null]"
           name="Version 1.0"
                     measure_data="[null]"/>
 
   <events id="2"
+          analysis_uuid="u2"
           component_uuid="2"
-          snapshot_id="2"
           category="VERSION"
           description="[null]"
           name="Version 1.0"
index 7f1a90e23b8f655c8655f4766f3f3a025acb98d8..a73d4994ecd4281e47199ae61f525b4f42b56250 100644 (file)
   <!-- last -> select -->
   <snapshots id="1"
              uuid="u1"
-             component_uuid="P1" parent_snapshot_id="[null]" root_component_uuid="P1" root_snapshot_id="[null]"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000"
-             version="[null]" path="[null]"/>
+             component_uuid="P1"
+             parent_snapshot_id="[null]"
+             root_component_uuid="P1"
+             root_snapshot_id="[null]"
+             status="P"
+             islast="[true]"
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
+             build_date="1228222680000"
+             version="[null]"
+             path="[null]"/>
 
   <!-- not processed -> exclude -->
   <snapshots id="2"
              uuid="u2"
-             component_uuid="P1" parent_snapshot_id="[null]" root_component_uuid="P1" root_snapshot_id="[null]"
-             status="U" islast="[false]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000"
-             version="[null]" path="[null]"/>
+             component_uuid="P1"
+             parent_snapshot_id="[null]"
+             root_component_uuid="P1"
+             root_snapshot_id="[null]"
+             status="U"
+             islast="[false]"
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
+             build_date="1228222680000"
+             version="[null]"
+             path="[null]"/>
 
   <!-- on other resource -> exclude -->
   <snapshots id="3"
              uuid="u3"
-             component_uuid="uuid_222" parent_snapshot_id="[null]" root_component_uuid="uuid_222" root_snapshot_id="[null]"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000"
-             version="[null]" path="[null]"/>
+             component_uuid="uuid_222"
+             parent_snapshot_id="[null]"
+             root_component_uuid="uuid_222"
+             root_snapshot_id="[null]"
+             status="P"
+             islast="[true]"
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
+             build_date="1228222680000"
+             version="[null]"
+             path="[null]"/>
 
   <!-- without event -> select -->
   <snapshots id="4"
              uuid="u4"
-             component_uuid="P1" parent_snapshot_id="[null]" root_component_uuid="P1" root_snapshot_id="[null]"
-             status="P" islast="[false]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000"
-             version="[null]" path="[null]"/>
+             component_uuid="P1"
+             parent_snapshot_id="[null]"
+             root_component_uuid="P1"
+             root_snapshot_id="[null]"
+             status="P"
+             islast="[false]"
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
+             build_date="1228222680000"
+             version="[null]"
+             path="[null]"/>
 
   <!-- with event -> select -->
   <snapshots id="5"
              uuid="u5"
-             component_uuid="P1" parent_snapshot_id="[null]" root_component_uuid="P1" root_snapshot_id="[null]"
-             status="P" islast="[false]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000"
-             version="[null]" path="[null]"/>
+             component_uuid="P1"
+             parent_snapshot_id="[null]"
+             root_component_uuid="P1"
+             root_snapshot_id="[null]"
+             status="P"
+             islast="[false]"
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
+             build_date="1228222680000"
+             version="[null]"
+             path="[null]"/>
 
-  <events id="2" component_uuid="1" snapshot_id="5"
-          category="Version" description="[null]" name="Version 1.0" event_date="1228222680000"
+  <events id="2"
+          analysis_uuid="u5"
+          component_uuid="1"
+          category="Version"
+          description="[null]"
+          name="Version 1.0"
+          event_date="1228222680000"
           created_at="1228222680000"
           event_data="[null]"/>