Search in sources :

Example 71 with IConnection

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

the class NodesSubTree method buildCamelSubTree.

/**
     * Build the SubSubTrees..
     * 
     * @param nodes
     */
private void buildCamelSubTree(INode node, boolean breakWhenMerge) {
    if (DEBUG) {
        System.out.print(node.getUniqueName());
    }
    for (IConnection connection : node.getOutgoingCamelSortedConnections()) {
        if (connection.getTarget().isActivate()) {
            buildCamelSubTree(connection.getTarget(), breakWhenMerge);
        }
    }
    visitedNodesMainCode.put(node, 0);
    nodes.add(node);
}
Also used : IConnection(org.talend.core.model.process.IConnection)

Example 72 with IConnection

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

the class AlfrescoOutputManager method createUI.

/**
     * Checks the connections and creates the UI (a dialog actually)
     * 
     * @param parent
     * @return
     */
public AlfrescoModelDialog createUI(Composite parent) {
    IConnection inConn = null;
    AbstractNode connector = this.alfrescoOutputComponent;
    for (IConnection conn : connector.getIncomingConnections()) {
        if ((conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) || (conn.getLineStyle().equals(EConnectionType.FLOW_REF))) {
            inConn = conn;
            break;
        }
    }
    if (inConn != null) {
        if (!inConn.getMetadataTable().sameMetadataAs(connector.getMetadataList().get(0))) {
            MessageBox messageBox = new MessageBox(parent.getShell(), SWT.APPLICATION_MODAL | SWT.OK);
            //$NON-NLS-1$
            messageBox.setText(Messages.getString("AlfrescoOutputManager.schemaError.title"));
            //$NON-NLS-1$
            messageBox.setMessage(Messages.getString("AlfrescoOutputManager.schemaError.msg"));
            if (messageBox.open() == SWT.OK) {
                ((Shell) parent).close();
                return null;
            }
        }
    }
    // first load the model :
    try {
        // NB. or when modelManager is created
        modelManager.load();
    } catch (AlfrescoOutputException aoex) {
        MessageDialog.openError(new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL), Messages.getString("AlfrescoOutputManager.failedLoadModel"), //$NON-NLS-1$
        aoex.getMessage());
        modelManager.clear();
    }
    // then create and open the model dialog :
    AlfrescoModelDialog alfrescoModelDialog = new AlfrescoModelDialog(parent.getShell(), this);
    alfrescoModelDialog.open();
    // NB. this dialog is non-blocking ; model save is done in its okPressed()
    return alfrescoModelDialog;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) AbstractNode(org.talend.core.model.process.AbstractNode) AlfrescoModelDialog(org.talend.designer.alfrescooutput.ui.AlfrescoModelDialog) IConnection(org.talend.core.model.process.IConnection) AlfrescoOutputException(org.talend.designer.alfrescooutput.util.AlfrescoOutputException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 73 with IConnection

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

the class GenericElementParameter method updateSchema.

private void updateSchema() {
    IElement element = this.getElement();
    if (element instanceof Node) {
        Node node = (Node) element;
        List<INodeConnector> connectors = node.getConnectorsFromType(EConnectionType.FLOW_MAIN);
        for (INodeConnector connector : connectors) {
            if (connector instanceof GenericNodeConnector) {
                Connector componentConnector = ((GenericNodeConnector) connector).getComponentConnector();
                Schema schema = null;
                schema = getRootProperties().getSchema(componentConnector, ((GenericNodeConnector) connector).isOutput());
                IMetadataTable mainTable = node.getMetadataFromConnector(connector.getName());
                if (schema != null && mainTable != null) {
                    MetadataTable metadataTable = MetadataToolAvroHelper.convertFromAvro(schema);
                    IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
                    if (!mainTable.sameMetadataAs(newTable) || !newTable.sameMetadataAs(mainTable)) {
                        mainTable.setListColumns(newTable.getListColumns());
                        List<IElementParameter> schemaParameters = node.getElementParametersFromField(EParameterFieldType.SCHEMA_REFERENCE);
                        updateSchemaParameters(schemaParameters, connector.getName(), schema);
                        if (this.askPropagate == null && node.getOutgoingConnections().size() != 0) {
                            boolean hasPropagation = false;
                            for (IConnection connection : node.getOutgoingConnections()) {
                                if (connector.getName().equals(connection.getConnectorName())) {
                                    if (isSchemaPropagated(connection.getTarget())) {
                                        hasPropagation = true;
                                        break;
                                    }
                                }
                            }
                            if (hasPropagation) {
                                Display.getDefault().syncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        askPropagate = ChangeMetadataCommand.askPropagate();
                                    }
                                });
                            }
                        }
                        if (this.askPropagate != null && this.askPropagate) {
                            for (IConnection connection : node.getOutgoingConnections()) {
                                if (connector.getName().equals(connection.getConnectorName())) {
                                    INode target = connection.getTarget();
                                    if (!isSchemaPropagated(target)) {
                                        continue;
                                    }
                                    ChangeMetadataCommand cmd = new ChangeMetadataCommand(target, null, null, newTable, null);
                                    cmd.setPropagate(true);
                                    IProcess process = node.getProcess();
                                    if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
                                        CommandStack commandStack = ((org.talend.designer.core.ui.editor.process.Process) process).getCommandStack();
                                        commandStack.execute(cmd);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        this.askPropagate = null;
    }
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector) Connector(org.talend.components.api.component.Connector) CommandStack(org.eclipse.gef.commands.CommandStack) IElement(org.talend.core.model.process.IElement) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Schema(org.apache.avro.Schema) IConnection(org.talend.core.model.process.IConnection) IProcess(org.talend.core.model.process.IProcess) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess)

Example 74 with IConnection

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

the class CreateComponentOnLinkHelper method setupTMap.

public static void setupTMap(Node node) {
    if (!GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
        return;
    }
    IConnection inputConnection = node.getIncomingConnections().get(0);
    IConnection outputConnection = node.getOutgoingConnections().get(0);
    if (outputConnection.getMetadataTable() != null && inputConnection.getMetadataTable() != null) {
        outputConnection.getMetadataTable().setListColumns(inputConnection.getMetadataTable().clone(false).getListColumns());
        ((Process) node.getProcess()).checkProcess();
    }
    if ("tMap".equals(node.getComponent().getName())) {
        IDesignerMapperService service = (IDesignerMapperService) GlobalServiceRegister.getDefault().getService(IDesignerMapperService.class);
        service.createAutoMappedNode(node, inputConnection, outputConnection);
    }
}
Also used : IDesignerMapperService(org.talend.core.service.IDesignerMapperService) IConnection(org.talend.core.model.process.IConnection)

Example 75 with IConnection

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

the class UpdateNodeParameterCommand method syncSchemaForTMap.

private void syncSchemaForTMap(Node node) {
    for (IConnection conn : node.getOutgoingConnections()) {
        if (conn.getLineStyle() == EConnectionType.FLOW_MAIN) {
            IMetadataTable metadataTable = null;
            for (IMetadataTable table : node.getMetadataList()) {
                if (table.getTableName() != null && table.getTableName().equals(conn.getMetadataTable().getTableName())) {
                    metadataTable = table;
                }
            }
            if (metadataTable != null) {
                Node target = (Node) conn.getTarget();
                IElementParameter schemaTypeParam = target.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
                if (schemaTypeParam == null) {
                    schemaTypeParam = target.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
                }
                if (schemaTypeParam != null) {
                    ChangeMetadataCommand cmd = new ChangeMetadataCommand(target, schemaTypeParam, null, metadataTable);
                    cmd.setRepositoryMode(true);
                    cmd.execute(true);
                }
            }
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) IElementParameter(org.talend.core.model.process.IElementParameter) IConnection(org.talend.core.model.process.IConnection)

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