Search in sources :

Example 11 with FlowPropertyDao

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);
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) Unit(org.openlca.core.model.Unit) UnitGroupDao(org.openlca.core.database.UnitGroupDao) FlowProperty(org.openlca.core.model.FlowProperty)

Example 12 with FlowPropertyDao

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

Example 13 with FlowPropertyDao

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);
}
Also used : FlowDao(org.openlca.core.database.FlowDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) After(org.junit.After)

Example 14 with FlowPropertyDao

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

Example 15 with FlowPropertyDao

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

Aggregations

FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)20 FlowProperty (org.openlca.core.model.FlowProperty)14 FlowDao (org.openlca.core.database.FlowDao)7 UnitGroupDao (org.openlca.core.database.UnitGroupDao)7 ProcessDao (org.openlca.core.database.ProcessDao)5 Flow (org.openlca.core.model.Flow)5 Unit (org.openlca.core.model.Unit)5 UnitGroup (org.openlca.core.model.UnitGroup)5 IDatabase (org.openlca.core.database.IDatabase)3 UnitDao (org.openlca.core.database.UnitDao)3 Process (org.openlca.core.model.Process)3 ArrayList (java.util.ArrayList)2 After (org.junit.After)2 Before (org.junit.Before)2 Test (org.junit.Test)2 CategoryDao (org.openlca.core.database.CategoryDao)2 LocationDao (org.openlca.core.database.LocationDao)2 ProductSystemDao (org.openlca.core.database.ProductSystemDao)2 FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)2 FlowType (org.openlca.core.model.FlowType)2