Search in sources :

Example 1 with FlowType

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

Example 2 with FlowType

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

Example 3 with FlowType

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

Example 4 with FlowType

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

Example 5 with FlowType

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);
}
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)

Aggregations

FlowType (org.openlca.core.model.FlowType)9 ProcessLink (org.openlca.core.model.ProcessLink)5 ArrayList (java.util.ArrayList)2 Link (org.openlca.app.editors.graphical.model.Link)2 ProductSystemNode (org.openlca.app.editors.graphical.model.ProductSystemNode)2 MutableProcessLinkSearchMap (org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 ZipEntry (java.util.zip.ZipEntry)1 ProcessNode (org.openlca.app.editors.graphical.model.ProcessNode)1 Exchange (org.openlca.core.model.Exchange)1 Process (org.openlca.core.model.Process)1 ProductSystem (org.openlca.core.model.ProductSystem)1 FlowDescriptor (org.openlca.core.model.descriptors.FlowDescriptor)1 FlowPropertyDescriptor (org.openlca.core.model.descriptors.FlowPropertyDescriptor)1 UnitDescriptor (org.openlca.core.model.descriptors.UnitDescriptor)1 FlowRef (org.openlca.io.maps.FlowRef)1