use of org.openlca.core.model.ProcessLink in project olca-modules by GreenDelta.
the class LinkContributionsTest method link.
private ProcessLink link(long provider, long flow, long recipient) {
ProcessLink link = new ProcessLink();
link.flowId = flow;
link.providerId = provider;
link.processId = recipient;
return link;
}
use of org.openlca.core.model.ProcessLink in project olca-modules by GreenDelta.
the class ModelImport method addLink.
private void addLink(Process out, Process in, Flow flow, Integer exchangeId) {
boolean isWaste = flow.flowType == FlowType.WASTE_FLOW;
ProcessLink link = new ProcessLink();
link.flowId = flow.id;
link.providerId = isWaste ? in.id : out.id;
link.processId = isWaste ? out.id : in.id;
Exchange exchange = null;
Process linked = isWaste ? out : in;
for (Exchange e : linked.exchanges) {
if (e.isInput == isWaste || !Objects.equals(flow, e.flow))
continue;
exchange = e;
if (exchangeId == null || exchangeId == e.internalId) {
break;
}
}
if (exchange == null)
return;
link.exchangeId = exchange.id;
system.processLinks.add(link);
}
use of org.openlca.core.model.ProcessLink 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.ProcessLink 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.ProcessLink in project olca-app by GreenDelta.
the class MassCreationCommand method execute.
@Override
public void execute() {
for (RootDescriptor process : toCreate) addNode(process);
for (ProcessLink newLink : newLinks) link(newLink);
for (ProcessNode node : sysNode.getChildren()) if (node.figure.isVisible())
oldConstraints.put(node.figure, node.figure.getBounds().getCopy());
((LayoutManager) sysNode.figure.getLayoutManager()).layout(sysNode.figure, sysNode.editor.getLayoutType());
sysNode.editor.setDirty();
if (sysNode.editor.getOutline() != null)
sysNode.editor.getOutline().refresh();
}
Aggregations