Search in sources :

Example 16 with ProcessLink

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

Example 17 with ProcessLink

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

Example 18 with ProcessLink

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

Example 19 with ProcessLink

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

Example 20 with ProcessLink

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();
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) LayoutManager(org.openlca.app.editors.graphical.layout.LayoutManager) ProcessNode(org.openlca.app.editors.graphical.model.ProcessNode) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor)

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