Search in sources :

Example 11 with ParameterDao

use of org.openlca.core.database.ParameterDao in project olca-modules by GreenDelta.

the class FormulaInterpreterTest method setUp.

/**
 * sets the following parameters:
 *
 * fi_tests_global = 32
 *
 * fi_tests_local = fi_tests_global + 10
 */
@Before
public void setUp() {
    globalParam = new Parameter();
    globalParam.name = "fi_tests_global";
    globalParam.isInputParameter = true;
    globalParam.scope = ParameterScope.GLOBAL;
    globalParam.value = 32;
    new ParameterDao(db).insert(globalParam);
    process = new Process();
    var localParam = new Parameter();
    localParam.name = "fi_tests_local";
    localParam.formula = "fi_tests_global + 10";
    localParam.isInputParameter = false;
    localParam.scope = ParameterScope.PROCESS;
    process.parameters.add(localParam);
    process = new ProcessDao(db).insert(process);
    interpreter = ParameterTable.interpreter(db, Collections.singleton(process.id), Collections.emptySet());
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) ProcessDao(org.openlca.core.database.ProcessDao) Parameter(org.openlca.core.model.Parameter) Process(org.openlca.core.model.Process) Before(org.junit.Before)

Example 12 with ParameterDao

use of org.openlca.core.database.ParameterDao in project olca-modules by GreenDelta.

the class FormulaInterpreterTest method tearDown.

@After
public void tearDown() {
    new ParameterDao(db).delete(globalParam);
    new ProcessDao(db).delete(process);
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) ProcessDao(org.openlca.core.database.ProcessDao) After(org.junit.After)

Example 13 with ParameterDao

use of org.openlca.core.database.ParameterDao in project olca-modules by GreenDelta.

the class ParameterTableTest method tearDown.

@After
public void tearDown() {
    IDatabase db = Tests.getDb();
    new ParameterDao(db).deleteAll();
    new ProcessDao(db).deleteAll();
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) After(org.junit.After)

Example 14 with ParameterDao

use of org.openlca.core.database.ParameterDao in project olca-modules by GreenDelta.

the class ParameterTableTest method setUp.

@Before
public void setUp() {
    IDatabase db = Tests.getDb();
    Parameter globalInp = inpParameter(42);
    globalInp.scope = ParameterScope.GLOBAL;
    Parameter globalDep = depParameter(2);
    globalDep.scope = ParameterScope.GLOBAL;
    ParameterDao paramDao = new ParameterDao(db);
    paramDao.insert(globalInp);
    paramDao.insert(globalDep);
    process = new Process();
    Parameter ppInp = inpParameter(84);
    ppInp.scope = ParameterScope.PROCESS;
    Parameter ppDep = depParameter(3);
    ppDep.scope = ParameterScope.PROCESS;
    process.parameters.add(ppInp);
    process.parameters.add(ppDep);
    new ProcessDao(db).insert(process);
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) Parameter(org.openlca.core.model.Parameter) Process(org.openlca.core.model.Process) Before(org.junit.Before)

Example 15 with ParameterDao

use of org.openlca.core.database.ParameterDao in project olca-modules by GreenDelta.

the class ParameterReferencesTest method createParameter.

private Parameter createParameter(String name, String formula, ParameterScope scope, Uncertainty u) {
    Parameter p = new Parameter();
    p.name = name;
    p.value = 1;
    if (formula != null) {
        p.isInputParameter = false;
        p.formula = formula;
    } else
        p.isInputParameter = true;
    if (scope != null)
        p.scope = scope;
    else
        p.scope = ParameterScope.GLOBAL;
    p.refId = UUID.randomUUID().toString();
    p.uncertainty = u;
    if (p.scope != ParameterScope.GLOBAL)
        return p;
    return new ParameterDao(db).insert(p);
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) Parameter(org.openlca.core.model.Parameter)

Aggregations

ParameterDao (org.openlca.core.database.ParameterDao)23 Parameter (org.openlca.core.model.Parameter)10 ArrayList (java.util.ArrayList)5 ProcessDao (org.openlca.core.database.ProcessDao)5 HashSet (java.util.HashSet)4 HashMap (java.util.HashMap)3 Set (java.util.Set)3 Before (org.junit.Before)3 ParameterDescriptor (org.openlca.core.model.descriptors.ParameterDescriptor)3 After (org.junit.After)2 IDatabase (org.openlca.core.database.IDatabase)2 Process (org.openlca.core.model.Process)2 TLongLongHashMap (gnu.trove.map.hash.TLongLongHashMap)1 List (java.util.List)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 IContentProposal (org.eclipse.jface.fieldassist.IContentProposal)1 Test (org.junit.Test)1 CategoryElement (org.openlca.app.navigation.elements.CategoryElement)1 ModelElement (org.openlca.app.navigation.elements.ModelElement)1 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)1