Search in sources :

Example 81 with IConnection

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

the class PostgresGenerationManager method initExpression.

@Override
protected String initExpression(DbMapComponent component, ExternalDbMapEntry dbMapEntry) {
    String expression = super.initExpression(component, dbMapEntry);
    // String expression = dbMapEntry.getExpression();
    if (expression != null) {
        List<? extends IConnection> inputConnections = component.getIncomingConnections();
        ExternalDbMapData data = (ExternalDbMapData) component.getExternalData();
        if (inputConnections == null) {
            return expression;
        }
        for (ExternalDbMapTable input : data.getInputTables()) {
            ExternalDbMapTable inputTable = input;
            IConnection connection = null;
            for (IConnection iconn : inputConnections) {
                if (iconn.getName().equals(input.getTableName())) {
                    connection = iconn;
                    break;
                }
            }
            if (connection == null) {
                return expression;
            }
            INode source = connection.getSource();
            String schemaStr = "";
            String tableNameStr = "";
            if (source != null) {
                if (isELTDBMap(source)) {
                    tableNameStr = connection.getName();
                } else {
                    IElementParameter schema = source.getElementParameter("ELT_SCHEMA_NAME");
                    IElementParameter tableName = source.getElementParameter("ELT_TABLE_NAME");
                    if (schema != null && schema.getValue() != null) {
                        schemaStr = TalendTextUtils.removeQuotes(schema.getValue().toString());
                    }
                    if (tableName != null && tableName.getValue() != null) {
                        tableNameStr = TalendTextUtils.removeQuotes(tableName.getValue().toString());
                    }
                }
            }
            for (IMetadataColumn co : connection.getMetadataTable().getListColumns()) {
                String columnLabel = co.getOriginalDbColumnName();
                if (columnLabel == null || "".equals(columnLabel)) {
                    columnLabel = co.getLabel();
                }
                String[] patternSubs = getPattenSubs(schemaStr, tableNameStr, columnLabel);
                MapExpressionParser parser = new MapExpressionParser(patternSubs[0]);
                expression = parser.replaceLocation(expression, patternSubs[0], patternSubs[1]);
                if (inputTable.getAlias() != null && !"".equals(inputTable.getAlias())) {
                    patternSubs = getPattenSubs("", inputTable.getAlias(), columnLabel);
                    parser = new MapExpressionParser(patternSubs[0]);
                    expression = parser.replaceLocation(expression, patternSubs[0], patternSubs[1]);
                }
            }
        }
    }
    List<IMetadataTable> metadataList = component.getMetadataList();
    if (metadataList != null) {
        for (IMetadataTable table : metadataList) {
            String tableName = table.getLabel();
            for (IMetadataColumn column : table.getListColumns()) {
                String columnLabel = column.getOriginalDbColumnName();
                if (columnLabel == null || "".equals(columnLabel)) {
                    columnLabel = column.getLabel();
                }
                String[] patternSubs = getPattenSubs("", tableName, columnLabel);
                MapExpressionParser parser = new MapExpressionParser(patternSubs[0]);
                expression = parser.replaceLocation(expression, patternSubs[0], patternSubs[1]);
            }
        }
    }
    return expression;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) ExternalDbMapData(org.talend.designer.dbmap.external.data.ExternalDbMapData) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) MapExpressionParser(org.talend.designer.dbmap.language.generation.MapExpressionParser) IElementParameter(org.talend.core.model.process.IElementParameter) IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 82 with IConnection

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

the class HL7OutputLinkUI method createCombo.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.hl7.ui.HL7UI#createCombo(org.eclipse.swt.widgets.Composite)
     */
@Override
protected void createCombo(Composite mainComposite) {
    metaTableViewer = new ComboViewer(mainComposite, SWT.NONE | SWT.READ_ONLY);
    metaTableViewer.setContentProvider(new ArrayContentProvider());
    metaTableViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IConnection) {
                return ((IConnection) element).getUniqueName();
            }
            return super.getText(element);
        }
    });
    List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(externalNode, IConnectionCategory.FLOW);
    metaTableViewer.setInput(incomingConnections);
    final Combo combo = metaTableViewer.getCombo();
    combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    combo.select(0);
    combo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (hl7Manager != null) {
                ((HL7OutputManager) hl7Manager).setCurrentSchema(combo.getText());
            }
            IStructuredSelection selection = (IStructuredSelection) metaTableViewer.getSelection();
            Object obj = selection.getFirstElement();
            xmlViewer.refresh();
            xmlViewer.expandAll();
            schemaViewer.setInput(((IConnection) obj).getMetadataTable().getListColumns());
            initlinkers();
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IConnection(org.talend.core.model.process.IConnection) Combo(org.eclipse.swt.widgets.Combo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 83 with IConnection

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

the class HL7OutputUI method initSchemaTable.

protected void initSchemaTable() {
    if (externalNode.isHL7Output()) {
        // !externalNode.istWriteXMLField() && !externalNode.istMDMOutput()) {
        IMetadataTable metadataTable = null;
        List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(externalNode, IConnectionCategory.FLOW);
        if (incomingConnections.size() <= 0) {
            metadataTable = this.externalNode.getMetadataList().get(0);
        } else {
            metadataTable = incomingConnections.get(0).getMetadataTable();
        }
        if (metadataTable != null) {
            List<IMetadataColumn> columnList = metadataTable.getListColumns();
            schemaViewer.setInput(columnList);
        } else {
            schemaViewer.setInput(new ArrayList<IMetadataColumn>());
        }
    } else {
        IConnection inConn = null;
        for (IConnection conn : externalNode.getIncomingConnections()) {
            if ((conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) || (conn.getLineStyle().equals(EConnectionType.FLOW_REF))) {
                inConn = conn;
                break;
            }
        }
        if (inConn != null) {
            List<IMetadataColumn> columnList = inConn.getMetadataTable().getListColumns();
            schemaViewer.setInput(columnList);
        } else {
            schemaViewer.setInput(new ArrayList<IMetadataColumn>());
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 84 with IConnection

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

the class ParallelExecutionAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    boolean hasFlowConnection = false;
    for (IConnection connection : node.getOutgoingConnections()) {
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
            hasFlowConnection = true;
            break;
        }
    }
    if (hasFlowConnection) {
        MessageDialog.openError(getWorkbenchPart().getSite().getShell(), Messages.getString(//$NON-NLS-1$
        "ParallelExecutionAction.gotLink"), //$NON-NLS-1$
        Messages.getString("ParallelExecutionAction.noOutputLink"));
        return;
    }
    IElementParameter enableParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE.getName());
    if (enableParallelizeParameter != null) {
        parallelEnable = (Boolean) enableParallelizeParameter.getValue();
    }
    IElementParameter numberParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE_NUMBER.getName());
    if (numberParallelizeParameter != null) {
        numberParallel = (String) numberParallelizeParameter.getValue();
    }
    Dialog dialog = new ParallelDialog(getWorkbenchPart().getSite().getShell());
    if (dialog.open() == Dialog.OK) {
        Command command = new PropertyChangeCommand(node, EParameterName.PARALLELIZE.getName(), parallelEnable);
        execute(command);
    }
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Dialog(org.eclipse.jface.dialogs.Dialog) IElementParameter(org.talend.core.model.process.IElementParameter) IConnection(org.talend.core.model.process.IConnection)

Example 85 with IConnection

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

the class ModifyMergeOrderAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    super.run();
    MergeOrderDialog dialog = new MergeOrderDialog(this.getWorkbenchPart().getSite().getShell(), mergeComponent);
    if (dialog.open() == MergeOrderDialog.OK) {
        for (IConnection connection : mergeComponent.getIncomingConnections()) {
            if (connection.getSource().isStart() && (connection.getSource().getOutgoingConnections(EConnectionType.ON_SUBJOB_ERROR).size() != 0 || connection.getSource().getOutgoingConnections(EConnectionType.ON_SUBJOB_OK).size() != 0)) {
                //$NON-NLS-1$
                MessageDialog.openError(//$NON-NLS-1$
                new Shell(), //$NON-NLS-1$
                Messages.getString("ModifyMergeOrderAction.ERROE"), //$NON-NLS-1$
                Messages.getString("ModifyMergeOrderAction.ConnectionModifyError"));
                return;
            }
            if (connection.getSource().getIncomingConnections(EConnectionType.ON_SUBJOB_ERROR).size() != 0 || connection.getSource().getIncomingConnections(EConnectionType.ON_SUBJOB_OK).size() != 0) {
                //$NON-NLS-1$
                MessageDialog.openError(//$NON-NLS-1$
                new Shell(), //$NON-NLS-1$
                Messages.getString("ModifyMergeOrderAction.ERROE"), //$NON-NLS-1$
                Messages.getString("ModifyMergeOrderAction.ConnectionModifyError"));
                return;
            }
        }
        ChangeMergeOrderCommand cmd = new ChangeMergeOrderCommand(mergeComponent, dialog.getConnectionList());
        execute(cmd);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IConnection(org.talend.core.model.process.IConnection) ChangeMergeOrderCommand(org.talend.designer.core.ui.editor.cmd.ChangeMergeOrderCommand) MergeOrderDialog(org.talend.designer.core.ui.dialog.mergeorder.MergeOrderDialog)

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