Search in sources :

Example 21 with ProcessLink

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);
}
Also used : ProductSystem(org.openlca.core.model.ProductSystem) FlowType(org.openlca.core.model.FlowType) Link(org.openlca.app.editors.graphical.model.Link) ProcessLink(org.openlca.core.model.ProcessLink)

Example 22 with ProcessLink

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);
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) MassCreationCommand(org.openlca.app.editors.graphical.command.MassCreationCommand) Command(org.eclipse.gef.commands.Command) ProductSystemNode(org.openlca.app.editors.graphical.model.ProductSystemNode) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) ConnectionDialog(org.openlca.app.editors.graphical.search.ConnectionDialog)

Example 23 with ProcessLink

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;
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) ProductSystemNode(org.openlca.app.editors.graphical.model.ProductSystemNode) FlowType(org.openlca.core.model.FlowType)

Example 24 with 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;
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink)

Aggregations

ProcessLink (org.openlca.core.model.ProcessLink)24 ProductSystemNode (org.openlca.app.editors.graphical.model.ProductSystemNode)7 Link (org.openlca.app.editors.graphical.model.Link)5 ProcessNode (org.openlca.app.editors.graphical.model.ProcessNode)5 Exchange (org.openlca.core.model.Exchange)5 FlowType (org.openlca.core.model.FlowType)5 Process (org.openlca.core.model.Process)4 ProductSystem (org.openlca.core.model.ProductSystem)4 MutableProcessLinkSearchMap (org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap)3 Flow (org.openlca.core.model.Flow)3 ArrayList (java.util.ArrayList)2 Command (org.eclipse.gef.commands.Command)2 Test (org.junit.Test)2 ProductSystemDao (org.openlca.core.database.ProductSystemDao)2 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)2 TLongLongHashMap (gnu.trove.map.hash.TLongLongHashMap)1 HashMap (java.util.HashMap)1 DeleteLinkCommand (org.openlca.app.editors.graphical.command.DeleteLinkCommand)1 MassCreationCommand (org.openlca.app.editors.graphical.command.MassCreationCommand)1 LayoutManager (org.openlca.app.editors.graphical.layout.LayoutManager)1