Package com.asakusafw.vocabulary.flow.graph

Examples of com.asakusafw.vocabulary.flow.graph.FlowElementInput


    private List<FlowBlock.Input> toBlockInputs(List<PortConnection> inputs) {
        assert inputs != null;
        Map<FlowElementInput, Set<PortConnection>> map = new LinkedHashMap<FlowElementInput, Set<PortConnection>>();
        for (PortConnection input : inputs) {
            FlowElementInput port = input.getDownstream();
            Maps.addToSet(map, port, input);
        }
        List<FlowBlock.Input> results = Lists.create();
        for (Map.Entry<FlowElementInput, Set<PortConnection>> entry : map.entrySet()) {
            results.add(new FlowBlock.Input(entry.getKey(), entry.getValue()));
View Full Code Here


            Map<FlowElementInput, FlowElementInput> inputMapping,
            Map<FlowElementOutput, FlowElementOutput> outputMapping) {
        assert inputMapping != null;
        assert outputMapping != null;
        for (FlowBlock.Input bound : blockInputs) {
            FlowElementInput port = inputMapping.get(bound.getElementPort());
            assert port != null;
            bound.setElementPort(port);
        }
        for (FlowBlock.Output bound : blockOutputs) {
            FlowElementOutput port = outputMapping.get(bound.getElementPort());
View Full Code Here

            if (elem != unified) {
                List<FlowElementInput> srcInput = elem.getInputPorts();
                List<FlowElementInput> uniInput = unified.getInputPorts();
                assert srcInput.size() == uniInput.size();
                for (int i = 0, n = srcInput.size(); i < n; i++) {
                    FlowElementInput srcPort = srcInput.get(i);
                    FlowElementInput uniPort = uniInput.get(i);
                    for (PortConnection conn : srcPort.getConnected()) {
                        FlowElementOutput opposite = unifiedOutputs.get(conn.getUpstream());
                        assert opposite != null;
                        PortConnection.connect(opposite, uniPort);
                    }
                    srcPort.disconnectAll();
                }
            }
        }

        // reconnect outputs
        for (FlowElement elem : elementMapping.values()) {
            FlowElement unified = unifiedElements.get(elem);
            assert unified != null;
            if (elem != unified) {
                List<FlowElementOutput> srcOutput = elem.getOutputPorts();
                List<FlowElementOutput> uniOutput = unified.getOutputPorts();
                assert srcOutput.size() == uniOutput.size();
                for (int i = 0, n = srcOutput.size(); i < n; i++) {
                    FlowElementOutput srcPort = srcOutput.get(i);
                    FlowElementOutput uniPort = uniOutput.get(i);
                    for (PortConnection conn : srcPort.getConnected()) {
                        FlowElementInput opposite = unifiedInputs.get(conn.getDownstream());
                        assert opposite != null;
                        PortConnection.connect(uniPort, opposite);
                    }
                    srcPort.disconnectAll();
                }
View Full Code Here

        assert inputMapping != null;
        assert outputMapping != null;
        Map<FlowElementInput, FlowBlock.Input> map = Maps.create();
        for (Iterator<FlowBlock.Input> iter = blockInputs.iterator(); iter.hasNext();) {
            FlowBlock.Input blockPort = iter.next();
            FlowElementInput elementPort = inputMapping.get(blockPort.getElementPort());
            assert elementPort != null;
            FlowBlock.Input unified = map.get(elementPort);
            if (unified == null) {
                map.put(elementPort, blockPort);
                blockPort.setElementPort(elementPort);
View Full Code Here

        if (foundTarget == false) {
            return changed;
        }
        Map<FlowElementInput, FlowBlock.Input> inputs = Maps.create();
        for (FlowBlock.Input input : blockInputs) {
            FlowElementInput elementInput = input.getElementPort();
            assert inputs.containsKey(elementInput) == false;
            inputs.put(elementInput, input);
        }
        for (Map.Entry<FlowBlock.Input, List<FlowBlock.Output>> entry : targets.entrySet()) {
            List<FlowBlock.Output> upstream = entry.getValue();
            if (upstream.size() == 1) {
                continue;
            }
            FlowElement primaryElement = upstream.get(0).getElementPort().getOwner();
            assert primaryElement.getDescription().getKind() == FlowElementKind.PSEUD;
            assert primaryElement.getInputPorts().size() == 1;
            FlowElementInput primaryInput = primaryElement.getInputPorts().get(0);
            FlowBlock.Input primarySource = inputs.get(primaryInput);
            assert primarySource != null;

            for (int i = 1, n = upstream.size(); i < n; i++) {
                FlowBlock.Output otherTarget = upstream.get(i);
                FlowElement otherElement = otherTarget.getElementPort().getOwner();
                LOG.debug("Unifying pseud element: {} -> {}", otherElement, primaryElement);

                assert otherElement.getDescription().getKind() == FlowElementKind.PSEUD;
                assert otherElement.getInputPorts().size() == 1;
                FlowElementInput otherInput = otherElement.getInputPorts().get(0);
                FlowBlock.Input otherSource = inputs.get(otherInput);
                assert otherSource != null;
                for (FlowBlock.Connection conn : otherSource.getConnections()) {
                    FlowBlock.connect(conn.getUpstream(), primarySource);
                }
View Full Code Here

            addMapping(outputMapping, orig.getOutputPorts(), copy.getOutputPorts());
        }

        // ポート接続のコピー
        for (Map.Entry<FlowElementInput, FlowElementInput> entry : inputMapping.entrySet()) {
            FlowElementInput origIn = entry.getKey();
            FlowElementInput copyIn = entry.getValue();
            for (FlowElementOutput origOut : origIn.getOpposites()) {
                if (elements.contains(origOut.getOwner()) == false) {
                    continue;
                }
                FlowElementOutput copyOut = outputMapping.get(origOut);
View Full Code Here

        if (isIdentity(element) == false) {
            throw new IllegalArgumentException("element must be identity operator"); //$NON-NLS-1$
        }
        assert element.getInputPorts().size() == 1;
        assert element.getOutputPorts().size() == 1;
        FlowElementInput input = element.getInputPorts().get(0);
        FlowElementOutput output = element.getOutputPorts().get(0);
        Set<PortConnection> sources = Sets.from(input.getConnected());
        Set<PortConnection> targets = Sets.from(output.getConnected());
        if (sources.size() <= 1 && targets.size() <= 1) {
            return false;
        } else {
            for (PortConnection source : sources) {
                FlowElementOutput upstream = source.getUpstream();
                for (PortConnection target : targets) {
                    FlowElementInput downstream = target.getDownstream();
                    connectWithIdentity(element, upstream, downstream);
                }
            }
            disconnect(element);
            return true;
View Full Code Here

                output.getDescription().getDataType(),
                true,
                false,
                FlowBoundary.STAGE);
        FlowElementResolver resolver = new FlowElementResolver(desc);
        FlowElementInput stopIn = resolver.getInput(PseudElementDescription.INPUT_PORT_NAME);
        PortConnection.connect(output, stopIn);
    }
View Full Code Here

        while (next.isEmpty() == false) {
            PortConnection successor = next.removeFirst();
            if (connections.contains(successor)) {
                results.add(successor);
            } else {
                FlowElementInput nextInput = successor.getDownstream();
                for (FlowElementOutput output : nextInput.getOwner().getOutputPorts()) {
                    next.addAll(output.getConnected());
                }
            }
        }
        return results;
View Full Code Here

        }
        Iterator<FlowElementInput> inputIterator = inputs.iterator();
        Iterator<FlowElementOutput> outputIterator = outputs.iterator();
        while (inputIterator.hasNext()) {
            assert outputIterator.hasNext();
            FlowElementInput input = inputIterator.next();
            FlowElementOutput output = outputIterator.next();
            bypass(input, output, attributes);
        }
        assert outputIterator.hasNext() == false;
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.vocabulary.flow.graph.FlowElementInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.