use of spold2.IntermediateExchange in project olca-modules by GreenDelta.
the class PriceMapper method findPrice.
private Property findPrice(IntermediateExchange ie) {
for (Property p : ie.properties) {
String name = p.name;
String unit = p.unit;
if (name == null || unit == null)
continue;
if ("price".equalsIgnoreCase(name) && unit.startsWith("EUR"))
return p;
}
return null;
}
use of spold2.IntermediateExchange in project olca-modules by GreenDelta.
the class PriceMapper method map.
void map(IntermediateExchange ie, Exchange e) {
if (currency == null || ie == null || ie.amount == null || e == null)
return;
Property price = findPrice(ie);
if (price == null)
return;
double val = ie.amount * price.amount;
if (val == 0)
return;
e.costs = val;
e.currency = currency;
}
use of spold2.IntermediateExchange in project olca-modules by GreenDelta.
the class ProcessImport method valid.
private boolean valid(DataSet ds) {
Activity activity = Spold2.getActivity(ds);
if (activity.id == null || activity.name == null)
return false;
IntermediateExchange refFlow = null;
for (IntermediateExchange techFlow : Spold2.getProducts(ds)) {
if (techFlow.outputGroup == null)
continue;
if (techFlow.outputGroup != 0)
continue;
if (techFlow.amount == null || techFlow.amount == 0)
continue;
refFlow = techFlow;
break;
}
return refFlow != null;
}
use of spold2.IntermediateExchange in project olca-modules by GreenDelta.
the class ProcessImport method getProcessName.
/**
* The name of the process has the following pattern:
* <p>
* <process name> | <product name> | <system model>, <process type>
* <p>
* Where <system model> is a mnemonic like "APOS" or "Cutoff" and the process
* type is "U" when it is a unit process or "S" when it is a LCI result
*/
private String getProcessName(DataSet ds) {
// the process and ref. product name
Activity a = Spold2.getActivity(ds);
String name = a != null ? a.name : "?";
IntermediateExchange qRef = Spold2.getReferenceProduct(ds);
if (qRef != null && qRef.name != null) {
name += " | " + qRef.name;
}
// we try to infer a short name for the system model here
// because the short name is part of the master data which
// is not always available (or can be found) when importing
// a data set
String model = null;
Representativeness repri = Spold2.getRepresentativeness(ds);
if (repri.systemModelName != null) {
String sys = repri.systemModelName.toLowerCase();
if (sys.contains("consequential")) {
model = "Consequential";
} else if (sys.contains("apos") || sys.contains("allocation at the point of substitution")) {
model = "APOS";
} else if (sys.contains("cut-off") || sys.contains("cutoff")) {
model = "Cutoff";
} else if (sys.contains("legacy")) {
model = "Legacy";
} else {
model = repri.systemModelName;
}
}
if (model != null) {
name += " | " + model;
}
// the process type
String type = a != null && a.type == 2 ? "S" : "U";
name += ", " + type;
return name;
}
use of spold2.IntermediateExchange in project olca-modules by GreenDelta.
the class RefDataImport method importDataSet.
public void importDataSet(DataSet ds) {
if (ds == null)
return;
try {
classification(ds);
geography(ds);
for (IntermediateExchange e : Spold2.getProducts(ds)) {
if (e.amount == 0 && config.skipNullExchanges)
continue;
productFlow(ds, e);
}
for (ElementaryExchange e : Spold2.getElemFlows(ds)) {
elementaryFlow(e);
}
} catch (Exception e) {
log.error("failed to import reference data from data set", e);
}
}
Aggregations