Search in sources :

Example 1 with DQIndicator

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

the class CellWriter method dataQualityHeader.

/**
 * Writes the data quality indicators of the given system into the given
 * row, starting with column col.
 */
public int dataQualityHeader(Sheet sheet, int row, int col, DQSystem system) {
    Collections.sort(system.indicators);
    for (DQIndicator indicator : system.indicators) {
        String name = Integer.toString(indicator.position);
        if (!Strings.isNullOrEmpty(indicator.name)) {
            name = indicator.name.substring(0, 1);
        }
        cell(sheet, row, col++, name, true);
    }
    return col;
}
Also used : DQIndicator(org.openlca.core.model.DQIndicator)

Example 2 with DQIndicator

use of org.openlca.core.model.DQIndicator 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 3 with DQIndicator

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

the class DQSystemImport method mapIndicators.

private void mapIndicators(JsonObject json, DQSystem s) {
    JsonArray indicators = Json.getArray(json, "indicators");
    if (indicators == null || indicators.size() == 0)
        return;
    for (JsonElement e : indicators) {
        if (!e.isJsonObject())
            continue;
        JsonObject i = e.getAsJsonObject();
        DQIndicator indicator = new DQIndicator();
        indicator.name = Json.getString(i, "name");
        indicator.position = Json.getInt(i, "position", 0);
        mapScores(i, indicator);
        s.indicators.add(indicator);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) DQIndicator(org.openlca.core.model.DQIndicator)

Example 4 with DQIndicator

use of org.openlca.core.model.DQIndicator 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 5 with DQIndicator

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

the class DQSystemInfoPage method createRemoveIndicatorButton.

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

Aggregations

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