use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class ProductSystemImport method sameExchange.
private boolean sameExchange(Exchange srcExchange, Exchange destExchange) {
if (srcExchange.isInput != destExchange.isInput)
return false;
Unit srcUnit = srcExchange.unit;
Unit destUnit = destExchange.unit;
Flow srcFlow = srcExchange.flow;
Flow destFlow = destExchange.flow;
return srcUnit != null && destUnit != null && srcFlow != null && destFlow != null && Strings.nullOrEqual(srcUnit.refId, destUnit.refId) && Strings.nullOrEqual(srcFlow.refId, destFlow.refId);
}
use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class FlowExport method doIt.
@Override
protected void doIt(CSVPrinter printer, IDatabase db) throws IOException {
log.trace("write flows");
FlowDao dao = new FlowDao(db);
List<Flow> flows = dao.getAll();
for (Flow flow : flows) {
Object[] line = createLine(flow);
printer.printRecord(line);
}
log.trace("{} flows written", flows.size());
}
use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class ProcessWriter method writeDummies.
private void writeDummies() {
for (Flow flow : inputProducts) {
if (outputProducts.contains(flow))
continue;
var p = Process.of("Dummy: " + flow.name, flow);
p.id = flow.id;
p.category = new Category();
p.category.name = "Dummy processes";
writeProcess(p);
}
}
use of org.openlca.core.model.Flow in project olca-modules by GreenDelta.
the class ProcessWriter method writeReferenceFlows.
@SuppressWarnings("unchecked")
private void writeReferenceFlows() {
// order flows by their type
int n = ElementaryFlowType.values().length;
List<Flow>[] buckets = new List[n];
for (int i = 0; i < n; i++) {
buckets[i] = new ArrayList<>();
}
for (Map.Entry<Flow, Compartment> e : flowCompartments.entrySet()) {
ElementaryFlowType type = e.getValue().type();
buckets[type.ordinal()].add(e.getKey());
}
// write the flow information
for (var type : ElementaryFlowType.values()) {
writeln(type.blockHeader());
// duplicate names are not allowed here
HashSet<String> handledNames = new HashSet<>();
for (Flow flow : buckets[type.ordinal()]) {
String name;
String unit = null;
FlowMapEntry mapEntry = mappedFlow(flow);
if (mapEntry != null) {
// handle mapped flows
name = mapEntry.targetFlow().flow.name;
if (mapEntry.targetFlow().unit != null) {
unit = unit(mapEntry.targetFlow().unit.name);
}
} else {
// handle unmapped flows
name = flow.name;
Unit refUnit = null;
if (flow.referenceFlowProperty != null) {
if (flow.referenceFlowProperty.unitGroup != null) {
refUnit = flow.referenceFlowProperty.unitGroup.referenceUnit;
}
}
unit = unit(refUnit);
}
if (name == null || unit == null)
continue;
String id = name.trim().toLowerCase();
if (handledNames.contains(id))
continue;
handledNames.add(id);
writeln(name, unit, flow.casNumber, "");
}
writeln();
writeln("End");
writeln();
writeln();
}
}
use of org.openlca.core.model.Flow 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;
}
Aggregations