Search in sources :

Example 1 with AbstractNode

use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.

the class DeleteNodeContainerCommand method execute.

@Override
@SuppressWarnings("unchecked")
public void execute() {
    connectionDeletedInfosMap = new MultiKeyMap();
    process.setActivate(false);
    List uniqueNameList = new ArrayList();
    for (INode node : nodeList) {
        if (node.getJobletNode() != null) {
            continue;
        }
        uniqueNameList.add(node.getUniqueName());
        NodeContainer nodeContainer = ((Node) node).getNodeContainer();
        ((Process) process).removeNodeContainer(nodeContainer);
        List<IConnection> inputList = (List<IConnection>) node.getIncomingConnections();
        List<IConnection> outputList = (List<IConnection>) node.getOutgoingConnections();
        boolean builtIn = node.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
        for (IConnection connection : inputList) {
            // see bug 0002633: "rejects" link disappears at times.
            if (connection != null && connection.getSourceNodeConnector() != null) {
                connection.getSourceNodeConnector().setCurLinkNbOutput(connection.getSourceNodeConnector().getCurLinkNbOutput() - 1);
            }
            INode prevNode = connection.getSource();
            if ((prevNode instanceof Node) && ((Node) prevNode).getJobletNode() != null) {
                Node jobletnode = (Node) prevNode.getJobletNode();
                ((AbstractJobletContainer) jobletnode.getNodeContainer()).getOutputs().remove(connection);
                if (!nodeList.contains(jobletnode)) {
                    boolean builtInJobletNode = jobletnode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
                    storeMetadata(connection, jobletnode, true);
                    jobletnode.removeOutput(connection);
                    if (!builtInJobletNode) {
                        process.removeUniqueConnectionName(connection.getUniqueName());
                    }
                }
            }
            if (!nodeList.contains(prevNode)) {
                boolean builtInPrevNode = prevNode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
                boolean remove = true;
                if ((prevNode instanceof Node) && ((Node) prevNode).isELTMapComponent()) {
                    remove = false;
                }
                storeMetadata(connection, prevNode, remove);
                prevNode.removeOutput(connection);
                if (!builtInPrevNode && remove) {
                    process.removeUniqueConnectionName(connection.getUniqueName());
                }
            }
        }
        for (IConnection connection : outputList) {
            INode nextNode = connection.getTarget();
            if ((nextNode instanceof Node) && ((Node) nextNode).getJobletNode() != null) {
                Node jobletnode = (Node) nextNode.getJobletNode();
                ((AbstractJobletContainer) jobletnode.getNodeContainer()).getInputs().remove(connection);
                if (!nodeList.contains(jobletnode)) {
                    jobletnode.removeInput(connection);
                    boolean builtInJobletNode = jobletnode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
                    if (!builtInJobletNode) {
                        process.removeUniqueConnectionName(connection.getUniqueName());
                    }
                }
            }
            if (!nodeList.contains(nextNode)) {
                INodeConnector nodeConnector = nextNode.getConnectorFromType(connection.getLineStyle());
                nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() - 1);
                nextNode.removeInput(connection);
                if (nextNode != null) {
                    for (int i = 0; i < nextNode.getIncomingConnections().size(); i++) {
                        Connection nextNodeConnection = (Connection) nextNode.getIncomingConnections().get(i);
                        nextNodeConnection.updateName();
                    }
                }
                if (nextNode.getExternalNode() instanceof AbstractNode) {
                    ((AbstractNode) nextNode.getExternalNode()).removeInput(connection);
                }
            }
            if (!builtIn) {
                process.removeUniqueConnectionName(connection.getUniqueName());
            }
        }
        if (builtIn) {
            for (IMetadataTable meta : node.getMetadataList()) {
                String metaName = meta.getTableName();
                process.removeUniqueConnectionName(metaName);
            }
            // for tmap remove join table names
            final List<String> names = CorePlugin.getDefault().getMapperService().getJoinTableNames(node.getExternalData());
            if (!names.isEmpty()) {
                joinTableNames.addAll(names);
                for (String name : joinTableNames) {
                    process.removeUniqueConnectionName(name);
                }
            }
        }
    }
    process.setActivate(true);
    process.checkStartNodes();
    process.checkProcess();
}
Also used : INode(org.talend.core.model.process.INode) MultiKeyMap(org.apache.commons.collections.map.MultiKeyMap) AbstractNode(org.talend.core.model.process.AbstractNode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractNode(org.talend.core.model.process.AbstractNode) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Process(org.talend.designer.core.ui.editor.process.Process) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with AbstractNode

use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.

the class DeleteNodeContainerCommand method undo.

@Override
@SuppressWarnings("unchecked")
public void undo() {
    process.setActivate(false);
    for (INode node : nodeList) {
        if (node.getJobletNode() != null) {
            continue;
        }
        NodeContainer nodeContainer = ((Node) node).getNodeContainer();
        this.process.addUniqueNodeName(node.getUniqueName());
        ((Process) process).addNodeContainer(nodeContainer);
        List<Connection> inputList = (List<Connection>) node.getIncomingConnections();
        List<Connection> outputList = (List<Connection>) node.getOutgoingConnections();
        boolean builtIn = node.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
        for (Connection connection : inputList) {
            // see bug 0004514: need to undo for 0002633
            if (connection != null && connection.getSourceNodeConnector() != null) {
                connection.getSourceNodeConnector().setCurLinkNbOutput(connection.getSourceNodeConnector().getCurLinkNbOutput() + 1);
            }
            INode prevNode = connection.getSource();
            if ((prevNode instanceof Node) && ((Node) prevNode).getJobletNode() != null) {
                Node jobletnode = (Node) prevNode.getJobletNode();
                ((AbstractJobletContainer) jobletnode.getNodeContainer()).getOutputs().add(connection);
                restoreMetadata(connection, jobletnode);
            }
            if (!nodeList.contains(prevNode)) {
                if (!prevNode.getOutgoingConnections().contains(connection)) {
                    prevNode.addOutput(connection);
                }
                restoreMetadata(connection, prevNode);
                connection.reconnect();
                connection.updateAllId();
                boolean builtInPrevNode = prevNode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
                if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME) && !builtInPrevNode) {
                    // for bug 10024
                    // see 10583
                    String name = connection.getUniqueName();
                    if (connection.getConnectorName().startsWith("TRIGGER_OUTPUT")) {
                        if (process.checkValidConnectionName(name)) {
                            process.addUniqueConnectionName(name);
                        }
                    } else {
                        process.addUniqueConnectionName(name);
                    }
                }
            }
        }
        for (IConnection connection : outputList) {
            INode nextNode = connection.getTarget();
            if ((nextNode instanceof Node) && ((Node) nextNode).getJobletNode() != null) {
                Node jobletnode = (Node) nextNode.getJobletNode();
                ((AbstractJobletContainer) jobletnode.getNodeContainer()).getInputs().add(connection);
            }
            if (!nodeList.contains(nextNode)) {
                if (!nextNode.getIncomingConnections().contains(connection)) {
                    nextNode.addInput(connection);
                }
                INodeConnector nodeConnector = nextNode.getConnectorFromType(connection.getLineStyle());
                nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() + 1);
                connection.reconnect();
                if (nextNode.getExternalNode() instanceof AbstractNode) {
                    ((AbstractNode) nextNode.getExternalNode()).addInput(connection);
                }
            }
            if (!builtIn) {
                if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME)) {
                    // for bug 10024
                    // see 10583
                    String name = connection.getUniqueName();
                    // name = process.generateUniqueConnectionName(name);
                    process.addUniqueConnectionName(name);
                }
            }
        }
        if (builtIn) {
            for (IMetadataTable meta : node.getMetadataList()) {
                String metaName = meta.getTableName();
                process.addUniqueConnectionName(metaName);
            }
            // tmap join table
            for (String name : joinTableNames) {
                process.addUniqueConnectionName(name);
            }
        }
    }
    process.setActivate(true);
    process.checkStartNodes();
    process.checkProcess();
}
Also used : INode(org.talend.core.model.process.INode) AbstractNode(org.talend.core.model.process.AbstractNode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractNode(org.talend.core.model.process.AbstractNode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Process(org.talend.designer.core.ui.editor.process.Process) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with AbstractNode

use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.

the class ConnectionDeleteCommand method undo.

@Override
public void undo() {
    Process process = (Process) connectionList.get(0).getSource().getProcess();
    for (Connection connection : connectionList) {
        collpseJoblet(connection);
        ConnectionDeletedInfo deletedInfo = connectionDeletedInfosMap.get(connection);
        if (deletedInfo != null) {
            INode source = connection.getSource();
            if (source != null && deletedInfo.metadataTable != null) {
                List<IMetadataTable> metaList = source.getMetadataList();
                if (!metaList.contains(deletedInfo.metadataTable)) {
                    metaList.add(deletedInfo.metadataTableIndex, deletedInfo.metadataTable);
                }
            }
        }
        connection.reconnect();
        INode target = connection.getTarget();
        if (target.getExternalNode() instanceof AbstractNode) {
            ((AbstractNode) target.getExternalNode()).addInput(connection);
        }
        INodeConnector nodeConnectorSource, nodeConnectorTarget;
        nodeConnectorSource = connection.getSourceNodeConnector();
        if (nodeConnectorSource != null) {
            nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
        }
        nodeConnectorTarget = connection.getTargetNodeConnector();
        if (nodeConnectorTarget != null) {
            nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
        }
    }
    process.checkStartNodes();
    process.checkProcess();
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) AbstractNode(org.talend.core.model.process.AbstractNode) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 4 with AbstractNode

use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.

the class ConnectionDeleteCommand method execute.

@Override
public void execute() {
    connectionDeletedInfosMap = new HashMap<Connection, ConnectionDeleteCommand.ConnectionDeletedInfo>();
    Process process = (Process) connectionList.get(0).getSource().getProcess();
    for (Connection connection : connectionList) {
        boolean re = deleteExpendNode(connection);
        if (re) {
            return;
        }
        ConnectionDeletedInfo deletedInfo = new ConnectionDeletedInfo();
        connectionDeletedInfosMap.put(connection, deletedInfo);
        INode source = connection.getSource();
        if (source != null && source instanceof Node && !(((Node) source).isELTMapComponent())) {
            deletedInfo.metadataTable = connection.getMetadataTable();
            List<IMetadataTable> metaList = source.getMetadataList();
            if (metaList != null && deletedInfo.metadataTable != null) {
                deletedInfo.metadataTableIndex = metaList.indexOf(deletedInfo.metadataTable);
            }
        }
        connection.disconnect();
        final INode target = connection.getTarget();
        if (target.getExternalNode() instanceof AbstractNode) {
            ((AbstractNode) target.getExternalNode()).removeInput(connection);
        }
        INodeConnector nodeConnectorSource, nodeConnectorTarget;
        nodeConnectorSource = connection.getSourceNodeConnector();
        if (nodeConnectorSource != null) {
            nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
        }
        nodeConnectorTarget = connection.getTargetNodeConnector();
        nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
    }
    process.checkStartNodes();
    process.checkProcess();
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) AbstractNode(org.talend.core.model.process.AbstractNode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractNode(org.talend.core.model.process.AbstractNode) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 5 with AbstractNode

use of org.talend.core.model.process.AbstractNode in project tdi-studio-se by Talend.

the class NodesSubTree method buildBigDataSubTree.

private void buildBigDataSubTree(INode node) {
    if (((AbstractNode) node).isThereLinkWithRef()) {
        this.isRefSubTree = true;
        List<INode> newRefNodes = ((AbstractNode) node).getRefNodes();
        if (newRefNodes != null) {
            if (refNodes == null) {
                refNodes = new ArrayList<INode>(newRefNodes);
            } else {
                refNodes.addAll(((AbstractNode) node).getRefNodes());
            }
            for (INode refNode : newRefNodes) {
                buildBigDataSubTree(refNode);
            }
        }
    }
    for (IConnection connection : node.getOutgoingSortedConnections()) {
        if (connection.getTarget().isActivate()) {
            if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.MAIN)) {
                if (!connection.getLineStyle().hasConnectionCategory(IConnectionCategory.USE_ITERATE)) {
                    allMainSubTreeConnections.add(connection);
                }
                buildBigDataSubTree(connection.getTarget());
            }
            if (connection.getLineStyle().equals(EConnectionType.RUN_AFTER)) {
                afterSubProcesses.add(connection.getTarget().getUniqueName());
            }
            if (connection.getLineStyle().equals(EConnectionType.ON_SUBJOB_OK)) {
                beforeSubProcesses.add(connection.getTarget().getUniqueName());
            }
        }
    }
    nodes.add(node);
}
Also used : INode(org.talend.core.model.process.INode) AbstractNode(org.talend.core.model.process.AbstractNode) IConnection(org.talend.core.model.process.IConnection)

Aggregations

AbstractNode (org.talend.core.model.process.AbstractNode)6 INode (org.talend.core.model.process.INode)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)4 IConnection (org.talend.core.model.process.IConnection)4 INodeConnector (org.talend.core.model.process.INodeConnector)4 Connection (org.talend.designer.core.ui.editor.connections.Connection)4 Process (org.talend.designer.core.ui.editor.process.Process)4 Node (org.talend.designer.core.ui.editor.nodes.Node)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)2 MultiKeyMap (org.apache.commons.collections.map.MultiKeyMap)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Shell (org.eclipse.swt.widgets.Shell)1 AlfrescoModelDialog (org.talend.designer.alfrescooutput.ui.AlfrescoModelDialog)1 AlfrescoOutputException (org.talend.designer.alfrescooutput.util.AlfrescoOutputException)1