use of org.openlca.core.matrix.index.ImpactIndex in project olca-modules by GreenDelta.
the class Library method syncImpacts.
/**
* Returns the impact categories of the library in matrix order. If this
* information is not present or something went wrong while synchronizing
* the impact index with the database, an empty option is returned.
*/
public Optional<ImpactIndex> syncImpacts(IDatabase db) {
var proto = getImpactIndex();
int size = proto.getImpactCount();
if (size == 0)
return Optional.empty();
var index = new ImpactIndex();
var impacts = descriptors(new ImpactCategoryDao(db));
for (int i = 0; i < size; i++) {
var entry = proto.getImpact(i);
var impact = impacts.get(entry.getImpact().getId());
if (impact == null)
return Optional.empty();
index.add(impact);
}
return Optional.of(index);
}
use of org.openlca.core.matrix.index.ImpactIndex in project olca-modules by GreenDelta.
the class SystemExport method mapImpactCategoryIndices.
private List<ImpactDescriptor> mapImpactCategoryIndices(ExcelHeader header, ImpactIndex impactIndex) {
var sortedCategories = impactIndex.content().stream().sorted((i1, i2) -> Strings.compare(i1.name, i2.name)).collect(Collectors.toList());
int counter = 0;
for (ImpactDescriptor category : sortedCategories) {
header.putIndexMapping(counter, impactIndex.of(category));
counter++;
}
return sortedCategories;
}
Aggregations