use of org.openlca.io.CategoryPair in project olca-modules by GreenDelta.
the class FlowInfo method getAll.
public static List<FlowInfo> getAll(SystemExportConfig conf, EnviIndex index) {
EntityCache cache = conf.getEntityCache();
Set<FlowDescriptor> flows = getFlowDescriptors(index);
List<FlowInfo> infos = new ArrayList<>();
for (FlowDescriptor flow : flows) {
CategoryPair catPair = CategoryPair.create(flow, cache);
FlowInfo info = new FlowInfo();
info.realId = flow.id;
info.id = flow.refId;
info.name = flow.name;
info.category = catPair.getCategory();
info.subCategory = catPair.getSubCategory();
if (flow.location != null) {
Location location = cache.get(Location.class, flow.location);
if (location != null)
info.location = location.code;
}
String unit = DisplayValues.referenceUnit(flow, cache);
info.unit = unit;
infos.add(info);
}
return infos;
}
use of org.openlca.io.CategoryPair in project olca-modules by GreenDelta.
the class ProductInfo method getAll.
public static List<ProductInfo> getAll(SystemExportConfig conf, TechIndex index) {
EntityCache cache = conf.getEntityCache();
List<ProductInfo> infos = new ArrayList<>(index.size() + 2);
for (int i = 0; i < index.size(); i++) {
TechFlow pair = index.at(i);
RootDescriptor process = pair.provider();
FlowDescriptor product = pair.flow();
ProductInfo info = new ProductInfo();
info.provider = pair;
info.ref = pair.equals(index.getRefFlow());
info.process = process.name;
info.processId = process.refId;
info.product = product.name;
info.productId = product.refId;
if (process.category != null) {
Category cat = cache.get(Category.class, process.category);
CategoryPair catPair = new CategoryPair(cat);
info.processCategory = catPair.getCategory();
info.processSubCategory = catPair.getSubCategory();
}
if (process instanceof ProcessDescriptor) {
ProcessDescriptor p = (ProcessDescriptor) process;
if (p.location != null) {
Location loc = cache.get(Location.class, p.location);
if (loc != null)
info.processLocation = loc.code;
}
}
infos.add(info);
}
return infos;
}
use of org.openlca.io.CategoryPair in project olca-modules by GreenDelta.
the class CellWriter method flow.
private void flow(Sheet sheet, int row, int col, EnviFlow flow, boolean isRow) {
if (flow == null || flow.flow() == null)
return;
FlowDescriptor f = flow.flow();
cell(sheet, isRow ? row : row++, !isRow ? col : col++, f.refId, false);
cell(sheet, isRow ? row : row++, !isRow ? col : col++, f.name, false);
CategoryPair flowCat = CategoryPair.create(f, cache);
cell(sheet, isRow ? row : row++, !isRow ? col : col++, flowCat.getCategory(), false);
cell(sheet, isRow ? row : row++, !isRow ? col : col++, flowCat.getSubCategory(), false);
cell(sheet, isRow ? row : row++, !isRow ? col : col++, flowUnit(f), false);
}
use of org.openlca.io.CategoryPair in project olca-modules by GreenDelta.
the class ProjectInventorySheet method writeInfo.
private void writeInfo(FlowDescriptor flow, int row) {
int col = 1;
Excel.cell(sheet, row, col++, flow.refId);
Excel.cell(sheet, row, col++, flow.name);
CategoryPair flowCat = CategoryPair.create(flow, export.cache);
Excel.cell(sheet, row, col++, flowCat.getCategory());
Excel.cell(sheet, row, col++, flowCat.getSubCategory());
Excel.cell(sheet, row, col++, DisplayValues.referenceUnit(flow, export.cache));
}
Aggregations