Search in sources :

Example 96 with IConnection

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

the class ConnectionManager method getAllSourceNode.

/**
     * DOC bqian Comment method "getAllSourceNode".
     * 
     * @param source
     * @param list
     */
private static void getAllSourceNode(INode source, List<INode> list) {
    List<? extends IConnection> connections = source.getIncomingConnections();
    for (IConnection connection : connections) {
        INode node = connection.getSource();
        list.add(node);
        getAllSourceNode(node, list);
    }
}
Also used : INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection)

Example 97 with IConnection

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

the class ConnectionManager method countNbMergeOutgoing.

private static int countNbMergeOutgoing(INode node, Set<INode> checkedNode) {
    int curNb = 0;
    if (checkedNode.contains(node)) {
        return 0;
    }
    checkedNode.add(node);
    if (node.getComponent().useMerge()) {
        // if the component use merge even if there is no connection, then add one merge.
        curNb++;
    }
    for (IConnection curConnec : node.getOutgoingConnections()) {
        if (curConnec.getLineStyle().equals(EConnectionType.FLOW_MERGE)) {
            curNb++;
        } else if (curConnec.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
            // if main, then test the next component to check if there is a merge
            curNb += countNbMergeOutgoing(curConnec.getTarget(), checkedNode);
        }
    }
    return curNb;
}
Also used : IConnection(org.talend.core.model.process.IConnection)

Example 98 with IConnection

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

the class ConnectionManager method canConnectToTarget.

public static boolean canConnectToTarget(INode source, INode oldTarget, INode newTarget, EConnectionType lineStyle, String connectorName, String connectionName, boolean refactorJoblet) {
    newlineStyle = lineStyle;
    if (source.equals(newTarget)) {
        return false;
    }
    if (PluginChecker.isJobLetPluginLoaded()) {
        IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null) {
            if (service.isTriggerNode(newTarget) && !service.canConnectTriggerNode(newTarget, lineStyle)) {
                return false;
            }
            // can't connect from joblet's node, bug 21411
            if (service.isJobletComponent(source.getJobletNode())) {
                return false;
            }
        }
    }
    INode processStartNode = source.getProcessStartNode(true);
    // if the target is the start of the (source) process, then can't connect.
    if (processStartNode.equals(newTarget)) {
        return false;
    }
    // to avoid different db elt input link to map.
    if (newTarget.isELTComponent() && newTarget.getComponent().getName().endsWith("Map")) {
        //$NON-NLS-1$
        String targetName = newTarget.getComponent().getOriginalFamilyName();
        String sourceName = processStartNode.getComponent().getOriginalFamilyName();
        if (!targetName.equals(sourceName) && !(lineStyle.hasConnectionCategory(IConnectionCategory.DEPENDENCY))) {
            return false;
        }
    }
    // fix bug 0004935: Error on job save
    if (checkCircle(source, newTarget)) {
        return false;
    }
    if (newTarget.isFileScaleComponent()) {
        if (newlineStyle.hasConnectionCategory(IConnectionCategory.FLOW) && !connectorName.equals("FSCOMBINE")) {
            //$NON-NLS-1$
            return false;
        }
    }
    // Modify Connection Type depending old and new target.
    if (newlineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
        // if the connection type is not the default one, then we don't change automatically.
        // && newlineStyle.getName().equals(newConnectionType)) {
        newlineStyle = EConnectionType.FLOW_MAIN;
        if (newTarget.getComponent().useLookup()) {
            int nbMain = 0;
            for (IConnection connec : newTarget.getIncomingConnections()) {
                if (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
                    nbMain++;
                }
            }
            if (nbMain >= 1) {
                newlineStyle = EConnectionType.FLOW_REF;
            } else {
                newlineStyle = EConnectionType.FLOW_MAIN;
            }
        } else if (newTarget.getComponent().useMerge()) {
            newlineStyle = EConnectionType.FLOW_MERGE;
        }
    }
    boolean isJoblet = false;
    if (PluginChecker.isJobLetPluginLoaded()) {
        IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null && service.isJobletComponent(newTarget) && !lineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
            List<INodeConnector> inputConnector = service.getFreeTriggerBuiltConnectors(newTarget, lineStyle, true);
            if (inputConnector.isEmpty()) {
                return false;
            }
            isJoblet = true;
        }
    }
    if (!isJoblet) {
        INodeConnector connectorFromType = newTarget.getConnectorFromType(newlineStyle);
        int maxInput = connectorFromType.getMaxLinkInput();
        if (maxInput != -1 && (connectorFromType.getCurLinkNbInput() >= maxInput)) {
            return false;
        }
    }
    if (!canConnect(source, newTarget, lineStyle, connectionName, refactorJoblet)) {
        return false;
    }
    return true;
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 99 with IConnection

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

the class ConnectionManager method testIfNoStartAfterAddConnection.

private static boolean testIfNoStartAfterAddConnection(Node source, Node target) {
    // connection is added only to test if there is still a start
    // it will be removed after the test
    INode targetStartNode = target.getProcessStartNode(true);
    INode sourceStartNode = source.getProcessStartNode(true);
    Connection connection = new Connection(source, target, newlineStyle, false);
    ((List<IConnection>) source.getOutgoingConnections()).add(connection);
    ((List<IConnection>) target.getIncomingConnections()).add(connection);
    boolean noStart = (!((Node) sourceStartNode).checkIfCanBeStart()) && ((targetStartNode == null) || (!((Node) targetStartNode).checkIfCanBeStart()));
    ((List<IConnection>) source.getOutgoingConnections()).remove(connection);
    ((List<IConnection>) target.getIncomingConnections()).remove(connection);
    return noStart;
}
Also used : 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) List(java.util.List)

Example 100 with IConnection

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

the class SetParallelizationCommand method setParallelization.

private void setParallelization(INode node) {
    if (node.isActivate()) {
        if (node.getOutgoingConnections().size() > 0) {
            for (IConnection con : node.getOutgoingConnections()) {
                EConnectionType lineStyle = con.getLineStyle();
                if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
                    if (!lineStyle.equals(EConnectionType.FLOW_MERGE)) {
                        boolean isEndRow = con.getTarget().getOutgoingConnections().size() == 0;
                        boolean isStartRow = node.isStart();
                        if (ParallelExecutionUtils.isPartitionKeysExist(con)) {
                            ParallelExecutionUtils.reSetParKeyValuesForCon(con);
                        }
                        if (!isEndRow && isComponentCanParlization(con, (Node) con.getTarget())) {
                            // tPartitioner,need do Repartitioner automatic
                            if (isExistParalInSubjob(existParallelMap, node) && !isStartRow && isComponentNeedRepartion(con, (Node) con.getTarget())) {
                                setRepartioner(con);
                            } else {
                                // when pervious con is par/repar/none,keep current is none
                                if (isExistParalInSubjob(existParallelMap, node) && (ParallelExecutionUtils.existPreviousPar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousNone((Node) con.getSource()) || ParallelExecutionUtils.existPreviousRepar((Node) con.getSource()))) {
                                    setNone(con);
                                } else {
                                    setPartioner(con, lineStyle, isStartRow);
                                }
                            }
                        } else {
                            if (!con.getSource().isStart()) {
                                setDepartioner(con);
                            }
                        }
                    } else {
                        setParallelization(con.getTarget());
                    }
                } else {
                    // in case the con here is not data flow,such as onSubjobOk,we skip to next target
                    setParallelization(con.getTarget());
                }
            }
        } else {
            if (!node.isStart()) {
                setDeparallelization(node);
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) EConnectionType(org.talend.core.model.process.EConnectionType)

Aggregations

IConnection (org.talend.core.model.process.IConnection)149 ArrayList (java.util.ArrayList)79 INode (org.talend.core.model.process.INode)63 List (java.util.List)60 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)57 Node (org.talend.designer.core.ui.editor.nodes.Node)47 HashMap (java.util.HashMap)36 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)33 IElementParameter (org.talend.core.model.process.IElementParameter)31 Map (java.util.Map)25 Connection (org.talend.designer.core.ui.editor.connections.Connection)25 INodeConnector (org.talend.core.model.process.INodeConnector)24 Point (org.eclipse.swt.graphics.Point)13 Process (org.talend.designer.core.ui.editor.process.Process)13 IJobletProviderService (org.talend.core.ui.IJobletProviderService)12 HashSet (java.util.HashSet)11 MetadataTable (org.talend.core.model.metadata.MetadataTable)10 IProcess (org.talend.core.model.process.IProcess)10 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)9 IExternalNode (org.talend.core.model.process.IExternalNode)8