Search in sources :

Example 11 with Exchange

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

the class AllocationSheet method getFactorExchange.

private Exchange getFactorExchange(int row) {
    String name = config.getString(sheet, row, 0);
    if (name == null)
        return null;
    String category = config.getString(sheet, row, 1);
    Flow flow = config.refData.getFlow(name, category);
    String direction = config.getString(sheet, row, 2);
    if (flow == null || direction == null)
        return null;
    boolean input = direction.equalsIgnoreCase("Input");
    for (Exchange exchange : process.exchanges) {
        if (exchange.isInput == input && Objects.equals(exchange.flow, flow))
            return exchange;
    }
    return null;
}
Also used : Exchange(org.openlca.core.model.Exchange) Flow(org.openlca.core.model.Flow)

Example 12 with Exchange

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

the class IOSheet method read.

private void read() {
    if (sheet == null) {
        return;
    }
    try {
        log.trace("read exchanges; inputs={}", forInputs);
        int row = 1;
        while (true) {
            Exchange exchange = readExchange(row);
            if (exchange == null) {
                break;
            }
            row++;
        }
    } catch (Exception e) {
        log.error("failed to read exchanges", e);
    }
}
Also used : Exchange(org.openlca.core.model.Exchange)

Example 13 with Exchange

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

the class InfoSheet method readQuanRef.

private void readQuanRef() {
    // the outputs must be already imported
    String qRefName = config.getString(sheet, 9, 1);
    Exchange qRef = null;
    for (Exchange exchange : process.exchanges) {
        if (exchange.isInput || exchange.flow == null) {
            continue;
        }
        if (Objects.equals(qRefName, exchange.flow.name)) {
            qRef = exchange;
            break;
        }
    }
    if (qRef == null) {
        log.warn("could not find quantitative reference {}", qRefName);
    } else {
        process.quantitativeReference = qRef;
    }
}
Also used : Exchange(org.openlca.core.model.Exchange)

Example 14 with Exchange

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

the class IOSheet method getExchanges.

private List<Exchange> getExchanges() {
    var exchanges = new ArrayList<Exchange>();
    for (Exchange exchange : config.process.exchanges) {
        if (exchange.isInput == forInputs)
            exchanges.add(exchange);
    }
    exchanges.sort((e1, e2) -> {
        if (e1.flow == null || e2.flow == null)
            return 0;
        return Strings.compare(e1.flow.name, e2.flow.name);
    });
    return exchanges;
}
Also used : Exchange(org.openlca.core.model.Exchange) ArrayList(java.util.ArrayList)

Example 15 with Exchange

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

the class InfoSheet method qRefSection.

private void qRefSection() {
    config.header(sheet, row++, 0, "Quantitative reference");
    String qRefName = null;
    Exchange qRef = process.quantitativeReference;
    if (qRef != null && qRef.flow != null)
        qRefName = qRef.flow.name;
    writePair("Quantitative reference", qRefName);
}
Also used : Exchange(org.openlca.core.model.Exchange)

Aggregations

Exchange (org.openlca.core.model.Exchange)90 Process (org.openlca.core.model.Process)21 ArrayList (java.util.ArrayList)15 Flow (org.openlca.core.model.Flow)14 Test (org.junit.Test)7 AllocationFactor (org.openlca.core.model.AllocationFactor)6 ProcessDao (org.openlca.core.database.ProcessDao)5 Parameter (org.openlca.core.model.Parameter)5 ProcessLink (org.openlca.core.model.ProcessLink)5 HashSet (java.util.HashSet)3 Uncertainty (org.openlca.core.model.Uncertainty)3 JsonObject (com.google.gson.JsonObject)2 HashMap (java.util.HashMap)2 List (java.util.List)2 M (org.openlca.app.M)2 Labels (org.openlca.app.util.Labels)2 MsgBox (org.openlca.app.util.MsgBox)2 FlowProperty (org.openlca.core.model.FlowProperty)2 FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)2 IExchange (org.openlca.ecospold.IExchange)2