Search in sources :

Example 1 with UserMasterData

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

the class EcoSpold2Export method exportProcess.

public void exportProcess(Process process) {
    var ds = new DataSet();
    ds.description = new ActivityDescription();
    ds.masterData = new UserMasterData();
    mapActivity(process, ds);
    mapLocation(process, ds);
    ProcessDoc.map(process, ds);
    mapExchanges(process, ds);
    mapParameters(process, ds);
    MasterData.writeIndexEntry(ds);
    var fileName = process.refId == null ? UUID.randomUUID().toString() : process.refId;
    var file = new File(activityDir, fileName + ".spold");
    EcoSpold2.write(ds, file);
}
Also used : ActivityDescription(spold2.ActivityDescription) DataSet(spold2.DataSet) UserMasterData(spold2.UserMasterData) File(java.io.File)

Example 2 with UserMasterData

use of spold2.UserMasterData 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 3 with UserMasterData

use of spold2.UserMasterData 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 4 with UserMasterData

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

the class EcoSpold2Export method createIntermediateExchange.

private IntermediateExchange createIntermediateExchange(Exchange exchange, Process process, UserMasterData masterData) {
    IntermediateExchange e2Ex = new IntermediateExchange();
    if (exchange.isInput)
        e2Ex.inputGroup = 5;
    else {
        if (Objects.equals(exchange, process.quantitativeReference))
            e2Ex.outputGroup = 0;
        else if (exchange.flow.flowType == FlowType.WASTE_FLOW)
            e2Ex.outputGroup = 3;
        else
            e2Ex.outputGroup = 2;
    }
    e2Ex.flowId = exchange.flow.refId;
    ProcessDescriptor provider = getDefaultProvider(exchange);
    if (provider != null)
        e2Ex.activityLinkId = provider.refId;
    mapExchangeData(exchange, e2Ex);
    Units.map(exchange.unit, e2Ex, masterData);
    MasterData.writeTechFlow(e2Ex, masterData);
    return e2Ex;
}
Also used : IntermediateExchange(spold2.IntermediateExchange) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor)

Example 5 with UserMasterData

use of spold2.UserMasterData 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)3 IntermediateExchange (spold2.IntermediateExchange)3 UserMasterData (spold2.UserMasterData)2 File (java.io.File)1 Exchange (org.openlca.core.model.Exchange)1 Flow (org.openlca.core.model.Flow)1 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)1 ActivityDescription (spold2.ActivityDescription)1 Compartment (spold2.Compartment)1 DataSet (spold2.DataSet)1 FlowData (spold2.FlowData)1