Search in sources :

Example 1 with UnitGroupDao

use of org.openlca.core.database.UnitGroupDao in project olca-modules by GreenDelta.

the class TestData method unitGroup.

public static UnitGroup unitGroup(String unit) {
    String groupId = KeyGen.get("group", unit);
    UnitGroupDao dao = new UnitGroupDao(Tests.getDb());
    UnitGroup group = dao.getForRefId(groupId);
    if (group != null)
        return group;
    group = new UnitGroup();
    group.name = "Unit group of " + unit;
    group.refId = groupId;
    String unitId = KeyGen.get("unit", unit);
    Unit refUnit = new Unit();
    refUnit.refId = unitId;
    refUnit.name = unit;
    refUnit.conversionFactor = 1.0;
    group.units.add(refUnit);
    group.referenceUnit = refUnit;
    return dao.insert(group);
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) Unit(org.openlca.core.model.Unit) UnitGroupDao(org.openlca.core.database.UnitGroupDao)

Example 2 with UnitGroupDao

use of org.openlca.core.database.UnitGroupDao 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 3 with UnitGroupDao

use of org.openlca.core.database.UnitGroupDao in project olca-modules by GreenDelta.

the class UnitGroupSheet method write.

private void write() {
    Excel.trackSize(sheet, 0, 7);
    writeHeader();
    var groups = new UnitGroupDao(config.database).getAll();
    groups.sort(new EntitySorter());
    for (UnitGroup group : groups) {
        row++;
        write(group);
    }
    Excel.autoSize(sheet, 0, 7);
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) UnitGroupDao(org.openlca.core.database.UnitGroupDao)

Example 4 with UnitGroupDao

use of org.openlca.core.database.UnitGroupDao in project olca-modules by GreenDelta.

the class UnitExport method doIt.

@Override
protected void doIt(CSVPrinter printer, IDatabase db) throws IOException {
    log.trace("write units");
    UnitGroupDao dao = new UnitGroupDao(db);
    int count = 0;
    for (UnitGroup unitGroup : dao.getAll()) {
        for (Unit unit : unitGroup.units) {
            Object[] line = createLine(unitGroup, unit);
            printer.printRecord(line);
        }
        count++;
    }
    log.trace("{} units written", count);
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) Unit(org.openlca.core.model.Unit) UnitGroupDao(org.openlca.core.database.UnitGroupDao)

Example 5 with UnitGroupDao

use of org.openlca.core.database.UnitGroupDao in project olca-modules by GreenDelta.

the class UnitGroupExport method doIt.

@Override
protected void doIt(CSVPrinter printer, IDatabase db) throws Exception {
    log.trace("write unit groups");
    UnitGroupDao dao = new UnitGroupDao(db);
    List<UnitGroup> groups = dao.getAll();
    for (UnitGroup group : groups) {
        Object[] line = createLine(group);
        printer.printRecord(line);
    }
    log.trace("{} unit groups written", groups.size());
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) UnitGroupDao(org.openlca.core.database.UnitGroupDao)

Aggregations

UnitGroupDao (org.openlca.core.database.UnitGroupDao)19 UnitGroup (org.openlca.core.model.UnitGroup)14 Unit (org.openlca.core.model.Unit)9 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)7 FlowProperty (org.openlca.core.model.FlowProperty)4 Test (org.junit.Test)3 FlowDao (org.openlca.core.database.FlowDao)3 ProcessDao (org.openlca.core.database.ProcessDao)3 ProductSystemDao (org.openlca.core.database.ProductSystemDao)2 UnitDao (org.openlca.core.database.UnitDao)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ActorDao (org.openlca.core.database.ActorDao)1 CategoryDao (org.openlca.core.database.CategoryDao)1 CurrencyDao (org.openlca.core.database.CurrencyDao)1 DQSystemDao (org.openlca.core.database.DQSystemDao)1 IDatabase (org.openlca.core.database.IDatabase)1 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)1 ImpactMethodDao (org.openlca.core.database.ImpactMethodDao)1 LocationDao (org.openlca.core.database.LocationDao)1