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);
}
}
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);
}
}
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);
}
}
}
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;
}
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;
}
Aggregations