From: Simon Brandhof Date: Tue, 12 Jul 2011 15:29:09 +0000 (+0200) Subject: SONAR-2610 Replace the table ASYNC_MEASURES_SNAPSHOTS by MANUAL_MEASURES X-Git-Tag: 2.10~162 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=13963270280fc022c083d54a6e3105c1da0f1c2f;p=sonarqube.git SONAR-2610 Replace the table ASYNC_MEASURES_SNAPSHOTS by MANUAL_MEASURES --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 76c1bdf43dc..5b4358eb5cb 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -183,7 +183,6 @@ public class CorePlugin extends SonarPlugin { extensions.add(RulesWidget.class); extensions.add(SizeWidget.class); extensions.add(EventsWidget.class); - extensions.add(CustomMeasuresWidget.class); // chart extensions.add(XradarChart.class); @@ -197,7 +196,6 @@ public class CorePlugin extends SonarPlugin { extensions.add(ProfileSensor.class); extensions.add(ProfileEventsSensor.class); extensions.add(ProjectLinksSensor.class); - extensions.add(AsynchronousMeasuresSensor.class); extensions.add(UnitTestDecorator.class); extensions.add(VersionEventsSensor.class); extensions.add(CheckAlertThresholds.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AsynchronousMeasuresSensor.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AsynchronousMeasuresSensor.java deleted file mode 100644 index 3a23449aec9..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AsynchronousMeasuresSensor.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.sensors; - -import org.sonar.api.batch.Phase; -import org.sonar.api.batch.Sensor; -import org.sonar.api.batch.SensorContext; -import org.sonar.core.NotDryRun; -import org.sonar.jpa.dao.AsyncMeasuresService; -import org.sonar.api.database.model.Snapshot; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.ResourceUtils; - -@NotDryRun -@Phase(name = Phase.Name.PRE) -public class AsynchronousMeasuresSensor implements Sensor { - - private AsyncMeasuresService reviewsService; - private Snapshot snapshot; - - public AsynchronousMeasuresSensor(AsyncMeasuresService reviewsService, Snapshot snapshot) { - this.reviewsService = reviewsService; - this.snapshot = snapshot; - } - - public boolean shouldExecuteOnProject(Project project) { - return true; - } - - public void analyse(Project project, SensorContext context) { - if (!ResourceUtils.isRootProject(project)) { - return; - } - reviewsService.refresh(snapshot); - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CustomMeasuresWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CustomMeasuresWidget.java deleted file mode 100644 index 5bb3525a3fd..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CustomMeasuresWidget.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.widgets; - -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.Description; -import org.sonar.api.web.RubyRailsWidget; - -@Description("Displays manual measures entered on the project.") -public class CustomMeasuresWidget extends AbstractRubyTemplate implements RubyRailsWidget { - public String getId() { - return "custom_measures"; - } - - public String getTitle() { - return "Custom measures"; - } - - @Override - protected String getTemplatePath() { - return "/org/sonar/plugins/core/widgets/custom_measures.html.erb"; - } -} \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb deleted file mode 100644 index d53de7b202d..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb +++ /dev/null @@ -1,68 +0,0 @@ - <% - measures = @snapshot.async_measures.select{ |m| - m.metric and m.metric.enabled==true and m.metric.user_managed? - }.sort{ |m1,m2| - m1.metric.name <=> m2.metric.name - } - %> - <% if is_admin?(@snapshot) || measures.size>0 %> - - <% - measures.each do |m| - html_name_id = "review_name_#{m.metric.short_name}" - html_value_id = "review_value_#{m.metric.short_name}" - html_date_id = "review_date_#{m.metric.short_name}" - %> -
-

<%= m.metric.short_name %>

-

- <%= format_measure(m, :suffix => '', :url => m.url) -%> -

- <% if m.measure_date %> -

<%= l(m.measure_date.to_date) %> - <% if m.review? && is_admin?(@snapshot) %> - <%= link_to 'delete', - {:controller => 'project', :action => 'delete_review', :id => m.id, :sid => @snapshot.id}, :method => 'delete', :confirm => 'Delete this measure ?', - :class => 'action', :id => "delete_review_#{m.metric_key}" %> - <% end %> -

- <% end %> - <% unless m.description.blank? %> -

<%= m.description %>

- <% end %> -
- <% end %> - <% if is_admin?(@snapshot) %> -
-

- <% if @review %> - <%= render :partial => 'dashboard_edit_review' %> - <% else %> - <%= link_to_remote 'Add a measure', - {:url => {:controller => 'project', :action => 'edit_review', :sid => @snapshot.id}, :update => 'add_review_form'}, - {:class => 'action', :id => 'add_review'} %> - <% end %> -

-
- <% end %> -
- <% end %> diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java index 532848bb4f2..c54b8d6d126 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java @@ -82,8 +82,6 @@ public class ProjectModule extends Module { addComponent(TimeMachineConfiguration.class); addComponent(org.sonar.api.database.daos.MeasuresDao.class); addComponent(ProfilesDao.class); - addComponent(AsyncMeasuresDao.class); - addComponent(AsyncMeasuresService.class); addComponent(DefaultRulesManager.class); addComponent(DefaultSensorContext.class); addComponent(Languages.class); diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/AsyncMeasuresDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/AsyncMeasuresDao.java deleted file mode 100644 index 5f09d281a97..00000000000 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/AsyncMeasuresDao.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.jpa.dao; - -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.AsyncMeasureSnapshot; -import org.sonar.api.database.model.MeasureModel; -import org.sonar.api.database.model.ResourceModel; -import org.sonar.api.database.model.Snapshot; - -import javax.persistence.NoResultException; -import javax.persistence.Query; -import java.util.Date; -import java.util.List; - -public class AsyncMeasuresDao extends BaseDao { - - public AsyncMeasuresDao(DatabaseSession session) { - super(session); - } - - public MeasureModel getAsyncMeasure(Long asyncMeasureId) { - return getSession().getEntityManager().find(MeasureModel.class, asyncMeasureId); - } - - public void deleteAsyncMeasure(MeasureModel asyncMeasure) { - deleteAsyncMeasureSnapshots(asyncMeasure.getId()); - getSession().remove(asyncMeasure); - } - - public Snapshot getPreviousSnapshot(Snapshot s) { - try { - return (Snapshot) getSession().createQuery( - "SELECT s FROM Snapshot s " + - "WHERE s.createdAt<:date " + - "AND s.scope=:scope " + - "AND s.resourceId=:resourceId " + - "ORDER BY s.createdAt DESC") - .setParameter("date", s.getCreatedAt()) - .setParameter("scope", s.getScope()) - .setParameter("resourceId", s.getResourceId()) - .setMaxResults(1) - .getSingleResult(); - } catch (NoResultException ex) { - return null; - } - } - - public List getNextSnapshotsUntilDate(MeasureModel measure, Date date) { - Query query = getSession().createQuery( - "SELECT s FROM Snapshot s " + - "WHERE s.resourceId=:projectId " + - "AND s.createdAt>=:beginDate " + - (date != null ? "AND s.createdAt<:endDate " : "") + - "AND s.scope=:scope " + - "ORDER BY s.createdAt ASC ") - .setParameter("projectId", measure.getProjectId()) - .setParameter("beginDate", measure.getMeasureDate()) - .setParameter("scope", ResourceModel.SCOPE_PROJECT); - if (date != null) { - query.setParameter("endDate", date); - } - return query.getResultList(); - } - - public AsyncMeasureSnapshot createAsyncMeasureSnapshot(Long asyncMeasureId, Integer snapshotId, Date AsyncMeasureDate, Date snapshotDate, Integer metricId, Integer projectId) { - AsyncMeasureSnapshot asyncMeasureSnapshot = new AsyncMeasureSnapshot(asyncMeasureId, snapshotId, AsyncMeasureDate, snapshotDate, metricId, projectId); - getSession().save(asyncMeasureSnapshot); - return asyncMeasureSnapshot; - } - - public void updateAsyncMeasureSnapshot(AsyncMeasureSnapshot asyncMeasureSnapshot, Snapshot snapshot) { - if (snapshot != null) { - asyncMeasureSnapshot.setSnapshotId(snapshot.getId()); - asyncMeasureSnapshot.setSnapshotDate(snapshot.getCreatedAt()); - } else { - asyncMeasureSnapshot.setSnapshotId(null); - asyncMeasureSnapshot.setSnapshotDate(null); - } - getSession().merge(asyncMeasureSnapshot); - } - - public void removeSnapshotFromAsyncMeasureSnapshot(AsyncMeasureSnapshot asyncMeasureSnapshot) { - asyncMeasureSnapshot.setSnapshotId(null); - asyncMeasureSnapshot.setSnapshotDate(null); - getSession().merge(asyncMeasureSnapshot); - } - - - public AsyncMeasureSnapshot getNextAsyncMeasureSnapshot(Integer projetcId, Integer metricId, Date date) { - try { - return (AsyncMeasureSnapshot) getSession().createQuery( - "SELECT ams FROM AsyncMeasureSnapshot ams " + - "WHERE ams.projectId=:projectId " + - "AND ams.metricId=:metricId " + - "AND ams.measureDate>:date " + - "ORDER BY ams.measureDate ASC") - .setParameter("projectId", projetcId) - .setParameter("metricId", metricId) - .setParameter("date", date) - .setMaxResults(1) - .getSingleResult(); - } catch (NoResultException ex) { - return null; - } - } - - public List getNextAsyncMeasureSnapshotsUntilDate(MeasureModel asyncMeasure, Date endDate) { - Query query = getSession().createQuery( - "SELECT ams FROM AsyncMeasureSnapshot ams " + - "WHERE ams.projectId=:projectId " + - "AND ams.metricId=:metricId " + - (endDate != null ? "AND ams.measureDate<:endDate " : "") + - "AND ams.snapshotDate>=:measureDate " + - "ORDER BY ams.snapshotDate ASC ") - .setParameter("projectId", asyncMeasure.getProjectId()) - .setParameter("metricId", asyncMeasure.getMetricId()) - .setParameter("measureDate", asyncMeasure.getMeasureDate()); - if (endDate != null) { - query.setParameter("endDate", endDate); - } - return query.getResultList(); - } - - public List getPreviousAsyncMeasureSnapshots(Integer projectId, Date beginDate, Date endDate) { - Query query = getSession().createQuery( - "SELECT ams FROM AsyncMeasureSnapshot ams " + - "WHERE ams.projectId=:projectId " + - "AND ams.measureDate<=:endDate " + - (beginDate != null ? "AND ams.measureDate>:beginDate " : "") + - "AND ams.snapshotId IS NULL " + - "ORDER BY ams.measureDate ASC") - .setParameter("projectId", projectId) - .setParameter("endDate", endDate); - if (beginDate != null) { - query.setParameter("beginDate", beginDate); - } - return query.getResultList(); - } - - public List getAsyncMeasureSnapshotsFromSnapshotId(Integer snapshotId, List metricIdsToExclude) { - Query query = getSession().createQuery( - "SELECT ams FROM AsyncMeasureSnapshot ams " + - "WHERE ams.snapshotId=:snapshotId " + - (!metricIdsToExclude.isEmpty() ? "AND ams.metricId NOT IN (:metricIdsToExclude) " : "") + - "ORDER BY ams.measureDate ASC") - .setParameter("snapshotId", snapshotId); - if (!metricIdsToExclude.isEmpty()) { - query.setParameter("metricIdsToExclude", metricIdsToExclude); - } - return query.getResultList(); - } - - public AsyncMeasureSnapshot getLastAsyncMeasureSnapshot(Integer projetcId, Integer metricId, Date date) { - try { - return (AsyncMeasureSnapshot) getSession().createQuery( - "SELECT ams FROM AsyncMeasureSnapshot ams " + - "WHERE ams.projectId=:projectId " + - "AND ams.metricId=:metricId " + - "AND ams.measureDate<:date " + - "ORDER BY ams.measureDate DESC") - .setParameter("projectId", projetcId) - .setParameter("metricId", metricId) - .setParameter("date", date) - .setMaxResults(1) - .getSingleResult(); - } catch (NoResultException ex) { - return null; - } - } - - public void deleteAsyncMeasureSnapshots(Long asyncMeasureId) { - getSession().createQuery( - "DELETE FROM AsyncMeasureSnapshot ams WHERE ams.measureId=:measureId") - .setParameter("measureId", asyncMeasureId) - .executeUpdate(); - } - -} diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/AsyncMeasuresService.java b/sonar-core/src/main/java/org/sonar/jpa/dao/AsyncMeasuresService.java deleted file mode 100644 index e985ee3c614..00000000000 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/AsyncMeasuresService.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.jpa.dao; - -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.AsyncMeasureSnapshot; -import org.sonar.api.database.model.MeasureModel; -import org.sonar.api.database.model.Snapshot; - -import java.util.*; - -public class AsyncMeasuresService { - private final DatabaseSession session; - - public AsyncMeasuresService(DatabaseSession session) { - this.session = session; - } - - public void refresh(Snapshot snapshot) { - AsyncMeasuresDao dao = new AsyncMeasuresDao(session); - Snapshot previousSnapshot = dao.getPreviousSnapshot(snapshot); - Date datePreviousSnapshot = (previousSnapshot != null ? previousSnapshot.getCreatedAt() : null); - - List previousAsyncMeasureSnapshots = dao.getPreviousAsyncMeasureSnapshots( - snapshot.getResourceId(), datePreviousSnapshot, snapshot.getCreatedAt()); - if (previousSnapshot != null) { - previousAsyncMeasureSnapshots.addAll(dao.getAsyncMeasureSnapshotsFromSnapshotId( - previousSnapshot.getId(), getMetricIds(previousAsyncMeasureSnapshots))); - } - - for (AsyncMeasureSnapshot asyncMeasureSnapshot : purge(previousAsyncMeasureSnapshots)) { - if (asyncMeasureSnapshot.getSnapshotId() == null) { - dao.updateAsyncMeasureSnapshot(asyncMeasureSnapshot, snapshot); - } else { - dao.createAsyncMeasureSnapshot( - asyncMeasureSnapshot.getMeasureId(), snapshot.getId(), asyncMeasureSnapshot.getMeasureDate(), - snapshot.getCreatedAt(), asyncMeasureSnapshot.getMetricId(), asyncMeasureSnapshot.getProjectId()); - } - } - session.commit(); - } - - public void registerMeasure(Long id) { - AsyncMeasuresDao dao = new AsyncMeasuresDao(session); - registerMeasure(dao.getAsyncMeasure(id), dao); - } - - private List getMetricIds(List list) { - List ids = new ArrayList(); - for (AsyncMeasureSnapshot ams : list) { - ids.add(ams.getMetricId()); - } - return ids; - } - - private Collection purge(List list) { - Map measuresById = new LinkedHashMap(); - for (AsyncMeasureSnapshot currentAsyncMeasureSnapshot : list) { - AsyncMeasureSnapshot asyncMeasureSnapshotFromMap = measuresById.get(currentAsyncMeasureSnapshot.getMetricId()); - if (asyncMeasureSnapshotFromMap != null) { - if (asyncMeasureSnapshotFromMap.getMeasureDate().before(currentAsyncMeasureSnapshot.getMeasureDate())) { - measuresById.put(currentAsyncMeasureSnapshot.getMetricId(), currentAsyncMeasureSnapshot); - } - } else { - measuresById.put(currentAsyncMeasureSnapshot.getMetricId(), currentAsyncMeasureSnapshot); - } - } - return measuresById.values(); - } - - - public void deleteMeasure(Long id) { - AsyncMeasuresDao dao = new AsyncMeasuresDao(session); - MeasureModel measure = dao.getAsyncMeasure(id); - AsyncMeasureSnapshot pastAsyncMeasureSnapshot = dao.getLastAsyncMeasureSnapshot(measure.getProjectId(), - measure.getMetricId(), measure.getMeasureDate()); - dao.deleteAsyncMeasure(measure); - if (pastAsyncMeasureSnapshot != null) { - MeasureModel pastAsyncMeasure = dao.getAsyncMeasure(pastAsyncMeasureSnapshot.getMeasureId()); - dao.deleteAsyncMeasureSnapshots(pastAsyncMeasureSnapshot.getMeasureId()); - registerMeasure(pastAsyncMeasure, dao); - } - session.commit(); - } - - private void registerMeasure(MeasureModel measure, AsyncMeasuresDao dao) { - AsyncMeasureSnapshot nextAsyncMeasureSnapshot = dao.getNextAsyncMeasureSnapshot( - measure.getProjectId(), measure.getMetricId(), measure.getMeasureDate()); - Date dateNextAsyncMeasure = (nextAsyncMeasureSnapshot != null) ? nextAsyncMeasureSnapshot.getMeasureDate() : null; - - List nextAsyncMeasureSnapshots = dao.getNextAsyncMeasureSnapshotsUntilDate( - measure, dateNextAsyncMeasure); - if (!nextAsyncMeasureSnapshots.isEmpty()) { - for (AsyncMeasureSnapshot asyncMeasureSnapshot : nextAsyncMeasureSnapshots) { - dao.createAsyncMeasureSnapshot(measure.getId(), asyncMeasureSnapshot.getSnapshotId(), measure.getMeasureDate(), - asyncMeasureSnapshot.getSnapshotDate(), measure.getMetricId(), measure.getProjectId()); - dao.removeSnapshotFromAsyncMeasureSnapshot(asyncMeasureSnapshot); - } - } else { - List nextSnapshotsUntilDate = dao.getNextSnapshotsUntilDate(measure, dateNextAsyncMeasure); - if (!nextSnapshotsUntilDate.isEmpty()) { - for (Snapshot nextSnapshot : nextSnapshotsUntilDate) { - dao.createAsyncMeasureSnapshot(measure.getId(), nextSnapshot.getId(), measure.getMeasureDate(), - nextSnapshot.getCreatedAt(), measure.getMetricId(), measure.getProjectId()); - } - } else { - dao.createAsyncMeasureSnapshot(measure.getId(), null, measure.getMeasureDate(), - null, measure.getMetricId(), measure.getProjectId()); - } - } - } - -} \ No newline at end of file diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/DaoFacade.java b/sonar-core/src/main/java/org/sonar/jpa/dao/DaoFacade.java index fad86b13ce3..462f8752a81 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/DaoFacade.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dao/DaoFacade.java @@ -23,14 +23,12 @@ public class DaoFacade { private final RulesDao rulesDao; private final MeasuresDao measuresDao; - private final AsyncMeasuresDao asyncMeasureDao; private final ProfilesDao profilesDao; - public DaoFacade(ProfilesDao profilesDao, RulesDao rulesDao, MeasuresDao measuresDao, AsyncMeasuresDao asyncMeasureDao) { + public DaoFacade(ProfilesDao profilesDao, RulesDao rulesDao, MeasuresDao measuresDao) { super(); this.rulesDao = rulesDao; this.measuresDao = measuresDao; - this.asyncMeasureDao = asyncMeasureDao; this.profilesDao = profilesDao; } @@ -45,9 +43,4 @@ public class DaoFacade { public MeasuresDao getMeasuresDao() { return measuresDao; } - - public AsyncMeasuresDao getAsyncMeasureDao() { - return asyncMeasureDao; - } - } diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java index 83e0774bcd7..0a9a08813a0 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java +++ b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java @@ -40,7 +40,7 @@ public class SchemaMigration { - complete the Derby DDL file used for unit tests : sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl */ - public static final int LAST_VERSION = 210; + public static final int LAST_VERSION = 213; public final static String TABLE_NAME = "schema_migrations"; diff --git a/sonar-core/src/main/resources/META-INF/persistence.xml b/sonar-core/src/main/resources/META-INF/persistence.xml index 276b3f21cd9..a4a8d36b3e4 100644 --- a/sonar-core/src/main/resources/META-INF/persistence.xml +++ b/sonar-core/src/main/resources/META-INF/persistence.xml @@ -29,7 +29,6 @@ org.sonar.api.profiles.RulesProfile org.sonar.api.rules.ActiveRule org.sonar.api.rules.ActiveRuleParam - org.sonar.api.database.model.AsyncMeasureSnapshot org.sonar.api.batch.Event org.sonar.api.profiles.Alert org.sonar.api.rules.ActiveRuleChange diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/AsyncMeasuresDaoTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/AsyncMeasuresDaoTest.java deleted file mode 100644 index ea86260a583..00000000000 --- a/sonar-core/src/test/java/org/sonar/jpa/dao/AsyncMeasuresDaoTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.jpa.dao; - -import org.junit.Test; -import org.sonar.api.database.model.AsyncMeasureSnapshot; -import org.sonar.api.database.model.MeasureModel; -import org.sonar.api.database.model.ResourceModel; -import org.sonar.api.database.model.Snapshot; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class AsyncMeasuresDaoTest extends AbstractDbUnitTestCase { - - private static final int PROJECT_ID = 1; - private static final int METRIC_ID = 1; - - @Test - public void testGetNextAsyncMeasureSnapshot() { - setupData("sharedFixture", "testGetNextAsyncMeasureSnapshot"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - AsyncMeasureSnapshot asyncMeasure = asyncMeasuresDao.getNextAsyncMeasureSnapshot( - PROJECT_ID, METRIC_ID, stringToDate("2008-12-04 08:00:00.00")); - - assertThat(asyncMeasure.getId(), is(3)); - } - - @Test - public void testGetNextSnapshotsUntilDate() { - setupData("sharedFixture", "testGetNextSnapshotsUntilDate"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 1l); - List snapshotIds = asyncMeasuresDao.getNextSnapshotsUntilDate( - asyncMeasure, stringToDate("2008-12-06 12:00:00.00")); - - assertThat(snapshotIds.size(), is(2)); - assertThat(snapshotIds.get(0).getId(), is(2)); - assertThat(snapshotIds.get(1).getId(), is(4)); - } - - @Test - public void testGetPreviousSnapshot() { - setupData("sharedFixture", "testGetPreviousSnapshot"); - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - Snapshot s = new Snapshot(); - s.setCreatedAt(stringToDate("2008-12-04 08:00:00.00")); - s.setScope(ResourceModel.SCOPE_PROJECT); - ResourceModel resource1 = getSession().getEntity(ResourceModel.class, 1); - ResourceModel resource2 = getSession().getEntity(ResourceModel.class, 2); - - s.setResource(resource1); - assertThat(asyncMeasuresDao.getPreviousSnapshot(s).getId(), is(1)); - - s.setResource(resource2); - assertThat(asyncMeasuresDao.getPreviousSnapshot(s).getId(), is(5)); - } - - @Test - public void testGetNextAsyncMeasureSnapshotsUntilDate() { - setupData("sharedFixture", "testGetNextAsyncMeasureSnapshotsUntilDate"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 3l); - List asyncMeasureSnapshots = asyncMeasuresDao.getNextAsyncMeasureSnapshotsUntilDate( - asyncMeasure, stringToDate("2008-12-06 08:00:00.00")); - - assertThat(asyncMeasureSnapshots.size(), is(2)); - assertThat(asyncMeasureSnapshots.get(0).getId(), is(2)); - assertThat(asyncMeasureSnapshots.get(1).getId(), is(3)); - } - - @Test - public void testDeleteAsyncMeasure() { - setupData("sharedFixture", "testDeleteAsyncMeasure"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 1l); - asyncMeasuresDao.deleteAsyncMeasure(asyncMeasure); - - getSession().commit(); - checkTables("testDeleteAsyncMeasure", "project_measures", "async_measure_snapshots"); - } - - @Test - public void testGetAsyncMeasureSnapshotsFromSnapshotId() { - setupData("sharedFixture", "testGetAsyncMeasureSnapshotsFromSnapshotId"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - Integer snapshotId = 1; - List asyncMeasureSnapshots = asyncMeasuresDao.getAsyncMeasureSnapshotsFromSnapshotId( - snapshotId, Arrays.asList(1)); - assertThat(asyncMeasureSnapshots.size(), is(1)); - assertThat(asyncMeasureSnapshots.get(0).getId(), is(2)); - } - - @Test - public void testGetLastAsyncMeasureSnapshot() { - setupData("sharedFixture", "testGetLastAsyncMeasureSnapshot"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - AsyncMeasureSnapshot asyncMeasureSnapshot = asyncMeasuresDao.getLastAsyncMeasureSnapshot( - PROJECT_ID, METRIC_ID, stringToDate("2008-12-04 12:00:00.00")); - assertThat(asyncMeasureSnapshot.getId(), is(2)); - } - - @Test - public void testDeleteAsyncMeasureSnapshots() { - setupData("sharedFixture", "testDeleteAsyncMeasureSnapshots"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - asyncMeasuresDao.deleteAsyncMeasureSnapshots(1l); - - checkTables("testDeleteAsyncMeasureSnapshots", "async_measure_snapshots"); - } - - @Test - public void testGetPreviousAsyncMeasureSnapshots() { - setupData("sharedFixture", "testGetPreviousAsyncMeasureSnapshots"); - - AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession()); - List asyncMeasureSnapshots = asyncMeasuresDao.getPreviousAsyncMeasureSnapshots( - PROJECT_ID, stringToDate("2008-12-04 08:00:00.00"), stringToDate("2008-12-08 08:00:00.00")); - assertThat(asyncMeasureSnapshots.size(), is(2)); - assertThat(asyncMeasureSnapshots.get(0).getId(), is(5)); - assertThat(asyncMeasureSnapshots.get(1).getId(), is(6)); - } - - - private static Date stringToDate(String sDate) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS"); - try { - return sdf.parse(sDate); - } catch (ParseException e) { - throw new RuntimeException("Bad date format."); - } - } - -} diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/AsyncMeasuresServiceTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/AsyncMeasuresServiceTest.java deleted file mode 100644 index 7b936b5ee9f..00000000000 --- a/sonar-core/src/test/java/org/sonar/jpa/dao/AsyncMeasuresServiceTest.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.jpa.dao; - -import org.junit.Test; -import org.sonar.api.database.model.Snapshot; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - -public class AsyncMeasuresServiceTest extends AbstractDbUnitTestCase { - - @Test - public void assignLatestMeasuresToLastSnapshot() { - setupData("sharedFixture", "assignLatestMeasuresToLastSnapshot"); - - AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession()); - Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 2); - asyncMeasuresService.refresh(snapshot); - - checkTables("assignLatestMeasuresToLastSnapshot", "async_measure_snapshots"); - } - - @Test - public void assignNewMeasuresToLastSnapshot() { - setupData("sharedFixture", "assignNewMeasuresToLastSnapshot"); - - AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession()); - Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 2); - asyncMeasuresService.refresh(snapshot); - - checkTables("assignNewMeasuresToLastSnapshot", "async_measure_snapshots"); - } - - @Test - public void assignMeasuresWhenNoPreviousSnapshot() { - setupData("sharedFixture", "assignMeasuresWhenNoPreviousSnapshot"); - - AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession()); - Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 1); - asyncMeasuresService.refresh(snapshot); - - checkTables("assignMeasuresWhenNoPreviousSnapshot", "async_measure_snapshots"); - } - - @Test - public void assignLatestMeasuresWhenNoPreviousSnapshot() { - setupData("sharedFixture", "assignLatestMeasuresWhenNoPreviousSnapshot"); - - AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession()); - Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 1); - asyncMeasuresService.refresh(snapshot); - - checkTables("assignLatestMeasuresWhenNoPreviousSnapshot", "async_measure_snapshots"); - } - - @Test - public void assignPastMeasuresToPastSnapshot() { - setupData("sharedFixture", "assignPastMeasuresToPastSnapshot"); - - AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession()); - Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 3); - asyncMeasuresService.refresh(snapshot); - - checkTables("assignPastMeasuresToPastSnapshot", "async_measure_snapshots"); - } - - @Test - public void assignNewMeasureToFutureSnapshots() { - setupData("sharedFixture", "assignNewMeasureToFutureSnapshots"); - - AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession()); - asyncMeasuresService.registerMeasure(2l); - - checkTables("assignNewMeasureToFutureSnapshots", "async_measure_snapshots"); - } - - @Test - public void assignMeasureToFutureSnapshotsWithDifferentMetric() { - setupData("sharedFixture", "assignMeasureToFutureSnapshotsWithDifferentMetric"); - - AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession()); - asyncMeasureService.registerMeasure(3l); - - checkTables("assignMeasureToFutureSnapshotsWithDifferentMetric", "async_measure_snapshots"); - } - - @Test - public void assignAPastMeasureToNextSnapshotsWithDifferentMetric() { - setupData("sharedFixture", "assignAPastMeasureToNextSnapshotsWithDifferentMetric"); - - AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession()); - asyncMeasureService.registerMeasure(2l); - - checkTables("assignAPastMeasureToNextSnapshotsWithDifferentMetric", "async_measure_snapshots"); - } - - @Test - public void addFutureSnapshot() { - setupData("sharedFixture", "addFutureSnapshot"); - - AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession()); - asyncMeasureService.registerMeasure(2l); - - checkTables("addFutureSnapshot", "async_measure_snapshots"); - } - - @Test - public void addInvisibleMeasure() { - setupData("sharedFixture", "addInvisibleMeasure"); - - AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession()); - asyncMeasureService.registerMeasure(2l); - - checkTables("addInvisibleMeasure", "async_measure_snapshots"); - } - - @Test - public void deleteMeasure() { - setupData("sharedFixture", "deleteMeasure"); - - AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession()); - asyncMeasureService.deleteMeasure(2l); - - checkTables("deleteMeasure", "async_measure_snapshots"); - } - - @Test - public void deleteLastMeasure() { - setupData("sharedFixture", "deleteLastMeasure"); - - AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession()); - asyncMeasureService.deleteMeasure(1l); - - checkTables("deleteLastMeasure", "async_measure_snapshots"); - } - -} diff --git a/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java b/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java index 834657bb7f9..d8f23f16b50 100644 --- a/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java +++ b/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java @@ -82,7 +82,7 @@ public abstract class AbstractDbUnitTestCase { public DaoFacade getDao() { if (dao == null) { - dao = new DaoFacade(new ProfilesDao(session), new RulesDao(session), new MeasuresDao(session), new AsyncMeasuresDao(session)); + dao = new DaoFacade(new ProfilesDao(session), new RulesDao(session), new MeasuresDao(session)); } return dao; } diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/sharedFixture.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/sharedFixture.xml deleted file mode 100644 index c748a030e3a..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/sharedFixture.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasure-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasure-result.xml deleted file mode 100644 index 1905e69d94e..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasure-result.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasure.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasure.xml deleted file mode 100644 index a31a3a3103f..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasure.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasureSnapshots-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasureSnapshots-result.xml deleted file mode 100644 index a9371f88cc4..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasureSnapshots-result.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasureSnapshots.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasureSnapshots.xml deleted file mode 100644 index cf0a5f96390..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testDeleteAsyncMeasureSnapshots.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetAsyncMeasureSnapshotsFromSnapshotId.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetAsyncMeasureSnapshotsFromSnapshotId.xml deleted file mode 100644 index f83aff294c3..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetAsyncMeasureSnapshotsFromSnapshotId.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetLastAsyncMeasureSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetLastAsyncMeasureSnapshot.xml deleted file mode 100644 index c449c6eef14..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetLastAsyncMeasureSnapshot.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextAsyncMeasureSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextAsyncMeasureSnapshot.xml deleted file mode 100644 index baba9aad126..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextAsyncMeasureSnapshot.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextAsyncMeasureSnapshotsUntilDate.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextAsyncMeasureSnapshotsUntilDate.xml deleted file mode 100644 index ff8b246f66b..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextAsyncMeasureSnapshotsUntilDate.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextSnapshotsUntilDate.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextSnapshotsUntilDate.xml deleted file mode 100644 index 096f1983d3b..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetNextSnapshotsUntilDate.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetPreviousAsyncMeasureSnapshots.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetPreviousAsyncMeasureSnapshots.xml deleted file mode 100644 index a268b957d61..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetPreviousAsyncMeasureSnapshots.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetPreviousSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetPreviousSnapshot.xml deleted file mode 100644 index 115b532c994..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresDaoTest/testGetPreviousSnapshot.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addFutureSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addFutureSnapshot-result.xml deleted file mode 100644 index 7a12ccd2074..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addFutureSnapshot-result.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addFutureSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addFutureSnapshot.xml deleted file mode 100644 index 4c2bea917dd..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addFutureSnapshot.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addInvisibleMeasure-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addInvisibleMeasure-result.xml deleted file mode 100644 index f10b82f86cd..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addInvisibleMeasure-result.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addInvisibleMeasure.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addInvisibleMeasure.xml deleted file mode 100644 index bca00e33772..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/addInvisibleMeasure.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignAPastMeasureToNextSnapshotsWithDifferentMetric-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignAPastMeasureToNextSnapshotsWithDifferentMetric-result.xml deleted file mode 100644 index 7d20af58577..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignAPastMeasureToNextSnapshotsWithDifferentMetric-result.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignAPastMeasureToNextSnapshotsWithDifferentMetric.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignAPastMeasureToNextSnapshotsWithDifferentMetric.xml deleted file mode 100644 index 74d8837d110..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignAPastMeasureToNextSnapshotsWithDifferentMetric.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresToLastSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresToLastSnapshot-result.xml deleted file mode 100644 index d881a39193f..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresToLastSnapshot-result.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresToLastSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresToLastSnapshot.xml deleted file mode 100644 index 13c290cb14d..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresToLastSnapshot.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresWhenNoPreviousSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresWhenNoPreviousSnapshot-result.xml deleted file mode 100644 index 99475dfb9d1..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresWhenNoPreviousSnapshot-result.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresWhenNoPreviousSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresWhenNoPreviousSnapshot.xml deleted file mode 100644 index 7ea8aa5fbaa..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignLatestMeasuresWhenNoPreviousSnapshot.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasureToFutureSnapshotsWithDifferentMetric-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasureToFutureSnapshotsWithDifferentMetric-result.xml deleted file mode 100644 index d2b62cbf6d8..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasureToFutureSnapshotsWithDifferentMetric-result.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasureToFutureSnapshotsWithDifferentMetric.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasureToFutureSnapshotsWithDifferentMetric.xml deleted file mode 100644 index 9d343211f29..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasureToFutureSnapshotsWithDifferentMetric.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasuresWhenNoPreviousSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasuresWhenNoPreviousSnapshot-result.xml deleted file mode 100644 index f8df127f391..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasuresWhenNoPreviousSnapshot-result.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasuresWhenNoPreviousSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasuresWhenNoPreviousSnapshot.xml deleted file mode 100644 index 036b21882df..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignMeasuresWhenNoPreviousSnapshot.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasureToFutureSnapshots-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasureToFutureSnapshots-result.xml deleted file mode 100644 index 36a166be735..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasureToFutureSnapshots-result.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasureToFutureSnapshots.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasureToFutureSnapshots.xml deleted file mode 100644 index 5478f7f10bc..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasureToFutureSnapshots.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasuresToLastSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasuresToLastSnapshot-result.xml deleted file mode 100644 index 977d0365d79..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasuresToLastSnapshot-result.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasuresToLastSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasuresToLastSnapshot.xml deleted file mode 100644 index c73190edccd..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignNewMeasuresToLastSnapshot.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignPastMeasuresToPastSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignPastMeasuresToPastSnapshot-result.xml deleted file mode 100644 index 04ea0cd38d6..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignPastMeasuresToPastSnapshot-result.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignPastMeasuresToPastSnapshot.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignPastMeasuresToPastSnapshot.xml deleted file mode 100644 index 1916d0b87f4..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/assignPastMeasuresToPastSnapshot.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteLastMeasure-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteLastMeasure-result.xml deleted file mode 100644 index bbfd4845003..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteLastMeasure-result.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteLastMeasure.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteLastMeasure.xml deleted file mode 100644 index d0a260f60f1..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteLastMeasure.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteMeasure-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteMeasure-result.xml deleted file mode 100644 index ed2be1cb346..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteMeasure-result.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteMeasure.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteMeasure.xml deleted file mode 100644 index 17b279547f2..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/deleteMeasure.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/sharedFixture.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/sharedFixture.xml deleted file mode 100644 index d1a6b09be2f..00000000000 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/AsyncMeasuresServiceTest/sharedFixture.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - \ No newline at end of file diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/AsyncMeasureSnapshot.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/AsyncMeasureSnapshot.java deleted file mode 100644 index 2abee562b20..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/AsyncMeasureSnapshot.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.database.model; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.sonar.api.database.BaseIdentifiable; - -import java.util.Date; -import javax.persistence.*; - -/** - * Class to map an aysync measure with hibernate model - */ -@Entity -@Table(name = "async_measure_snapshots") -public class AsyncMeasureSnapshot extends BaseIdentifiable { - - @Column(name = "project_measure_id", updatable = true, nullable = true) - private Long measureId; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "measure_date", updatable = true, nullable = true) - private Date measureDate; - - @Column(name = "snapshot_id", updatable = true, nullable = true) - private Integer snapshotId; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "snapshot_date", updatable = true, nullable = true) - private Date snapshotDate; - - @Column(name = "metric_id", updatable = true, nullable = true) - private Integer metricId; - - @Column(name = "project_id", updatable = true, nullable = true) - private Integer projectId; - - /** - * This is the constructor to use - * - * @param measureId - * @param snapshotId the snapshot id to which the measure is attached - * @param measureDate the date of the measure - * @param snapshotDate the snapshot date - * @param metricId the metric the measure is attached to - * @param projectId the id of the project - */ - public AsyncMeasureSnapshot(Long measureId, Integer snapshotId, Date measureDate, Date snapshotDate, Integer metricId, Integer projectId) { - this.measureId = measureId; - this.measureDate = measureDate; - this.snapshotId = snapshotId; - this.snapshotDate = snapshotDate; - this.projectId = projectId; - this.metricId = metricId; - } - - /** - * Default constructor - */ - public AsyncMeasureSnapshot() { - } - - public Long getMeasureId() { - return measureId; - } - - public void setMeasureId(Long measureId) { - this.measureId = measureId; - } - - public Integer getSnapshotId() { - return snapshotId; - } - - public void setSnapshotId(Integer snapshotId) { - this.snapshotId = snapshotId; - } - - public Date getMeasureDate() { - return measureDate; - } - - public void setMeasureDate(Date measureDate) { - this.measureDate = measureDate; - } - - public Date getSnapshotDate() { - return snapshotDate; - } - - public void setSnapshotDate(Date snapshotDate) { - this.snapshotDate = snapshotDate; - } - - public Integer getMetricId() { - return metricId; - } - - public void setMetricId(Integer metricId) { - this.metricId = metricId; - } - - public Integer getProjectId() { - return projectId; - } - - public void setProjectId(Integer projectId) { - this.projectId = projectId; - } - - public void setMeasure(MeasureModel measure) { - setMeasureId(measure.getId()); - setMeasureDate(measure.getMeasureDate()); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof AsyncMeasureSnapshot)) { - return false; - } - if (this == obj) { - return true; - } - AsyncMeasureSnapshot other = (AsyncMeasureSnapshot) obj; - return new EqualsBuilder() - .append(measureId, other.getMeasureId()) - .append(measureDate, other.getMeasureDate()) - .append(snapshotId, other.getSnapshotId()) - .append(snapshotDate, other.getSnapshotDate()) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(measureId) - .append(measureDate) - .append(snapshotDate) - .append(snapshotId) - .toHashCode(); - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .append("id", getId()) - .append("measureId", measureId) - .append("measureDate", measureDate) - .append("snapshotId", snapshotId) - .append("snapshotDate", snapshotDate) - .toString(); - } -} diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 3f3ee2f382c..6afe5f7d449 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -162,11 +162,9 @@ public final class Platform { servicesContainer.as(Characteristics.NO_CACHE).addComponent(MeasuresDao.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(org.sonar.api.database.daos.MeasuresDao.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(ProfilesDao.class); - servicesContainer.as(Characteristics.NO_CACHE).addComponent(AsyncMeasuresDao.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(DaoFacade.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(DefaultRulesManager.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(ProfilesManager.class); - servicesContainer.as(Characteristics.NO_CACHE).addComponent(AsyncMeasuresService.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(Backup.class); servicesContainer.as(Characteristics.CACHE).addComponent(AuthenticatorFactory.class); servicesContainer.as(Characteristics.CACHE).addComponent(ServerLifecycleNotifier.class); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 7e1e99c67cc..8c60ad0fab7 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -32,7 +32,6 @@ import org.sonar.api.rules.RulePriority; import org.sonar.api.rules.RuleRepository; import org.sonar.api.utils.ValidationMessages; import org.sonar.api.web.*; -import org.sonar.jpa.dao.AsyncMeasuresService; import org.sonar.jpa.dialect.Dialect; import org.sonar.jpa.session.DatabaseConnector; import org.sonar.markdown.Markdown; @@ -261,22 +260,10 @@ public final class JRubyFacade { return getContainer().getComponent(Backup.class); } - public void registerAsyncMeasure(long asyncMeasureId) { - getAsyncMeasuresService().registerMeasure(asyncMeasureId); - } - - public void deleteAsyncMeasure(long asyncMeasureId) { - getAsyncMeasuresService().deleteMeasure(asyncMeasureId); - } - private ProfilesManager getProfilesManager() { return getContainer().getComponent(ProfilesManager.class); } - private AsyncMeasuresService getAsyncMeasuresService() { - return getContainer().getComponent(AsyncMeasuresService.class); - } - public void reloadConfiguration() { getContainer().getComponent(CoreConfiguration.class).reload(); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb index f70f303af8b..8a68161aaeb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb @@ -105,7 +105,6 @@ class ComponentsController < ApplicationController 'rule_id' => nil, 'rule_priority' => nil, 'characteristic_id' => nil})) - measures.concat(AsyncMeasureSnapshot.search(page_sids, mids)) end measures else diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb index 75077f60ff9..435943a7b61 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb @@ -73,7 +73,6 @@ class MetricsController < ApplicationController def delete_from_web metric = Metric.by_id(params[:id].to_i) if params[:id] && params[:id].size > 0 if metric - AsyncMeasureSnapshot.delete_all("metric_id = #{metric.id}") del_count = Metric.delete(params[:id].to_i) flash[:notice] = 'Successfully deleted.' if del_count == 1 flash[:error] = 'Unable to delete this metric.' if del_count != 1 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index 24b1d8aa46e..00be0035799 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -18,8 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # class ProjectController < ApplicationController - verify :method => :post, :only => [ :set_links, :add_review, :set_exclusions, :delete_exclusions ], :redirect_to => { :action => :index } - verify :method => :delete, :only => [ :delete, :delete_review ], :redirect_to => { :action => :index } + verify :method => :post, :only => [ :set_links, :set_exclusions, :delete_exclusions ], :redirect_to => { :action => :index } + verify :method => :delete, :only => [ :delete ], :redirect_to => { :action => :index } SECTION=Navigation::SECTION_RESOURCE @@ -27,73 +27,6 @@ class ProjectController < ApplicationController redirect_to :overwrite_params => {:controller => :dashboard, :action => 'index'} end - def show_reviews - @snapshot = Snapshot.find(params[:sid].to_i) - render :partial => 'dashboard_reviews' - end - - def edit_review - @snapshot = Snapshot.find(params[:sid].to_i) - return access_denied unless has_role?(:admin, @snapshot) - - @review = ProjectMeasure.new(:measure_date => @snapshot.created_at, :value => 0) - @review_types = Metric.review_types - render :partial => 'dashboard_edit_review' - end - - def add_review - @snapshot=Snapshot.find(params[:sid].to_i) - return access_denied unless has_role?(:admin, @snapshot) - - measure = ProjectMeasure.new(params[:review]) - measure.project = @snapshot.project - - if measure.metric.nil? - flash[:error] = 'Please select a metric' - redirect_to :action => 'index', :id => measure.project_id - return - end - - if measure.measure_date <= @snapshot.created_at.to_date - if measure.metric.val_type==Metric::VALUE_TYPE_STRING - measure.text_value=params['review']['value'] - measure.value=0 - end - measure.url=params[:url] if params[:url] - measure.description=params[:description] if params[:description] - begin - measure.save! - java_facade.registerAsyncMeasure(measure.id.to_i) - flash[:notice] = 'Measure added' - rescue - flash[:error] = measure.errors.full_messages.join("
") - end - - else - flash[:error] = "The date should not be after #{l(@snapshot.created_at.to_date)}" - end - - if request.xhr? - render :update do |page| - page.redirect_to :action => 'index', :id => measure.project_id - end - else - redirect_to :action => 'index', :id => measure.project_id - end - end - - def delete_review - measure = ProjectMeasure.find(params[:id].to_i) - if measure && measure.review? - return access_denied unless has_role?(:admin, measure.project) - - java_facade.deleteAsyncMeasure(measure.id.to_i) - redirect_to :action => 'index', :id => measure.project_id - else - redirect_to_default - end - end - def delete if params[:id] @project = Project.by_key(params[:id]) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb index d2841e7b3d9..47d0d223998 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb @@ -53,7 +53,6 @@ class TimemachineController < ApplicationController end measures=ProjectMeasure.find(:all, :conditions => {:rule_id => nil, :rule_priority => nil, :snapshot_id => @sids, :characteristic_id => nil}) - measures.concat(AsyncMeasureSnapshot.search(@sids)) rows_by_metric_id={} @rows=[] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/async_measure_snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/async_measure_snapshot.rb deleted file mode 100644 index 2f37204dded..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/async_measure_snapshot.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2011 SonarSource -# mailto:contact AT sonarsource DOT com -# -# Sonar is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# Sonar is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with Sonar; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 -# -class AsyncMeasureSnapshot < ActiveRecord::Base - - belongs_to :async_measure, :foreign_key => 'project_measure_id', :class_name => "ProjectMeasure" - belongs_to :snapshot - - def self.search(sids, metric_ids=nil) - sql='async_measure_snapshots.snapshot_id IN (:sids)' - hash={:sids => sids} - if metric_ids - sql+=' AND async_measure_snapshots.metric_id IN (:mids)' - hash[:mids]=metric_ids - end - async_measures=AsyncMeasureSnapshot.find(:all, - :include => ['async_measure'], - :conditions => [sql, hash]) - - result=[] - async_measures.each do |am| - clone=am.async_measure.clone - clone.snapshot_id=am.snapshot_id - result<0 measures=ProjectMeasure.find(:all, :conditions => ['rule_priority is null and rule_id is null and characteristic_id is null and snapshot_id in (?)', @page_sids]) - if filter.display_user_managed_metrics? - measures.concat(AsyncMeasureSnapshot.search(@page_sids, @metric_ids)) - end - measures.each do |m| snapshot=@snapshots_by_id[m.snapshot_id] @measures_by_snapshot[snapshot]||={} diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb index 54675821f79..1921ddfe8c3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -31,9 +31,6 @@ class ProjectMeasure < ActiveRecord::Base belongs_to :characteristic has_one :measure_data, :class_name => 'MeasureData', :foreign_key => 'measure_id' - has_many :async_measure_snapshots - has_many :snapshots, :through => :async_measure_snapshots - validates_numericality_of :value, :if => :numerical_metric? validate :validate_date, :validate_value @@ -213,49 +210,6 @@ class ProjectMeasure < ActiveRecord::Base end end - # return reviews from the snapshot and also reviews created after the snapshot - def self.find_reviews_for_last_snapshot(snapshot) - ProjectMeasure.find(:all, :include => [:async_measure_snapshots, :measure_data], - :conditions => ['async_measure_snapshots.project_id=project_measures.project_id AND ' + - '((async_measure_snapshots.snapshot_id IS NULL AND project_measures.measure_date>?) ' + - 'OR async_measure_snapshots.snapshot_id=?) ', snapshot.created_at, snapshot.id]) - end - - def self.find_reviews_for_last_snapshot_with_opts(snapshot, options) - metrics = options[:metrics].nil? ? [] : Metric.ids_from_keys(options[:metrics].split(',')) - include = (options[:includeparams] == "true") ? [:async_measure_snapshots, :measure_data] : :async_measure_snapshots - - metrics_conditions = (metrics.empty?) ? "" : "AND project_measures.metric_id IN (?)" - conditions = 'async_measure_snapshots.project_id=project_measures.project_id AND ' + - '((async_measure_snapshots.snapshot_id IS NULL AND project_measures.measure_date>?) ' + - 'OR async_measure_snapshots.snapshot_id=?) ' + metrics_conditions - if metrics.empty? - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.created_at, snapshot.id]) - else - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.created_at, snapshot.id, metrics]) - end - end - - def self.find_reviews(snapshot) - conditions = 'async_measure_snapshots.snapshot_id=? ' + metrics_conditions - ProjectMeasure.find(:all, :include => [:async_measure_snapshots, :measure_data], - :conditions => ['async_measure_snapshots.snapshot_id=? ', snapshot.id]) - end - - - def self.find_reviews_with_opts(snapshot, options={}) - metrics = options[:metrics].nil? ? [] : Metric.ids_from_keys(options[:metrics].split(',')) - include = (options[:includeparams] == "true") ? [:async_measure_snapshots, :measure_data] : :async_measure_snapshots - - metrics_conditions = (metrics.empty?) ? "" : "AND project_measures.metric_id IN (?)" - conditions = 'async_measure_snapshots.snapshot_id=? ' + metrics_conditions - if metrics.empty? - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.id]) - else - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.id, metrics]) - end - end - def tip if rule_id rule.description diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb index 9a0d2b5eaa3..5a6fd0ea838 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -35,10 +35,6 @@ class Snapshot < ActiveRecord::Base has_one :source, :class_name => 'SnapshotSource', :dependent => :destroy has_many :violations, :class_name => 'RuleFailure' - has_many :async_measure_snapshots - has_many :async_measures, :through => :async_measure_snapshots - - STATUS_UNPROCESSED = 'U' STATUS_PROCESSED = 'P' @@ -98,10 +94,6 @@ class Snapshot < ActiveRecord::Base parent_snapshot_id.nil? end - def all_measures - measures + async_measures - end - def descendants children.map(&:descendants).flatten + children end @@ -219,7 +211,7 @@ class Snapshot < ActiveRecord::Base @measures_hash ||= begin hash = {} - all_measures.each do |measure| + measures.each do |measure| hash[measure.metric_id]=measure end hash diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb index 269022642c2..2f56659b79b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb @@ -23,11 +23,11 @@ class CreateAsyncMeasureSnapshotsTable < ActiveRecord::Migration create_table :async_measure_snapshots do |t| t.column :project_measure_id, :integer, :null => true t.column :measure_date, :datetime, :null => true - t.column :snapshot_id, :integer, :null => true + t.column :snapshot_id, :integer, :null => true t.column :snapshot_date, :datetime, :null => true - t.column :metric_id, :integer, :null => true - t.column :project_id, :integer, :null => true - end + t.column :metric_id, :integer, :null => true + t.column :project_id, :integer, :null => true + end add_index :async_measure_snapshots, :snapshot_id, :name => 'async_m_s_snapshot_id' add_index :async_measure_snapshots, :project_measure_id, :name => 'async_m_s_measure_id' add_index :async_measure_snapshots, [:project_id, :metric_id], :name => 'async_m_s_project_metric' diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb index a30b36ad7f2..140b7c90213 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb @@ -77,10 +77,9 @@ class CreateDashboards < ActiveRecord::Migration dashboard.widgets.build(:widget_key => 'description', :name => 'Description', :column_index => 1, :row_index => 6, :configured => true) dashboard.widgets.build(:widget_key => 'rules', :name => 'Rules', :column_index => 2, :row_index => 1, :configured => true) dashboard.widgets.build(:widget_key => 'alerts', :name => 'Alerts', :column_index => 2, :row_index => 2, :configured => true) - dashboard.widgets.build(:widget_key => 'custom_measures', :name => 'Custom measures', :column_index => 2, :row_index => 3, :configured => true) - dashboard.widgets.build(:widget_key => 'file_design', :name => 'File design', :column_index => 2, :row_index => 4, :configured => true) - dashboard.widgets.build(:widget_key => 'package_design', :name => 'Package design', :column_index => 2, :row_index => 5, :configured => true) - dashboard.widgets.build(:widget_key => 'ckjm', :name => 'CKJM', :column_index => 2, :row_index => 6, :configured => true) + dashboard.widgets.build(:widget_key => 'file_design', :name => 'File design', :column_index => 2, :row_index => 3, :configured => true) + dashboard.widgets.build(:widget_key => 'package_design', :name => 'Package design', :column_index => 2, :row_index => 4, :configured => true) + dashboard.widgets.build(:widget_key => 'ckjm', :name => 'CKJM', :column_index => 2, :row_index => 5, :configured => true) dashboard.save dashboard diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/211_create_manual_measures.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/211_create_manual_measures.rb new file mode 100644 index 00000000000..72e065fc238 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/211_create_manual_measures.rb @@ -0,0 +1,30 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class CreateManualMeasures < ActiveRecord::Migration + + def self.up + # TODO + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb new file mode 100644 index 00000000000..bdd7fd6b42e --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb @@ -0,0 +1,30 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class MoveAsyncMeasures < ActiveRecord::Migration + + def self.up + # TODO + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/213_drop_async_measures_table.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/213_drop_async_measures_table.rb new file mode 100644 index 00000000000..7346d954978 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/213_drop_async_measures_table.rb @@ -0,0 +1,33 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class DropAsyncMeasuresTable < ActiveRecord::Migration + + def self.up + remove_index('async_measure_snapshots', :name => 'async_m_s_snapshot_id') + remove_index('async_measure_snapshots', :name => 'async_m_s_measure_id') + remove_index('async_measure_snapshots', :name => 'async_m_s_project_metric') + drop_table('async_measure_snapshots') + end + +end diff --git a/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl b/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl index a2c2ad8d445..c9feaaa71f9 100644 --- a/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl +++ b/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl @@ -67,20 +67,6 @@ create table ALERTS ( primary key (id) ); -create table ASYNC_MEASURE_SNAPSHOTS ( - ID INTEGER not null, - PROJECT_MEASURE_ID INTEGER, - MEASURE_DATE TIMESTAMP, - SNAPSHOT_ID INTEGER, - SNAPSHOT_DATE TIMESTAMP, - METRIC_ID INTEGER, - PROJECT_ID INTEGER, - primary key (id) -); -CREATE INDEX ASYNC_M_S_MEASURE_ID ON ASYNC_MEASURE_SNAPSHOTS (PROJECT_MEASURE_ID); -CREATE INDEX ASYNC_M_S_PROJECT_METRIC ON ASYNC_MEASURE_SNAPSHOTS (PROJECT_ID, METRIC_ID); -CREATE INDEX ASYNC_M_S_SNAPSHOT_ID ON ASYNC_MEASURE_SNAPSHOTS (SNAPSHOT_ID); - create table CHARACTERISTICS ( ID INTEGER not null, QUALITY_MODEL_ID INTEGER,