use of org.openlca.core.model.UnitGroup in project olca-modules by GreenDelta.
the class ImpactMethodReferenceSearchTest method createFlow.
private Flow createFlow() {
Flow flow = new Flow();
UnitGroup group = new UnitGroup();
Unit unit = new Unit();
unit.name = "unit";
group.units.add(unit);
group = db.insert(group);
FlowProperty property = new FlowProperty();
property.unitGroup = group;
property = db.insert(property);
FlowPropertyFactor factor = new FlowPropertyFactor();
factor.flowProperty = property;
flow.flowPropertyFactors.add(factor);
return db.insert(flow);
}
use of org.openlca.core.model.UnitGroup in project olca-modules by GreenDelta.
the class TestData method unit.
public static Unit unit(String name) {
String unitId = KeyGen.get("unit", name);
UnitDao dao = new UnitDao(Tests.getDb());
Unit unit = dao.getForRefId(unitId);
if (unit != null)
return unit;
UnitGroup group = unitGroup(name);
return group.referenceUnit;
}
use of org.openlca.core.model.UnitGroup 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.model.UnitGroup in project olca-modules by GreenDelta.
the class ProjectReferenceSearchTest method createProjectVariant.
private ProjectVariant createProjectVariant(String p1Name, String p2Name, String p3Name, long methodId) {
ProjectVariant variant = new ProjectVariant();
variant.productSystem = db.insert(new ProductSystem());
variant.parameterRedefs.add(createParameterRedef(p1Name, methodId));
variant.parameterRedefs.add(createParameterRedef(p2Name, p3Name + "*5"));
FlowPropertyFactor factor = new FlowPropertyFactor();
factor.flowProperty = db.insert(new FlowProperty());
variant.flowPropertyFactor = factor;
UnitGroup unitGroup = new UnitGroup();
Unit unit = new Unit();
unit.name = "unit";
unitGroup.units.add(unit);
unitGroup = db.insert(unitGroup);
unit = unitGroup.getUnit(unit.name);
variant.unit = unit;
Flow flow = new Flow();
flow.flowPropertyFactors.add(factor);
// don't add flow to expected references, just for persisting the factor
flow = db.insert(flow);
return variant;
}
use of org.openlca.core.model.UnitGroup in project olca-modules by GreenDelta.
the class UnitGroupReferenceSearchTest method createModel.
@Override
protected UnitGroup createModel() {
UnitGroup group = new UnitGroup();
group.category = insertAndAddExpected("category", new Category());
group.defaultFlowProperty = insertAndAddExpected("defaultFlowProperty", new FlowProperty());
return db.insert(group);
}
Aggregations