Search in sources :

Example 11 with IElementParameter

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

the class DCSchemaController method createButtonCommand.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createButtonCommand(org
     * .eclipse.swt.widgets.Button)
     */
@SuppressWarnings("unchecked")
protected Command createButtonCommand(Button button) {
    Button inputButton = button;
    Map<INode, Map<IMetadataTable, Boolean>> inputInfos = new HashMap<INode, Map<IMetadataTable, Boolean>>();
    Node node;
    if (elem instanceof Node) {
        node = (Node) elem;
    } else {
        // else instanceof Connection
        node = (Node) ((Connection) elem).getSource();
    }
    String componentName = node.getComponent().getName();
    initConnectionParameters();
    IContextManager manager;
    if (part == null) {
        manager = new EmptyContextManager();
    } else {
        manager = part.getProcess().getContextManager();
    }
    IElement oldElement = elem;
    if (isUseExistingConnection()) {
        this.elem = connectionNode;
        initConnectionParametersWithContext(connectionNode, manager.getDefaultContext());
    } else {
        initConnectionParametersWithContext(elem, manager.getDefaultContext());
    }
    this.elem = oldElement;
    if (!GlobalServiceRegister.getDefault().isServiceRegistered(IDCService.class)) {
        return null;
    }
    IDCService restService = (IDCService) GlobalServiceRegister.getDefault().getService(IDCService.class);
    restService.setupRestHelperInstance(connParameters.getHost(), connParameters.getPort(), connParameters.getUserName(), connParameters.getPassword(), connParameters.getDirectory(), connParameters.isHttps());
    String entityName = elem.getPropertyValue("ENTITY").toString().replaceAll("\"", "");
    IMetadataTable inputMetadata = null, inputMetaCopy = null;
    Connection inputConec = null;
    String propertyName = (String) inputButton.getData(PARAMETER_NAME);
    IElementParameter param = node.getElementParameter(propertyName);
    IElementParameter connectionParam = param.getChildParameters().get(EParameterName.CONNECTION.getName());
    String connectionName = null;
    if (connectionParam != null) {
        connectionName = (String) connectionParam.getValue();
    }
    boolean inputReadOnly = false, outputReadOnly = false, inputReadOnlyNode = false, inputReadOnlyParam = false;
    for (Connection connec : (List<Connection>) node.getIncomingConnections()) {
        if (connec.isActivate() && (EConnectionType.FLOW_MAIN.equals(connec.getLineStyle()) || EConnectionType.TABLE.equals(connec.getLineStyle()) || EConnectionType.FLOW_MERGE.equals(connec.getLineStyle()) || EConnectionType.FLOW_REF.equals(connec.getLineStyle()))) {
            if (connectionName != null && !connec.getName().equals(connectionName)) {
                continue;
            }
            inputMetadata = connec.getMetadataTable();
            inputMetaCopy = inputMetadata.clone();
            inputConec = connec;
            if (connec.getSource().isReadOnly()) {
                inputReadOnlyNode = true;
            } else {
                for (IElementParameter curParam : connec.getSource().getElementParameters()) {
                    if (curParam.getFieldType() == EParameterFieldType.SCHEMA_TYPE || curParam.getFieldType() == EParameterFieldType.DCSCHEMA) {
                        if (curParam.isReadOnly()) {
                            inputReadOnlyParam = true;
                        }
                    }
                }
            }
            // check if the inputMetadata is readonly
            if (inputMetadata != null) {
                for (IMetadataColumn column : inputMetadata.getListColumns()) {
                    IMetadataColumn columnCopied = inputMetaCopy.getColumn(column.getLabel());
                    columnCopied.setCustom(column.isCustom());
                    columnCopied.setReadOnly(column.isReadOnly());
                }
                inputMetaCopy.setReadOnly(inputMetadata.isReadOnly());
                inputReadOnly = prepareReadOnlyTable(inputMetaCopy, inputReadOnlyParam, inputReadOnlyNode);
            }
            // store the value for Dialog
            Map<IMetadataTable, Boolean> oneInput = new HashMap<IMetadataTable, Boolean>();
            oneInput.put(inputMetaCopy, inputReadOnly);
            inputInfos.put(connec.getSource(), oneInput);
        }
    }
    if (connectionParam != null && inputMetadata == null) {
        //$NON-NLS-1$
        MessageDialog.openError(//$NON-NLS-1$
        button.getShell(), //$NON-NLS-1$
        Messages.getString("SchemaTypeController.inputNotSet"), //$NON-NLS-1$
        Messages.getString("SchemaTypeController.connectionNotAvaliable"));
        return null;
    }
    IMetadataTable originaleMetadataTable = getMetadataTableFromXml(node);
    // check if the outputMetadata is readonly
    IMetadataTable originaleOutputTable = node.getMetadataFromConnector(param.getContext());
    IMetadataTable outputMetaCopy = originaleOutputTable.clone();
    for (IMetadataColumn column : originaleOutputTable.getListColumns()) {
        IMetadataColumn columnCopied = outputMetaCopy.getColumn(column.getLabel());
        columnCopied.setCustom(column.isCustom());
        columnCopied.setReadOnly(column.isReadOnly());
    }
    outputMetaCopy.setReadOnly(originaleOutputTable.isReadOnly() || param.isReadOnly(node.getElementParametersWithChildrens()));
    outputMetaCopy.sortCustomColumns();
    // create the MetadataDialog
    MetadataDialog metaDialog = null;
    if (inputMetadata != null) {
        if (inputInfos != null && inputInfos.size() > 1 && connectionName == null) {
            MetadataDialogForMerge metaDialogForMerge = new MetadataDialogForMerge(composite.getShell(), inputInfos, outputMetaCopy, node, getCommandStack());
            //$NON-NLS-1$
            metaDialogForMerge.setText(Messages.getString("SchemaController.schemaOf") + node.getLabel());
            metaDialogForMerge.setInputReadOnly(inputReadOnly);
            metaDialogForMerge.setOutputReadOnly(outputReadOnly);
            if (metaDialogForMerge.open() == MetadataDialogForMerge.OK) {
                outputMetaCopy = metaDialogForMerge.getOutputMetaData();
                // check if the metadata is modified
                boolean modified = false;
                if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
                    modified = true;
                } else {
                    if (inputMetadata != null) {
                        // Notice: the Map inputInfos maybe is modified by the dialog.
                        Set<INode> inputNodes = inputInfos.keySet();
                        for (INode inputNode : inputNodes) {
                            Map<IMetadataTable, Boolean> oneInput = inputInfos.get(inputNode);
                            inputMetaCopy = (IMetadataTable) oneInput.keySet().toArray()[0];
                            if (!inputMetaCopy.sameMetadataAs(inputNode.getMetadataList().get(0), IMetadataColumn.OPTIONS_NONE)) {
                                modified = true;
                            }
                        }
                    }
                }
                // create the changeMetadataCommand
                if (modified) {
                    Command changeMetadataCommand = null;
                    // only output, no input
                    if (inputInfos.isEmpty()) {
                        changeMetadataCommand = new ChangeMetadataCommand(node, param, null, null, null, originaleOutputTable, outputMetaCopy);
                    } else {
                        Set<INode> inputNodes = inputInfos.keySet();
                        int count = 0;
                        for (INode inputNode : inputNodes) {
                            Map<IMetadataTable, Boolean> oneInput = inputInfos.get(inputNode);
                            inputMetaCopy = (IMetadataTable) oneInput.keySet().toArray()[0];
                            if (count == 0) {
                                changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputNode.getMetadataList().get(0), inputMetaCopy, originaleOutputTable, outputMetaCopy);
                            } else {
                                changeMetadataCommand = changeMetadataCommand.chain(new ChangeMetadataCommand(node, param, inputNode, inputNode.getMetadataList().get(0), inputMetaCopy, originaleOutputTable, outputMetaCopy));
                            }
                            count++;
                        }
                    }
                    return changeMetadataCommand;
                }
            }
        } else {
            Node inputNode = (Node) (inputConec.getSource());
            if (inputMetaCopy.getAttachedConnector() == null) {
                INodeConnector mainConnector;
                if (inputNode.isELTComponent()) {
                    mainConnector = inputNode.getConnectorFromType(EConnectionType.TABLE);
                } else {
                    mainConnector = inputNode.getConnectorFromType(EConnectionType.FLOW_MAIN);
                }
                inputMetaCopy.setAttachedConnector(mainConnector.getName());
            }
            metaDialog = new MetadataDialog(composite.getShell(), inputMetaCopy, inputNode, outputMetaCopy, node, getCommandStack());
        }
    } else {
        metaDialog = new MetadataDialog(composite.getShell(), outputMetaCopy, node, getCommandStack());
    }
    /*
         * Datacert: Populating data in the edit schema dialog
         *
         * @author : virtusa
         */
    List<IMetadataColumn> columnList = new ArrayList<IMetadataColumn>();
    String prefix = "";
    if (componentName.equalsIgnoreCase(Messages.getString("DataCertController.tDataCertDenormalize.componentName"))) {
        String denorCol = elem.getPropertyValue("DC_COLUMN_DENORMALIZE").toString().replaceAll("\"", "");
        ;
        prefix = denorCol;
        IMetadataTable inputTable = null;
        if (node.getIncomingConnections() != null && node.getIncomingConnections().size() > 0) {
            IConnection inputConn = node.getIncomingConnections().get(0);
            if (inputConn != null) {
                inputTable = inputConn.getMetadataTable();
            }
        }
        if (inputTable != null) {
            for (IMetadataColumn inCol : inputTable.getListColumns()) {
                if (!inCol.getLabel().equals(denorCol)) {
                    columnList.add(inCol);
                }
            }
        }
    }
    restService.addColumnsToSchema(entityName, componentName, prefix, columnList);
    outputMetaCopy.setListColumns(columnList);
    outputMetaCopy.setComment("Attribute Metadata");
    outputMetaCopy.setLabel("Attribute Metadata");
    outputMetaCopy.setTableName(entityName);
    if (metaDialog != null) {
        //$NON-NLS-1$
        metaDialog.setText(Messages.getString("AbstractSchemaController.schema.title", node.getLabel()));
        metaDialog.setInputReadOnly(false);
        metaDialog.setOutputReadOnly(false);
        if (metaDialog.open() == MetadataDialog.OK) {
            outputMetaCopy = metaDialog.getOutputMetaData();
            boolean modified = false;
            if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
                modified = true;
            }
            if (modified) {
                Node inputNode = null;
                if (inputConec != null) {
                    inputNode = (Node) inputConec.getSource();
                }
                ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputMetadata, inputMetaCopy, originaleOutputTable, outputMetaCopy);
                return changeMetadataCommand;
            }
        }
    }
    return null;
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector) Button(org.eclipse.swt.widgets.Button) MetadataDialog(org.talend.core.ui.metadata.dialog.MetadataDialog) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IContextManager(org.talend.core.model.process.IContextManager) IElement(org.talend.core.model.process.IElement) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Point(org.eclipse.swt.graphics.Point) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) Command(org.eclipse.gef.commands.Command) HashMap(java.util.HashMap) Map(java.util.Map) MetadataDialogForMerge(org.talend.core.ui.metadata.dialog.MetadataDialogForMerge)

Example 12 with IElementParameter

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

the class DbTypeListController method getCurrentDbms.

private static String getCurrentDbms(INode node) {
    boolean hasMappingType = false;
    String currentDbms = null;
    for (IElementParameter currentParam : node.getElementParameters()) {
        if (currentParam.getFieldType().equals(EParameterFieldType.MAPPING_TYPE) && currentParam.isShow(node.getElementParameters())) {
            currentDbms = (String) currentParam.getValue();
            hasMappingType = true;
        }
    }
    if (!hasMappingType) {
        // if there is no mapping type, then check if a db repository schema is used
        //$NON-NLS-1$
        IElementParameter schemaTypeParameter = node.getElementParameter("SCHEMA_TYPE");
        if (schemaTypeParameter == null) {
            return null;
        }
        String schemaType = (String) schemaTypeParameter.getValue();
        if (schemaType.equals("REPOSITORY")) {
            //$NON-NLS-1$
            // repository mode
            //$NON-NLS-1$
            String metaRepositoryName = (String) node.getElementParameter("REPOSITORY_SCHEMA_TYPE").getValue();
            Connection connection = MetadataToolHelper.getConnectionFromRepository(metaRepositoryName);
            if (connection instanceof DatabaseConnection) {
                // bug 13200
                if (((DatabaseConnection) connection).getDatabaseType().equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
                    // bug 7618 modify
                    currentDbms = (DBConnectionContextUtils.cloneOriginalValueConnection((DatabaseConnection) connection, true, null)).getDbmsId();
                } else {
                    currentDbms = ((DatabaseConnection) connection).getDbmsId();
                }
            }
        } else {
            //$NON-NLS-1$
            String componentDbType = "";
            for (IElementParameter param : (List<IElementParameter>) node.getElementParameters()) {
                if (param.getRepositoryValue() != null) {
                    if (param.getRepositoryValue().equals("TYPE")) {
                        //$NON-NLS-1$
                        componentDbType = (String) param.getValue();
                    }
                }
            }
            String componentProduct = EDatabaseTypeName.getTypeFromDbType(componentDbType).getProduct();
            if (EDatabaseTypeName.supportDbType(componentDbType)) {
                currentDbms = MetadataTalendType.getDefaultDbmsFromProduct(componentProduct).getId();
            }
        }
    }
    return currentDbms;
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) List(java.util.List)

Example 13 with IElementParameter

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

the class GuessSchemaController method useMockJob.

private void useMockJob() {
    /*
         * get the select node,it's the input node of the process. then transfer selected context varriable to
         * openContextChooseDialog, added by hyWang
         */
    final IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
    final Shell parentShell = this.composite.getShell();
    final Node inputNode = (Node) this.curParameter.getElement();
    if (connParameters == null) {
        initConnectionParameters();
    }
    final String tmpMemoSql = this.memoSQL;
    final DatabaseConnection connt = TracesConnectionUtils.createConnection(connParameters);
    IMetadataConnection iMetadataConnection = null;
    boolean isStatus = false;
    try {
        if (connt != null) {
            iMetadataConnection = ConvertionHelper.convert(connt);
            isStatus = checkConnection(iMetadataConnection);
        }
        if (isStatus) {
            if (EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(iMetadataConnection.getDbType())) {
                info = new DbInfo(iMetadataConnection.getDbType(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getUrl(), iMetadataConnection.getDriverClass(), iMetadataConnection.getDriverJarPath(), iMetadataConnection.getAdditionalParams());
            } else if (EDatabaseTypeName.HIVE.getDisplayName().equals(iMetadataConnection.getDbType())) {
                String jobTracker = TalendTextUtils.removeQuotes(String.valueOf(iMetadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL)));
                String nameNode = TalendTextUtils.removeQuotes(String.valueOf(iMetadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL)));
                String thrifturi = null;
                if (HiveModeInfo.get(iMetadataConnection.getDbVersionString()) == HiveModeInfo.EMBEDDED) {
                    thrifturi = "thrift://" + iMetadataConnection.getServerName() + ":" + iMetadataConnection.getPort();
                }
                info = new DbInfo(iMetadataConnection.getDbType(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getUrl(), jobTracker, nameNode, thrifturi, iMetadataConnection.getDriverJarPath());
                String hiveServerVersion = String.valueOf(iMetadataConnection.getParameter(ConnParameterKeys.HIVE_SERVER_VERSION));
                //$NON-NLS-1$
                String driverClass = "";
                if (HiveServerVersionInfo.HIVE_SERVER_2.getKey().equals(hiveServerVersion)) {
                    driverClass = EDatabase4DriverClassName.HIVE2.getDriverClass();
                } else {
                    driverClass = EDatabase4DriverClassName.HIVE.getDriverClass();
                }
                info.setDriverClassName(driverClass);
            } else {
                info = new DbInfo(iMetadataConnection.getDbType(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getUrl(), iMetadataConnection.getDriverJarPath());
            }
            final Property property = GuessSchemaProcess.getNewmockProperty();
            List<IContext> allcontexts = inputNode.getProcess().getContextManager().getListContext();
            OpenContextChooseComboDialog dialog = new OpenContextChooseComboDialog(parentShell, allcontexts);
            dialog.create();
            dialog.getShell().setText(CONTEXT_CHOOSE_DIALOG_TITLE);
            IContext selectContext = null;
            // job only have defoult context,or the query isn't context mode
            if (allcontexts.size() == 1 || TalendTextUtils.isCommonString(tmpMemoSql)) {
                selectContext = inputNode.getProcess().getContextManager().getDefaultContext();
            } else if (Window.OK == dialog.open()) {
                selectContext = dialog.getSelectedContext();
            }
            final IContext context = selectContext;
            if (context != null) {
                //
                final ProgressMonitorDialog pmd = new ProgressMonitorDialog(this.composite.getShell());
                pmd.run(true, true, new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                runShadowProcess(property, inputNode, context, switchParam);
                            }
                        });
                    }
                });
            }
        } else {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    //$NON-NLS-1$
                    String pid = "org.talend.sqlbuilder";
                    //$NON-NLS-1$
                    String mainMsg = Messages.getString("GuessSchemaController.connectionFailed");
                    ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connParameters.getConnectionComment());
                    if (dialog.getCodeOfButton() == Window.OK) {
                        openParamemerDialog(composite.getShell(), part.getProcess().getContextManager());
                    }
                }
            });
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
// else {
// try {
// pmd2.run(true, true, new IRunnableWithProgress() {
// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// Display.getDefault().asyncExec(new Runnable() {
//
// public void run() {
// String pid = SqlBuilderPlugin.PLUGIN_ID;
//                    String mainMsg = Messages.getString("GuessSchemaController.connectionFailed"); //$NON-NLS-1$
// ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite
// .getShell(), pid, mainMsg, connParameters.getConnectionComment());
// if (dialog.getCodeOfButton() == Window.OK) {
// openParamemerDialog(composite.getShell(), part.getTalendEditor().getProcess().getContextManager());
// }
// }
// });
// }
// });
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}
Also used : ErrorDialogWithDetailAreaAndContinueButton(org.talend.commons.ui.swt.dialogs.ErrorDialogWithDetailAreaAndContinueButton) IContext(org.talend.core.model.process.IContext) Node(org.talend.designer.core.ui.editor.nodes.Node) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException) ProcessorException(org.talend.designer.runprocess.ProcessorException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) OpenContextChooseComboDialog(org.talend.designer.core.ui.editor.properties.controllers.uidialog.OpenContextChooseComboDialog) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property)

Example 14 with IElementParameter

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

the class GuessSchemaController method createButtonCommand.

/**
     * This method is used for "Guess Query" button.
     *
     * @return
     */
// modified by hyWang
private Command createButtonCommand(Button btn, IContextManager manager) {
    this.btn = btn;
    IElementParameter elementParameterFromField = elem.getElementParameterFromField(EParameterFieldType.MEMO_SQL);
    memoSQL = (String) elementParameterFromField.getValue();
    initConnectionParameters();
    if (this.connParameters != null && memoSQL != null) {
        initConnectionParametersWithContext(elem, manager.getDefaultContext());
        // runShadowProcess();
        if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
            useMockJob();
        } else if (LanguageManager.getCurrentLanguage() == ECodeLanguage.PERL) {
            IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
            //$NON-NLS-1$ //$NON-NLS-2$
            memoSQL = memoSQL.substring(1, memoSQL.length() - 1).trim().replace("\\'", "\'");
            runShadowProcessForPerl();
            if (columns != null && columns.size() > 0) {
                Node node = (Node) elem;
                IMetadataTable tempMetatable = new MetadataTable();
                IMetadataTable inputMetaCopy, inputMetadata, outputMetaCopy, originaleOutputTable;
                String propertyName = (String) btn.getData(PARAMETER_NAME);
                IElementParameter param = node.getElementParameter(propertyName);
                for (IElementParameter eParam : elem.getElementParameters()) {
                    if (eParam.getContext() != null) {
                        param = eParam;
                    }
                }
                originaleOutputTable = node.getMetadataFromConnector(param.getContext());
                if (originaleOutputTable != null) {
                    outputMetaCopy = originaleOutputTable.clone();
                }
                tempMetatable.setListColumns(columns);
                MetadataDialog metaDialog = new MetadataDialog(composite.getShell(), tempMetatable, node, getCommandStack());
                if (metaDialog != null) {
                    //$NON-NLS-1$
                    metaDialog.setText(Messages.getString("AbstractSchemaController.schema.title", node.getLabel()));
                    if (metaDialog.open() == MetadataDialog.OK) {
                        outputMetaCopy = metaDialog.getOutputMetaData();
                        boolean modified = false;
                        if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
                            modified = true;
                        }
                        if (modified) {
                            if (switchParam != null) {
                                switchParam.setValue(Boolean.FALSE);
                            }
                            ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, param, originaleOutputTable, outputMetaCopy);
                            return changeMetadataCommand;
                        }
                    }
                }
            }
        }
        if (changeMetadataCommand != null) {
            return changeMetadataCommand;
        }
    }
    return null;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Node(org.talend.designer.core.ui.editor.nodes.Node) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) MetadataDialog(org.talend.core.ui.metadata.dialog.MetadataDialog) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 15 with IElementParameter

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

the class FileController method setDragAndDropActionBool.

private void setDragAndDropActionBool() {
    IElementParameter propertyParam = elem.getElementParameter("PROPERTY:REPOSITORY_PROPERTY_TYPE");
    try {
        if (propertyParam != null && propertyParam.getValue() != null && !"".equals(propertyParam.getValue())) {
            Item linkedRepositoryItem = null;
            IRepositoryViewObject repository = DesignerPlugin.getDefault().getProxyRepositoryFactory().getLastVersion(propertyParam.getValue().toString());
            if (repository != null && repository.getProperty() != null) {
                linkedRepositoryItem = repository.getProperty().getItem();
            }
            if (linkedRepositoryItem != null && linkedRepositoryItem instanceof XmlFileConnectionItem) {
                XmlFileConnectionItem xci = (XmlFileConnectionItem) linkedRepositoryItem;
                XmlFileConnection cc = (XmlFileConnection) xci.getConnection();
                String xmlFilePath = cc.getXmlFilePath();
                if (xmlFilePath != null && XmlUtil.isXSDFile(TalendQuoteUtils.removeQuotes(xmlFilePath))) {
                    dragAndDropActionBool = true;
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
}
Also used : Item(org.talend.core.model.properties.Item) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem)

Aggregations

IElementParameter (org.talend.core.model.process.IElementParameter)426 ArrayList (java.util.ArrayList)161 List (java.util.List)108 Node (org.talend.designer.core.ui.editor.nodes.Node)108 Map (java.util.Map)95 INode (org.talend.core.model.process.INode)92 HashMap (java.util.HashMap)82 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)73 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)69 Point (org.eclipse.swt.graphics.Point)57 ElementParameter (org.talend.designer.core.model.components.ElementParameter)48 ConnectionItem (org.talend.core.model.properties.ConnectionItem)45 IConnection (org.talend.core.model.process.IConnection)40 PersistenceException (org.talend.commons.exception.PersistenceException)39 Item (org.talend.core.model.properties.Item)37 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)37 IComponent (org.talend.core.model.components.IComponent)35 CCombo (org.eclipse.swt.custom.CCombo)33 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)29 Connection (org.talend.core.model.metadata.builder.connection.Connection)28