use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class GraphEditor method createNecessaryLinks.
public void createNecessaryLinks(ProcessNode node) {
MutableProcessLinkSearchMap linkSearch = node.parent().linkSearch;
ProductSystemNode sysNode = node.parent();
long id = node.process.id;
for (ProcessLink pLink : linkSearch.getLinks(id)) {
boolean isProvider = pLink.providerId == id;
long otherID = isProvider ? pLink.processId : pLink.providerId;
ProcessNode otherNode = model.getProcessNode(otherID);
if (otherNode == null)
continue;
ProcessNode outNode = null;
ProcessNode inNode = null;
FlowType type = sysNode.flows.type(pLink.flowId);
if (type == FlowType.PRODUCT_FLOW) {
outNode = isProvider ? node : otherNode;
inNode = isProvider ? otherNode : node;
} else if (type == FlowType.WASTE_FLOW) {
outNode = isProvider ? otherNode : node;
inNode = isProvider ? node : otherNode;
}
if (outNode == null)
continue;
if (!outNode.isExpandedRight() && !inNode.isExpandedLeft())
continue;
Link link = new Link();
link.outputNode = outNode;
link.inputNode = inNode;
link.processLink = pLink;
link.link();
}
}
use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class AvoidedCheck method canModify.
@Override
public boolean canModify(Exchange e) {
if (e == null)
return false;
Process p = editor.getModel();
if (Objects.equals(p.quantitativeReference, e))
return false;
if (e.flow == null)
return false;
FlowType type = e.flow.flowType;
if (type == null)
return false;
switch(type) {
case ELEMENTARY_FLOW:
return false;
case PRODUCT_FLOW:
return (e.isAvoided && e.isInput) || (!e.isAvoided && !e.isInput);
case WASTE_FLOW:
return (e.isAvoided && !e.isInput) || (!e.isAvoided && e.isInput);
default:
return false;
}
}
use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class ProcessExpander method createNecessaryNodes.
private void createNecessaryNodes() {
ProductSystemNode sysNode = node.parent();
long processID = node.process.id;
List<ProcessLink> links = sysNode.linkSearch.getLinks(processID);
for (ProcessLink pLink : links) {
FlowType type = sysNode.flows.type(pLink.flowId);
if (type == null || type == FlowType.ELEMENTARY_FLOW)
continue;
boolean isProvider = processID == pLink.providerId;
long otherID = isProvider ? pLink.processId : pLink.providerId;
ProcessNode outNode;
ProcessNode inNode;
if (isInputNode(type, isProvider)) {
inNode = this.node;
outNode = node(otherID, sysNode);
} else if (isOutputNode(type, isProvider)) {
outNode = this.node;
inNode = node(otherID, sysNode);
} else {
continue;
}
Link link = new Link();
link.outputNode = outNode;
link.inputNode = inNode;
link.processLink = pLink;
link.link();
}
}
use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class ProcessExpander method shouldBeVisible.
boolean shouldBeVisible() {
ProductSystemNode sysNode = node.parent();
MutableProcessLinkSearchMap linkSearch = sysNode.linkSearch;
long processId = node.process.id;
for (ProcessLink link : linkSearch.getLinks(processId)) {
FlowType type = sysNode.flows.type(link.flowId);
boolean isProvider = link.providerId == processId;
if (side == Side.INPUT) {
if (type == FlowType.PRODUCT_FLOW && !isProvider)
return true;
if (type == FlowType.WASTE_FLOW && isProvider)
return true;
} else if (side == Side.OUTPUT) {
if (type == FlowType.PRODUCT_FLOW && isProvider)
return true;
if (type == FlowType.WASTE_FLOW && !isProvider)
return true;
}
}
return false;
}
use of org.openlca.core.model.FlowType in project olca-app by GreenDelta.
the class MassCreationCommand method link.
private void link(ProcessLink newLink) {
ProductSystem system = sysNode.getProductSystem();
system.processLinks.add(newLink);
sysNode.linkSearch.put(newLink);
Link link = new Link();
link.processLink = newLink;
FlowType ftype = sysNode.flows.type(newLink.flowId);
boolean isWaste = ftype == FlowType.WASTE_FLOW;
link.outputNode = sysNode.getProcessNode(isWaste ? newLink.processId : newLink.providerId);
link.inputNode = sysNode.getProcessNode(isWaste ? newLink.providerId : newLink.processId);
link.link();
createdLinks.add(link);
}
Aggregations