Search in sources :

Example 1 with ProcessLink

use of org.openlca.core.model.ProcessLink in project olca-modules by GreenDelta.

the class ProductSystemReferenceSearchTest method createLink.

private ProcessLink createLink(Process p1, Process p2) {
    ProcessLink link = new ProcessLink();
    Flow flow = createFlow(false);
    Exchange e1 = new Exchange();
    e1.flow = flow;
    p1.exchanges.add(e1);
    Exchange e2 = new Exchange();
    e2.flow = flow;
    p2.exchanges.add(e2);
    link.processId = p1.id;
    link.providerId = p2.id;
    link.flowId = flow.id;
    addExpected("processId", p1);
    addExpected("providerId", p2);
    addExpected("exchangeId", e1);
    return link;
}
Also used : Exchange(org.openlca.core.model.Exchange) ProcessLink(org.openlca.core.model.ProcessLink) Flow(org.openlca.core.model.Flow)

Example 2 with ProcessLink

use of org.openlca.core.model.ProcessLink in project olca-modules by GreenDelta.

the class TestSystem method link.

public TestSystem link(Process process) {
    if (processes.contains(process))
        return this;
    index(process);
    for (Process p : processes) {
        for (Exchange e : p.exchanges) {
            if (isProvider(e))
                continue;
            if (e.flow == null || e.flow.flowType == FlowType.ELEMENTARY_FLOW)
                continue;
            long flowId = e.flow.id;
            Process provider = providers.get(flowId);
            if (provider == null)
                continue;
            ProcessLink link = new ProcessLink();
            link.providerId = provider.id;
            link.flowId = flowId;
            link.processId = p.id;
            link.exchangeId = e.id;
            if (!system.processLinks.contains(link)) {
                system.processLinks.add(link);
            }
        }
    }
    return this;
}
Also used : Exchange(org.openlca.core.model.Exchange) ProcessLink(org.openlca.core.model.ProcessLink) Process(org.openlca.core.model.Process)

Example 3 with ProcessLink

use of org.openlca.core.model.ProcessLink in project olca-modules by GreenDelta.

the class ExchangeUseSearchTest method createSystem.

private void createSystem() {
    ProductSystem system = new ProductSystem();
    system.name = SYS_NAME;
    system.referenceProcess = p;
    system.referenceExchange = p.exchanges.get(0);
    Flow linkFlow = p.exchanges.get(1).flow;
    ProcessLink link = new ProcessLink();
    link.providerId = p.id;
    link.processId = q.id;
    link.flowId = linkFlow.id;
    system.processLinks.add(link);
    system = new ProductSystemDao(db).insert(system);
    modelStack.push(system);
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) ProductSystem(org.openlca.core.model.ProductSystem) Flow(org.openlca.core.model.Flow) ProductSystemDao(org.openlca.core.database.ProductSystemDao)

Example 4 with ProcessLink

use of org.openlca.core.model.ProcessLink in project olca-modules by GreenDelta.

the class Update8Test method testSystemLink.

@Test
public void testSystemLink() {
    ProductSystemDao dao = new ProductSystemDao(db);
    ProductSystem system = new ProductSystem();
    ProcessLink link = new ProcessLink();
    link.providerType = ProcessLink.ProviderType.SUB_SYSTEM;
    system.processLinks.add(link);
    dao.insert(system);
    system = dao.getForId(system.id);
    assertTrue(system.processLinks.get(0).hasSubSystemProvider());
    dao.delete(system);
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) ProductSystem(org.openlca.core.model.ProductSystem) ProductSystemDao(org.openlca.core.database.ProductSystemDao) Test(org.junit.Test)

Example 5 with ProcessLink

use of org.openlca.core.model.ProcessLink in project olca-modules by GreenDelta.

the class ProductSystemLinks method map.

private void map() {
    mapProcessIds();
    for (ProcessLink link : system.processLinks) {
        link.providerId = destId(Process.class, link.providerId);
        link.processId = destId(Process.class, link.processId);
        link.flowId = destId(Flow.class, link.flowId);
        Ex ex = new Ex(link.exchangeId);
        link.exchangeId = ex.map().id;
    }
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) Process(org.openlca.core.model.Process) Flow(org.openlca.core.model.Flow)

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