Search in sources :

Example 71 with Parameter

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

the class Clipboard method readAsCalculatedParams.

static List<Parameter> readAsCalculatedParams(String text, ParameterScope scope) {
    ClipboardText ct = ClipboardText.split(text);
    List<Parameter> params = readParams(ct);
    for (Parameter param : params) {
        param.scope = scope;
        param.isInputParameter = false;
        if (param.formula == null) {
            param.formula = Double.toString(param.value);
        }
        param.uncertainty = null;
    }
    return params;
}
Also used : Parameter(org.openlca.core.model.Parameter)

Example 72 with Parameter

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

the class Formulas method evalGlobal.

private List<String> evalGlobal(List<Parameter> params) {
    try {
        FormulaInterpreter interpreter = new FormulaInterpreter();
        Scope scope = interpreter.getGlobalScope();
        for (Parameter p : params) bind(p, scope);
        evalParams(params, scope);
    } catch (Exception e) {
        log.warn("unexpected error in formula evaluation", e);
    }
    return errors;
}
Also used : Scope(org.openlca.expressions.Scope) Parameter(org.openlca.core.model.Parameter) FormulaInterpreter(org.openlca.expressions.FormulaInterpreter)

Example 73 with Parameter

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

the class ParameterPage method bindGlobalParamActions.

private void bindGlobalParamActions(Section section, TableViewer table) {
    var copy = TableClipboard.onCopySelected(table);
    var refresh = Actions.create(M.Reload, Icon.REFRESH.descriptor(), () -> {
        setGlobalTableInput();
        support.evaluate();
        editor.setDirty(true);
    });
    var usage = Actions.create(M.Usage, Icon.LINK.descriptor(), () -> {
        Parameter p = Viewers.getFirstSelected(table);
        if (p != null) {
            ParameterUsagePage.show(p.name);
        }
    });
    Actions.bind(table, copy, refresh, usage);
    Actions.bind(section, refresh);
}
Also used : Parameter(org.openlca.core.model.Parameter)

Example 74 with Parameter

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

the class ParameterSection method onPaste.

private void onPaste(String text) {
    var scope = entity().parameterScope();
    var params = forInputParameters ? Clipboard.readAsInputParams(text, scope) : Clipboard.readAsCalculatedParams(text, scope);
    boolean skipped = false;
    for (Parameter param : params) {
        String name = param.name;
        if (!Parameters.isValidName(name) || exists(name)) {
            skipped = true;
            continue;
        }
        entity().parameters.add(param);
    }
    if (skipped) {
        MsgBox.warning(M.SomeParametersWereNotAdded);
    }
    setInput();
    editor.setDirty(true);
    support.evaluate();
}
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