Search in sources :

Example 1 with ImpactFactor

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

the class ImpactMethodReferenceSearchTest method createModel.

@Override
protected ImpactMethod createModel() {
    ImpactMethod method = new ImpactMethod();
    method.category = insertAndAddExpected("category", new Category());
    String n1 = generateName();
    // String n2 = generateName();
    String n3 = generateName();
    String n4 = generateName();
    String n5 = generateName();
    // method.parameters.add(createParameter(n1, 3d, false));
    // method.parameters.add(createParameter(n2, n1 + "*2*" + n3, false));
    insertAndAddExpected(n3, createParameter(n3, "5*5", true));
    // formula with parameter to see if added as reference (unexpected)
    insertAndAddExpected(n4, createParameter(n4, "3*" + n5, true));
    Parameter globalUnreferenced = createParameter(n1, "3*3", true);
    Parameter globalUnreferenced2 = createParameter(n5, "3*3", true);
    // must be inserted manually
    globalUnreferenced = db.insert(globalUnreferenced);
    globalUnreferenced2 = db.insert(globalUnreferenced2);
    method.impactCategories.add(createImpactCategory(n4));
    method.impactCategories.add(createImpactCategory(n4));
    method = db.insert(method);
    for (ImpactCategory category : method.impactCategories) for (ImpactFactor f : category.impactFactors) {
        addExpected("flow", f.flow, "impactFactors", ImpactFactor.class, f.id);
        addExpected("flowPropertyFactor", f.flowPropertyFactor, "impactFactors", ImpactFactor.class, f.id);
        addExpected("flowProperty", f.flowPropertyFactor.flowProperty, "flowPropertyFactor", FlowPropertyFactor.class, f.flowPropertyFactor.id);
        addExpected("unit", f.unit, "impactFactors", ImpactFactor.class, f.id);
    }
    return method;
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor) ImpactCategory(org.openlca.core.model.ImpactCategory) Category(org.openlca.core.model.Category) Parameter(org.openlca.core.model.Parameter) ImpactCategory(org.openlca.core.model.ImpactCategory) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) ImpactMethod(org.openlca.core.model.ImpactMethod)

Example 2 with ImpactFactor

use of org.openlca.core.model.ImpactFactor 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));
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) ImpactCategory(org.openlca.core.model.ImpactCategory) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) Test(org.junit.Test)

Example 3 with ImpactFactor

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

the class ImpactMethodExport method addFactors.

private void addFactors(ImpactCategory impact, LCIAMethod lciaMethod) {
    FactorList list = new FactorList();
    lciaMethod.characterisationFactors = list;
    for (ImpactFactor oFactor : impact.impactFactors) {
        Factor iFactor = new Factor();
        list.factors.add(iFactor);
        // TODO: uncertainty values + formulas
        iFactor.meanValue = getRefAmount(oFactor);
        iFactor.flow = Export.of(oFactor.flow, config);
        if (oFactor.location != null) {
            iFactor.location = oFactor.location.code;
        }
    }
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor) FactorList(org.openlca.ilcd.methods.FactorList) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) ImpactFactor(org.openlca.core.model.ImpactFactor) Factor(org.openlca.ilcd.methods.Factor)

Example 4 with ImpactFactor

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

the class MethodImport method map.

private ImpactCategory map(spold2.ImpactCategory eCategory, ImpactIndicator eIndicator) {
    if (eCategory == null || eIndicator == null)
        return null;
    ImpactCategory impact = new ImpactCategory();
    impact.refId = KeyGen.get(eCategory.id, eIndicator.id);
    impact.name = eCategory.name + " - " + eIndicator.name;
    impact.lastChange = new Date().getTime();
    impact.referenceUnit = eIndicator.unit;
    eIndicator.factors.forEach(eFactor -> {
        ImpactFactor factor = map(eFactor);
        if (factor != null) {
            impact.impactFactors.add(factor);
        }
    });
    return impact;
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor) ImpactCategory(org.openlca.core.model.ImpactCategory) Date(java.util.Date)

Example 5 with ImpactFactor

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

the class MethodImport method map.

private ImpactFactor map(spold2.ImpactFactor eFactor) {
    FlowRec flowRec = flow(eFactor);
    if (flowRec == null)
        return null;
    ImpactFactor f = new ImpactFactor();
    f.flow = flowRec.flow;
    f.flowPropertyFactor = flowRec.property;
    f.unit = flowRec.unit;
    f.value = eFactor.amount;
    return f;
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor)

Aggregations

ImpactFactor (org.openlca.core.model.ImpactFactor)19 ImpactCategory (org.openlca.core.model.ImpactCategory)6 Parameter (org.openlca.core.model.Parameter)5 Test (org.junit.Test)4 Flow (org.openlca.core.model.Flow)4 FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)4 ArrayList (java.util.ArrayList)3 Uncertainty (org.openlca.core.model.Uncertainty)3 FlowDao (org.openlca.core.database.FlowDao)2 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)2 Exchange (org.openlca.core.model.Exchange)2 Unit (org.openlca.core.model.Unit)2 AbstractZipTest (org.openlca.jsonld.AbstractZipTest)2 JsonElement (com.google.gson.JsonElement)1 TLongByteHashMap (gnu.trove.map.hash.TLongByteHashMap)1 TLongHashSet (gnu.trove.set.hash.TLongHashSet)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1 Objects (java.util.Objects)1