aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-core/src/main')
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java48
1 files changed, 5 insertions, 43 deletions
diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java
index 1ed2f16042a..372674b94c4 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java
@@ -19,17 +19,14 @@
*/
package org.sonar.jpa.dao;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.Predicate;
-import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.measures.Metric;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
-import static com.google.common.collect.Lists.newArrayList;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.measures.Metric;
public class MeasuresDao {
@@ -40,18 +37,6 @@ public class MeasuresDao {
this.session = session;
}
- public Metric getMetric(Metric metric) {
- return getMetricsByName().get(metric.getKey());
- }
-
- public List<Metric> getMetrics(List<Metric> metrics) {
- List<Metric> result = newArrayList();
- for (Metric metric : metrics) {
- result.add(getMetric(metric));
- }
- return result;
- }
-
public Metric getMetric(String metricName) {
return getMetricsByName().get(metricName);
}
@@ -69,16 +54,6 @@ public class MeasuresDao {
});
}
- public Collection<Metric> getUserDefinedMetrics() {
- return CollectionUtils.select(getMetricsByName().values(), new Predicate() {
- @Override
- public boolean evaluate(Object o) {
- Metric m = (Metric) o;
- return m.getEnabled() && m.getOrigin() != Metric.Origin.JAV;
- }
- });
- }
-
public void disableAutomaticMetrics() {
session.createQuery("update " + Metric.class.getSimpleName() + " m set m.enabled=false where m.userManaged=false").executeUpdate();
session.commit();
@@ -97,7 +72,7 @@ public class MeasuresDao {
}
private void persistMetricWithoutClear(Metric metric) {
- Metric dbMetric = getMetric(metric);
+ Metric dbMetric = getMetric(metric.getKey());
if (dbMetric != null) {
dbMetric.merge(metric);
session.getEntityManager().merge(dbMetric);
@@ -107,19 +82,6 @@ public class MeasuresDao {
}
}
- public void persistMetric(Metric metric) {
- persistMetricWithoutClear(metric);
- metricsByName.clear();
- }
-
- public void disabledMetrics(Collection<Metric> metrics) {
- for (Metric metric : metrics) {
- metric.setEnabled(Boolean.FALSE);
- session.getEntityManager().persist(metric);
- metricsByName.put(metric.getName(), metric);
- }
- }
-
private Map<String, Metric> getMetricsByName() {
if (metricsByName.isEmpty()) {
List<Metric> metrics = session.getResults(Metric.class);