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