use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.
the class ProjectReferenceSearchTest method createProjectVariant.
private ProjectVariant createProjectVariant(String p1Name, String p2Name, String p3Name, long methodId) {
ProjectVariant variant = new ProjectVariant();
variant.productSystem = db.insert(new ProductSystem());
variant.parameterRedefs.add(createParameterRedef(p1Name, methodId));
variant.parameterRedefs.add(createParameterRedef(p2Name, p3Name + "*5"));
FlowPropertyFactor factor = new FlowPropertyFactor();
factor.flowProperty = db.insert(new FlowProperty());
variant.flowPropertyFactor = factor;
UnitGroup unitGroup = new UnitGroup();
Unit unit = new Unit();
unit.name = "unit";
unitGroup.units.add(unit);
unitGroup = db.insert(unitGroup);
unit = unitGroup.getUnit(unit.name);
variant.unit = unit;
Flow flow = new Flow();
flow.flowPropertyFactors.add(factor);
// don't add flow to expected references, just for persisting the factor
flow = db.insert(flow);
return variant;
}
use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.
the class ExchangeConversion method mapExtensions.
private void mapExtensions(Exchange oExchange, org.openlca.ilcd.processes.Exchange iExchange) {
ExchangeExtension ext = new ExchangeExtension(iExchange);
if (oExchange.isAvoided) {
// swap the direction
iExchange.direction = oExchange.isInput ? ExchangeDirection.OUTPUT : ExchangeDirection.INPUT;
ext.setAvoidedProduct(true);
}
setProvider(oExchange, ext);
ext.setAmount(oExchange.amount);
ext.setBaseUncertainty(oExchange.baseUncertainty);
ext.setPedigreeUncertainty(oExchange.dqEntry);
if (oExchange.formula != null) {
ext.setFormula(oExchange.formula);
}
if (oExchange.unit != null) {
ext.setUnitId(oExchange.unit.refId);
}
if (oExchange.flowPropertyFactor != null) {
FlowPropertyFactor propFactor = oExchange.flowPropertyFactor;
FlowProperty prop = propFactor.flowProperty;
if (prop != null) {
ext.setPropertyId(prop.refId);
}
}
}
use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.
the class RefSwitcher method switchRef.
/**
* Returns the corresponding flow property factor of the destination flow.
*/
FlowPropertyFactor switchRef(FlowPropertyFactor srcFactor, Flow destFlow) {
if (srcFactor == null || destFlow == null)
return null;
FlowProperty srcProp = srcFactor.flowProperty;
if (srcProp == null)
return null;
long propId = seq.get(seq.FLOW_PROPERTY, srcProp.refId);
for (FlowPropertyFactor fac : destFlow.flowPropertyFactors) {
if (fac.flowProperty == null)
continue;
if (propId == fac.flowProperty.id)
return fac;
}
return null;
}
use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.
the class FlowSheets method addFactors.
private boolean addFactors(Flow flow, List<Factor> factors) {
boolean updated = false;
for (Factor factor : factors) {
FlowProperty property = config.refData.getFlowProperty(factor.property);
if (property == null || flow.getFactor(property) != null) {
continue;
}
FlowPropertyFactor f = new FlowPropertyFactor();
f.flowProperty = property;
f.conversionFactor = factor.factor;
flow.flowPropertyFactors.add(f);
updated = true;
}
return updated;
}
use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.
the class FlowSheets method createPropertyFactors.
private void createPropertyFactors(int row, Flow flow, List<Factor> factors) {
String refProperty = config.getString(flowSheet, row, 10);
RefData refData = config.refData;
for (Factor factor : factors) {
FlowProperty property = refData.getFlowProperty(factor.property);
if (property == null) {
log.error("could not find flow property {} of flow property " + "factor ", factor.property);
continue;
}
FlowPropertyFactor f = new FlowPropertyFactor();
f.flowProperty = property;
f.conversionFactor = factor.factor;
flow.flowPropertyFactors.add(f);
if (Objects.equals(refProperty, property.name)) {
flow.referenceFlowProperty = property;
}
}
}
Aggregations