Search in sources :

Example 6 with Parameter

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

the class ProjectReferenceSearchTest method createParameter.

private Parameter createParameter(String name, Object value, boolean global) {
    Parameter parameter = new Parameter();
    parameter.name = name;
    boolean formula = value instanceof String;
    parameter.isInputParameter = !formula;
    if (formula)
        parameter.formula = value.toString();
    else
        parameter.value = (double) value;
    if (global)
        parameter.scope = ParameterScope.GLOBAL;
    else
        parameter.scope = ParameterScope.PROCESS;
    return parameter;
}
Also used : Parameter(org.openlca.core.model.Parameter)

Example 7 with Parameter

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

the class ProjectReferenceSearchTest method createParameterRedef.

private ParameterRedef createParameterRedef(String name, Object contextOrValue) {
    ParameterRedef redef = new ParameterRedef();
    redef.name = name;
    redef.value = 1d;
    if (contextOrValue instanceof Long) {
        redef.contextType = ModelType.IMPACT_METHOD;
        redef.contextId = (long) contextOrValue;
    } else {
        if (!parameters.containsKey(name)) {
            Parameter parameter = createParameter(name, contextOrValue.toString(), true);
            parameters.put(name, db.insert(parameter));
        }
    }
    return redef;
}
Also used : Parameter(org.openlca.core.model.Parameter) ParameterRedef(org.openlca.core.model.ParameterRedef)

Example 8 with Parameter

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

the class ParameterIOTests method testGlobalParameters.

@Test
public void testGlobalParameters() {
    Parameter param = new Parameter();
    param.refId = UUID.randomUUID().toString();
    param.description = "test parameter";
    param.isInputParameter = true;
    param.scope = ParameterScope.GLOBAL;
    param.name = "p_342637";
    param.value = 42;
    parameterDao.insert(param);
    Tests.emptyCache();
    Parameter alias = parameterDao.getForId(param.id);
    Assert.assertEquals("p_342637", alias.name);
    Assert.assertTrue(parameterDao.getGlobalParameters().contains(alias));
    parameterDao.delete(alias);
}
Also used : Parameter(org.openlca.core.model.Parameter) Test(org.junit.Test)

Example 9 with Parameter

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

the class ProcessParameterConversion method addDatabaseParams.

private void addDatabaseParams(List<org.openlca.ilcd.processes.Parameter> params) {
    ParameterDao dao = new ParameterDao(config.db);
    for (Parameter param : dao.getGlobalParameters()) {
        if (!valid(param))
            continue;
        org.openlca.ilcd.processes.Parameter iParam = convertParam(param);
        params.add(iParam);
        addScope(iParam, ParameterScope.GLOBAL);
    }
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) Parameter(org.openlca.core.model.Parameter)

Example 10 with Parameter

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

the class ProcessParameterConversion method processParams.

private List<org.openlca.ilcd.processes.Parameter> processParams(Process process) {
    List<org.openlca.ilcd.processes.Parameter> iParameters = new ArrayList<>();
    for (Parameter oParam : process.parameters) {
        if (!valid(oParam))
            continue;
        org.openlca.ilcd.processes.Parameter iParam = convertParam(oParam);
        iParameters.add(iParam);
        addScope(iParam, ParameterScope.PROCESS);
    }
    return iParameters;
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.openlca.core.model.Parameter)

Aggregations

Parameter (org.openlca.core.model.Parameter)74 Test (org.junit.Test)17 AbstractZipTest (org.openlca.jsonld.AbstractZipTest)14 Process (org.openlca.core.model.Process)12 ParameterDao (org.openlca.core.database.ParameterDao)11 Uncertainty (org.openlca.core.model.Uncertainty)8 ArrayList (java.util.ArrayList)7 Category (org.openlca.core.model.Category)6 ImpactCategory (org.openlca.core.model.ImpactCategory)6 ParameterRedef (org.openlca.core.model.ParameterRedef)6 Exchange (org.openlca.core.model.Exchange)5 ImpactFactor (org.openlca.core.model.ImpactFactor)5 ProductSystem (org.openlca.core.model.ProductSystem)5 Before (org.junit.Before)4 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 ImpactMethod (org.openlca.core.model.ImpactMethod)3 ProcessDao (org.openlca.core.database.ProcessDao)2 DQSystem (org.openlca.core.model.DQSystem)2 Flow (org.openlca.core.model.Flow)2