Search in sources :

Example 11 with SocialIndicator

use of org.openlca.core.model.SocialIndicator in project olca-modules by GreenDelta.

the class SocialIndicatorUseSearchTest method setup.

@Before
public void setup() {
    indicator = new SocialIndicator();
    indicator.name = "indicator";
    indicator = db.insert(indicator);
}
Also used : SocialIndicator(org.openlca.core.model.SocialIndicator) Before(org.junit.Before)

Example 12 with SocialIndicator

use of org.openlca.core.model.SocialIndicator in project olca-modules by GreenDelta.

the class SocialIndicatorImport method of.

@Override
public ImportStatus<SocialIndicator> of(String id) {
    var indicator = imp.get(SocialIndicator.class, id);
    // check if we are in update mode
    var update = false;
    if (indicator != null) {
        update = imp.shouldUpdate(indicator);
        if (!update) {
            return ImportStatus.skipped(indicator);
        }
    }
    // resolve the proto object
    var proto = imp.reader.getSocialIndicator(id);
    if (proto == null)
        return indicator != null ? ImportStatus.skipped(indicator) : ImportStatus.error("Could not resolve SocialIndicator " + id);
    var wrap = ProtoWrap.of(proto);
    if (update) {
        if (imp.skipUpdate(indicator, wrap))
            return ImportStatus.skipped(indicator);
    }
    // map the data
    if (indicator == null) {
        indicator = new SocialIndicator();
        indicator.refId = id;
    }
    wrap.mapTo(indicator, imp);
    map(proto, indicator);
    // insert or update it
    var dao = new SocialIndicatorDao(imp.db);
    indicator = update ? dao.update(indicator) : dao.insert(indicator);
    imp.putHandled(indicator);
    return update ? ImportStatus.updated(indicator) : ImportStatus.created(indicator);
}
Also used : SocialIndicator(org.openlca.core.model.SocialIndicator) ProtoSocialIndicator(org.openlca.proto.ProtoSocialIndicator) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao)

Example 13 with SocialIndicator

use of org.openlca.core.model.SocialIndicator in project olca-app by GreenDelta.

the class SocialAspectsPage method addIndicator.

private void addIndicator(Descriptor d) {
    SocialIndicatorDao dao = new SocialIndicatorDao(Database.get());
    SocialIndicator i = dao.getForId(d.id);
    SocialAspect a = new SocialAspect();
    a.indicator = i;
    getModel().socialAspects.add(a);
    treeModel.addAspect(a);
    tree.refresh();
    editor.setDirty(true);
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect) SocialIndicator(org.openlca.core.model.SocialIndicator) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao)

Example 14 with SocialIndicator

use of org.openlca.core.model.SocialIndicator in project olca-app by GreenDelta.

the class TreeLabel method getActivityValue.

private String getActivityValue(SocialAspect a) {
    if (a == null || a.indicator == null)
        return null;
    String t = Double.toString(a.activityValue);
    SocialIndicator i = a.indicator;
    if (i.activityVariable != null && i.activityUnit != null) {
        t += " [" + i.activityUnit.name + ", " + i.activityVariable + "]";
    }
    return t;
}
Also used : SocialIndicator(org.openlca.core.model.SocialIndicator)

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