use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class ProcessWriter method createExchangeRef.
private JsonObject createExchangeRef(Exchange exchange) {
if (exchange == null)
return null;
JsonObject obj = new JsonObject();
Json.put(obj, "@type", Exchange.class.getSimpleName());
Json.put(obj, "internalId", exchange.internalId);
Json.put(obj, "flow", exp.handleRef(exchange.flow));
return obj;
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class AllocationCleanup method run.
private void run() {
var products = getProducts();
if (products.size() < 2) {
process.allocationFactors.clear();
return;
}
removeInvalid();
if (process.allocationFactors.isEmpty()) {
checkFactors(process.quantitativeReference);
}
for (Exchange product : products) {
checkFactors(product);
}
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class AllocationCleanup method checkFactors.
private void checkFactors(Exchange product) {
if (product == null)
return;
double defaultValue = 0;
if (process.allocationFactors.isEmpty() && isQuantitativeReference(product)) {
// initialize quant. ref. with 1
defaultValue = 1;
}
checkFactor(product, AllocationMethod.PHYSICAL, defaultValue);
checkFactor(product, AllocationMethod.ECONOMIC, defaultValue);
for (Exchange exchange : process.exchanges) {
if (isProduct(exchange))
continue;
checkFactor(product, exchange, defaultValue);
}
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class ModelImport method exchange.
private Exchange exchange(Flow flow, Process p, boolean isInput) {
Exchange e = new Exchange();
e.isInput = isInput;
e.amount = 1.0;
e.flow = flow;
e.flowPropertyFactor = flow.getReferenceFactor();
e.unit = getRefUnit(flow);
p.exchanges.add(e);
return e;
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class Node method findExchange.
private Exchange findExchange(String flowID, boolean isInput) {
if (process == null || flowID == null)
return null;
ArrayList<Exchange> matches = new ArrayList<>(1);
for (Exchange e : process.exchanges) {
if (e.isInput != isInput || e.flow == null)
continue;
if (Objects.equals(flowID, e.flow.refId)) {
matches.add(e);
}
}
if (matches.size() == 1)
return matches.get(0);
Logger log = LoggerFactory.getLogger(getClass());
if (matches.size() > 1) {
log.warn("There are multiple exchanges with flowID={} isInput={} " + "in process={}; -> we take the first for linking", flowID, isInput, process.refId);
return matches.get(0);
}
log.warn("Could not find exchange with flowID={} isInput={} " + "in process={}", flowID, isInput, process.refId);
return null;
}
Aggregations