Search in sources :

Example 6 with SocialAspect

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;
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect) RiskLevel(org.openlca.core.model.RiskLevel)

Example 7 with SocialAspect

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);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) SocialAspect(org.openlca.core.model.SocialAspect) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject)

Example 8 with SocialAspect

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;
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect) Process(org.openlca.core.model.Process) Date(java.util.Date)

Example 9 with SocialAspect

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;
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect) SocialIndicator(org.openlca.core.model.SocialIndicator) Source(org.openlca.core.model.Source)

Example 10 with SocialAspect

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();
}
Also used : IDatabase(org.openlca.core.database.IDatabase) SocialAspect(org.openlca.core.model.SocialAspect) ProcessDao(org.openlca.core.database.ProcessDao) SocialIndicator(org.openlca.core.model.SocialIndicator) Process(org.openlca.core.model.Process) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

SocialAspect (org.openlca.core.model.SocialAspect)14 Process (org.openlca.core.model.Process)3 SocialIndicator (org.openlca.core.model.SocialIndicator)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)2 Source (org.openlca.core.model.Source)2 JsonElement (com.google.gson.JsonElement)1 Date (java.util.Date)1 Composite (org.eclipse.swt.widgets.Composite)1 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 IDatabase (org.openlca.core.database.IDatabase)1 ProcessDao (org.openlca.core.database.ProcessDao)1 Category (org.openlca.core.model.Category)1 DQSystem (org.openlca.core.model.DQSystem)1 Exchange (org.openlca.core.model.Exchange)1 Location (org.openlca.core.model.Location)1 Parameter (org.openlca.core.model.Parameter)1