Skip to content

Commit

Permalink
CloudEA Integration (QM, Rules, Actuator) (#22)
Browse files Browse the repository at this point in the history
* Add Class to Calculate Score of CloudEA Quality Model
* SecurityScore implemented
* Adjustment according to the Score interface.
* Changes in SecurityScore
* Added the Scores (SecurityScore and PrivacyScore) to TrustworthinessScore
* Adjusted the tmalibrary (actuator) to work properly with Python3
* Python Actuator Library Fix
* Updated submodules.
  • Loading branch information
joseadp authored and nmsa committed Dec 18, 2019
1 parent bda1684 commit 054d891
Show file tree
Hide file tree
Showing 16 changed files with 503 additions and 20 deletions.
2 changes: 1 addition & 1 deletion common/tma-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<version>8.0.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Connection getConnectionInstance() {
if ((connection == null) || connection.isClosed()) {
connection = DriverManager
.getConnection("jdbc:mysql://mysql-0.mysql.default.svc.cluster.local:3306/knowledge?"
+ "user=root&password=passtobereplaced");
+ "user=root&password=passtobereplaced&autoReconnect=true");
}
} catch (SQLException e) {
LOGGER.error(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package eubr.atmosphere.tma.entity.qualitymodel;

import java.io.Serializable;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -70,6 +72,9 @@ public MetricData calculate(ConfigurationProfile profile, Date timestamp) throws
}

MetricDataPK metricDataPK = new MetricDataPK();
if (timestamp == null) {
timestamp = new Timestamp(Instant.now().toEpochMilli());
}
metricDataPK.setValueTime(timestamp);
metricDataPK.setMetricId(this.getId());
metricData.setMetricId(metricDataPK);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package eubr.atmosphere.tma.entity.qualitymodel;

import java.io.Serializable;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -84,6 +86,9 @@ public MetricData calculate(ConfigurationProfile profile, Date timestamp)
}

MetricDataPK metricDataPK = new MetricDataPK();
if (timestamp == null) {
timestamp = new Timestamp(Instant.now().toEpochMilli());
}
metricDataPK.setValueTime(timestamp);
metricDataPK.setMetricId(this.getId());
metricData.setMetricId(metricDataPK);
Expand Down Expand Up @@ -125,6 +130,10 @@ protected double calculateAverage(ConfigurationProfile profile, MetricData metri
}
}

if (average == 0 || amount == 0) {
return 0;
}

if (this.normalizationKind == MetricNormalizationKind.COST) {
return 1 - (average / amount);
}
Expand Down Expand Up @@ -158,6 +167,10 @@ protected double calculateMinimum(ConfigurationProfile profile, MetricData metri
}
}

if (minimum == 0) {
return 0;
}

if (this.normalizationKind == MetricNormalizationKind.COST) {
return 1 - minimum;
}
Expand Down Expand Up @@ -191,6 +204,10 @@ protected double calculateMaximum(ConfigurationProfile profile, MetricData metri
}
}

if (maximum == 0) {
return 0;
}

if (this.normalizationKind == MetricNormalizationKind.COST) {
return 1 - maximum;
}
Expand Down Expand Up @@ -223,7 +240,10 @@ protected double calculateSum(ConfigurationProfile profile, MetricData metricDat
}
}


if (sum == 0) {
return 0;
}

if (this.normalizationKind == MetricNormalizationKind.COST) {
return 1 - sum;
}
Expand Down Expand Up @@ -286,4 +306,4 @@ public void setNumSamples(int numSamples) {
this.numSamples = numSamples;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public class PrivacyScore implements Score {
private int resourceId;
private long valueTime;

public PrivacyScore() {
this.configurationProfileId = -1;
this.attributeId = -1;
this.score = 0.0;
this.threshold = 0.0;
}

public PrivacyScore(Integer configurationProfileId, Integer attributeId, Double score, Double threshold) {
super();
this.score = score;
Expand Down
Loading

0 comments on commit 054d891

Please sign in to comment.