Search in sources :

Example 1 with FlowPropertyFactor

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

the class FlowReferenceSearchTest method createFlowPropertyFactor.

private FlowPropertyFactor createFlowPropertyFactor() {
    FlowPropertyFactor factor = new FlowPropertyFactor();
    factor.flowProperty = db.insert(new FlowProperty());
    return factor;
}
Also used : FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowProperty(org.openlca.core.model.FlowProperty)

Example 2 with FlowPropertyFactor

use of org.openlca.core.model.FlowPropertyFactor 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 3 with FlowPropertyFactor

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

the class ImpactMethodReferenceSearchTest method createModel.

@Override
protected ImpactMethod createModel() {
    ImpactMethod method = new ImpactMethod();
    method.category = insertAndAddExpected("category", new Category());
    String n1 = generateName();
    // String n2 = generateName();
    String n3 = generateName();
    String n4 = generateName();
    String n5 = generateName();
    // method.parameters.add(createParameter(n1, 3d, false));
    // method.parameters.add(createParameter(n2, n1 + "*2*" + n3, false));
    insertAndAddExpected(n3, createParameter(n3, "5*5", true));
    // formula with parameter to see if added as reference (unexpected)
    insertAndAddExpected(n4, createParameter(n4, "3*" + n5, true));
    Parameter globalUnreferenced = createParameter(n1, "3*3", true);
    Parameter globalUnreferenced2 = createParameter(n5, "3*3", true);
    // must be inserted manually
    globalUnreferenced = db.insert(globalUnreferenced);
    globalUnreferenced2 = db.insert(globalUnreferenced2);
    method.impactCategories.add(createImpactCategory(n4));
    method.impactCategories.add(createImpactCategory(n4));
    method = db.insert(method);
    for (ImpactCategory category : method.impactCategories) for (ImpactFactor f : category.impactFactors) {
        addExpected("flow", f.flow, "impactFactors", ImpactFactor.class, f.id);
        addExpected("flowPropertyFactor", f.flowPropertyFactor, "impactFactors", ImpactFactor.class, f.id);
        addExpected("flowProperty", f.flowPropertyFactor.flowProperty, "flowPropertyFactor", FlowPropertyFactor.class, f.flowPropertyFactor.id);
        addExpected("unit", f.unit, "impactFactors", ImpactFactor.class, f.id);
    }
    return method;
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor) ImpactCategory(org.openlca.core.model.ImpactCategory) Category(org.openlca.core.model.Category) Parameter(org.openlca.core.model.Parameter) ImpactCategory(org.openlca.core.model.ImpactCategory) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) ImpactMethod(org.openlca.core.model.ImpactMethod)

Example 4 with FlowPropertyFactor

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

the class TestData method flow.

public static Flow flow(String name, String unit, FlowType type) {
    String flowId = KeyGen.get("flow", name, unit);
    FlowDao dao = new FlowDao(Tests.getDb());
    Flow flow = dao.getForRefId(flowId);
    if (flow != null)
        return flow;
    flow = new Flow();
    flow.name = name;
    flow.refId = flowId;
    flow.flowType = type;
    FlowProperty property = property(unit);
    FlowPropertyFactor factor = new FlowPropertyFactor();
    factor.flowProperty = property;
    factor.conversionFactor = 1;
    flow.flowPropertyFactors.add(factor);
    flow.referenceFlowProperty = property;
    return dao.insert(flow);
}
Also used : FlowDao(org.openlca.core.database.FlowDao) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowProperty(org.openlca.core.model.FlowProperty) Flow(org.openlca.core.model.Flow)

Example 5 with FlowPropertyFactor

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

the class FlowPropertyFactorUseSearchTest method setup.

@Before
public void setup() {
    flow = new Flow();
    flow.name = "flow";
    property = new FlowProperty();
    property.name = "property";
    factor = new FlowPropertyFactor();
    factor.flowProperty = property;
    flow.flowPropertyFactors.add(factor);
    property = new FlowPropertyDao(database).insert(property);
    flow = new FlowDao(database).insert(flow);
    factor = flow.getFactor(property);
    search = new FlowPropertyFactorUseSearch(flow, database);
}
Also used : FlowDao(org.openlca.core.database.FlowDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowProperty(org.openlca.core.model.FlowProperty) Flow(org.openlca.core.model.Flow) Before(org.junit.Before)

Aggregations

FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)36 Flow (org.openlca.core.model.Flow)21 FlowProperty (org.openlca.core.model.FlowProperty)17 Unit (org.openlca.core.model.Unit)11 FlowDao (org.openlca.core.database.FlowDao)9 UnitGroup (org.openlca.core.model.UnitGroup)6 ArrayList (java.util.ArrayList)4 ImpactFactor (org.openlca.core.model.ImpactFactor)3 Collections (java.util.Collections)2 List (java.util.List)2 Objects (java.util.Objects)2 Before (org.junit.Before)2 Test (org.junit.Test)2 M (org.openlca.app.M)2 Category (org.openlca.core.model.Category)2 Exchange (org.openlca.core.model.Exchange)2 Uncertainty (org.openlca.core.model.Uncertainty)2 UnitMappingEntry (org.openlca.io.UnitMappingEntry)2 Strings (org.openlca.util.Strings)2 SQLException (java.sql.SQLException)1