use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class AllocationSheet method readRowFactors.
private AllocationFactor[] readRowFactors(int row, List<Exchange> products) {
String name = config.getString(sheet, row, 0);
Exchange product = getProduct(name, products);
if (product == null)
return null;
AllocationFactor[] factors = new AllocationFactor[2];
factors[0] = new AllocationFactor();
factors[0].productId = product.flow.id;
factors[0].value = config.getDouble(sheet, row, 2);
factors[0].method = AllocationMethod.PHYSICAL;
factors[1] = new AllocationFactor();
factors[1].productId = product.flow.id;
factors[1].value = config.getDouble(sheet, row, 3);
factors[1].method = AllocationMethod.ECONOMIC;
return factors;
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class AllocationSheet method getFactorExchange.
private Exchange getFactorExchange(int row) {
String name = config.getString(sheet, row, 0);
if (name == null)
return null;
String category = config.getString(sheet, row, 1);
Flow flow = config.refData.getFlow(name, category);
String direction = config.getString(sheet, row, 2);
if (flow == null || direction == null)
return null;
boolean input = direction.equalsIgnoreCase("Input");
for (Exchange exchange : process.exchanges) {
if (exchange.isInput == input && Objects.equals(exchange.flow, flow))
return exchange;
}
return null;
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class IOSheet method read.
private void read() {
if (sheet == null) {
return;
}
try {
log.trace("read exchanges; inputs={}", forInputs);
int row = 1;
while (true) {
Exchange exchange = readExchange(row);
if (exchange == null) {
break;
}
row++;
}
} catch (Exception e) {
log.error("failed to read exchanges", e);
}
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class InfoSheet method readQuanRef.
private void readQuanRef() {
// the outputs must be already imported
String qRefName = config.getString(sheet, 9, 1);
Exchange qRef = null;
for (Exchange exchange : process.exchanges) {
if (exchange.isInput || exchange.flow == null) {
continue;
}
if (Objects.equals(qRefName, exchange.flow.name)) {
qRef = exchange;
break;
}
}
if (qRef == null) {
log.warn("could not find quantitative reference {}", qRefName);
} else {
process.quantitativeReference = qRef;
}
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class IOSheet method getExchanges.
private List<Exchange> getExchanges() {
var exchanges = new ArrayList<Exchange>();
for (Exchange exchange : config.process.exchanges) {
if (exchange.isInput == forInputs)
exchanges.add(exchange);
}
exchanges.sort((e1, e2) -> {
if (e1.flow == null || e2.flow == null)
return 0;
return Strings.compare(e1.flow.name, e2.flow.name);
});
return exchanges;
}
Aggregations