Commit 649ee215 authored by Kyriakos Kritikos's avatar Kyriakos Kritikos

Small update

parent f0300396
......@@ -190,7 +190,7 @@ public class ModelImporter {
logger.debug("Processing country: " + name);
Country corCountry = null;
if (!hibernate)
corCountry = trans.createQuery("sql", "select distinct c.* from CAMEL_COUNTRY c, CAMEL_COUNTRY_ALTERNATIVENAMES_LIST list where c.name like '%" + name + "%' or (list.cdo_source=c.cdo_id and list.cdo_value='" + name + "')").getResult(Country.class).get(0);
corCountry = trans.createQuery("sql", "select distinct c.* from CAMEL_LOCATION_COUNTRY c, CAMEL_LOCATION_COUNTRY_ALTERNATIVENAMES_LIST list where c.name like '%" + name + "%' or (list.cdo_source=c.cdo_id and list.cdo_value='" + name + "')").getResult(Country.class).get(0);
else
corCountry = trans.createQuery("hql", "select c from Country c where c.name like '%" + name + "%' or '" + name + "' member of c.alternativeNames").getResult(Country.class).get(0);
Collection<Setting> references = EcoreUtil.UsageCrossReferencer.find(country, country.eResource());
......@@ -213,7 +213,7 @@ public class ModelImporter {
logger.debug("Processing region: " + name);
GeographicalRegion corRegion = null;
if (!hibernate)
corRegion = trans.createQuery("sql", "select distinct r.* from CAMEL_GEOGRAPHICALREGION r, CAMEL_GEOGRAPHICALREGION_ALTERNATIVENAMES_LIST list where r.name='" + name + "' or (list.cdo_source=r.cdo_id and list.cdo_value='" + name + "')").getResult(GeographicalRegion.class).get(0);
corRegion = trans.createQuery("sql", "select distinct r.* from CAMEL_LOCATION_GEOGRAPHICALREGION r, CAMEL_LOCATION_GEOGRAPHICALREGION_ALTERNATIVENAMES_LIST list where r.name='" + name + "' or (list.cdo_source=r.cdo_id and list.cdo_value='" + name + "')").getResult(GeographicalRegion.class).get(0);
else
corRegion = trans.createQuery("hql", "select r from GeographicalRegion r where r.name='" + name + "' or '" + name + "' member of r.alternativeNames").getResult(GeographicalRegion.class).get(0);
Collection<Setting> references = EcoreUtil.UsageCrossReferencer.find(region, region.eResource());
......@@ -310,7 +310,7 @@ public class ModelImporter {
CamelModel cm2 = (CamelModel)trans.getOrCreateResource(userPath + "/" + userEmail).getContents().get(0);
User u = null;
if (!hibernate)
u = trans.createQuery("sql", "select u.* from CAMEL_USER u where u.email='" + user.getEmail() + "'").getResult(User.class).get(0);
u = trans.createQuery("sql", "select u.* from CAMEL_ORGANISATION_USER u where u.email='" + user.getEmail() + "'").getResult(User.class).get(0);
else
u = trans.createQuery("hql", "select u from User u where u.email='" + user.getEmail() + "'").getResult(User.class).get(0);
u.getRequirementModels().addAll(cm2.getRequirementModels());
......@@ -369,8 +369,8 @@ public class ModelImporter {
DataCenter flexiant = null;
DataCenter gwdg = null;
if (!hibernate){
flexiant = trans.createQuery("sql", "select dc.* from CAMEL_ORGANISATION cp, CAMEL_DATACENTER dc, CAMEL_ORGANISATIONMODEL om, CAMEL_ORGANISATIONMODEL_DATACENTRES_LIST list where cp.name='Flexiant' and list.cdo_source=om.cdo_id and list.cdo_value=dc.cdo_id and om.organisation=cp.cdo_id").getResult(DataCenter.class).get(0);
gwdg = trans.createQuery("sql", "select dc.* from CAMEL_ORGANISATION cp, CAMEL_DATACENTER dc, CAMEL_ORGANISATIONMODEL om, CAMEL_ORGANISATIONMODEL_DATACENTRES_LIST list where cp.name='GWDG' and list.cdo_source=om.cdo_id and list.cdo_value=dc.cdo_id and om.organisation=cp.cdo_id").getResult(DataCenter.class).get(0);
flexiant = trans.createQuery("sql", "select dc.* from CAMEL_ORGANISATION_ORGANISATION cp, CAMEL_ORGANISATION_DATACENTER dc, CAMEL_ORGANISATION_ORGANISATIONMODEL om, CAMEL_ORGANISATION_ORGANISATIONMODEL_DATACENTRES_LIST list where cp.name='Flexiant' and list.cdo_source=om.cdo_id and list.cdo_value=dc.cdo_id and om.organisation=cp.cdo_id").getResult(DataCenter.class).get(0);
gwdg = trans.createQuery("sql", "select dc.* from CAMEL_ORGANISATION_ORGANISATION cp, CAMEL_ORGANISATION_DATACENTER dc, CAMEL_ORGANISATION_ORGANISATIONMODEL om, CAMEL_ORGANISATION_ORGANISATIONMODEL_DATACENTRES_LIST list where cp.name='GWDG' and list.cdo_source=om.cdo_id and list.cdo_value=dc.cdo_id and om.organisation=cp.cdo_id").getResult(DataCenter.class).get(0);
}
else{
flexiant = trans.createQuery("hql", "select dc from Organisation cp, Datacenter dc, OrganisationModel om where cp.name='Flexiant' and dc member of om.dataCentres and om.provider=cp").getResult(DataCenter.class).get(0);
......@@ -550,31 +550,31 @@ public class ModelImporter {
List<Unit> replUnits = new ArrayList<Unit>();
for (Unit u: units){
if (!hibernate){
List<Unit> uns = trans.createQuery("sql", "select u.* from CAMEL_COREUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
List<Unit> uns = trans.createQuery("sql", "select u.* from CAMEL_UNIT_COREUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
if (uns != null && !uns.isEmpty())
replUnits.add(uns.get(0));
else{
uns = trans.createQuery("sql", "select u.* from CAMEL_MONETARYUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
uns = trans.createQuery("sql", "select u.* from CAMEL_UNIT_MONETARYUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
if (uns != null && !uns.isEmpty())
replUnits.add(uns.get(0));
else{
uns = trans.createQuery("sql", "select u.* from CAMEL_REQUESTUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
uns = trans.createQuery("sql", "select u.* from CAMEL_UNIT_REQUESTUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
if (uns != null && !uns.isEmpty())
replUnits.add(uns.get(0));
else{
uns = trans.createQuery("sql", "select u.* from CAMEL_STORAGEUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
uns = trans.createQuery("sql", "select u.* from CAMEL_UNIT_STORAGEUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
if (uns != null && !uns.isEmpty())
replUnits.add(uns.get(0));
else{
uns = trans.createQuery("sql", "select u.* from CAMEL_THROUGHPUTUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
uns = trans.createQuery("sql", "select u.* from CAMEL_UNIT_THROUGHPUTUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
if (uns != null && !uns.isEmpty())
replUnits.add(uns.get(0));
else{
uns = trans.createQuery("sql", "select u.* from CAMEL_TIMEINTERVALUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
uns = trans.createQuery("sql", "select u.* from CAMEL_UNIT_TIMEINTERVALUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
if (uns != null && !uns.isEmpty())
replUnits.add(uns.get(0));
else{
uns = trans.createQuery("sql", "select u.* from CAMEL_TRANSACTIONUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
uns = trans.createQuery("sql", "select u.* from CAMEL_UNIT_TRANSACTIONUNIT u where lower(u.name)='" + u.getName().toLowerCase() + "'").getResult(Unit.class);
if (uns != null && !uns.isEmpty())
replUnits.add(uns.get(0));
}
......@@ -622,7 +622,7 @@ public class ModelImporter {
public static void main(String[] args){
int status = 0;
if (args.length == 0){
ModelImporter mi = new ModelImporter(true,true);
ModelImporter mi = new ModelImporter(true,false);
mi.importGeoLocationModels("input/geopolitical.owl", "locations");
mi.importProviderModels("input/providers");
//mi.importCloudLocations("input/providers/CloudLocationModel.xmi");
......
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