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