use of org.openlca.core.results.LocationResult in project olca-modules by GreenDelta.
the class ImpactHandler method getLocationContributions.
@Rpc("get/impacts/contributions/locations")
public RpcResponse getLocationContributions(RpcRequest req) {
return utils.contributionImpact(req, (result, impact, cache) -> {
LocationResult r = new LocationResult(result, cache.db);
List<Contribution<LocationDescriptor>> contributions = utils.toDescriptors(r.getContributions(impact));
contributions = utils.filter(contributions, contribution -> contribution.amount != 0);
return JsonRpc.encode(contributions, cache, json -> json.addProperty("unit", impact.referenceUnit));
});
}
use of org.openlca.core.results.LocationResult in project olca-modules by GreenDelta.
the class InventoryHandler method getLocationContributions.
@Rpc("get/inventory/contributions/locations")
public RpcResponse getLocationContributions(RpcRequest req) {
return utils.contributionFlow(req, (result, flow, cache) -> {
LocationResult r = new LocationResult(result, cache.db);
List<Contribution<LocationDescriptor>> cons = utils.toDescriptors(r.getContributions(flow.flow()));
cons = utils.filter(cons, c -> c.amount != 0);
String unit = utils.getUnit(flow, cache);
return JsonRpc.encode(cons, cache, json -> json.addProperty("unit", unit));
});
}
Aggregations