use of org.openlca.core.database.SocialIndicatorDao in project olca-modules by GreenDelta.
the class Sequence method init.
private void init(IDatabase db) {
index(CATEGORY, new CategoryDao(db));
index(LOCATION, new LocationDao(db));
index(ACTOR, new ActorDao(db));
index(SOURCE, new SourceDao(db));
index(UNIT, new UnitDao(db));
index(UNIT_GROUP, new UnitGroupDao(db));
index(FLOW_PROPERTY, new FlowPropertyDao(db));
index(FLOW, new FlowDao(db));
index(CURRENCY, new CurrencyDao(db));
index(PROCESS, new ProcessDao(db));
index(PRODUCT_SYSTEM, new ProductSystemDao(db));
index(IMPACT_CATEGORY, new ImpactCategoryDao(db));
index(IMPACT_METHOD, new ImpactMethodDao(db));
index(NW_SET, new NwSetDao(db));
index(PROJECT, new ProjectDao(db));
index(DQ_SYSTEM, new DQSystemDao(db));
index(SOCIAL_INDICATOR, new SocialIndicatorDao(db));
}
use of org.openlca.core.database.SocialIndicatorDao in project olca-modules by GreenDelta.
the class SocialIndicatorTest method testSocialIndicator.
@Test
public void testSocialIndicator() {
SocialIndicatorDao dao = new SocialIndicatorDao(Tests.getDb());
SocialIndicator indicator = createModel(dao);
doExport(indicator, dao);
doImport(dao, indicator);
dao.delete(indicator);
}
use of org.openlca.core.database.SocialIndicatorDao 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();
}
use of org.openlca.core.database.SocialIndicatorDao 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.database.SocialIndicatorDao 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);
}
Aggregations