use of org.openlca.core.model.ImpactCategory 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.ImpactCategory in project olca-modules by GreenDelta.
the class MethodImport method map.
private ImpactMethod map(spold2.ImpactMethod eMethod) {
if (eMethod.id == null) {
log.info("method {} has no id", eMethod.name);
return null;
}
log.info("import LCIA method {}", eMethod.name);
ImpactMethod method = new ImpactMethod();
method.refId = eMethod.id;
method.name = eMethod.name;
method.lastChange = new Date().getTime();
eMethod.categories.forEach(eCategory -> eCategory.indicators.forEach(eIndicator -> {
ImpactCategory impact = map(eCategory, eIndicator);
if (impact != null) {
method.impactCategories.add(impact);
}
}));
return method;
}
use of org.openlca.core.model.ImpactCategory in project olca-modules by GreenDelta.
the class ParameterReferencesTest method testImpactMethodParameter.
@Test
public void testImpactMethodParameter() {
Parameter p1Global = createParameter("p1", "2*2", null, null);
Parameter p1 = createParameter("p1", "2*2", ParameterScope.PROCESS, null);
Parameter p2 = createParameter("p2", "2*p1*p3", ParameterScope.PROCESS, null);
Parameter p3Global = createParameter("p3", "2*p4", null, null);
Parameter p4Global = createParameter("p4", "2", null, null);
ImpactCategory impact = createImpactCategory(null, new Parameter[] { p1, p2 });
with((store) -> {
JsonExport export = new JsonExport(db, store);
export.write(impact);
assertNotNull(store.get(ModelType.IMPACT_CATEGORY, impact.refId));
assertNull(store.get(ModelType.PARAMETER, p1.refId));
assertNull(store.get(ModelType.PARAMETER, p1Global.refId));
assertNull(store.get(ModelType.PARAMETER, p2.refId));
assertNotNull(store.get(ModelType.PARAMETER, p3Global.refId));
assertNotNull(store.get(ModelType.PARAMETER, p4Global.refId));
});
}
use of org.openlca.core.model.ImpactCategory in project olca-modules by GreenDelta.
the class ImpactMethodExport method run.
public void run(ImpactMethod method) {
if (method == null)
return;
if (config.store.contains(LCIAMethod.class, method.refId))
return;
for (ImpactCategory impact : method.impactCategories) {
LCIAMethod lciaMethod = new LCIAMethod();
putAttribute("olca_method_uuid", method.refId, lciaMethod.otherAttributes);
addMethodInfo(method, impact, lciaMethod);
addFactors(impact, lciaMethod);
config.store.put(lciaMethod);
}
}
use of org.openlca.core.model.ImpactCategory in project olca-modules by GreenDelta.
the class ImpactCategoryImport method run.
void run() {
log.trace("import LCIA categories");
for (ImpactDescriptor d : sourceDao.getDescriptors()) {
if (seq.contains(seq.IMPACT_CATEGORY, d.refId))
continue;
ImpactCategory src = sourceDao.getForId(d.id);
ImpactCategory dest = src.copy();
dest.refId = src.refId;
dest.category = refs.switchRef(src.category);
switchFactorRefs(dest);
dest = destDao.insert(dest);
seq.put(seq.IMPACT_CATEGORY, src.refId, dest.id);
}
}
Aggregations