use of org.openlca.core.model.SocialAspect in project olca-modules by GreenDelta.
the class ProcessImport method aspect.
private SocialAspect aspect(JsonObject json) {
SocialAspect a = new SocialAspect();
a.indicator = SocialIndicatorImport.run(Json.getRefId(json, "socialIndicator"), conf);
a.comment = Json.getString(json, "comment");
a.quality = Json.getString(json, "quality");
a.rawAmount = Json.getString(json, "rawAmount");
a.activityValue = Json.getDouble(json, "activityValue", 0d);
a.riskLevel = Json.getEnum(json, "riskLevel", RiskLevel.class);
a.source = SourceImport.run(Json.getRefId(json, "source"), conf);
return a;
}
use of org.openlca.core.model.SocialAspect in project olca-modules by GreenDelta.
the class ProcessImport method addSocialAspects.
private void addSocialAspects(JsonObject json, Process p) {
JsonArray aspects = Json.getArray(json, "socialAspects");
if (aspects == null || aspects.size() == 0)
return;
for (JsonElement a : aspects) {
if (!a.isJsonObject())
continue;
JsonObject o = a.getAsJsonObject();
SocialAspect aspect = aspect(o);
p.socialAspects.add(aspect);
}
}
use of org.openlca.core.model.SocialAspect in project olca-modules by GreenDelta.
the class SystemProcess method copyMetaData.
private void copyMetaData(Process p) {
Process refProc = setup.process();
if (refProc == null)
return;
for (SocialAspect sa : refProc.socialAspects) p.socialAspects.add(sa.copy());
p.socialDqSystem = refProc.socialDqSystem;
p.category = refProc.category;
p.defaultAllocationMethod = refProc.defaultAllocationMethod;
p.description = refProc.description;
if (refProc.documentation != null)
p.documentation = refProc.documentation.copy();
p.infrastructureProcess = refProc.infrastructureProcess;
p.lastChange = new Date().getTime();
p.location = refProc.location;
}
use of org.openlca.core.model.SocialAspect 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.SocialAspect 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();
}
Aggregations