diff --git a/src/de/tud/kom/p2psim/impl/util/db/dao/metric/MeasurementDAO.java b/src/de/tud/kom/p2psim/impl/util/db/dao/metric/MeasurementDAO.java index 88a230d01468001cfa309582068536f14e2f66fd..789584fb92a63994e8b8593d736f948c5540d5ff 100644 --- a/src/de/tud/kom/p2psim/impl/util/db/dao/metric/MeasurementDAO.java +++ b/src/de/tud/kom/p2psim/impl/util/db/dao/metric/MeasurementDAO.java @@ -168,6 +168,41 @@ public class MeasurementDAO extends DAO { groupMetric, observationDuration, describesWholeSimulation); addToPersistQueue(measurement); } + + /** + * Stores a statistical description of a series of values for group of + * hosts and a given spatial coordinate. + * + * @param metricDesc + * The {@link MetricDescription} which describes the metric. + * @param groupName + * The host group + * @param time + * A time for the measurement in simulation time + * @param stats + * the {@link DescriptiveStatistics} object used as input + * @param observationDuration + * duration of this observation in simulation time + * @param describesWholeSimulation + * true, if this measurement is a description of the WHOLE + * simulation + * @param locationX + * x coordinate for spatial sampling + * @param locationY + * y coordinate for spatial sampling + */ + public static void storeSpatialGroupStatisticsMeasurement( + MetricDescription metricDesc, String groupName, long time, + DescriptiveStatistics stats, long observationDuration, + boolean describesWholeSimulation, int locationX, int locationY) { + Metric metric = MetricDAO.lookupStatisticsMetric(metricDesc); + GroupMetric groupMetric = GroupMetricDAO.lookupGroupMetric(metric, + groupName); + MeasurementStatistic measurement = new MeasurementStatistic(time, stats, + groupMetric, observationDuration, describesWholeSimulation, locationX, locationY); + addToPersistQueue(measurement); + } + /** * Store a list-based measurement with a key (i.e., as a diff --git a/src/de/tud/kom/p2psim/impl/util/db/metric/MeasurementStatistic.java b/src/de/tud/kom/p2psim/impl/util/db/metric/MeasurementStatistic.java index 33d78f5f8a7618f6884333e8bf229901ae1a92c7..7e58233660911f7013494b564828b673b702670b 100644 --- a/src/de/tud/kom/p2psim/impl/util/db/metric/MeasurementStatistic.java +++ b/src/de/tud/kom/p2psim/impl/util/db/metric/MeasurementStatistic.java @@ -118,12 +118,15 @@ public class MeasurementStatistic implements GroupMetricBound { @Column(nullable = true, name = "[perc5]") private Double perc5; // 5 - - @Column(nullable = true, name = "[skewness]") - private Double skewness; - - @Column(nullable = true, name = "[kurtosis]") - private Double kurtosis; + + @Column(nullable = true, name = "[locationX]") + private Integer locationX; + + @Column(nullable = true, name = "[locationY]") + private Integer locationY; + + @Column(nullable = true, name = "[isSpatial]") + private boolean isSpatial; /** * Mapping to group metric @@ -155,6 +158,36 @@ public class MeasurementStatistic implements GroupMetricBound { this.groupMetric = groupMetric; } + /** + * Creates a {@link Measurement}-Object using the provided + * {@link DescriptiveStatistics} object, with spatial data attached. + * + * @param time + * The simulation time for to this measurement as Date + * @param stats + * the {@link DescriptiveStatistics} object + * @param hostMetric + * The reference to the {@link HostMetric}-Object, which + * describes this metric. Is used for the mapping. + * @param observationDuration + * duration of the observation + * @param describesWholeSimulation + * true, if this measurement describes the whole simulation + * @param locationX + * x coordinate for spatial sampling + * @param locationY + * y coordinate for spatial sampling + */ + public MeasurementStatistic(long time, DescriptiveStatistics stats, + GroupMetric groupMetric, long observationDuration, + boolean describesWholeSimulation, int locationX, int locationY) { + this(time, stats, observationDuration, describesWholeSimulation); + this.groupMetric = groupMetric; + this.locationX = locationX; + this.locationY = locationY; + this.isSpatial = true; + } + /** * Internal - write statistics * @@ -182,9 +215,8 @@ public class MeasurementStatistic implements GroupMetricBound { this.perc97 = checkForSpecialNumbers(stats.getPercentile(97.7)); this.perc5 = checkForSpecialNumbers(stats.getPercentile(5)); this.perc95 = checkForSpecialNumbers(stats.getPercentile(95)); - this.skewness = checkForSpecialNumbers(stats.getSkewness()); - this.kurtosis = checkForSpecialNumbers(stats.getKurtosis()); this.std = checkForSpecialNumbers(stats.getStandardDeviation()); + this.isSpatial = false; } /**