Search in sources :

Example 11 with Parameter

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

the class ParameterImport method run.

public void run() {
    log.trace("import global parameters");
    try {
        Set<String> existing = getExisting();
        for (Parameter param : sourceDao.getGlobalParameters()) {
            if (param.name == null)
                continue;
            if (existing.contains(param.name))
                continue;
            Parameter c = param.copy();
            destDao.insert(c);
        }
    } catch (Exception e) {
        log.error("Global parameter import failed", e);
    }
}
Also used : Parameter(org.openlca.core.model.Parameter)

Example 12 with Parameter

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

the class ParameterSheet method readParams.

private List<Parameter> readParams(String section, ParameterScope scope, boolean input) {
    int row = findSection(section);
    if (row < 0)
        return Collections.emptyList();
    List<Parameter> list = new ArrayList<>();
    row += 2;
    while (true) {
        String name = config.getString(sheet, row, 0);
        if (Strings.isNullOrEmpty(name))
            break;
        Parameter p = input ? readInputParam(row, name, scope) : readDependentParam(row, name, scope);
        list.add(p);
        row++;
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.openlca.core.model.Parameter)

Example 13 with Parameter

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

the class ParameterSheet method readInputParam.

private Parameter readInputParam(int row, String name, ParameterScope scope) {
    Parameter p = new Parameter();
    p.name = name;
    p.isInputParameter = true;
    p.scope = scope;
    p.value = config.getDouble(sheet, row, 1);
    p.uncertainty = config.getUncertainty(sheet, row, 2);
    p.description = config.getString(sheet, row, 7);
    return p;
}
Also used : Parameter(org.openlca.core.model.Parameter)

Example 14 with Parameter

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

the class ParameterSheet method syncGlobals.

private void syncGlobals(List<Parameter> sheetParams) {
    ParameterDao dao = new ParameterDao(config.database);
    List<Parameter> globals = new ArrayList<>();
    globals.addAll(dao.getGlobalParameters());
    for (Parameter p : sheetParams) {
        boolean found = false;
        for (Parameter global : globals) {
            String name = global.name;
            if (name == null)
                continue;
            if (name.equalsIgnoreCase(p.name)) {
                found = true;
                break;
            }
        }
        if (!found)
            globals.add(dao.insert(p));
    }
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) ArrayList(java.util.ArrayList) Parameter(org.openlca.core.model.Parameter)

Example 15 with Parameter

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

the class ParameterSheet method readDependentParam.

private Parameter readDependentParam(int row, String name, ParameterScope scope) {
    Parameter p = new Parameter();
    p.name = name;
    p.isInputParameter = false;
    p.scope = scope;
    p.formula = config.getString(sheet, row, 1);
    p.value = config.getDouble(sheet, row, 2);
    p.description = config.getString(sheet, row, 3);
    return p;
}
Also used : 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