-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating tma-utils project according to the unified knowledge model (#19
) * Updated TMA Deployment Instructions * Starting the knowledge unification * Final changes in the data model. * Updated score calculation according to new unified quality model * Updated score calculation * Created entity views
- Loading branch information
Showing
48 changed files
with
2,583 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
common/tma-utils/src/main/java/eubr/atmosphere/tma/database/QualityModelManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package eubr.atmosphere.tma.database; | ||
|
||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.sql.Timestamp; | ||
import java.sql.Types; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import eubr.atmosphere.tma.entity.qualitymodel.Data; | ||
import eubr.atmosphere.tma.entity.qualitymodel.DataPK; | ||
import eubr.atmosphere.tma.entity.qualitymodel.MetricData; | ||
|
||
public class QualityModelManager { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(QualityModelManager.class); | ||
|
||
public int saveMetricData(MetricData metricData) { | ||
String sql = "INSERT INTO MetricData(metricId, valueTime, value, resourceId) VALUES (?, ?, ?, ?)"; | ||
PreparedStatement ps; | ||
try { | ||
ps = DatabaseManager.getConnectionInstance().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); | ||
ps.setInt(1, metricData.getMetricId().getMetricId()); | ||
ps.setTimestamp(2, new Timestamp(metricData.getMetricId().getValueTime().getTime())); | ||
ps.setDouble(3, metricData.getValue()); | ||
if (metricData.getResourceId() == null) { | ||
ps.setNull(4, Types.INTEGER); | ||
} else { | ||
ps.setInt(4, metricData.getResourceId()); | ||
} | ||
DatabaseManager databaseManager = new DatabaseManager(); | ||
return databaseManager.execute(ps); | ||
} catch (SQLException e) { | ||
LOGGER.error("[ATMOSPHERE] Error when inserting MetricData in the database.", e); | ||
} | ||
return -1; | ||
} | ||
|
||
public List<Data> getLimitedDataListByIdAndTimestamp(Integer descriptionId) { | ||
|
||
List<Data> dataList = new ArrayList<>(); | ||
PreparedStatement ps = null; | ||
String sql = "SELECT d.probeId, d.descriptionId, d.resourceId, d.valueTime, d.value FROM Data d WHERE d.descriptionId = ?"; | ||
|
||
try { | ||
|
||
ps = DatabaseManager.getConnectionInstance().prepareStatement(sql); | ||
ps.setInt(1, descriptionId); | ||
|
||
ResultSet rs = DatabaseManager.executeQuery(ps); | ||
if (rs.next()) { | ||
|
||
Data data = new Data(); | ||
DataPK dataPK = new DataPK(); | ||
dataPK.setProbeId(rs.getInt("probeId")); | ||
dataPK.setDescriptionId(rs.getInt("descriptionId")); | ||
dataPK.setResourceId(rs.getInt("resourceId")); | ||
dataPK.setValueTime(rs.getDate("valueTime")); | ||
data.setId(dataPK); | ||
data.setValue(rs.getDouble("value")); | ||
|
||
dataList.add(data); | ||
|
||
} | ||
|
||
return dataList; | ||
} catch (SQLException e) { | ||
LOGGER.error("[ATMOSPHERE] Error when getting Data list by ID and Timestamp.", e); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/Action.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package eubr.atmosphere.tma.entity.qualitymodel; | ||
|
||
import java.io.Serializable; | ||
import javax.persistence.*; | ||
|
||
|
||
/** | ||
* The persistent class for the Action database table. | ||
* | ||
*/ | ||
@Entity | ||
@NamedQuery(name="Action.findAll", query="SELECT a FROM Action a") | ||
public class Action implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Id | ||
@GeneratedValue(strategy=GenerationType.IDENTITY) | ||
private int actionId; | ||
|
||
private String actionName; | ||
|
||
private int actuatorId; | ||
|
||
private int resourceId; | ||
|
||
public Action() { | ||
} | ||
|
||
public int getActionId() { | ||
return this.actionId; | ||
} | ||
|
||
public void setActionId(int actionId) { | ||
this.actionId = actionId; | ||
} | ||
|
||
public String getActionName() { | ||
return this.actionName; | ||
} | ||
|
||
public void setActionName(String actionName) { | ||
this.actionName = actionName; | ||
} | ||
|
||
public int getActuatorId() { | ||
return this.actuatorId; | ||
} | ||
|
||
public void setActuatorId(int actuatorId) { | ||
this.actuatorId = actuatorId; | ||
} | ||
|
||
public int getResourceId() { | ||
return this.resourceId; | ||
} | ||
|
||
public void setResourceId(int resourceId) { | ||
this.resourceId = resourceId; | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/ActionPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package eubr.atmosphere.tma.entity.qualitymodel; | ||
|
||
import java.io.Serializable; | ||
import javax.persistence.*; | ||
|
||
|
||
/** | ||
* The persistent class for the ActionPlan database table. | ||
* | ||
*/ | ||
@Entity | ||
@NamedQuery(name="ActionPlan.findAll", query="SELECT a FROM ActionPlan a") | ||
public class ActionPlan implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@EmbeddedId | ||
private ActionPlanPK id; | ||
|
||
private int executionOrder; | ||
|
||
private int status; | ||
|
||
public ActionPlan() { | ||
} | ||
|
||
public ActionPlanPK getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(ActionPlanPK id) { | ||
this.id = id; | ||
} | ||
|
||
public int getExecutionOrder() { | ||
return this.executionOrder; | ||
} | ||
|
||
public void setExecutionOrder(int executionOrder) { | ||
this.executionOrder = executionOrder; | ||
} | ||
|
||
public int getStatus() { | ||
return this.status; | ||
} | ||
|
||
public void setStatus(int status) { | ||
this.status = status; | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/ActionPlanPK.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package eubr.atmosphere.tma.entity.qualitymodel; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.persistence.Embeddable; | ||
|
||
/** | ||
* The primary key class for the ActionPlan database table. | ||
* | ||
*/ | ||
@Embeddable | ||
public class ActionPlanPK implements Serializable { | ||
//default serial version id, required for serializable classes. | ||
private static final long serialVersionUID = 1L; | ||
|
||
private int planId; | ||
|
||
private int actionId; | ||
|
||
public ActionPlanPK() { | ||
} | ||
public int getPlanId() { | ||
return this.planId; | ||
} | ||
public void setPlanId(int planId) { | ||
this.planId = planId; | ||
} | ||
public int getActionId() { | ||
return this.actionId; | ||
} | ||
public void setActionId(int actionId) { | ||
this.actionId = actionId; | ||
} | ||
|
||
public boolean equals(Object other) { | ||
if (this == other) { | ||
return true; | ||
} | ||
if (!(other instanceof ActionPlanPK)) { | ||
return false; | ||
} | ||
ActionPlanPK castOther = (ActionPlanPK)other; | ||
return | ||
(this.planId == castOther.planId) | ||
&& (this.actionId == castOther.actionId); | ||
} | ||
|
||
public int hashCode() { | ||
final int prime = 31; | ||
int hash = 17; | ||
hash = hash * prime + this.planId; | ||
hash = hash * prime + this.actionId; | ||
|
||
return hash; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
common/tma-utils/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/Actuator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package eubr.atmosphere.tma.entity.qualitymodel; | ||
|
||
import java.io.Serializable; | ||
import javax.persistence.*; | ||
|
||
|
||
/** | ||
* The persistent class for the Actuator database table. | ||
* | ||
*/ | ||
@Entity | ||
@NamedQuery(name="Actuator.findAll", query="SELECT a FROM Actuator a") | ||
public class Actuator implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Id | ||
@GeneratedValue(strategy=GenerationType.IDENTITY) | ||
private int actuatorId; | ||
|
||
private String address; | ||
|
||
private String pubKey; | ||
|
||
public Actuator() { | ||
} | ||
|
||
public int getActuatorId() { | ||
return this.actuatorId; | ||
} | ||
|
||
public void setActuatorId(int actuatorId) { | ||
this.actuatorId = actuatorId; | ||
} | ||
|
||
public String getAddress() { | ||
return this.address; | ||
} | ||
|
||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
|
||
public String getPubKey() { | ||
return this.pubKey; | ||
} | ||
|
||
public void setPubKey(String pubKey) { | ||
this.pubKey = pubKey; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...s/src/main/java/eubr/atmosphere/tma/entity/qualitymodel/AttributeAggregationOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package eubr.atmosphere.tma.entity.qualitymodel; | ||
|
||
/** | ||
* Attribute aggregation operator enumeration | ||
* @author JorgeLuiz | ||
*/ | ||
public enum AttributeAggregationOperator { | ||
|
||
NEUTRALITY(0, "NEUTRALITY"), SIMULTANEITY(1, "SIMULTANEITY"), REPLACEABILITY(2, "REPLACEABILITY"); | ||
|
||
private Integer valor; | ||
private String label; | ||
|
||
private AttributeAggregationOperator(Integer valor, String label) { | ||
this.valor = valor; | ||
this.label = label; | ||
} | ||
|
||
public Integer getValor() { | ||
return valor; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public static AttributeAggregationOperator getEnumByValor(Integer valor) { | ||
if (valor == null) { | ||
return null; | ||
} | ||
for (AttributeAggregationOperator item : AttributeAggregationOperator.values()) { | ||
if (item.getValor().intValue() == valor.intValue()) { | ||
return item; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.