Search in sources :

Example 16 with Exchange

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

the class AllocationSheet method readRowFactors.

private AllocationFactor[] readRowFactors(int row, List<Exchange> products) {
    String name = config.getString(sheet, row, 0);
    Exchange product = getProduct(name, products);
    if (product == null)
        return null;
    AllocationFactor[] factors = new AllocationFactor[2];
    factors[0] = new AllocationFactor();
    factors[0].productId = product.flow.id;
    factors[0].value = config.getDouble(sheet, row, 2);
    factors[0].method = AllocationMethod.PHYSICAL;
    factors[1] = new AllocationFactor();
    factors[1].productId = product.flow.id;
    factors[1].value = config.getDouble(sheet, row, 3);
    factors[1].method = AllocationMethod.ECONOMIC;
    return factors;
}
Also used : Exchange(org.openlca.core.model.Exchange) AllocationFactor(org.openlca.core.model.AllocationFactor)

Example 17 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 18 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 19 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 20 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)

Aggregations

Exchange (org.openlca.core.model.Exchange)90 Process (org.openlca.core.model.Process)20 ArrayList (java.util.ArrayList)15 Flow (org.openlca.core.model.Flow)15 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