Search in sources :

Example 1 with DQScore

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

the class DQResultTest method createDQSystem.

private void createDQSystem() {
    dqSystem = new DQSystem();
    for (int i = 1; i <= 5; i++) {
        DQIndicator indicator = new DQIndicator();
        indicator.position = i;
        dqSystem.indicators.add(indicator);
        for (int j = 1; j <= 5; j++) {
            DQScore score = new DQScore();
            score.position = j;
            indicator.scores.add(score);
        }
    }
    dqSystem = new DQSystemDao(db).insert(dqSystem);
}
Also used : DQScore(org.openlca.core.model.DQScore) DQSystem(org.openlca.core.model.DQSystem) DQIndicator(org.openlca.core.model.DQIndicator) DQSystemDao(org.openlca.core.database.DQSystemDao)

Example 2 with DQScore

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

the class DQSystems method ecoinvent.

/**
 * Creates an instance of the ecoinvent data quality system.
 */
public static DQSystem ecoinvent() {
    DQSystem system = new DQSystem();
    system.name = "ecoinvent data quality system";
    system.refId = EI_DQS;
    system.hasUncertainties = true;
    String[] indicators = eiIndicators();
    String[][] scores = eiScores();
    double[][] uncertainties = eiUncertainties();
    for (int i = 0; i < indicators.length; i++) {
        DQIndicator indicator = new DQIndicator();
        indicator.name = indicators[i];
        indicator.position = i + 1;
        for (int j = 0; j < scores[i].length; j++) {
            DQScore score = new DQScore();
            score.description = scores[i][j];
            score.position = j + 1;
            score.uncertainty = uncertainties[i][j];
            indicator.scores.add(score);
        }
        system.indicators.add(indicator);
    }
    return system;
}
Also used : DQScore(org.openlca.core.model.DQScore) DQSystem(org.openlca.core.model.DQSystem) DQIndicator(org.openlca.core.model.DQIndicator)

Example 3 with DQScore

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

the class DQSystemInfoPage method createAddScoreButton.

private void createAddScoreButton(Composite parent) {
    Button button = toolkit.createButton(parent, M.AddScore, SWT.NONE);
    if (getModel().indicators.size() == 0) {
        button.setEnabled(false);
        return;
    }
    Controls.onSelect(button, (e) -> {
        int newScore = getModel().getScoreCount() + 1;
        for (DQIndicator indicator : getModel().indicators) {
            DQScore score = new DQScore();
            score.position = newScore;
            score.label = "Score " + newScore;
            score.description = indicator.name + " - score " + newScore;
            indicator.scores.add(score);
        }
        getEditor().setDirty(true);
        redraw();
    });
}
Also used : Button(org.eclipse.swt.widgets.Button) DQScore(org.openlca.core.model.DQScore) DQIndicator(org.openlca.core.model.DQIndicator)

Example 4 with DQScore

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

the class DQSystemInfoPage method createAddIndicatorButton.

private void createAddIndicatorButton(Composite parent) {
    Button button = toolkit.createButton(parent, M.AddIndicator, SWT.NONE);
    Controls.onSelect(button, (e) -> {
        DQIndicator indicator = new DQIndicator();
        indicator.name = "Indicator " + (getModel().indicators.size() + 1);
        indicator.position = getModel().indicators.size() + 1;
        for (int i = 1; i <= getModel().getScoreCount(); i++) {
            DQScore score = new DQScore();
            score.position = i;
            score.label = getModel().getScoreLabel(i);
            score.description = indicator.name + " - score " + i;
            indicator.scores.add(score);
        }
        getModel().indicators.add(indicator);
        getEditor().setDirty(true);
        redraw();
    });
}
Also used : Button(org.eclipse.swt.widgets.Button) DQScore(org.openlca.core.model.DQScore) DQIndicator(org.openlca.core.model.DQIndicator)

Example 5 with DQScore

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

the class DQSystemInfoPage method createRemoveScoreButton.

private void createRemoveScoreButton(Composite parent, int position) {
    Button button = toolkit.createButton(parent, M.RemoveScore, SWT.NONE);
    Controls.onSelect(button, (e) -> {
        for (DQIndicator indicator : getModel().indicators) {
            for (DQScore score : new ArrayList<>(indicator.scores)) {
                if (score.position < position)
                    continue;
                if (score.position == position) {
                    indicator.scores.remove(score);
                    continue;
                }
                score.position--;
            }
        }
        getEditor().setDirty(true);
        redraw();
    });
}
Also used : Button(org.eclipse.swt.widgets.Button) DQScore(org.openlca.core.model.DQScore) ArrayList(java.util.ArrayList) DQIndicator(org.openlca.core.model.DQIndicator)

Aggregations

DQScore (org.openlca.core.model.DQScore)16 DQIndicator (org.openlca.core.model.DQIndicator)12 Button (org.eclipse.swt.widgets.Button)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 Text (org.eclipse.swt.widgets.Text)2 DQSystem (org.openlca.core.model.DQSystem)2 JsonElement (com.google.gson.JsonElement)1 ArrayList (java.util.ArrayList)1 Label (org.eclipse.swt.widgets.Label)1 DQSystemDao (org.openlca.core.database.DQSystemDao)1