Search in sources :

Example 6 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class ExternalNodeChangeCommand method init.

private void init() {
    connectionsToDelete = new HashMap<Connection, IODataComponent>();
    for (IODataComponent dataComponent : inAndOut.getOuputs()) {
        IConnection connection = dataComponent.getConnection();
        boolean metadataExists = false;
        for (IMetadataTable metadata : newMetaDataList) {
            if (connection.getMetadataTable().getTableName().equals(metadata.getTableName())) {
                metadataExists = true;
            }
        }
        if (!metadataExists && (connection instanceof Connection)) {
            connectionsToDelete.put((Connection) connection, dataComponent);
        }
    }
    for (Connection connection : (List<Connection>) node.getIncomingConnections()) {
        String schemaType = (String) connection.getSource().getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
        if (schemaType != null) {
            if (schemaType.equals(EmfComponent.REPOSITORY)) {
                String metaRepositoryName = (String) connection.getSource().getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
                IMetadataTable repositoryMetadata = MetadataToolHelper.getMetadataFromRepository(metaRepositoryName);
                if (repositoryMetadata == null) {
                    connection.getSource().setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
                } else {
                    repositoryMetadata = repositoryMetadata.clone();
                    repositoryMetadata.setTableName(connection.getSource().getUniqueName());
                    ((org.talend.core.model.metadata.MetadataTable) repositoryMetadata).setRepository(true);
                    if (!repositoryMetadata.sameMetadataAs(connection.getMetadataTable(), IMetadataColumn.OPTIONS_IGNORE_USED)) {
                        connection.getSource().setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
                    }
                }
            }
        }
    }
    //$NON-NLS-1$
    setLabel(Messages.getString("ExternalNodeChangeCommand.modifaicationFrom") + node.getUniqueName());
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IConnection(org.talend.core.model.process.IConnection) ArrayList(java.util.ArrayList) List(java.util.List) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 7 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class ExternalNodeChangeCommand method execute.

@Override
public void execute() {
    propagateInput();
    // bug 0020749
    if (!oldMetaDataList.isEmpty() && !newMetaDataList.isEmpty() && !oldMetaDataList.get(0).sameMetadataAs(newMetaDataList.get(0))) {
        node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
    }
    metadataOutputChanges.clear();
    List<IConnection> initTraceList = new ArrayList<IConnection>();
    for (IConnection connection : node.getOutgoingConnections()) {
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            IODataComponent dataComponent = inAndOut.getDataComponent(connection);
            boolean sameMetadataAs = connection.getMetadataTable().sameMetadataAs(dataComponent.getTable());
            IMetadataTable tempTable = null;
            boolean isSchemaAutoPropagated = true;
            if (connection.getTarget().getComponent() instanceof EmfComponent) {
                EmfComponent component = (EmfComponent) connection.getTarget().getComponent();
                isSchemaAutoPropagated = component.isSchemaAutoPropagated();
            }
            if (sameMetadataAs || !isSchemaAutoPropagated) {
                for (IMetadataTable itable : newMetaDataList) {
                    if (connection.getMetadataTable().getTableName().equals(itable.getTableName())) {
                        sameMetadataAs = connection.getMetadataTable().sameMetadataAs(itable);
                        tempTable = itable;
                        break;
                    }
                }
            } else {
                IMetadataTable table = connection.getMetadataTable();
                if (table == null || table.getListColumns().isEmpty()) {
                    initTraceList.add(connection);
                }
                INode connTar = connection.getTarget();
                boolean isAllowedPropagated = connTar.getComponent().isAllowedPropagated();
                boolean openDialog = false;
                Map<String, Boolean> jobletMap = new HashMap<String, Boolean>();
                if (isForTemlate()) {
                    openDialog = true;
                } else if (!isAllowedPropagated) {
                    openDialog = false;
                } else {
                    openDialog = getPropagate(connection, jobletMap);
                }
                if (openDialog) {
                    IElementParameter schemaParam = null;
                    if (connection != null) {
                        IMetadataTable connTable = connection.getMetadataTable();
                        IMetadataTable dataTable = dataComponent.getTable();
                        if (tempTable != null) {
                            dataTable = tempTable;
                        }
                        for (IElementParameter param : ((Node) connection.getTarget()).getElementParameters()) {
                            if (EParameterFieldType.SCHEMA_TYPE.equals(param.getFieldType()) || EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
                                INodeConnector connector = connection.getTarget().getConnectorFromName(connection.getConnectorName());
                                if (connector != null && param.getContext().equals(connector.getBaseSchema())) {
                                    schemaParam = param;
                                    break;
                                }
                            }
                        }
                        if (schemaParam != null) {
                            ChangeMetadataCommand cmd = new ChangeMetadataCommand(connection.getTarget(), schemaParam, connTable, dataTable);
                            cmd.execute(true);
                            metadataOutputChanges.add(cmd);
                        }
                        for (IElementParameter param : ((Node) connection.getSource()).getElementParameters()) {
                            if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) && param.getContext().equals(connection.getSource().getConnectorFromName(connection.getConnectorName()).getBaseSchema())) {
                                schemaParam = param;
                                break;
                            }
                        }
                        if (schemaParam != null) {
                            ChangeMetadataCommand cmd = new ChangeMetadataCommand(connection.getSource(), schemaParam, connTable, dataTable);
                            cmd.execute(true);
                            metadataOutputChanges.add(cmd);
                        }
                        if (((Node) connTar).isJoblet()) {
                            IElementParameter param = connTar.getElementParameter(connection.getTarget().getUniqueName());
                            if (param != null) {
                                IMetadataTable originaleOutputTable = connTar.getMetadataFromConnector(param.getContext());
                                if (originaleOutputTable != null) {
                                    MetadataToolHelper.copyTable(dataTable, originaleOutputTable);
                                }
                            }
                        } else if (((Node) connTar).getJobletNode() != null) {
                            IElementParameter param = ((Node) connTar).getJobletNode().getElementParameter(connection.getTarget().getUniqueName());
                            if (param != null) {
                                IMetadataTable originaleOutputTable = ((Node) connTar).getJobletNode().getMetadataFromConnector(param.getContext());
                                if (originaleOutputTable != null) {
                                    MetadataToolHelper.copyTable(dataTable, originaleOutputTable);
                                }
                            }
                        }
                    }
                    if (((Node) connTar).isJoblet()) {
                        changeCollapsedState(true, jobletMap, connTar);
                    }
                } else {
                    // no matter propagate or not the metadata change will be propagate to xmlmap emf data
                    final Node target = (Node) connection.getTarget();
                    if (target != null && target.getExternalNode() != null) {
                        if (GlobalServiceRegister.getDefault().isServiceRegistered(IXmlMapService.class)) {
                            final IXmlMapService service = (IXmlMapService) GlobalServiceRegister.getDefault().getService(IXmlMapService.class);
                            if (service.isXmlMapComponent(target.getExternalNode())) {
                                IODataComponent output = new IODataComponent(connection, dataComponent.getTable());
                                target.metadataInputChanged(output, connection.getUniqueName());
                            }
                        }
                        if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkMapService.class)) {
                            final ISparkMapService service = (ISparkMapService) GlobalServiceRegister.getDefault().getService(ISparkMapService.class);
                            if (service.isSparkMapComponent(target.getExternalNode())) {
                                IODataComponent output = new IODataComponent(connection, dataComponent.getTable());
                                target.metadataInputChanged(output, connection.getUniqueName());
                            }
                        }
                        if (GlobalServiceRegister.getDefault().isServiceRegistered(IDQComponentService.class)) {
                            final IDQComponentService service = (IDQComponentService) GlobalServiceRegister.getDefault().getService(IDQComponentService.class);
                            service.externalComponentChange(connection, dataComponent.getTable());
                        }
                    }
                }
            }
            if (connection instanceof Connection) {
                ((Connection) connection).updateName();
            }
        }
    }
    node.setExternalData(newExternalData);
    /*
         * It's better to clone, because will change that, if apply, bug 13325
         */
    // node.setExternalData(newExternalData.clone()); //should test later.
    List<IMetadataTable> cloneNewMetadata = new ArrayList<IMetadataTable>();
    if (newMetaDataList != null) {
        for (IMetadataTable t : newMetaDataList) {
            cloneNewMetadata.add(t.clone(true));
        }
    }
    node.setMetadataList(cloneNewMetadata);
    // init trace
    for (IConnection conn : initTraceList) {
        if (conn instanceof Connection) {
            ((Connection) conn).initTraceParamters();
        }
    }
    for (Connection connection : connectionsToDelete.keySet()) {
        connection.disconnect();
        INode prevNode = connection.getSource();
        INodeConnector nodeConnectorSource, nodeConnectorTarget;
        nodeConnectorSource = prevNode.getConnectorFromType(connection.getLineStyle());
        nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
        INode nextNode = connection.getTarget();
        nodeConnectorTarget = nextNode.getConnectorFromType(connection.getLineStyle());
        nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
        inAndOut.getOuputs().remove(connectionsToDelete.get(connection));
        ((Process) node.getProcess()).checkStartNodes();
    }
    ((Process) node.getProcess()).checkProcess();
    if (!isMetaLanguage) {
        refreshCodeView();
        ComponentSettings.switchToCurComponentSettingsView();
    }
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) Process(org.talend.designer.core.ui.editor.process.Process) IXmlMapService(org.talend.core.service.IXmlMapService) ISparkMapService(org.talend.core.service.ISparkMapService) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IDQComponentService(org.talend.core.service.IDQComponentService) IElementParameter(org.talend.core.model.process.IElementParameter) EmfComponent(org.talend.designer.core.model.components.EmfComponent) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 8 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class EntryContentProposal method getDescription.

@Override
public String getDescription() {
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    String separator = " - ";
    if (entry instanceof TreeNode) {
        TreeNode inputEntry = (TreeNode) entry;
        IMetadataColumn metadataColumn = null;
        if (inputEntry.eContainer() instanceof InputXmlTree) {
            InputXmlTree tree = (InputXmlTree) inputEntry.eContainer();
            List<IODataComponent> inputs = mapperManager.getMapperComponent().getIODataComponents().getInputs();
            IMetadataTable table = null;
            for (int i = 0; i < inputs.size(); i++) {
                IODataComponent ioDataComponent = inputs.get(i);
                if (tree.getName() != null && tree.getName().equals(ioDataComponent.getConnection().getName())) {
                    table = ioDataComponent.getTable();
                    break;
                }
            }
            if (table != null && table.getListColumns() != null) {
                for (IMetadataColumn column : table.getListColumns()) {
                    if (inputEntry.getName().equals(column.getLabel())) {
                        metadataColumn = column;
                    }
                }
            }
        }
        //$NON-NLS-1$ //$NON-NLS-2$
        sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(inputEntry.getName()).append(//$NON-NLS-1$
        "' ");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        sb.append(Messages.getString("EntryContentProposal.properties"));
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(inputEntry.getName());
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(inputEntry.isKey());
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(format(inputEntry.getType()));
        if (metadataColumn != null) {
            sb.append(CARRIAGE_RETURN);
            //$NON-NLS-1$
            sb.append(separator).append(Messages.getString("EntryContentProposal.length"));
            if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) {
                sb.append(format(metadataColumn.getLength()));
            }
            sb.append(CARRIAGE_RETURN);
            //$NON-NLS-1$
            sb.append(separator).append(Messages.getString("EntryContentProposal.precision"));
            if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) {
                sb.append(format(metadataColumn.getPrecision()));
            }
            sb.append(CARRIAGE_RETURN);
            sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
            format(metadataColumn.getDefault()));
            sb.append(CARRIAGE_RETURN);
            sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
            format(metadataColumn.getComment()));
        }
        sb.append(CARRIAGE_RETURN);
        if (inputEntry.eContainer() instanceof TreeNode) {
            //$NON-NLS-1$
            sb.append(separator).append(Messages.getString("EntryContentProposal.xPath")).append(inputEntry.getXpath());
            sb.append(CARRIAGE_RETURN);
        }
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
        sb.append(CARRIAGE_RETURN);
    } else if (entry instanceof VarNode) {
        //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
        sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
    }
    return sb.toString();
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 9 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class ChangeMetadataCommand method propagateDatas.

private void propagateDatas(boolean isExecute) {
    // update currentConnector when flow main type
    if (schemaParam != null && (schemaParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || schemaParam.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) && EConnectionType.FLOW_MAIN.getDefaultMenuName().toUpperCase().equals(schemaParam.getContext())) {
        currentConnector = EConnectionType.FLOW_MAIN.getName();
    }
    String baseConnectorForCurrentNode = node.getConnectorFromName(currentConnector).getBaseSchema();
    // Propagate :
    if (outputdataContainer != null && (!outputdataContainer.getInputs().isEmpty() || !outputdataContainer.getOuputs().isEmpty())) {
        for (IODataComponent currentIO : outputdataContainer.getInputs()) {
            INode sourceNode = currentIO.getSource();
            if (currentIO.hasChanged() && (sourceNode.getConnectorFromName(currentIO.getConnection().getConnectorName()).getBaseSchema().equals(baseConnectorForCurrentNode))) {
                sourceNode.metadataOutputChanged(currentIO, currentIO.getName());
                if (isExecute) {
                    currentIO.setTable(oldInputMetadata);
                    currentIO.setColumnNameChanged(null);
                } else {
                    currentIO.setTable(newInputMetadata);
                    currentIO.setColumnNameChanged(null);
                }
            }
        }
        for (IODataComponent currentIO : outputdataContainer.getOuputs()) {
            INodeConnector nodeConnector = null;
            String baseConnector = null;
            Node sourceNode = (Node) currentIO.getSource();
            nodeConnector = sourceNode.getConnectorFromName(currentIO.getConnection().getConnectorName());
            baseConnector = nodeConnector.getBaseSchema();
            INode targetNode = currentIO.getTarget();
            boolean sourceIsBuiltIn = ((Node) currentIO.getSource()).getConnectorFromType(currentIO.getConnection().getLineStyle()).isMultiSchema();
            boolean targetIsBuiltIn = ((Node) targetNode).getConnectorFromType(currentIO.getConnection().getLineStyle()).isMultiSchema();
            boolean isJoblet = ((Node) targetNode).isJoblet();
            if (!isJoblet && baseConnector.equals(baseConnectorForCurrentNode) && (targetIsBuiltIn || (targetNode.getMetadataFromConnector(baseConnector) != null && !targetNode.getMetadataFromConnector(baseConnector).sameMetadataAs(newOutputMetadata)))) {
                targetNode.metadataInputChanged(currentIO, currentIO.getUniqueName());
                if (isExecute) {
                    if (targetNode instanceof Node) {
                        if (((Node) targetNode).getComponent().isSchemaAutoPropagated() && getPropagate() && targetNode.getMetadataList().size() > 0) {
                            IMetadataTable tmpClone;
                            if (sourceIsBuiltIn) {
                                IMetadataTable tab = node.getMetadataTable(currentIO.getConnection().getMetadataTable().getTableName());
                                if (tab == null && node.getJobletNode() != null) {
                                    tab = node.getJobletNode().getMetadataTable(currentIO.getConnection().getMetadataTable().getTableName());
                                }
                                tmpClone = tab.clone(true);
                            } else {
                                IMetadataTable tab = node.getMetadataFromConnector(currentIO.getConnection().getConnectorName());
                                if (tab == null && node.getJobletNode() != null) {
                                    tab = node.getJobletNode().getMetadataFromConnector(currentIO.getConnection().getConnectorName());
                                }
                                tmpClone = tab.clone(true);
                            }
                            IMetadataTable toCopy = newOutputMetadata.clone();
                            // wzhang modify to add feature 7611
                            String dbmsId = null;
                            IMetadataTable copy;
                            if (((Node) targetNode).getMetadataFromConnector(baseConnector) != null) {
                                dbmsId = targetNode.getMetadataFromConnector(baseConnector).getDbms();
                                MetadataToolHelper.copyTable(dbmsId, toCopy, tmpClone);
                                toCopy = tmpClone;
                                // only if the target node have exactly the same connector
                                copy = ((Node) targetNode).getMetadataFromConnector(baseConnector).clone(true);
                            } else {
                                // can only be FLOW right now for this case. //$NON-NLS-1$
                                final String mainConnector = "FLOW";
                                dbmsId = targetNode.getMetadataFromConnector(mainConnector).getDbms();
                                MetadataToolHelper.copyTable(dbmsId, toCopy, tmpClone);
                                toCopy = tmpClone;
                                // if don't have the same connector, take the main connector of the component.
                                copy = ((Node) targetNode).getMetadataFromConnector(mainConnector).clone(true);
                            }
                            // MetadataTool.copyTable(toCopy, copy);
                            // wzhang modify to add feature 7611
                            MetadataToolHelper.copyTable(dbmsId, toCopy, copy);
                            ChangeMetadataCommand cmd = new ChangeMetadataCommand(targetNode, null, null, copy, inputSchemaParam);
                            if (outputdataContainer.getOuputs().size() > 0) {
                                List<ColumnNameChanged> columnNameChanged = outputdataContainer.getOuputs().get(0).getColumnNameChanged();
                                for (IODataComponent dataComp : cmd.outputdataContainer.getOuputs()) {
                                    dataComp.setColumnNameChanged(columnNameChanged);
                                }
                            }
                            cmd.setRepositoryMode(repositoryMode);
                            cmd.execute(true);
                            propagatedChange.add(cmd);
                        }
                    }
                    currentIO.setTable(oldOutputMetadata);
                    currentIO.setColumnNameChanged(null);
                } else {
                    if (targetNode instanceof Node) {
                        if (!targetIsBuiltIn && getPropagate()) {
                            if (((Node) targetNode).getComponent().isSchemaAutoPropagated()) {
                                if (outputdataContainer.getOuputs().size() > 0) {
                                    List<ColumnNameChanged> columnNameChanged = outputdataContainer.getOuputs().get(0).getColumnNameChanged();
                                    for (ChangeMetadataCommand cmd : propagatedChange) {
                                        for (IODataComponent dataComp : cmd.outputdataContainer.getOuputs()) {
                                            dataComp.setColumnNameChanged(columnNameChanged);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    currentIO.setTable(newOutputMetadata);
                    currentIO.setColumnNameChanged(null);
                }
            }
        }
    } else if (dataComponent != null) {
        for (IConnection outgoingConnection : node.getOutgoingConnections()) {
            if (outgoingConnection.getConnectorName().equals(currentConnector)) {
                outgoingConnection.getTarget().metadataInputChanged(dataComponent, outgoingConnection.getName());
            }
        }
    } else {
        if (!node.getOutgoingConnections().isEmpty()) {
            IMetadataTable relativeOldOutputMetadata = null;
            IMetadataTable relativeNewOutputMetadata = null;
            if (isExecute) {
                relativeOldOutputMetadata = oldOutputMetadata;
                relativeNewOutputMetadata = newOutputMetadata;
            } else {
                relativeOldOutputMetadata = newOutputMetadata;
                relativeNewOutputMetadata = oldOutputMetadata;
            }
            for (IConnection outgoingConnection : node.getOutgoingConnections()) {
                if (!outgoingConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
                    continue;
                }
                final Node target = (Node) outgoingConnection.getTarget();
                if (target != null && target.getExternalNode() != null) {
                    List<IMetadataColumn> oldListColumns = relativeOldOutputMetadata.getListColumns();
                    List<IMetadataColumn> newListColumns = relativeNewOutputMetadata.getListColumns();
                    List<ColumnNameChanged> columnNameChanges = new ArrayList<ColumnNameChanged>();
                    int size = oldListColumns.size();
                    int newSize = newListColumns.size();
                    if (newSize < size) {
                        size = newSize;
                    }
                    IODataComponent output = new IODataComponent(outgoingConnection, relativeNewOutputMetadata);
                    if (newListColumns != null) {
                        List<ColumnNameChanged> newColumnsList = output.getNewMetadataColumns();
                        // new added columns list
                        Set<String> newAddedColumns = new HashSet<String>();
                        // newest columns after user changed
                        Set<String> newestColumns = new HashSet<String>();
                        // init
                        if (newColumnsList != null) {
                            for (ColumnNameChanged columnChanged : newColumnsList) {
                                newAddedColumns.add(columnChanged.getNewName());
                            }
                        }
                        for (IMetadataColumn metadataColumn : newListColumns) {
                            newestColumns.add(metadataColumn.getLabel());
                        }
                        // check
                        for (int i = 0; i < size; i++) {
                            IMetadataColumn oldMetadataColumn = oldListColumns.get(i);
                            String columnName = oldMetadataColumn.getLabel();
                            // been removed
                            if (!newestColumns.contains(columnName)) {
                                IMetadataColumn newMetadataColumn = newListColumns.get(i);
                                String newColumnNameAtThisIndex = newMetadataColumn.getLabel();
                                // column, so we suppose the more possible truth is that it is a renamed column
                                if (newAddedColumns.contains(newColumnNameAtThisIndex)) {
                                    columnNameChanges.add(new ColumnNameChanged(columnName, newColumnNameAtThisIndex));
                                }
                            }
                        }
                    }
                    output.setColumnNameChanged(columnNameChanges);
                    target.metadataInputChanged(output, outgoingConnection.getName());
                }
            }
        }
    }
    if (inputdataContainer != null) {
        for (IODataComponent currentIO : inputdataContainer.getOuputs()) {
            if (currentIO.hasChanged() && (currentIO.getSource().getConnectorFromName(currentIO.getConnection().getConnectorName()).getBaseSchema().equals(currentConnector))) {
                INode targetNode = currentIO.getTarget();
                targetNode.metadataInputChanged(currentIO, currentIO.getUniqueName());
                if (isExecute) {
                    currentIO.setTable(oldInputMetadata);
                    currentIO.setColumnNameChanged(null);
                } else {
                    currentIO.setTable(newInputMetadata);
                    currentIO.setColumnNameChanged(null);
                }
            }
        }
    }
// End propagate
}
Also used : INode(org.talend.core.model.process.INode) HashSet(java.util.HashSet) Set(java.util.Set) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) ArrayList(java.util.ArrayList) List(java.util.List) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 10 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class ChangeValuesFromRepository method getRealSourceNode.

@SuppressWarnings("unchecked")
protected Node getRealSourceNode(INode target) {
    Node sourceNode = null;
    IODataComponent input = null;
    List<org.talend.designer.core.ui.editor.connections.Connection> incomingConnections = null;
    incomingConnections = (List<org.talend.designer.core.ui.editor.connections.Connection>) target.getIncomingConnections();
    for (org.talend.designer.core.ui.editor.connections.Connection connec : incomingConnections) {
        if (connec.isActivate() && connec.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            input = new IODataComponent(connec);
        }
    }
    if (input != null) {
        INode source = input.getSource();
        if (source instanceof Node) {
            sourceNode = (Node) source;
        // final IExternalNode externalNode =
        // sourceNode.getExternalNode();
        // if (sourceNode.getPluginFullName() != null &&
        // !"".equals(sourceNode.getPluginFullName())
        // && sourceNode.getExternalNode() != null) {
        // return getRealSourceNode(externalNode);
        // }
        }
    }
    return sourceNode;
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) WSDLSchemaConnection(org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection) SAPConnection(org.talend.core.model.metadata.builder.connection.SAPConnection) FTPConnection(org.talend.core.model.metadata.builder.connection.FTPConnection) HL7Connection(org.talend.core.model.metadata.builder.connection.HL7Connection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) IODataComponent(org.talend.core.model.components.IODataComponent)

Aggregations

IODataComponent (org.talend.core.model.components.IODataComponent)20 IConnection (org.talend.core.model.process.IConnection)11 ArrayList (java.util.ArrayList)10 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)10 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)7 List (java.util.List)6 IODataComponentContainer (org.talend.core.model.components.IODataComponentContainer)6 INode (org.talend.core.model.process.INode)5 Connection (org.talend.designer.core.ui.editor.connections.Connection)5 Node (org.talend.designer.core.ui.editor.nodes.Node)4 IExternalNode (org.talend.core.model.process.IExternalNode)3 INodeConnector (org.talend.core.model.process.INodeConnector)3 HashMap (java.util.HashMap)2 ColumnNameChanged (org.talend.core.model.metadata.ColumnNameChanged)2 Process (org.talend.designer.core.ui.editor.process.Process)2 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)2 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 EList (org.eclipse.emf.common.util.EList)1