Search in sources :

Example 1 with UnitGroup

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

Example 2 with UnitGroup

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

Example 3 with UnitGroup

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

Example 4 with UnitGroup

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;
}
Also used : ProjectVariant(org.openlca.core.model.ProjectVariant) UnitGroup(org.openlca.core.model.UnitGroup) ProductSystem(org.openlca.core.model.ProductSystem) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) Unit(org.openlca.core.model.Unit) FlowProperty(org.openlca.core.model.FlowProperty) Flow(org.openlca.core.model.Flow)

Example 5 with UnitGroup

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

Aggregations

UnitGroup (org.openlca.core.model.UnitGroup)44 FlowProperty (org.openlca.core.model.FlowProperty)18 Unit (org.openlca.core.model.Unit)18 UnitGroupDao (org.openlca.core.database.UnitGroupDao)14 Flow (org.openlca.core.model.Flow)9 FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)6 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)5 Category (org.openlca.core.model.Category)4 Process (org.openlca.core.model.Process)4 Test (org.junit.Test)3 Actor (org.openlca.core.model.Actor)3 ProductSystem (org.openlca.core.model.ProductSystem)3 Source (org.openlca.core.model.Source)3 ArrayList (java.util.ArrayList)2 FlowDao (org.openlca.core.database.FlowDao)2 ProcessDao (org.openlca.core.database.ProcessDao)2 ImpactMethod (org.openlca.core.model.ImpactMethod)2 SocialIndicator (org.openlca.core.model.SocialIndicator)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1