Search in sources :

Example 6 with SocialIndicator

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

Example 7 with SocialIndicator

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

Example 8 with SocialIndicator

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();
}
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)

Example 9 with SocialIndicator

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

Example 10 with SocialIndicator

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);
}
Also used : Category(org.openlca.core.model.Category) UnitGroup(org.openlca.core.model.UnitGroup) SocialIndicator(org.openlca.core.model.SocialIndicator) Unit(org.openlca.core.model.Unit) FlowProperty(org.openlca.core.model.FlowProperty)

Aggregations

SocialIndicator (org.openlca.core.model.SocialIndicator)14 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)4 SocialAspect (org.openlca.core.model.SocialAspect)3 Test (org.junit.Test)2 Category (org.openlca.core.model.Category)2 FlowProperty (org.openlca.core.model.FlowProperty)2 Process (org.openlca.core.model.Process)2 Source (org.openlca.core.model.Source)2 UnitGroup (org.openlca.core.model.UnitGroup)2 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 IDatabase (org.openlca.core.database.IDatabase)1 ProcessDao (org.openlca.core.database.ProcessDao)1 Actor (org.openlca.core.model.Actor)1 Currency (org.openlca.core.model.Currency)1 DQSystem (org.openlca.core.model.DQSystem)1 Flow (org.openlca.core.model.Flow)1 ImpactCategory (org.openlca.core.model.ImpactCategory)1 ImpactMethod (org.openlca.core.model.ImpactMethod)1 Location (org.openlca.core.model.Location)1