Search in sources :

Example 1 with Json

use of org.openlca.jsonld.Json in project olca-modules by GreenDelta.

the class ImpactMethodImport method mapNwSets.

private void mapNwSets(JsonObject json, ImpactMethod method) {
    var array = Json.getArray(json, "nwSets");
    if (array == null)
        return;
    for (JsonElement e : array) {
        if (!e.isJsonObject())
            continue;
        var nwObj = e.getAsJsonObject();
        var nwSet = new NwSet();
        method.nwSets.add(nwSet);
        In.mapAtts(nwObj, nwSet, 0L);
        nwSet.weightedScoreUnit = Json.getString(json, "weightedScoreUnit");
        Json.stream(Json.getArray(nwObj, "factors")).filter(JsonElement::isJsonObject).map(f -> nwFactor(f.getAsJsonObject(), method)).forEach(nwSet.factors::add);
    }
}
Also used : Objects(java.util.Objects) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) ImpactMethod(org.openlca.core.model.ImpactMethod) Strings(org.openlca.util.Strings) Json(org.openlca.jsonld.Json) NwFactor(org.openlca.core.model.NwFactor) NwSet(org.openlca.core.model.NwSet) ModelType(org.openlca.core.model.ModelType) JsonElement(com.google.gson.JsonElement) NwSet(org.openlca.core.model.NwSet)

Aggregations

JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Objects (java.util.Objects)1 ImpactMethod (org.openlca.core.model.ImpactMethod)1 ModelType (org.openlca.core.model.ModelType)1 NwFactor (org.openlca.core.model.NwFactor)1 NwSet (org.openlca.core.model.NwSet)1 Json (org.openlca.jsonld.Json)1 Strings (org.openlca.util.Strings)1