Search in sources :

Example 6 with FlowPropertyFactor

use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.

the class ProjectReferenceSearchTest method createProjectVariant.

private ProjectVariant createProjectVariant(String p1Name, String p2Name, String p3Name, long methodId) {
    ProjectVariant variant = new ProjectVariant();
    variant.productSystem = db.insert(new ProductSystem());
    variant.parameterRedefs.add(createParameterRedef(p1Name, methodId));
    variant.parameterRedefs.add(createParameterRedef(p2Name, p3Name + "*5"));
    FlowPropertyFactor factor = new FlowPropertyFactor();
    factor.flowProperty = db.insert(new FlowProperty());
    variant.flowPropertyFactor = factor;
    UnitGroup unitGroup = new UnitGroup();
    Unit unit = new Unit();
    unit.name = "unit";
    unitGroup.units.add(unit);
    unitGroup = db.insert(unitGroup);
    unit = unitGroup.getUnit(unit.name);
    variant.unit = unit;
    Flow flow = new Flow();
    flow.flowPropertyFactors.add(factor);
    // don't add flow to expected references, just for persisting the factor
    flow = db.insert(flow);
    return variant;
}
Also used : ProjectVariant(org.openlca.core.model.ProjectVariant) UnitGroup(org.openlca.core.model.UnitGroup) ProductSystem(org.openlca.core.model.ProductSystem) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) Unit(org.openlca.core.model.Unit) FlowProperty(org.openlca.core.model.FlowProperty) Flow(org.openlca.core.model.Flow)

Example 7 with FlowPropertyFactor

use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.

the class ExchangeConversion method mapExtensions.

private void mapExtensions(Exchange oExchange, org.openlca.ilcd.processes.Exchange iExchange) {
    ExchangeExtension ext = new ExchangeExtension(iExchange);
    if (oExchange.isAvoided) {
        // swap the direction
        iExchange.direction = oExchange.isInput ? ExchangeDirection.OUTPUT : ExchangeDirection.INPUT;
        ext.setAvoidedProduct(true);
    }
    setProvider(oExchange, ext);
    ext.setAmount(oExchange.amount);
    ext.setBaseUncertainty(oExchange.baseUncertainty);
    ext.setPedigreeUncertainty(oExchange.dqEntry);
    if (oExchange.formula != null) {
        ext.setFormula(oExchange.formula);
    }
    if (oExchange.unit != null) {
        ext.setUnitId(oExchange.unit.refId);
    }
    if (oExchange.flowPropertyFactor != null) {
        FlowPropertyFactor propFactor = oExchange.flowPropertyFactor;
        FlowProperty prop = propFactor.flowProperty;
        if (prop != null) {
            ext.setPropertyId(prop.refId);
        }
    }
}
Also used : ExchangeExtension(org.openlca.ilcd.util.ExchangeExtension) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowProperty(org.openlca.core.model.FlowProperty)

Example 8 with FlowPropertyFactor

use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.

the class RefSwitcher method switchRef.

/**
 * Returns the corresponding flow property factor of the destination flow.
 */
FlowPropertyFactor switchRef(FlowPropertyFactor srcFactor, Flow destFlow) {
    if (srcFactor == null || destFlow == null)
        return null;
    FlowProperty srcProp = srcFactor.flowProperty;
    if (srcProp == null)
        return null;
    long propId = seq.get(seq.FLOW_PROPERTY, srcProp.refId);
    for (FlowPropertyFactor fac : destFlow.flowPropertyFactors) {
        if (fac.flowProperty == null)
            continue;
        if (propId == fac.flowProperty.id)
            return fac;
    }
    return null;
}
Also used : FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowProperty(org.openlca.core.model.FlowProperty)

Example 9 with FlowPropertyFactor

use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.

the class FlowSheets method addFactors.

private boolean addFactors(Flow flow, List<Factor> factors) {
    boolean updated = false;
    for (Factor factor : factors) {
        FlowProperty property = config.refData.getFlowProperty(factor.property);
        if (property == null || flow.getFactor(property) != null) {
            continue;
        }
        FlowPropertyFactor f = new FlowPropertyFactor();
        f.flowProperty = property;
        f.conversionFactor = factor.factor;
        flow.flowPropertyFactors.add(f);
        updated = true;
    }
    return updated;
}
Also used : FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowProperty(org.openlca.core.model.FlowProperty)

Example 10 with FlowPropertyFactor

use of org.openlca.core.model.FlowPropertyFactor in project olca-modules by GreenDelta.

the class FlowSheets method createPropertyFactors.

private void createPropertyFactors(int row, Flow flow, List<Factor> factors) {
    String refProperty = config.getString(flowSheet, row, 10);
    RefData refData = config.refData;
    for (Factor factor : factors) {
        FlowProperty property = refData.getFlowProperty(factor.property);
        if (property == null) {
            log.error("could not find flow property {} of flow property " + "factor ", factor.property);
            continue;
        }
        FlowPropertyFactor f = new FlowPropertyFactor();
        f.flowProperty = property;
        f.conversionFactor = factor.factor;
        flow.flowPropertyFactors.add(f);
        if (Objects.equals(refProperty, property.name)) {
            flow.referenceFlowProperty = property;
        }
    }
}
Also used : FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) FlowProperty(org.openlca.core.model.FlowProperty)

Aggregations

FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)36 Flow (org.openlca.core.model.Flow)21 FlowProperty (org.openlca.core.model.FlowProperty)17 Unit (org.openlca.core.model.Unit)11 FlowDao (org.openlca.core.database.FlowDao)9 UnitGroup (org.openlca.core.model.UnitGroup)6 ArrayList (java.util.ArrayList)4 ImpactFactor (org.openlca.core.model.ImpactFactor)3 Collections (java.util.Collections)2 List (java.util.List)2 Objects (java.util.Objects)2 Before (org.junit.Before)2 Test (org.junit.Test)2 M (org.openlca.app.M)2 Category (org.openlca.core.model.Category)2 Exchange (org.openlca.core.model.Exchange)2 Uncertainty (org.openlca.core.model.Uncertainty)2 UnitMappingEntry (org.openlca.io.UnitMappingEntry)2 Strings (org.openlca.util.Strings)2 SQLException (java.sql.SQLException)1