From bda168446f33bd1bac5cd8964a8fcee078137c49 Mon Sep 17 00:00:00 2001 From: JorgeLuiz Date: Fri, 1 Nov 2019 07:03:05 -0300 Subject: [PATCH] Minor fixes related to the Score interface (#21) * Fixing the changes related to the Score interface. --- .../qualitymodel/CompositeAttributeView.java | 10 +- .../entity/qualitymodel/LeafAttribute.java | 4 +- .../qualitymodel/MetricAttributeView.java | 4 +- .../atmosphere/tma/utils/PrivacyScore.java | 121 +++++++++++------- 4 files changed, 84 insertions(+), 55 deletions(-) diff --git a/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/CompositeAttributeView.java b/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/CompositeAttributeView.java index da56465..5b4e0d7 100644 --- a/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/CompositeAttributeView.java +++ b/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/CompositeAttributeView.java @@ -1,8 +1,8 @@ package eubr.atmosphere.tma.entity.qualitymodel; import java.io.Serializable; -import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.persistence.Entity; @@ -45,7 +45,7 @@ public class CompositeAttributeView extends MetricAttributeView implements Seria public CompositeAttributeView() { } - public MetricData calculate(ConfigurationProfile profile, Timestamp timestamp) throws UndefinedException { + public MetricData calculate(ConfigurationProfile profile, Date timestamp) throws UndefinedException { if (profile == null || ListUtils.isEmpty(profile.getPreferences())) { throw new UndefinedMetricException( @@ -82,7 +82,7 @@ public MetricData calculate(ConfigurationProfile profile, Timestamp timestamp) t return metricData; } - protected double calculateNeutrality(ConfigurationProfile profile, Timestamp timestamp) throws UndefinedException { + protected double calculateNeutrality(ConfigurationProfile profile, Date timestamp) throws UndefinedException { double score = 0.0; if (ListUtils.isNotEmpty(children)) { for (MetricAttributeView child : children) { @@ -99,7 +99,7 @@ protected double calculateNeutrality(ConfigurationProfile profile, Timestamp tim return score; } - protected double calculateSimultaneity(ConfigurationProfile profile, Timestamp timestamp) throws UndefinedException { + protected double calculateSimultaneity(ConfigurationProfile profile, Date timestamp) throws UndefinedException { double score = 0.0; if (ListUtils.isNotEmpty(this.children)) { for (MetricAttributeView child : children) { @@ -121,7 +121,7 @@ protected double calculateSimultaneity(ConfigurationProfile profile, Timestamp t return score; } - protected double calculateReplaceability(ConfigurationProfile profile, Timestamp timestamp) throws UndefinedException { + protected double calculateReplaceability(ConfigurationProfile profile, Date timestamp) throws UndefinedException { double score = 0.0; if (ListUtils.isNotEmpty(this.children)) { for (MetricAttributeView child : children) { diff --git a/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/LeafAttribute.java b/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/LeafAttribute.java index 8e2b6b6..a94d630 100644 --- a/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/LeafAttribute.java +++ b/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/LeafAttribute.java @@ -1,7 +1,7 @@ package eubr.atmosphere.tma.entity.qualitymodel; import java.io.Serializable; -import java.sql.Timestamp; +import java.util.Date; import java.util.Iterator; import java.util.List; @@ -56,7 +56,7 @@ public LeafAttribute(double maximumThreshold, MetricAggregationOperator metricAg this.numSamples = numSamples; } - public MetricData calculate(ConfigurationProfile profile, Timestamp timestamp) + public MetricData calculate(ConfigurationProfile profile, Date timestamp) throws UndefinedMetricException { if (profile == null || ListUtils.isEmpty(profile.getPreferences())) { diff --git a/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/MetricAttributeView.java b/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/MetricAttributeView.java index 5b89e97..e4679c5 100644 --- a/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/MetricAttributeView.java +++ b/common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/MetricAttributeView.java @@ -1,7 +1,7 @@ package eubr.atmosphere.tma.entity.qualitymodel; import java.io.Serializable; -import java.sql.Timestamp; +import java.util.Date; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -37,7 +37,7 @@ public abstract class MetricAttributeView implements Serializable { @JoinColumn(name="compositeattributeId") private CompositeAttributeView compositeattribute; - public abstract MetricData calculate(ConfigurationProfile user, Timestamp timestamp) + public abstract MetricData calculate(ConfigurationProfile user, Date timestamp) throws UndefinedException; public MetricAttributeView() { diff --git a/common/tma-utils/src/main/java/eubr/atmosphere/tma/utils/PrivacyScore.java b/common/tma-utils/src/main/java/eubr/atmosphere/tma/utils/PrivacyScore.java index 6c4181f..275f71b 100644 --- a/common/tma-utils/src/main/java/eubr/atmosphere/tma/utils/PrivacyScore.java +++ b/common/tma-utils/src/main/java/eubr/atmosphere/tma/utils/PrivacyScore.java @@ -7,50 +7,79 @@ */ public class PrivacyScore implements Score { - private Double score; - private Integer configurationProfileId; - private Integer attributeId; - private Double threshold; - - public PrivacyScore(Integer configurationProfileId, Integer attributeId, Double score, Double threshold) { - super(); - this.score = score; - this.configurationProfileId = configurationProfileId; - this.attributeId = attributeId; - this.threshold = threshold; - } - - @Override - public Double getScore() { - return this.score; - } - - public void setScore(Double score) { - this.score = score; - } - - public Integer getConfigurationProfileId() { - return configurationProfileId; - } - - public void setConfigurationProfileId(Integer configurationProfileId) { - this.configurationProfileId = configurationProfileId; - } - - public Integer getAttributeId() { - return attributeId; - } - - public void setAttributeId(Integer attributeId) { - this.attributeId = attributeId; - } - - public Double getThreshold() { - return threshold; - } - - public void setThreshold(Double threshold) { - this.threshold = threshold; - } - + private Double score; + private Integer configurationProfileId; + private Integer attributeId; + private Double threshold; + private int metricId; + private int resourceId; + private long valueTime; + + public PrivacyScore(Integer configurationProfileId, Integer attributeId, Double score, Double threshold) { + super(); + this.score = score; + this.configurationProfileId = configurationProfileId; + this.attributeId = attributeId; + this.threshold = threshold; + } + + @Override + public Double getScore() { + return this.score; + } + + public void setScore(Double score) { + this.score = score; + } + + public Integer getConfigurationProfileId() { + return configurationProfileId; + } + + public void setConfigurationProfileId(Integer configurationProfileId) { + this.configurationProfileId = configurationProfileId; + } + + public Integer getAttributeId() { + return attributeId; + } + + public void setAttributeId(Integer attributeId) { + this.attributeId = attributeId; + } + + public Double getThreshold() { + return threshold; + } + + public void setThreshold(Double threshold) { + this.threshold = threshold; + } + + @Override + public long getValueTime() { + return this.valueTime; + } + + public void setValueTime(long valueTime) { + this.valueTime = valueTime; + } + + @Override + public int getResourceId() { + return this.resourceId; + } + + public void setResourceId(int resourceId) { + this.resourceId = resourceId; + } + + @Override + public int getMetricId() { + return this.metricId; + } + + public void setMetricId(int metricId) { + this.metricId = metricId; + } }