Search in sources :

Example 1 with CategoryPair

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;
}
Also used : EntityCache(org.openlca.core.database.EntityCache) FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) ArrayList(java.util.ArrayList) CategoryPair(org.openlca.io.CategoryPair) Location(org.openlca.core.model.Location)

Example 2 with CategoryPair

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;
}
Also used : Category(org.openlca.core.model.Category) EntityCache(org.openlca.core.database.EntityCache) FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) TechFlow(org.openlca.core.matrix.index.TechFlow) ArrayList(java.util.ArrayList) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) CategoryPair(org.openlca.io.CategoryPair) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) Location(org.openlca.core.model.Location)

Example 3 with CategoryPair

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);
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) CategoryPair(org.openlca.io.CategoryPair)

Example 4 with CategoryPair

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));
}
Also used : CategoryPair(org.openlca.io.CategoryPair)

Aggregations

CategoryPair (org.openlca.io.CategoryPair)4 FlowDescriptor (org.openlca.core.model.descriptors.FlowDescriptor)3 ArrayList (java.util.ArrayList)2 EntityCache (org.openlca.core.database.EntityCache)2 Location (org.openlca.core.model.Location)2 TechFlow (org.openlca.core.matrix.index.TechFlow)1 Category (org.openlca.core.model.Category)1 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)1 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)1