use of org.openlca.core.database.FlowPropertyDao in project olca-modules by GreenDelta.
the class EcoSpold2ImportTest method createUnit.
private void createUnit(String unitRefId, String propertyRefId, String name) {
Unit unit = new Unit();
unit.name = name;
unit.refId = unitRefId;
UnitGroup group = new UnitGroup();
group.refId = UUID.randomUUID().toString();
group.referenceUnit = unit;
group.units.add(unit);
group = new UnitGroupDao(Tests.getDb()).insert(group);
FlowProperty prop = new FlowProperty();
prop.unitGroup = group;
prop.name = "property for " + name;
prop.refId = propertyRefId;
prop = new FlowPropertyDao(Tests.getDb()).insert(prop);
group.defaultFlowProperty = prop;
group = new UnitGroupDao(Tests.getDb()).update(group);
}
use of org.openlca.core.database.FlowPropertyDao in project olca-modules by GreenDelta.
the class TestData method property.
public static FlowProperty property(String unit) {
String refId = KeyGen.get("property", unit);
FlowPropertyDao dao = new FlowPropertyDao(Tests.getDb());
FlowProperty prop = dao.getForRefId(refId);
if (prop != null)
return prop;
prop = new FlowProperty();
prop.name = "Flow property for " + unit;
prop.flowPropertyType = FlowPropertyType.PHYSICAL;
prop.refId = refId;
prop.unitGroup = unitGroup(unit);
return dao.insert(prop);
}
use of org.openlca.core.database.FlowPropertyDao in project olca-modules by GreenDelta.
the class FlowPropertyFactorUseSearchTest method tearDown.
@After
public void tearDown() {
new FlowDao(database).delete(flow);
new FlowPropertyDao(database).delete(property);
}
use of org.openlca.core.database.FlowPropertyDao in project olca-modules by GreenDelta.
the class DatabaseImport method updateUnitGroups.
/**
* Set the default flow properties in the given unit groups.
*/
private void updateUnitGroups(HashMap<String, UnitGroup> requireUpdate, Sequence seq) {
FlowPropertyDao propertyDao = new FlowPropertyDao(dest);
UnitGroupDao unitGroupDao = new UnitGroupDao(dest);
for (String refId : requireUpdate.keySet()) {
UnitGroup unitGroup = requireUpdate.get(refId);
long propId = seq.get(seq.FLOW_PROPERTY, refId);
unitGroup.defaultFlowProperty = propertyDao.getForId(propId);
unitGroup.lastChange = Calendar.getInstance().getTimeInMillis();
Version.incUpdate(unitGroup);
unitGroupDao.update(unitGroup);
}
}
use of org.openlca.core.database.FlowPropertyDao in project olca-modules by GreenDelta.
the class FlowPropertyExport method doIt.
@Override
protected void doIt(CSVPrinter printer, IDatabase db) throws IOException {
log.trace("write flow properties");
FlowPropertyDao dao = new FlowPropertyDao(db);
List<FlowProperty> properties = dao.getAll();
for (FlowProperty property : properties) {
Object[] line = createLine(property);
printer.printRecord(line);
}
log.trace("{} flow properties written", properties.size());
}
Aggregations