Search in sources :

Example 1 with ElementaryExchange

use of spold2.ElementaryExchange in project olca-modules by GreenDelta.

the class ProcessImport method createElementaryExchanges.

private void createElementaryExchanges(DataSet ds, Process process) {
    for (ElementaryExchange e : Spold2.getElemFlows(ds)) {
        if (e.amount == 0 && config.skipNullExchanges)
            continue;
        String refId = e.flowId;
        Flow flow = index.getFlow(refId);
        if (flow == null) {
            log.warn("could not create flow for: " + e.flowId);
        }
        createExchange(e, refId, flow, process);
    }
}
Also used : ElementaryExchange(spold2.ElementaryExchange) Flow(org.openlca.core.model.Flow)

Example 2 with ElementaryExchange

use of spold2.ElementaryExchange in project olca-modules by GreenDelta.

the class RefDataImport method importDataSet.

public void importDataSet(DataSet ds) {
    if (ds == null)
        return;
    try {
        classification(ds);
        geography(ds);
        for (IntermediateExchange e : Spold2.getProducts(ds)) {
            if (e.amount == 0 && config.skipNullExchanges)
                continue;
            productFlow(ds, e);
        }
        for (ElementaryExchange e : Spold2.getElemFlows(ds)) {
            elementaryFlow(e);
        }
    } catch (Exception e) {
        log.error("failed to import reference data from data set", e);
    }
}
Also used : IntermediateExchange(spold2.IntermediateExchange) ElementaryExchange(spold2.ElementaryExchange)

Example 3 with ElementaryExchange

use of spold2.ElementaryExchange in project olca-modules by GreenDelta.

the class EcoSpold2Export method mapExchanges.

private void mapExchanges(Process process, DataSet ds) {
    if (ds.flowData == null)
        ds.flowData = new FlowData();
    for (Exchange exchange : process.exchanges) {
        if (!isValid(exchange))
            continue;
        Flow flow = exchange.flow;
        UserMasterData masterData = ds.masterData;
        if (flow.flowType == FlowType.ELEMENTARY_FLOW) {
            ElementaryExchange e = createElemExchange(exchange, masterData);
            ds.flowData.elementaryExchanges.add(e);
        } else {
            IntermediateExchange e = createIntermediateExchange(exchange, process, masterData);
            ds.flowData.intermediateExchanges.add(e);
        }
    }
}
Also used : Exchange(org.openlca.core.model.Exchange) ElementaryExchange(spold2.ElementaryExchange) IntermediateExchange(spold2.IntermediateExchange) FlowData(spold2.FlowData) ElementaryExchange(spold2.ElementaryExchange) IntermediateExchange(spold2.IntermediateExchange) UserMasterData(spold2.UserMasterData) Flow(org.openlca.core.model.Flow)

Example 4 with ElementaryExchange

use of spold2.ElementaryExchange in project olca-modules by GreenDelta.

the class MasterData method writeElemFlow.

// TODO: handle parameters
// private void writeParamters(UserMasterData masterData) {
// for (Parameter parameter : dataSet.getParameters()) {
// Parameter masterParam = new Parameter();
// masterData.getParameters().add(masterParam);
// masterParam.setId(parameter.getId());
// masterParam.setName(parameter.getName());
// masterParam.setUnitName(parameter.getUnitName());
// }
// }
public static void writeElemFlow(ElementaryExchange elemFlow, UserMasterData masterData) {
    ElementaryExchange masterFlow = new ElementaryExchange();
    masterData.elementaryExchanges.add(masterFlow);
    masterFlow.id = elemFlow.flowId;
    masterFlow.name = elemFlow.name;
    masterFlow.unitId = elemFlow.unitId;
    masterFlow.unit = elemFlow.unit;
    masterFlow.compartment = elemFlow.compartment;
    masterFlow.casNumber = elemFlow.casNumber;
    masterFlow.formula = elemFlow.formula;
}
Also used : ElementaryExchange(spold2.ElementaryExchange)

Example 5 with ElementaryExchange

use of spold2.ElementaryExchange in project olca-modules by GreenDelta.

the class EcoSpold2Export method createElemExchange.

private ElementaryExchange createElemExchange(Exchange exchange, UserMasterData masterData) {
    var e2Ex = elemFlowMap.apply(exchange);
    if (e2Ex != null)
        return e2Ex;
    e2Ex = new ElementaryExchange();
    if (exchange.isInput) {
        e2Ex.inputGroup = 4;
    } else {
        e2Ex.outputGroup = 4;
    }
    var flow = exchange.flow;
    e2Ex.flowId = flow.refId;
    e2Ex.formula = flow.formula;
    mapExchangeData(exchange, e2Ex);
    // compartment
    if (flow.category != null) {
        var comp = new Compartment();
        comp.id = flow.category.refId;
        comp.subCompartment = flow.category.name;
        if (flow.category.category != null) {
            comp.compartment = flow.category.category.name;
        }
    }
    Units.map(exchange.unit, e2Ex, masterData);
    MasterData.writeElemFlow(e2Ex, masterData);
    return e2Ex;
}
Also used : ElementaryExchange(spold2.ElementaryExchange) Compartment(spold2.Compartment)

Aggregations

ElementaryExchange (spold2.ElementaryExchange)5 Flow (org.openlca.core.model.Flow)2 IntermediateExchange (spold2.IntermediateExchange)2 Exchange (org.openlca.core.model.Exchange)1 Compartment (spold2.Compartment)1 FlowData (spold2.FlowData)1 UserMasterData (spold2.UserMasterData)1