Search in sources :

Example 1 with DQSystemDao

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));
}
Also used : SourceDao(org.openlca.core.database.SourceDao) CurrencyDao(org.openlca.core.database.CurrencyDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) CategoryDao(org.openlca.core.database.CategoryDao) ActorDao(org.openlca.core.database.ActorDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) LocationDao(org.openlca.core.database.LocationDao) UnitDao(org.openlca.core.database.UnitDao) DQSystemDao(org.openlca.core.database.DQSystemDao) NwSetDao(org.openlca.core.database.NwSetDao) FlowDao(org.openlca.core.database.FlowDao) ImpactMethodDao(org.openlca.core.database.ImpactMethodDao) ProcessDao(org.openlca.core.database.ProcessDao) UnitGroupDao(org.openlca.core.database.UnitGroupDao) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) ProductSystemDao(org.openlca.core.database.ProductSystemDao) ProjectDao(org.openlca.core.database.ProjectDao)

Example 2 with DQSystemDao

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);
}
Also used : DQScore(org.openlca.core.model.DQScore) DQSystem(org.openlca.core.model.DQSystem) DQIndicator(org.openlca.core.model.DQIndicator) DQSystemDao(org.openlca.core.database.DQSystemDao)

Example 3 with DQSystemDao

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);
}
Also used : DQSystem(org.openlca.core.model.DQSystem) ProtoDQSystem(org.openlca.proto.ProtoDQSystem) DQSystemDao(org.openlca.core.database.DQSystemDao)

Example 4 with DQSystemDao

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

Example 5 with DQSystemDao

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

Aggregations

DQSystemDao (org.openlca.core.database.DQSystemDao)5 DQSystem (org.openlca.core.model.DQSystem)3 ActorDao (org.openlca.core.database.ActorDao)1 CategoryDao (org.openlca.core.database.CategoryDao)1 CurrencyDao (org.openlca.core.database.CurrencyDao)1 FlowDao (org.openlca.core.database.FlowDao)1 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)1 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)1 ImpactMethodDao (org.openlca.core.database.ImpactMethodDao)1 LocationDao (org.openlca.core.database.LocationDao)1 NwSetDao (org.openlca.core.database.NwSetDao)1 ProcessDao (org.openlca.core.database.ProcessDao)1 ProductSystemDao (org.openlca.core.database.ProductSystemDao)1 ProjectDao (org.openlca.core.database.ProjectDao)1 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)1 SourceDao (org.openlca.core.database.SourceDao)1 UnitDao (org.openlca.core.database.UnitDao)1 UnitGroupDao (org.openlca.core.database.UnitGroupDao)1 DQIndicator (org.openlca.core.model.DQIndicator)1 DQScore (org.openlca.core.model.DQScore)1