use of org.openlca.core.model.ImpactFactor in project olca-modules by GreenDelta.
the class ImpactMethodReferenceSearchTest method createModel.
@Override
protected ImpactMethod createModel() {
ImpactMethod method = new ImpactMethod();
method.category = insertAndAddExpected("category", new Category());
String n1 = generateName();
// String n2 = generateName();
String n3 = generateName();
String n4 = generateName();
String n5 = generateName();
// method.parameters.add(createParameter(n1, 3d, false));
// method.parameters.add(createParameter(n2, n1 + "*2*" + n3, false));
insertAndAddExpected(n3, createParameter(n3, "5*5", true));
// formula with parameter to see if added as reference (unexpected)
insertAndAddExpected(n4, createParameter(n4, "3*" + n5, true));
Parameter globalUnreferenced = createParameter(n1, "3*3", true);
Parameter globalUnreferenced2 = createParameter(n5, "3*3", true);
// must be inserted manually
globalUnreferenced = db.insert(globalUnreferenced);
globalUnreferenced2 = db.insert(globalUnreferenced2);
method.impactCategories.add(createImpactCategory(n4));
method.impactCategories.add(createImpactCategory(n4));
method = db.insert(method);
for (ImpactCategory category : method.impactCategories) for (ImpactFactor f : category.impactFactors) {
addExpected("flow", f.flow, "impactFactors", ImpactFactor.class, f.id);
addExpected("flowPropertyFactor", f.flowPropertyFactor, "impactFactors", ImpactFactor.class, f.id);
addExpected("flowProperty", f.flowPropertyFactor.flowProperty, "flowPropertyFactor", FlowPropertyFactor.class, f.flowPropertyFactor.id);
addExpected("unit", f.unit, "impactFactors", ImpactFactor.class, f.id);
}
return method;
}
use of org.openlca.core.model.ImpactFactor in project olca-modules by GreenDelta.
the class FlowPropertyFactorUseSearchTest method testFindInImpactCategory.
@Test
public void testFindInImpactCategory() {
ImpactFactor iFactor = new ImpactFactor();
iFactor.flow = flow;
iFactor.flowPropertyFactor = factor;
ImpactCategory category = new ImpactCategory();
category.impactFactors.add(iFactor);
ImpactCategoryDao dao = new ImpactCategoryDao(database);
dao.insert(category);
List<RootDescriptor> results = search.findUses(factor);
dao.delete(category);
Assert.assertEquals(1, results.size());
Descriptor expected = Descriptor.of(category);
Assert.assertEquals(expected, results.get(0));
}
use of org.openlca.core.model.ImpactFactor in project olca-modules by GreenDelta.
the class ImpactMethodExport method addFactors.
private void addFactors(ImpactCategory impact, LCIAMethod lciaMethod) {
FactorList list = new FactorList();
lciaMethod.characterisationFactors = list;
for (ImpactFactor oFactor : impact.impactFactors) {
Factor iFactor = new Factor();
list.factors.add(iFactor);
// TODO: uncertainty values + formulas
iFactor.meanValue = getRefAmount(oFactor);
iFactor.flow = Export.of(oFactor.flow, config);
if (oFactor.location != null) {
iFactor.location = oFactor.location.code;
}
}
}
use of org.openlca.core.model.ImpactFactor in project olca-modules by GreenDelta.
the class MethodImport method map.
private ImpactCategory map(spold2.ImpactCategory eCategory, ImpactIndicator eIndicator) {
if (eCategory == null || eIndicator == null)
return null;
ImpactCategory impact = new ImpactCategory();
impact.refId = KeyGen.get(eCategory.id, eIndicator.id);
impact.name = eCategory.name + " - " + eIndicator.name;
impact.lastChange = new Date().getTime();
impact.referenceUnit = eIndicator.unit;
eIndicator.factors.forEach(eFactor -> {
ImpactFactor factor = map(eFactor);
if (factor != null) {
impact.impactFactors.add(factor);
}
});
return impact;
}
use of org.openlca.core.model.ImpactFactor in project olca-modules by GreenDelta.
the class MethodImport method map.
private ImpactFactor map(spold2.ImpactFactor eFactor) {
FlowRec flowRec = flow(eFactor);
if (flowRec == null)
return null;
ImpactFactor f = new ImpactFactor();
f.flow = flowRec.flow;
f.flowPropertyFactor = flowRec.property;
f.unit = flowRec.unit;
f.value = eFactor.amount;
return f;
}
Aggregations