use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class CreateLinkCommand method getProcessLink.
private ProcessLink getProcessLink() {
if (processLink == null)
processLink = new ProcessLink();
processLink.flowId = flowId;
ProductSystemNode sysNode = sysNode();
if (sysNode == null)
return processLink;
FlowType type = sysNode.flows.type(flowId);
if (input != null) {
var p = input.parent().process;
if (type == FlowType.PRODUCT_FLOW) {
processLink.processId = p.id;
processLink.exchangeId = input.exchange.id;
} else if (type == FlowType.WASTE_FLOW) {
processLink.providerId = p.id;
processLink.setProviderType(p.type);
}
}
if (output != null) {
var p = output.parent().process;
if (type == FlowType.PRODUCT_FLOW) {
processLink.providerId = p.id;
processLink.setProviderType(p.type);
} else if (type == FlowType.WASTE_FLOW) {
processLink.processId = p.id;
processLink.exchangeId = output.exchange.id;
}
}
return processLink;
}
use of org.openlca.core.model.FlowType 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;
}
use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class AvoidedCheck method setChecked.
@Override
protected void setChecked(Exchange e, boolean value) {
if (e.isAvoided == value || !canModify(e))
return;
e.isAvoided = value;
if (!value)
e.defaultProviderId = 0;
FlowType type = e.flow.flowType;
if (type == FlowType.PRODUCT_FLOW)
e.isInput = value;
if (type == FlowType.WASTE_FLOW)
e.isInput = !value;
editor.setDirty(true);
}
use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class ProductSystemInfoPage method getRefCandidates.
private List<Exchange> getRefCandidates(Process p) {
if (p == null)
return Collections.emptyList();
List<Exchange> candidates = new ArrayList<>();
for (Exchange e : p.exchanges) {
if (e.flow == null)
continue;
FlowType type = e.flow.flowType;
if (e.isInput && type == FlowType.WASTE_FLOW)
candidates.add(e);
else if (!e.isInput && type == FlowType.PRODUCT_FLOW)
candidates.add(e);
}
Collections.sort(candidates, (e1, e2) -> Strings.compare(Labels.name(e1.flow), Labels.name(e2.flow)));
return candidates;
}
Aggregations