use of org.openlca.core.model.ProcessLink 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);
}
use of org.openlca.core.model.ProcessLink in project olca-app by GreenDelta.
the class SearchConnectorsAction method executeRequest.
private void executeRequest(ExchangeNode enode) {
ProductSystemNode sysNode = node.parent();
ConnectionDialog dialog = new ConnectionDialog(enode);
if (dialog.open() != IDialogConstants.OK_ID)
return;
List<RootDescriptor> newProcesses = dialog.getNewProcesses();
List<ProcessLink> newLinks = dialog.getNewLinks();
Command command = type == PROVIDER ? MassCreationCommand.providers(newProcesses, newLinks, sysNode) : MassCreationCommand.recipients(newProcesses, newLinks, sysNode);
Commands.executeCommand(command, sysNode.editor);
}
use of org.openlca.core.model.ProcessLink 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.ProcessLink in project olca-app by GreenDelta.
the class ExchangeNode method isConnected.
/**
* Returns true if this exchange is connected.
*/
public boolean isConnected() {
var parent = parent();
if (parent == null || parent.process == null || exchange == null)
return false;
var linkSearch = parent.parent().linkSearch;
var links = linkSearch.getConnectionLinks(parent.process.id);
for (ProcessLink link : links) {
if (link.exchangeId == exchange.id)
return true;
}
return false;
}
Aggregations