use of org.openlca.core.model.descriptors.UnitDescriptor in project olca-app by GreenDelta.
the class JsonRefCollector method buildFlows.
private List<FlowRef> buildFlows(ZipFile zip) {
List<FlowRef> flowRefs = new ArrayList<>();
for (ZipEntry e : flowEntries) {
JsonObject obj = unpack(e, zip);
if (obj == null)
continue;
String id = Json.getString(obj, "@id");
if (id == null)
continue;
FlowRef ref = new FlowRef();
ref.flow = new FlowDescriptor();
ref.flow.refId = id;
ref.flow.name = Json.getString(obj, "name");
ref.flow.flowType = Json.getEnum(obj, "flowType", FlowType.class);
// the category
String catID = Json.getRefId(obj, "category");
ref.flowCategory = categoryPaths.get(catID);
// find the reference flow property
String propID = null;
JsonArray props = Json.getArray(obj, "flowProperties");
if (props != null) {
for (JsonElement elem : props) {
if (!elem.isJsonObject())
continue;
JsonObject prop = elem.getAsJsonObject();
boolean isRef = Json.getBool(prop, "referenceFlowProperty", false);
if (!isRef)
continue;
propID = Json.getRefId(prop, "flowProperty");
break;
}
}
if (propID != null) {
ref.property = new FlowPropertyDescriptor();
ref.property.refId = propID;
ref.property.name = propertyNames.get(propID);
String unitID = propertyUnits.get(propID);
if (unitID != null) {
ref.unit = new UnitDescriptor();
ref.unit.refId = unitID;
ref.unit.name = unitNames.get(unitID);
}
}
flowRefs.add(ref);
}
return flowRefs;
}
Aggregations