Search in sources :

Example 26 with IConnection

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

the class SetParallelizationCommand method setDeparallelization.

private void setDeparallelization(INode node) {
    if (node.isActivate()) {
        for (IConnection con : node.getIncomingConnections()) {
            EConnectionType lineStyle = con.getLineStyle();
            if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
                con.getElementParameter(EParameterName.PARTITIONER.getName()).setValue(Boolean.FALSE);
                con.getElementParameter(EParameterName.REPARTITIONER.getName()).setValue(Boolean.FALSE);
                con.getElementParameter(EParameterName.NONE.getName()).setValue(Boolean.FALSE);
                con.setPropertyValue(EParameterName.DEPARTITIONER.getName(), Boolean.TRUE);
            }
        }
        if (node.getOutgoingConnections().size() > 0) {
            setParallelization(node);
        }
    }
}
Also used : IConnection(org.talend.core.model.process.IConnection) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 27 with IConnection

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

the class Connection method orderConnectionsByMetadata.

private void orderConnectionsByMetadata() {
    List<IMetadataTable> tableList = source.getMetadataList();
    List<IConnection> connectionList = (List<IConnection>) source.getOutgoingConnections();
    List<IConnection> tmpList = new ArrayList<IConnection>(connectionList);
    connectionList.clear();
    for (IMetadataTable table : tableList) {
        String tableName = table.getTableName();
        for (IConnection connection : tmpList) {
            if (connection.isActivate() && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && connection.getMetadataTable() != null && connection.getMetadataTable().getTableName() != null && connection.getMetadataTable().getTableName().equals(tableName) && connection.getConnectorName().equals(table.getAttachedConnector())) {
                connectionList.add(connection);
            }
        }
    }
    // add connections without metadata
    for (IConnection connection : tmpList) {
        if (!connectionList.contains(connection)) {
            connectionList.add(connection);
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IConnection(org.talend.core.model.process.IConnection)

Example 28 with IConnection

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

the class ConnectionPart method createFigure.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractConnectionEditPart#createFigure()
     */
@Override
protected IFigure createFigure() {
    IConnection conn = (IConnection) getModel();
    ConnectionFigure connection = new ConnectionFigure(conn, conn.getSourceNodeConnector().getConnectionProperty(conn.getLineStyle()), conn.getSource());
    if (DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.EDITOR_LINESTYLE)) {
        connection.setLineWidth(2);
        connection.setConnectionRouter(new TalendBorderItemRectilinearRouter());
    } else {
        connection.setLineWidth(1);
    }
    if (((Connection) getModel()).isActivate()) {
        connection.setAlpha(-1);
    } else {
        connection.setAlpha(Connection.ALPHA_VALUE);
    }
    if (PluginChecker.isAutoParalelPluginLoaded()) {
        connection.updateStatus();
    }
    return connection;
}
Also used : IConnection(org.talend.core.model.process.IConnection) IConnection(org.talend.core.model.process.IConnection)

Example 29 with IConnection

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

the class SetParallelizationCommand method isComponentNeedRepartion.

private boolean isComponentNeedRepartion(IConnection con, Node needToPar) {
    String partitioning = needToPar.getComponent().getPartitioning();
    if (partitioning.equals("AUTO")) {
        if (ParallelExecutionUtils.existPreviousPar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousDepar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousRepar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousNone((Node) con.getSource())) {
            return false;
        }
        return true;
    } else {
        // compare the target node's key with the previous tPartitioner's hashKeys to see if need repartitioning.
        boolean needRepar = false;
        IConnection previousParCon = ParallelExecutionUtils.getPreviousParCon((Node) con.getSource());
        if (previousParCon != null) {
            String[] partitionKey = partitioning.split("\\.");
            IElementParameter parTableCon = previousParCon.getElementParameter(HASH_KEYS);
            IElementParameter parTableNode = needToPar.getElementParameter(partitionKey[0]);
            if (parTableNode != null) {
                // for the partition key
                String clumnKeyListName = "KEY_COLUMN";
                String clumnNodeListName = partitionKey[1];
                List<String> parKeyValues = new ArrayList<String>();
                List<String> columnKeyValues = new ArrayList<String>();
                ElementParameter nodeElemForList = null;
                for (Map conColumnListMap : (List<Map>) parTableCon.getValue()) {
                    if (conColumnListMap.get(clumnKeyListName) instanceof String) {
                        parKeyValues.add((String) conColumnListMap.get(clumnKeyListName));
                    }
                }
                for (Object nodeItemList : parTableNode.getListItemsValue()) {
                    if (((ElementParameter) nodeItemList).getFieldType().equals(EParameterFieldType.PREV_COLUMN_LIST) || ((ElementParameter) nodeItemList).getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
                        nodeElemForList = (ElementParameter) nodeItemList;
                        break;
                    }
                }
                if (nodeElemForList != null) {
                    for (Map nodeColumnListMap : (List<Map>) parTableNode.getValue()) {
                        Object value = nodeColumnListMap.get(clumnNodeListName);
                        if (nodeColumnListMap.get(clumnNodeListName) instanceof String) {
                            columnKeyValues.add((String) value);
                        } else if (value instanceof Integer) {
                            Integer index = (Integer) value;
                            if (nodeElemForList.getListItemsDisplayName().length > index) {
                                columnKeyValues.add(nodeElemForList.getListItemsDisplayName()[index]);
                            }
                        }
                    }
                }
                if (columnKeyValues.size() > 0) {
                    if (columnKeyValues.equals(parKeyValues)) {
                        needRepar = false;
                    } else {
                        needRepar = true;
                    }
                }
            }
        }
        return needRepar;
    }
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 30 with IConnection

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

the class TableByRowController method updateSubjobStarts.

/**
     * DOC nrousseau Comment method "updateSubjobStarts".
     * 
     * @param param
     */
public static void updateSubjobStarts(IElement element, IElementParameter param) {
    if (!param.isBasedOnSubjobStarts() || !(element instanceof Node)) {
        return;
    }
    // Each time one link of the type SUBJOB_START_ORDER will be connected or disconnected
    // it will update the value of this table.
    List<String> uniqueNameStarts = new ArrayList<String>();
    Node node = (Node) element;
    List<IConnection> incomingSubjobStartsConn = (List<IConnection>) node.getIncomingConnections(EConnectionType.SYNCHRONIZE);
    for (IConnection connection : incomingSubjobStartsConn) {
        uniqueNameStarts.add(connection.getSource().getUniqueName());
    }
    List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
    List<Map<String, Object>> newParamValues = new ArrayList<Map<String, Object>>();
    String[] codes = param.getListItemsDisplayCodeName();
    for (String currentUniqueNameStart : uniqueNameStarts) {
        Map<String, Object> newLine = null;
        boolean found = false;
        for (int k = 0; k < paramValues.size() && !found; k++) {
            Map<String, Object> currentLine = paramValues.get(k);
            if (currentLine.get(codes[0]).equals(currentUniqueNameStart)) {
                found = true;
                newLine = currentLine;
            }
        }
        if (!found) {
            newLine = TableController.createNewLine(param);
            newLine.put(codes[0], currentUniqueNameStart);
        }
        newParamValues.add(newLine);
    }
    paramValues.clear();
    paramValues.addAll(newParamValues);
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Point(org.eclipse.swt.graphics.Point) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

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