Commit 86534a43 authored by Kyriakos Kritikos's avatar Kyriakos Kritikos

Made modification to conform to naming scheme of xtext plus associate metric model to unit model

parent e9066ac8
......@@ -7,7 +7,7 @@
xmlns:metric="http://www.paasage.eu/2015/06/camel/metric"
xmlns:unit="http://www.paasage.eu/2015/06/camel/unit"
xsi:schemaLocation="http://www.paasage.eu/2015/06/camel camel.ecore http://www.paasage.eu/2015/06/camel/metric camel.ecore#//metric http://www.paasage.eu/2015/06/camel/unit camel.ecore#//unit"
name="Basic Metric Model">
name="Basic_Metric_Model">
<metrics
xsi:type="metric:RawMetric"
name="RAW_AVAIL"
......@@ -175,22 +175,22 @@
<properties
name="STORAGE_COST"/>
<properties
name="EXECUTION TIME"
name="EXECUTION_TIME"
type="MEASURABLE"/>
<properties
name="RESPONSE TIME"
name="RESPONSE_TIME"
type="MEASURABLE"/>
<properties
name="NETWORK LATENCY"
name="NETWORK_LATENCY"
type="MEASURABLE"/>
<properties
name="CPU UTILIZATION"
name="CPU_UTILIZATION"
type="MEASURABLE"/>
<properties
name="MEMORY UTILIZATION"
name="MEMORY_UTILIZATION"
type="MEASURABLE"/>
<properties
name="DISK UTILIZATION"
name="DISK_UTILIZATION"
type="MEASURABLE"/>
<properties
name="THROUGHPUT"
......@@ -208,7 +208,7 @@
name="SECONDS"
unit="SECONDS"/>
<units xsi:type="unit:ThroughputUnit"
name="Requests per second"
name="Requests_per_second"
unit="REQUESTS_PER_SECOND"/>
<units xsi:type="unit:MonetaryUnit"
name="euros"
......
......@@ -7,15 +7,15 @@
xmlns:provider="http://www.paasage.eu/2015/06/camel/provider"
xmlns:type="http://www.paasage.eu/2015/06/camel/type"
xsi:schemaLocation="http://www.paasage.eu/2015/06/camel camel.ecore http://www.paasage.eu/2015/06/camel/provider camel.ecore#//provider http://www.paasage.eu/2015/06/camel/type camel.ecore#//type"
name="Flexiant Camel Model">
name="Flexiant_Camel_Model">
<locationModels
name="Flexiant Location">
name="Flexiant_Location">
<countries
id="UK"
name="United Kingdom"/>
</locationModels>
<organisationModels
name="Flexiant Organisation Model">
name="Flexiant_Organisation_Model">
<provider
name="Flexiant"
www="www.flexiant.com"
......@@ -26,13 +26,13 @@
IaaS="true"
providerModel="//@providerModels.0"/>
<dataCentres
name="Flexiant Data Centre"
name="Flexiant_Data_Centre"
codeName="flexiant"
location="//@locationModels.0/@countries.0"
cloudProvider="//@organisationModels.0/@provider"/>
</organisationModels>
<providerModels
name="Flexiant Provider Model">
name="Flexiant_Provider_Model">
<constraints
xsi:type="provider:Implies"
name="LOWEST_VM_Constraint_Mapping"
......
......@@ -25,6 +25,7 @@ import eu.paasage.camel.location.Country;
import eu.paasage.camel.location.GeographicalRegion;
import eu.paasage.camel.location.LocationFactory;
import eu.paasage.camel.location.LocationModel;
import eu.paasage.camel.metric.Metric;
import eu.paasage.camel.metric.MetricContext;
import eu.paasage.camel.metric.MetricModel;
import eu.paasage.camel.organisation.CloudProvider;
......@@ -322,7 +323,7 @@ public class ModelImporter {
/* This method just creates an empty type model and returns it as output.*/
private EObject createEmptyTypeModel(){
TypeModel tm = TypeFactory.eINSTANCE.createTypeModel();
tm.setName("Camel Type Model");
tm.setName("Camel_Type_Model");
return tm;
}
......@@ -379,13 +380,13 @@ public class ModelImporter {
*/
private EObject createUnitModel(){
UnitModel um = UnitFactory.eINSTANCE.createUnitModel();
um.setName("Global Unit Model");
um.setName("Global_Unit_Model");
EList<Unit> units = um.getUnits();
//Create Units per Dimension
CoreUnit cu = UnitFactory.eINSTANCE.createCoreUnit();
/*!!!CoreUnit cu = UnitFactory.eINSTANCE.createCoreUnit();
cu.setName("cores");
cu.setUnit(UnitType.CORES);
units.add(cu);
units.add(cu);*/
Dimensionless dim = UnitFactory.eINSTANCE.createDimensionless();
dim.setUnit(UnitType.PERCENTAGE);
dim.setName("percentage");
......@@ -423,11 +424,11 @@ public class ModelImporter {
gigabytes.setUnit(UnitType.GIGABYTES);
units.add(gigabytes);
ThroughputUnit reqsPerSec = UnitFactory.eINSTANCE.createThroughputUnit();
reqsPerSec.setName("requests per second");
reqsPerSec.setName("requests_per_second");
reqsPerSec.setUnit(UnitType.REQUESTS_PER_SECOND);
units.add(reqsPerSec);
ThroughputUnit transPerSec = UnitFactory.eINSTANCE.createThroughputUnit();
transPerSec.setName("transactions per second");
transPerSec.setName("transactions_per_second");
transPerSec.setUnit(UnitType.TRANSACTIONS_PER_SECOND);
units.add(transPerSec);
TimeIntervalUnit milliseconds = UnitFactory.eINSTANCE.createTimeIntervalUnit();
......@@ -471,14 +472,14 @@ public class ModelImporter {
public void createRepositoryStructure(){
CDOClient cl = new CDOClient();
CDOTransaction trans = cl.openTransaction();
trans.getOrCreateResourceFolder("metrics");
CDOResource res = trans.getOrCreateResource("metrics/metrics");
res.getContents().add(cl.loadModel("input/Metric.xmi"));
trans.getOrCreateResourceFolder("sec");
trans.getOrCreateResourceFolder("locations");
trans.getOrCreateResourceFolder("units");
res = trans.getOrCreateResource("units/units");
CDOResource res = trans.getOrCreateResource("units/units");
res.getContents().add(createUnitModel());
trans.getOrCreateResourceFolder("metrics");
res = trans.getOrCreateResource("metrics/metrics");
trans.getOrCreateResourceFolder("types");
//Create an empty type model here
res = trans.getOrCreateResource("types/types");
......@@ -510,6 +511,37 @@ public class ModelImporter {
else return SecurityPopulator.populate(path, cl, resourcePath, inCdo);
}
public boolean loadFixMetricModel(String filePath){
MetricModel mm = (MetricModel)cl.loadModel(filePath);
mm = EcoreUtil.copy(mm);
EList<Unit> units = mm.getUnits();
CDOTransaction trans = cl.openTransaction();
List<Unit> replUnits = new ArrayList<Unit>();
for (Unit u: units){
Unit unit = trans.createQuery("hql", "select u from Unit u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class).get(0);
replUnits.add(unit);
}
for (Metric m: mm.getMetrics()){
Unit u = m.getUnit();
if (u != null){
int index = units.indexOf(u);
m.setUnit(replUnits.get(index));
}
}
mm.getUnits().clear();
CDOResource res = trans.getOrCreateResource("metrics/metrics");
res.getContents().add(mm);
try{
trans.commit();
trans.close();
return true;
}
catch(Exception e){
logger.error("Something went wrong while attempting to store basic metric model",e);
}
return false;
}
/* This method should be called when the importing of all types of models has been finished
* as it is related to the closing of the CDOSession established through the internally
* exploited CDOClient.
......@@ -524,7 +556,8 @@ public class ModelImporter {
ModelImporter mi = new ModelImporter(true);
mi.importGeoLocationModels("input/geopolitical.owl", "locations");
mi.importProviderModels("input/providers");
mi.importCloudLocations("input/providers/CloudLocationModel.xmi");
//mi.importCloudLocations("input/providers/CloudLocationModel.xmi");
mi.loadFixMetricModel("input/Metric.xmi");
mi.importSecurityModel("input/CSA_CCM_v3.0.1.xlsx","sec/security");
mi.importUseCaseModels();
mi.finish();
......
......@@ -26,6 +26,7 @@ import eu.paasage.camel.location.LocationModel;
public class LocationGenerator {
private String path;
private LocationModel lm = null;
private boolean alterNames = false;
public LocationGenerator(String path){
this.path = path;
......@@ -73,7 +74,7 @@ public class LocationGenerator {
cn.setName(officialName);
st = ind.getProperty(code);
if (st == null){
cn.setId(officialName);
cn.setId(officialName.replace(" ", "_").replace("-","_"));
}
else{
cn.setId(st.getString());
......
......@@ -99,9 +99,10 @@ public class SecurityPopulator {
units.add(secs);*/
sm = SecurityFactory.eINSTANCE.createSecurityModel();
sm.setName("Basic Security Model");
sm.setName("Basic_Security_Model");
EList<SecurityControl> secControls = sm.getSecurityControls();
//Process remaining rows
int subDomainIndex = 0;
while (rowIterator.hasNext()){
Row row = rowIterator.next();
Cell cell = row.getCell(0);
......@@ -109,8 +110,8 @@ public class SecurityPopulator {
String domain = cell.getStringCellValue();
if (domain == null || domain.trim().equals("")) break;
cell = row.getCell(1);
String id = cell.getStringCellValue();
String domainId = id.substring(0,id.indexOf("-"));
String id = cell.getStringCellValue().replace("-", "_");
String domainId = id.substring(0,id.indexOf("_"));
cell = row.getCell(2);
String description = cell.getStringCellValue();
SecurityControl sc = SecurityFactory.eINSTANCE.createSecurityControl();
......@@ -128,12 +129,13 @@ public class SecurityPopulator {
sd.setId(domainId);
secDomIds.put(domainId, sd);
sm.getSecurityDomains().add(sd);
subDomainIndex = 0;
}
sc.setDomain(sd);
SecurityDomain subDomain = SecurityFactory.eINSTANCE.createSecurityDomain();
subDomain.setName(domainName);
subDomain.setId(nameToId(domainName));
subDomain.setId(domainId + "_" + (subDomainIndex++) + "_" + nameToId(domainName));
sc.setName(id);
sc.setSubDomain(subDomain);
sm.getSecurityDomains().add(subDomain);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment