use of org.openlca.core.database.DQSystemDao 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.DQSystemDao in project olca-modules by GreenDelta.
the class DQResultTest method createDQSystem.
private void createDQSystem() {
dqSystem = new DQSystem();
for (int i = 1; i <= 5; i++) {
DQIndicator indicator = new DQIndicator();
indicator.position = i;
dqSystem.indicators.add(indicator);
for (int j = 1; j <= 5; j++) {
DQScore score = new DQScore();
score.position = j;
indicator.scores.add(score);
}
}
dqSystem = new DQSystemDao(db).insert(dqSystem);
}
use of org.openlca.core.database.DQSystemDao in project olca-modules by GreenDelta.
the class DqSystemImport method of.
@Override
public ImportStatus<DQSystem> of(String id) {
var dqSystem = imp.get(DQSystem.class, id);
// check if we are in update mode
var update = false;
if (dqSystem != null) {
update = imp.shouldUpdate(dqSystem);
if (!update) {
return ImportStatus.skipped(dqSystem);
}
}
// resolve the proto object
var proto = imp.reader.getDQSystem(id);
if (proto == null)
return dqSystem != null ? ImportStatus.skipped(dqSystem) : ImportStatus.error("Could not resolve DQSystem " + id);
var wrap = ProtoWrap.of(proto);
if (update) {
if (imp.skipUpdate(dqSystem, wrap))
return ImportStatus.skipped(dqSystem);
}
// map the data
if (dqSystem == null) {
dqSystem = new DQSystem();
dqSystem.refId = id;
}
wrap.mapTo(dqSystem, imp);
map(proto, dqSystem);
// insert or update it
var dao = new DQSystemDao(imp.db);
dqSystem = update ? dao.update(dqSystem) : dao.insert(dqSystem);
imp.putHandled(dqSystem);
return update ? ImportStatus.updated(dqSystem) : ImportStatus.created(dqSystem);
}
use of org.openlca.core.database.DQSystemDao in project olca-modules by GreenDelta.
the class DQSystems method ecoinvent.
/**
* Returns the ecoinvent data quality system from the database. It creates a
* new instance of the system and inserts it in the database if it does not
* exist yet.
*/
public static DQSystem ecoinvent(IDatabase db) {
if (db == null)
return null;
DQSystemDao dao = new DQSystemDao(db);
DQSystem dqs = dao.getForRefId(EI_DQS);
if (dqs == null) {
dqs = dao.insert(ecoinvent());
}
return dqs;
}
use of org.openlca.core.database.DQSystemDao in project olca-app by GreenDelta.
the class DQSystemViewer method setInput.
public void setInput(IDatabase db) {
List<DQSystemDescriptor> systems = new DQSystemDao(db).getDescriptors();
Collections.sort(systems, (sys1, sys2) -> {
if (sys1 == null || sys2 == null)
return 0;
return Strings.compare(sys1.name, sys2.name);
});
super.setInput(systems);
}
Aggregations