Search in sources :

Example 1 with Flow

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

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

the class ProductSystemReferenceSearchTest method createLink.

private ProcessLink createLink(Process p1, Process p2) {
    ProcessLink link = new ProcessLink();
    Flow flow = createFlow(false);
    Exchange e1 = new Exchange();
    e1.flow = flow;
    p1.exchanges.add(e1);
    Exchange e2 = new Exchange();
    e2.flow = flow;
    p2.exchanges.add(e2);
    link.processId = p1.id;
    link.providerId = p2.id;
    link.flowId = flow.id;
    addExpected("processId", p1);
    addExpected("providerId", p2);
    addExpected("exchangeId", e1);
    return link;
}
Also used : Exchange(org.openlca.core.model.Exchange) ProcessLink(org.openlca.core.model.ProcessLink) Flow(org.openlca.core.model.Flow)

Example 3 with Flow

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

the class FlowDescriptorTest method setUp.

@Before
public void setUp() {
    property = new FlowProperty();
    property = new FlowPropertyDao(db).insert(property);
    flow = new Flow();
    flow.referenceFlowProperty = property;
    flow = flowDao.insert(flow);
}
Also used : FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) FlowProperty(org.openlca.core.model.FlowProperty) Flow(org.openlca.core.model.Flow) Before(org.junit.Before)

Example 4 with Flow

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

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

the class TestProcess method addCosts.

public TestProcess addCosts(String flow, double amount, String currency) {
    for (Exchange e : process.exchanges) {
        Flow f = e.flow;
        if (f == null || !Strings.nullOrEqual(f.name, flow))
            continue;
        e.currency = TestData.currency(currency);
        e.costs = amount;
        break;
    }
    return this;
}
Also used : Exchange(org.openlca.core.model.Exchange) Flow(org.openlca.core.model.Flow)

Aggregations

Flow (org.openlca.core.model.Flow)102 FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)23 FlowDao (org.openlca.core.database.FlowDao)22 FlowProperty (org.openlca.core.model.FlowProperty)17 Exchange (org.openlca.core.model.Exchange)14 Unit (org.openlca.core.model.Unit)14 Process (org.openlca.core.model.Process)13 UnitGroup (org.openlca.core.model.UnitGroup)9 ArrayList (java.util.ArrayList)8 Before (org.junit.Before)7 Test (org.junit.Test)7 TechFlow (org.openlca.core.matrix.index.TechFlow)6 Category (org.openlca.core.model.Category)6 ProcessDao (org.openlca.core.database.ProcessDao)5 EnviFlow (org.openlca.core.matrix.index.EnviFlow)5 Location (org.openlca.core.model.Location)5 FlowMapEntry (org.openlca.io.maps.FlowMapEntry)5 FlowRef (org.openlca.io.maps.FlowRef)5 HashSet (java.util.HashSet)4 List (java.util.List)4