Search in sources :

Example 1 with JobletConnectionReconnectCommand

use of org.talend.designer.core.ui.editor.cmd.JobletConnectionReconnectCommand in project tdi-studio-se by Talend.

the class JobletContainer method refreshJobletConnections.

private void refreshJobletConnections() {
    Iterator<IConnection> inIterator = inputs.iterator();
    while (inIterator.hasNext()) {
        IConnection conn = inIterator.next();
        if (isCollapsed()) {
            ((Connection) conn).reconnect(conn.getSource(), this.node, conn.getLineStyle());
        } else {
            out: for (NodeContainer nodeContainer : this.nodeContainers) {
                Node connNode = nodeContainer.getNode();
                IElementParameter elePa = this.node.getElementParameter(connNode.getJoblet_unique_name());
                if (elePa != null) {
                    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                    IElementParameter elechild = null;
                    String uniqueName = null;
                    boolean isTri = service.isTriggerNode(connNode);
                    if (service != null && isTri) {
                        elechild = elePa.getChildParameters().get("COMPONENT_LIST");
                        uniqueName = conn.getMetaName();
                    } else {
                        elechild = elePa.getChildParameters().get("CONNECTION");
                        uniqueName = conn.getUniqueName();
                    }
                    if (elechild != null && elechild.getValue().equals(uniqueName)) {
                        List<? extends INodeConnector> connList = new JobletUtil().createConnectors(connNode, this.getProcess());
                        // modify///////////////////////////////////////////////////////////////////////////////////////////////////////
                        List<INodeConnector> inodeConnList = new ArrayList<INodeConnector>();
                        inodeConnList.addAll(connList);
                        inodeConnList.addAll(connNode.getListConnector());
                        connNode.setListConnector(inodeConnList);
                        // connNode.getListConnector().addAll(connList);
                        IMetadataTable iTable = this.node.getMetadataTable(connNode.getUniqueName());
                        if (iTable != null && !connNode.getMetadataList().contains(iTable)) {
                        // connNode.getMetadataList().add(iTable);
                        }
                        JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                        reConnectCommand.setNewTarget(connNode);
                        reConnectCommand.execute();
                        break;
                    } else if (getFlowInput(inputs).size() == 1 && !isTri && new JobletUtil().isJobletInput(connNode, this.getProcess())) {
                        for (IConnection flowConn : getFlowInput(inputs)) {
                            if (!flowConn.getUniqueName().equals(conn.getUniqueName())) {
                                continue out;
                            }
                        }
                        JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                        reConnectCommand.setNewTarget(connNode);
                        reConnectCommand.execute();
                        break;
                    }
                }
            }
        }
    }
    Iterator<IConnection> outIterator = outputs.iterator();
    while (outIterator.hasNext()) {
        IConnection conn = outIterator.next();
        if (isCollapsed()) {
            ((Connection) conn).reconnect(this.node, conn.getTarget(), conn.getLineStyle());
        } else {
            for (NodeContainer nodeContainer : this.nodeContainers) {
                Node connNode = nodeContainer.getNode();
                if (conn.getConnectorName().equals(connNode.getJoblet_unique_name())) {
                    List<? extends INodeConnector> connList = new JobletUtil().createConnectors(connNode, this.getProcess());
                    List<INodeConnector> inodeConnList = new ArrayList<INodeConnector>();
                    inodeConnList.addAll(connList);
                    inodeConnList.addAll(connNode.getListConnector());
                    connNode.setListConnector(inodeConnList);
                    // connNode.setListConnector(connList);
                    IMetadataTable iTable = this.node.getMetadataTable(connNode.getUniqueName());
                    if (iTable != null && !connNode.getMetadataList().contains(iTable)) {
                    // connNode.getMetadataList().add(iTable);
                    }
                    JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                    reConnectCommand.setNewSource(connNode);
                    reConnectCommand.execute();
                // return;
                }
            }
        }
    }
    if (!isCollapsed()) {
        for (NodeContainer nodeContainer : this.nodeContainers) {
            Node connNode = nodeContainer.getNode();
            IProcess jobletProcess = this.getNode().getComponent().getProcess();
            List<? extends INode> jobletNodes = jobletProcess.getGraphicalNodes();
            for (INode n : jobletNodes) {
                if (connNode.getJoblet_unique_name().equals(n.getUniqueName())) {
                    connNode.setDummy(n.isDummy());
                // connNode.setActivate(n.isActivate());
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) INodeConnector(org.talend.core.model.process.INodeConnector) JobletConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.JobletConnectionReconnectCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 IConnection (org.talend.core.model.process.IConnection)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 INode (org.talend.core.model.process.INode)1 INodeConnector (org.talend.core.model.process.INodeConnector)1 IProcess (org.talend.core.model.process.IProcess)1 IJobletProviderService (org.talend.core.ui.IJobletProviderService)1 JobletConnectionReconnectCommand (org.talend.designer.core.ui.editor.cmd.JobletConnectionReconnectCommand)1 Connection (org.talend.designer.core.ui.editor.connections.Connection)1 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1