Search in sources :

Example 16 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class CassandraConnForm method addFieldsListeners.

/*
     * (non-Javadoc)
     *
     * @see org.talend.repository.nosql.ui.common.AbstractNoSQLForm#addFieldsListeners()
     */
@Override
protected void addFieldsListeners() {
    dbVersionCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            getConnection().getAttributes().put(INoSQLCommonAttributes.DB_VERSION, repositoryTranslator.getValue(dbVersionCombo.getText()));
            updateAPITypeComboField();
            updatePortDecoration();
        }
    });
    apiTypeCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            getConnection().getAttributes().put(INoSQLCommonAttributes.API_TYPE, repositoryTranslator.getValue(apiTypeCombo.getText()));
            updatePortDecoration();
        }
    });
    serverText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            getConnection().getAttributes().put(INoSQLCommonAttributes.HOST, serverText.getText());
        }
    });
    portText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            getConnection().getAttributes().put(INoSQLCommonAttributes.PORT, portText.getText());
        }
    });
    portText.getTextControl().addVerifyListener(new VerifyListener() {

        @Override
        public void verifyText(VerifyEvent e) {
            if (!isContextMode()) {
                e.doit = e.text.matches("[0-9]*");
            }
        }
    });
    databaseText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            getConnection().getAttributes().put(INoSQLCommonAttributes.DATABASE, databaseText.getText());
        }
    });
    checkRequireAuthBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            checkFieldsValue();
            updateAuthGroup();
            updateAttributes();
            getConnection().getAttributes().put(INoSQLCommonAttributes.REQUIRED_AUTHENTICATION, String.valueOf(checkRequireAuthBtn.getSelection()));
        }
    });
    userText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            getConnection().getAttributes().put(INoSQLCommonAttributes.USERNAME, userText.getText());
        }
    });
    pwdText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(INoSQLCommonAttributes.PASSWORD, conn.getValue(pwdText.getText(), true));
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) VerifyListener(org.eclipse.swt.events.VerifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 17 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class UnifyPasswordEncryption4NoSQLConnectionMigrationTask method execute.

/*
     * (non-Javadoc)
     *
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org .talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    if (item instanceof NoSQLConnectionItem) {
        Connection connection = ((NoSQLConnectionItem) item).getConnection();
        connection.setEncryptAndDecryptFuncPair(CryptoMigrationUtil.encryptFunc(), CryptoMigrationUtil.decryptFunc());
        if (connection instanceof NoSQLConnection) {
            NoSQLConnection noSqlConn = (NoSQLConnection) connection;
            try {
                if (!noSqlConn.isContextMode()) {
                    String pass = noSqlConn.getAttributes().get(ICassandraAttributies.PASSWORD);
                    pass = cleanPassword(pass);
                    noSqlConn.getAttributes().put(ICassandraAttributies.PASSWORD, noSqlConn.getValue(pass, true));
                    factory.save(item, true);
                    return ExecutionResult.SUCCESS_NO_ALERT;
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : Connection(org.talend.core.model.metadata.builder.connection.Connection) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 18 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class FixCassandraDataStaxDbtypesProblemMigrationTask method execute.

/*
     * (non-Javadoc)
     *
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    if (item instanceof NoSQLConnectionItem) {
        boolean modify = false;
        Connection connection = ((NoSQLConnectionItem) item).getConnection();
        if (connection instanceof NoSQLConnection) {
            NoSQLConnection noSqlConn = (NoSQLConnection) connection;
            EMap<String, String> attributes = noSqlConn.getAttributes();
            String dbVersion = attributes.get(INoSQLCommonAttributes.DB_VERSION);
            if (!CASSANDRA_2_0_0.equals(dbVersion)) {
                return ExecutionResult.NOTHING_TO_DO;
            }
            boolean isDatastaxApiType = ICassandraConstants.API_TYPE_DATASTAX.equals(attributes.get(INoSQLCommonAttributes.API_TYPE));
            if (!isDatastaxApiType) {
                return ExecutionResult.NOTHING_TO_DO;
            }
            Set<MetadataTable> tables = ConnectionHelper.getTables(noSqlConn);
            if (tables == null || tables.isEmpty()) {
                return ExecutionResult.NOTHING_TO_DO;
            }
            MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(ICassandraConstants.DBM_DATASTAX_ID);
            for (MetadataTable table : tables) {
                EList<MetadataColumn> columns = table.getColumns();
                if (columns == null || columns.isEmpty()) {
                    continue;
                }
                for (MetadataColumn column : columns) {
                    String sourceType = column.getSourceType();
                    if (sourceType == null || sourceType.isEmpty()) {
                        continue;
                    }
                    modify = true;
                    sourceType = sourceType.toLowerCase();
                    column.setSourceType(sourceType);
                    String talendType = mappingTypeRetriever.getDefaultSelectedTalendType(sourceType);
                    if (talendType == null) {
                        talendType = JavaTypesManager.STRING.getId();
                    }
                    column.setTalendType(talendType);
                }
            }
        }
        if (modify) {
            try {
                ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                factory.save(item, true);
                return ExecutionResult.SUCCESS_WITH_ALERT;
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : MappingTypeRetriever(org.talend.core.model.metadata.MappingTypeRetriever) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 19 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class NOSQLService method updateNoSqlConnection.

@Override
public boolean updateNoSqlConnection(Connection connection) throws Exception {
    if (isNoSQLConnection(connection)) {
        NoSQLConnection noSqlConn = (NoSQLConnection) connection;
        String pass = noSqlConn.getAttributes().get(IMongoDBAttributes.PASSWORD);
        if (pass != null) {
            pass = PasswordMigrationUtil.encryptPasswordIfNeeded(pass);
            noSqlConn.getAttributes().put(IMongoDBAttributes.PASSWORD, noSqlConn.getValue(pass, true));
            return true;
        }
    }
    return false;
}
Also used : NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection)

Example 20 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class CassandraConnForm method saveAttributes.

@Override
protected void saveAttributes() {
    super.saveAttributes();
    NoSQLConnection conn = getConnection();
    conn.getAttributes().put(INoSQLCommonAttributes.DB_VERSION, repositoryTranslator.getValue(dbVersionCombo.getText()));
    conn.getAttributes().put(INoSQLCommonAttributes.API_TYPE, repositoryTranslator.getValue(apiTypeCombo.getText()));
    conn.getAttributes().put(INoSQLCommonAttributes.HOST, serverText.getText());
    conn.getAttributes().put(INoSQLCommonAttributes.PORT, portText.getText());
    conn.getAttributes().put(INoSQLCommonAttributes.DATABASE, databaseText.getText());
    conn.getAttributes().put(INoSQLCommonAttributes.REQUIRED_AUTHENTICATION, String.valueOf(checkRequireAuthBtn.getSelection()));
    conn.getAttributes().put(INoSQLCommonAttributes.USERNAME, userText.getText());
    conn.getAttributes().put(INoSQLCommonAttributes.PASSWORD, conn.getValue(pwdText.getText(), true));
}
Also used : NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection)

Aggregations

NoSQLConnection (org.talend.repository.model.nosql.NoSQLConnection)30 NoSQLConnectionItem (org.talend.repository.model.nosql.NoSQLConnectionItem)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)4 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)4 EHadoopParamName (org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)4 JSONArray (org.talend.utils.json.JSONArray)4 JSONException (org.talend.utils.json.JSONException)4 JSONObject (org.talend.utils.json.JSONObject)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)3 AbstractForm (org.talend.metadata.managment.ui.wizard.AbstractForm)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1