use of org.openlca.core.model.SocialIndicator in project olca-modules by GreenDelta.
the class SocialIndicatorImport method map.
@Override
SocialIndicator map(JsonObject json, long id) {
if (json == null)
return null;
SocialIndicator i = new SocialIndicator();
In.mapAtts(json, i, id, conf);
i.activityVariable = Json.getString(json, "activityVariable");
i.evaluationScheme = Json.getString(json, "evaluationScheme");
i.unitOfMeasurement = Json.getString(json, "unitOfMeasurement");
// import the quantity before setting the unit to assure that the
// unit is already in the database
String quanId = Json.getRefId(json, "activityQuantity");
i.activityQuantity = FlowPropertyImport.run(quanId, conf);
String unitId = Json.getRefId(json, "activityUnit");
i.activityUnit = conf.db.get(ModelType.UNIT, unitId);
return conf.db.put(i);
}
use of org.openlca.core.model.SocialIndicator in project olca-app by GreenDelta.
the class TreeModel method addAspect.
void addAspect(SocialAspect a) {
if (a == null || a.indicator == null)
return;
SocialIndicator i = a.indicator;
CategoryNode n = getNode(i.category);
n.aspects.add(a);
}
use of org.openlca.core.model.SocialIndicator in project olca-modules by GreenDelta.
the class TestSocialAspectImport method testCopySocialAspects.
/**
* Test that social aspects of processes are copied between databases:
* https://github.com/GreenDelta/olca-app/issues/88. We ignore this test by
* default, because creating temporary databases take so long...
*/
@Test
@Ignore
public void testCopySocialAspects() throws Exception {
IDatabase db1 = Derby.createInMemory();
SocialIndicator indicator = new SocialIndicator();
indicator.refId = "si";
SocialIndicatorDao idao = new SocialIndicatorDao(db1);
idao.insert(indicator);
Process process = new Process();
process.refId = "pr";
SocialAspect aspect = new SocialAspect();
aspect.indicator = indicator;
process.socialAspects.add(aspect);
ProcessDao pdao = new ProcessDao(db1);
pdao.insert(process);
IDatabase db2 = Derby.createInMemory();
DatabaseImport imp = new DatabaseImport(db1, db2);
imp.run();
db1.close();
idao = new SocialIndicatorDao(db2);
indicator = idao.getForRefId("si");
assertNotNull(indicator);
pdao = new ProcessDao(db2);
process = pdao.getForRefId("pr");
assertEquals(1, process.socialAspects.size());
aspect = process.socialAspects.get(0);
assertNotNull(aspect.indicator);
assertEquals("si", aspect.indicator.refId);
db2.close();
}
use of org.openlca.core.model.SocialIndicator in project olca-modules by GreenDelta.
the class ProcessReferenceSearchTest method createSocialAspect.
private SocialAspect createSocialAspect() {
SocialAspect aspect = new SocialAspect();
aspect.indicator = db.insert(new SocialIndicator());
aspect.source = db.insert(new Source());
return aspect;
}
use of org.openlca.core.model.SocialIndicator in project olca-modules by GreenDelta.
the class SocialIndicatorReferenceSearchTest method createModel.
@Override
protected SocialIndicator createModel() {
SocialIndicator indicator = new SocialIndicator();
indicator.category = insertAndAddExpected("category", new Category());
indicator.activityQuantity = insertAndAddExpected("activityQuantity", new FlowProperty());
UnitGroup group = new UnitGroup();
Unit unit = new Unit();
group.units.add(unit);
indicator.activityUnit = unit;
group = db.insert(group);
addExpected("activityUnit", unit);
return db.insert(indicator);
}
Aggregations