use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class FlowSheets method readFlows.
private void readFlows() {
int row = 1;
while (true) {
String uuid = config.getString(flowSheet, row, 0);
if (Strings.isNullOrEmpty(uuid)) {
break;
}
Flow flow = dao.getForRefId(uuid);
if (flow != null) {
syncFlow(row, flow);
} else {
createFlow(row, uuid);
}
row++;
}
}
use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class FlowSheets method createFlow.
private void createFlow(int row, String uuid) {
String name = config.getString(flowSheet, row, 1);
String category = config.getString(flowSheet, row, 3);
Flow flow = new Flow();
flow.refId = uuid;
flow.name = name;
flow.category = config.getCategory(category, ModelType.FLOW);
setAttributes(row, flow);
List<Factor> factors = this.factors.get(key(name, category));
if (factors == null) {
log.error("could not create flow {}/{}; no flow property factors", name, category);
return;
}
createPropertyFactors(row, flow, factors);
flow = dao.insert(flow);
config.refData.putFlow(name, category, flow);
}
use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class IOSheet method readExchange.
private Exchange readExchange(int row) {
RefData refData = config.refData;
String name = config.getString(sheet, row, 0);
if (name == null) {
return null;
}
String category = config.getString(sheet, row, 1);
Flow flow = refData.getFlow(name, category);
if (flow == null) {
return refDataError(row, "flow: " + name + "/" + category);
}
String propName = config.getString(sheet, row, 2);
FlowProperty property = refData.getFlowProperty(propName);
if (property == null) {
return refDataError(row, "flow property: " + propName);
}
if (flow.getFactor(property) == null) {
return refDataError(row, "flow property factor: " + propName);
}
String unitName = config.getString(sheet, row, 3);
Unit unit = refData.getUnit(unitName);
if (unit == null) {
return refDataError(row, "unit: " + unitName);
}
var exchange = config.process.add(Exchange.of(flow, property, unit));
exchange.isInput = forInputs;
exchange.amount = config.getDouble(sheet, row, 4);
String formula = config.getString(sheet, row, 5);
if (!Strings.nullOrEmpty(formula)) {
exchange.formula = formula;
}
String description = config.getString(sheet, row, 6);
if (!Strings.nullOrEmpty(description)) {
exchange.description = description;
}
exchange.uncertainty = config.getUncertainty(sheet, row, 7);
if ("Yes".equals(config.getString(sheet, row, 12)))
exchange.isAvoided = true;
return exchange;
}
use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class FlowSheets method write.
private void write() {
Excel.trackSize(flowSheet, 0, 10);
Excel.trackSize(factorSheet, 0, 4);
writeFlowHeader();
writeFactorHeader();
var flows = new FlowDao(config.database).getAll();
flows.sort(new EntitySorter());
for (Flow flow : flows) {
flowRow++;
write(flow);
for (FlowPropertyFactor factor : flow.flowPropertyFactors) {
factorRow++;
writeFactor(flow, factor);
}
}
Excel.autoSize(flowSheet, 0, 10);
Excel.autoSize(factorSheet, 0, 4);
}
use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class IOSheet method write.
private void write(Exchange exchange) {
Flow flow = exchange.flow;
Excel.cell(sheet, row, 0, flow.name);
Excel.cell(sheet, row, 1, CategoryPath.getFull(flow.category));
Excel.cell(sheet, row, 2, getFlowProperty(exchange));
Excel.cell(sheet, row, 3, getUnit(exchange));
Excel.cell(sheet, row, 4, exchange.amount);
Excel.cell(sheet, row, 5, exchange.formula);
Excel.cell(sheet, row, 6, exchange.description);
config.uncertainty(sheet, row, 7, exchange.uncertainty);
if (!forInputs)
Excel.cell(sheet, row, 12, exchange.isAvoided ? "Yes" : "");
}
Aggregations