Search in sources :

Example 1 with Unit

use of org.openlca.core.model.Unit 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 Unit

use of org.openlca.core.model.Unit 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 Unit

use of org.openlca.core.model.Unit 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 Unit

use of org.openlca.core.model.Unit 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 Unit

use of org.openlca.core.model.Unit in project olca-modules by GreenDelta.

the class ProductSystemImport method sameExchange.

private boolean sameExchange(Exchange srcExchange, Exchange destExchange) {
    if (srcExchange.isInput != destExchange.isInput)
        return false;
    Unit srcUnit = srcExchange.unit;
    Unit destUnit = destExchange.unit;
    Flow srcFlow = srcExchange.flow;
    Flow destFlow = destExchange.flow;
    return srcUnit != null && destUnit != null && srcFlow != null && destFlow != null && Strings.nullOrEqual(srcUnit.refId, destUnit.refId) && Strings.nullOrEqual(srcFlow.refId, destFlow.refId);
}
Also used : Unit(org.openlca.core.model.Unit) Flow(org.openlca.core.model.Flow)

Aggregations

Unit (org.openlca.core.model.Unit)50 UnitGroup (org.openlca.core.model.UnitGroup)18 Flow (org.openlca.core.model.Flow)13 FlowProperty (org.openlca.core.model.FlowProperty)13 FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)11 UnitGroupDao (org.openlca.core.database.UnitGroupDao)9 ArrayList (java.util.ArrayList)6 FlowDao (org.openlca.core.database.FlowDao)4 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)4 List (java.util.List)3 IDatabase (org.openlca.core.database.IDatabase)3 Collections (java.util.Collections)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Objects (java.util.Objects)2 Test (org.junit.Test)2 M (org.openlca.app.M)2 ProcessDao (org.openlca.core.database.ProcessDao)2 UnitDao (org.openlca.core.database.UnitDao)2 ImpactFactor (org.openlca.core.model.ImpactFactor)2