Search in sources :

Example 41 with IConnection

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

the class DisableParallelizationCommand method disableParallelization.

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

Example 42 with IConnection

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

the class ConnectionReconnectCommand method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.commands.Command#execute()
     */
@Override
public void execute() {
    metadataChanges.clear();
    if (newSource != null) {
        INodeConnector connector = oldSource.getConnectorFromName(connectorName);
        connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() - 1);
        connector = newSource.getConnectorFromName(connectorName);
        connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() + 1);
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
            newSourceSchemaType = (String) newSource.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
            boolean builtInNewSource = newSource.getConnectorFromName(connectorName).isMultiSchema();
            boolean builtInOldSource = oldSource.getConnectorFromName(connectorName).isMultiSchema();
            if ((!builtInNewSource) && (!builtInOldSource)) {
                setSchemaToNotBuiltInNode(oldSource, newSource, oldMetadataTable);
                connection.setMetaName(newSource.getUniqueName());
            } else {
                if (!builtInNewSource) {
                    int num = 0;
                    for (int i = 0; i < oldSource.getMetadataList().size(); i++) {
                        IMetadataTable meta = oldSource.getMetadataList().get(i);
                        if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
                            num = i;
                        }
                    }
                    oldSource.getMetadataList().remove(num);
                    setSchemaToNotBuiltInNode(oldSource, newSource, oldMetadataTable);
                    connection.setMetaName(newSource.getUniqueName());
                }
                if (!builtInOldSource) {
                    IMetadataTable meta = oldMetadataTable.clone();
                    meta.setTableName(connection.getUniqueName());
                    newSource.getMetadataList().add(meta);
                    connection.setMetaName(meta.getTableName());
                }
                if ((builtInOldSource) && (builtInNewSource)) {
                    int num = 0;
                    for (int i = 0; i < oldSource.getMetadataList().size(); i++) {
                        IMetadataTable meta = oldSource.getMetadataList().get(i);
                        if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
                            num = i;
                        }
                    }
                    oldSource.getMetadataList().remove(num);
                    newSource.getMetadataList().add(oldMetadataTable);
                }
            }
        // if (newSourceSchemaType != null) {
        // newSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newSourceSchemaType);
        // }
        // if (oldSourceSchemaType != null) {
        // oldSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
        // }
        } else {
            connection.setMetaName(newSource.getUniqueName());
        }
        connection.reconnect(newSource, oldTarget, newLineStyle);
        connection.updateName();
        if (newSourceSchemaType != null && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            IMetadataTable sourceMetadataTable = newSource.getMetadataFromConnector(connector.getName());
            // IMetadataTable targetMetadataTable = oldTarget.getMetadataFromConnector(connector.getName());
            if (oldMetadataTable != null && sourceMetadataTable != null) {
                boolean sameFlag = oldMetadataTable.sameMetadataAs(sourceMetadataTable, IMetadataColumn.OPTIONS_NONE);
                // For the auto propagate.
                if (!sameFlag && oldTarget.getComponent().isSchemaAutoPropagated() && (oldMetadataTable.getListColumns().isEmpty() || getPropagateDialog())) {
                    IElementParameter param = oldTarget.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
                    if (param == null) {
                        param = oldTarget.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
                    }
                    if (param != null && param.getContext() != null && !param.getContext().equals(connection.getLineStyle().getName())) {
                        param = null;
                    }
                    ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(oldTarget, param, null, sourceMetadataTable);
                    changeMetadataCmd.execute(true);
                    metadataChanges.add(changeMetadataCmd);
                }
            }
        }
        ((Process) newSource.getProcess()).checkStartNodes();
        ((Process) newSource.getProcess()).checkProcess();
    } else if (newTarget != null) {
        newTargetSchemaType = (String) newTarget.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
        INodeConnector connector = oldTarget.getConnectorFromType(oldLineStyle);
        connector.setCurLinkNbInput(connector.getCurLinkNbInput() - 1);
        connector = newTarget.getConnectorFromType(newLineStyle);
        connector.setCurLinkNbInput(connector.getCurLinkNbInput() + 1);
        connection.reconnect(oldSource, newTarget, newLineStyle);
        connection.updateName();
        if (newTargetSchemaType != null) {
            // TDI-28557:if target is repository mode,can not propagate to target and set to build-in,or target is
            // build-in mode,need user to choose by the pop up dialog
            boolean isPropagate = false;
            boolean isRepoMode = newTargetSchemaType.equals(EmfComponent.REPOSITORY);
            if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && !connection.getLineStyle().equals(EConnectionType.FLOW_REF)) {
                IMetadataTable targetOldMetadataTable = newTarget.getMetadataFromConnector(connector.getName());
                if (oldMetadataTable != null && targetOldMetadataTable != null) {
                    boolean sameFlag = oldMetadataTable.sameMetadataAs(targetOldMetadataTable, IMetadataColumn.OPTIONS_NONE);
                    isPropagate = (!sameFlag && newTarget.getComponent().isSchemaAutoPropagated() && !isRepoMode && (targetOldMetadataTable.getListColumns().isEmpty() || getPropagateDialog()));
                    // For the auto propagate.
                    if (isPropagate) {
                        IElementParameter param = newTarget.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
                        if (param != null && param.getContext() != null && !param.getContext().equals(connection.getLineStyle().getName())) {
                            param = null;
                        }
                        ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(newTarget, param, null, oldMetadataTable);
                        changeMetadataCmd.execute(true);
                        metadataChanges.add(changeMetadataCmd);
                    }
                }
            }
            if (isPropagate) {
                newTarget.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
            }
        }
        ((Process) oldSource.getProcess()).checkStartNodes();
        ((Process) oldSource.getProcess()).checkProcess();
    } else {
        //$NON-NLS-1$
        throw new IllegalStateException("Should not happen");
    }
    if (oldSource instanceof Node) {
        if (((Node) oldSource).isJoblet()) {
            ((Node) oldSource).getNodeContainer().setInputs(new HashSet<IConnection>(((Node) oldSource).getInputs()));
            ((Node) oldSource).getNodeContainer().setOutputs(new HashSet<IConnection>(((Node) oldSource).getOutputs()));
        }
    }
    if (oldTarget instanceof Node) {
        if (((Node) oldTarget).isJoblet()) {
            ((Node) oldTarget).getNodeContainer().setInputs(new HashSet<IConnection>(((Node) oldTarget).getInputs()));
            ((Node) oldTarget).getNodeContainer().setOutputs(new HashSet<IConnection>(((Node) oldTarget).getOutputs()));
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 43 with IConnection

use of org.talend.core.model.process.IConnection 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 44 with IConnection

use of org.talend.core.model.process.IConnection 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 45 with IConnection

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

the class ComboController method createButtonCommand.

/**
     * This method is used for "Guess Query" button.
     * 
     * @return
     */
private Command createButtonCommand() {
    IMetadataTable repositoryMetadata = null;
    IMetadataTable newRepositoryMetadata = null;
    String realTableName = null;
    String realTableId = null;
    // Only for getting the real table name.
    if (elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()).equals(EmfComponent.REPOSITORY)) {
        String paramName;
        IElementParameter repositorySchemaTypeParameter = elem.getElementParameter(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
        Object repositoryControl = hashCurControls.get(repositorySchemaTypeParameter.getName());
        paramName = EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
        if (repositoryControl != null) {
            String selectedComboItem = ((CCombo) repositoryControl).getText();
            if (selectedComboItem != null && selectedComboItem.length() > 0) {
                //$NON-NLS-1$
                String value = new String("");
                for (int i = 0; i < elem.getElementParameters().size(); i++) {
                    IElementParameter param = elem.getElementParameters().get(i);
                    if (param.getName().equals(paramName)) {
                        for (int j = 0; j < param.getListItemsValue().length; j++) {
                            if (selectedComboItem.equals(param.getListItemsDisplayName()[j])) {
                                value = (String) param.getListItemsValue()[j];
                            }
                        }
                    }
                }
                if (elem instanceof Node) {
                    // this.dynamicProperty.updateRepositoryList();
                    String connectionId = value.toString().split(" - ")[0];
                    String tableLabel = value.toString().split(" - ")[1];
                    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                    Item item = null;
                    try {
                        IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
                        if (repobj != null) {
                            Property property = repobj.getProperty();
                            if (property != null) {
                                item = property.getItem();
                            }
                        }
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                    if (item != null && item instanceof ConnectionItem) {
                        boolean findTable = false;
                        Connection connection = ((ConnectionItem) item).getConnection();
                        for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
                            if (table.getLabel().equals(tableLabel)) {
                                repositoryMetadata = ConvertionHelper.convert(table);
                                findTable = true;
                                break;
                            }
                        }
                        if (!findTable) {
                            repositoryMetadata = new MetadataTable();
                        }
                    }
                // if (repositoryTableMap.containsKey(value)) {
                // repositoryMetadata = repositoryTableMap.get(value);
                // realTableName = repositoryMetadata.getTableName();
                // realTableId = repositoryMetadata.getId();
                // } else {
                // repositoryMetadata = new MetadataTable();
                // }
                }
            }
        }
    }
    // Ends
    QueryGuessCommand cmd = null;
    INode node = null;
    if (elem instanceof INode) {
        node = (INode) elem;
    } else {
        // else instanceof Connection
        node = ((IConnection) elem).getSource();
    }
    newRepositoryMetadata = node.getMetadataList().get(0);
    if (newRepositoryMetadata == null) {
        String schemaSelected = (String) node.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
        if (schemaSelected != null) {
            String connectionId = schemaSelected.toString().split(" - ")[0];
            String tableLabel = schemaSelected.toString().split(" - ")[1];
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            Item item = null;
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        item = property.getItem();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
            if (item != null && item instanceof ConnectionItem) {
                boolean findTable = false;
                Connection connection = ((ConnectionItem) item).getConnection();
                for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
                    if (table.getLabel().equals(tableLabel)) {
                        repositoryMetadata = ConvertionHelper.convert(table);
                        findTable = true;
                        break;
                    }
                }
                if (!findTable) {
                    repositoryMetadata = new MetadataTable();
                }
            }
        // repositoryMetadata = repositoryTableMap.get(schemaSelected);
        } else if (newRepositoryMetadata == null) {
            MessageDialog.openWarning(new Shell(), Messages.getString("ComboController.alert"), //$NON-NLS-1$ //$NON-NLS-2$
            Messages.getString("ComboController.nothingGuess"));
            return cmd;
        }
    }
    cmd = new QueryGuessCommand(node, newRepositoryMetadata);
    /* parameter can be null,the setMaps won't use the third parameter */
    cmd.setMaps(dynamicProperty.getTableIdAndDbTypeMap(), dynamicProperty.getTableIdAndDbSchemaMap(), null);
    //$NON-NLS-1$
    String type = getValueFromRepositoryName("TYPE");
    cmd.setParameters(realTableId, realTableName, type);
    return cmd;
}
Also used : INode(org.talend.core.model.process.INode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) Point(org.eclipse.swt.graphics.Point) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Shell(org.eclipse.swt.widgets.Shell) CCombo(org.eclipse.swt.custom.CCombo) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

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