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