Search in sources :

Example 11 with NoSQLConnection

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

the class NoSQLSchemaUtilTest method testGetSchemaNameByTableLabel.

/**
 * Test method for
 * {@link org.talend.repository.nosql.metadata.NoSQLSchemaUtil#getSchemaNameByTableLabel(org.talend.repository.model.nosql.NoSQLConnection, java.lang.String)}
 * .
 */
@Test
public void testGetSchemaNameByTableLabel() {
    MetadataTable table = RelationalFactory.eINSTANCE.createTdTable();
    table.setLabel(tableLabel);
    NoSQLConnection connection = NosqlFactory.eINSTANCE.createNoSQLConnection();
    NoSQLSchemaUtil.addTable2Connection(connection, table, dbName);
    String schemaNameByTableLabel = NoSQLSchemaUtil.getSchemaNameByTableLabel(connection, table.getLabel());
    Assert.assertNotNull(schemaNameByTableLabel);
    Assert.assertSame(schemaNameByTableLabel, dbName);
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) Test(org.junit.Test)

Example 12 with NoSQLConnection

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

the class MongoDBConnForm 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();
            updateReplicaField();
            if (checkRequireAuthBtn.getSelection()) {
                authMechanismCombo.getCombo().setItems(getAuthMechanismLables(repositoryTranslator.getValue(dbVersionCombo.getText())));
                authMechanismCombo.select(0);
            }
            getConnection().getAttributes().put(INoSQLCommonAttributes.DB_VERSION, repositoryTranslator.getValue(dbVersionCombo.getText()));
        }
    });
    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());
        }
    });
    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();
            authMechanismCombo.getCombo().setItems(getAuthMechanismLables(repositoryTranslator.getValue(dbVersionCombo.getText())));
            getConnection().getAttributes().put(INoSQLCommonAttributes.REQUIRED_AUTHENTICATION, String.valueOf(checkRequireAuthBtn.getSelection()));
        }
    });
    checkSetAuthDatabaseBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean checked = checkSetAuthDatabaseBtn.getSelection();
            updateAuthGroup();
            getConnection().getAttributes().put(IMongoDBAttributes.SET_AUTHENTICATION_DATABASE, String.valueOf(checkSetAuthDatabaseBtn.getSelection()));
        }
    });
    authDatabaseText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            getConnection().getAttributes().put(IMongoDBAttributes.AUTHENTICATION_DATABASE, authDatabaseText.getText());
        }
    });
    authMechanismCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            updateAuthGroup();
            updateEncryptionGroup();
            getConnection().getAttributes().put(IMongoDBAttributes.AUTHENTICATION_MECHANISM, getAuthMechanismValue(authMechanismCombo.getText()));
        }
    });
    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));
        }
    });
    authKrbUserPrincipalText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.KRB_USER_PRINCIPAL, authKrbUserPrincipalText.getText());
        }
    });
    authKrbRealmText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.KRB_REALM, authKrbRealmText.getText());
        }
    });
    authKrbKdcText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.KRB_KDC, authKrbKdcText.getText());
        }
    });
    checkUseReplicaBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateAttributes();
            updateReplicaField();
            checkFieldsValue();
            getConnection().getAttributes().put(IMongoDBAttributes.USE_REPLICA_SET, String.valueOf(checkUseReplicaBtn.getSelection()));
        }
    });
    checkUseConnStringBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateAttributes();
            updateReplicaField();
            checkFieldsValue();
            getConnection().getAttributes().put(IMongoDBAttributes.USE_CONN_STRING, String.valueOf(checkUseConnStringBtn.getSelection()));
        }
    });
    connStringText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.CONN_STRING, connStringText.getText());
        }
    });
    certificateField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.X509_CERT, certificateField.getText());
        }
    });
    keyStorePassText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.X509_CERT_KEYSTORE_PASSWORD, conn.getValue(keyStorePassText.getText(), true));
        }
    });
    trustStorePassText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.X509_CERT_AUTH_TRUSTSTORE_PASSWORD, conn.getValue(trustStorePassText.getText(), true));
        }
    });
    checkUseCertAuthBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            checkFieldsValue();
            updateAuthGroup();
            getConnection().getAttributes().put(IMongoDBAttributes.X509_USE_CERT_AUTH, String.valueOf(checkUseCertAuthBtn.getSelection()));
        }
    });
    authCertificateField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            NoSQLConnection conn = getConnection();
            conn.getAttributes().put(IMongoDBAttributes.X509_CERT_AUTH, authCertificateField.getText());
        }
    });
    replicaTableView.getExtendedTableModel().addAfterOperationListListener(new IListenableListListener() {

        @Override
        public void handleEvent(ListenableListEvent event) {
            saveReplicaModel();
        }
    });
    replicaTableView.getExtendedTableModel().addModifiedBeanListener(new IModifiedBeanListener<HashMap<String, Object>>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<HashMap<String, Object>> event) {
            saveReplicaModel();
        }
    });
    checkRequireEncryptionBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean hide = !checkRequireEncryptionBtn.getSelection();
            hideControl(encryptionGroup, false);
            checkFieldsValue();
            updateAttributes();
            getConnection().getAttributes().put(IMongoDBAttributes.REQUIRED_ENCRYPTION, String.valueOf(checkRequireEncryptionBtn.getSelection()));
        }
    });
}
Also used : ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) HashMap(java.util.HashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener)

Example 13 with NoSQLConnection

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

the class MongoDBConnForm method initializeFields.

@Override
protected void initializeFields() {
    NoSQLConnection conn = getConnection();
    String dbVersion = conn.getAttributes().get(INoSQLCommonAttributes.DB_VERSION);
    String server = conn.getAttributes().get(INoSQLCommonAttributes.HOST);
    String port = conn.getAttributes().get(INoSQLCommonAttributes.PORT);
    String database = conn.getAttributes().get(INoSQLCommonAttributes.DATABASE);
    String user = conn.getAttributes().get(INoSQLCommonAttributes.USERNAME);
    String passwd = conn.getValue(conn.getAttributes().get(INoSQLCommonAttributes.PASSWORD), false);
    boolean isUseConnString = Boolean.parseBoolean(conn.getAttributes().get(IMongoDBAttributes.USE_CONN_STRING));
    String connString = conn.getAttributes().get(IMongoDBAttributes.CONN_STRING);
    boolean isUseRequireAuth = Boolean.parseBoolean(conn.getAttributes().get(INoSQLCommonAttributes.REQUIRED_AUTHENTICATION));
    boolean isUseReplicaSet = Boolean.parseBoolean(conn.getAttributes().get(IMongoDBAttributes.USE_REPLICA_SET));
    String authMechanism = conn.getAttributes().get(IMongoDBAttributes.AUTHENTICATION_MECHANISM);
    String x509_cert = conn.getAttributes().get(IMongoDBAttributes.X509_CERT);
    String x509_cert_keystore_pass = conn.getAttributes().get(IMongoDBAttributes.X509_CERT_KEYSTORE_PASSWORD);
    if (StringUtils.isNotBlank(x509_cert_keystore_pass)) {
        x509_cert_keystore_pass = MongoDBConnectionUtil.decrypt(x509_cert_keystore_pass);
    }
    boolean isUseX509CertAuth = Boolean.parseBoolean(conn.getAttributes().get(IMongoDBAttributes.X509_USE_CERT_AUTH));
    String X509_auth_cert = conn.getAttributes().get(IMongoDBAttributes.X509_CERT_AUTH);
    String X509_auth_cert_truststore_pass = conn.getAttributes().get(IMongoDBAttributes.X509_CERT_AUTH_TRUSTSTORE_PASSWORD);
    if (StringUtils.isNotBlank(X509_auth_cert_truststore_pass)) {
        X509_auth_cert_truststore_pass = MongoDBConnectionUtil.decrypt(X509_auth_cert_truststore_pass);
    }
    boolean isUseAuthDatbase = Boolean.parseBoolean(conn.getAttributes().get(IMongoDBAttributes.SET_AUTHENTICATION_DATABASE));
    String authDatabase = conn.getAttributes().get(IMongoDBAttributes.AUTHENTICATION_DATABASE);
    String authKrbUserPrincipal = conn.getAttributes().get(IMongoDBAttributes.KRB_USER_PRINCIPAL);
    String authKrbRealm = conn.getAttributes().get(IMongoDBAttributes.KRB_REALM);
    String authKrbKdc = conn.getAttributes().get(IMongoDBAttributes.KRB_KDC);
    if (validText(dbVersion)) {
        authMechanismCombo.getCombo().setItems(getAuthMechanismLables(dbVersion));
        dbVersionCombo.setText(repositoryTranslator.getLabel(dbVersion));
    } else {
        dbVersionCombo.select(0);
    }
    serverText.setText(server == null ? IMongoConstants.DEFAULT_HOST : server);
    portText.setText(port == null ? IMongoConstants.DEFAULT_PORT : port);
    // $NON-NLS-1$
    databaseText.setText(database == null ? "" : database);
    checkUseConnStringBtn.setSelection(isUseConnString);
    checkRequireAuthBtn.setSelection(isUseRequireAuth);
    checkUseReplicaBtn.setSelection(isUseReplicaSet);
    checkUseCertAuthBtn.setSelection(isUseX509CertAuth);
    if (isUseConnString) {
        connStringText.setText(connString == null ? "" : connString);
    }
    if (checkRequireAuthBtn.getSelection()) {
        // $NON-NLS-1$
        userText.setText(user == null ? "" : user);
        // $NON-NLS-1$
        pwdText.setText(passwd == null ? "" : passwd);
        if (StringUtils.isEmpty(authMechanism))
            authMechanism = IMongoConstants.NEGOTIATE_MEC;
        certificateField.setText(x509_cert);
        keyStorePassText.setText(x509_cert_keystore_pass);
        if (isUseX509CertAuth) {
            authCertificateField.setText(X509_auth_cert == null ? "" : X509_auth_cert);
            trustStorePassText.setText(X509_auth_cert_truststore_pass);
        }
        authMechanismCombo.setText(Messages.getString("MongoDBConnForm." + authMechanism));
        checkSetAuthDatabaseBtn.setSelection(isUseAuthDatbase);
        authDatabaseText.setText(authDatabase == null ? "" : authDatabase);
        authKrbUserPrincipalText.setText(authKrbUserPrincipal == null ? IMongoConstants.DEFAULT_KRB_USER_PRINCIPAL : authKrbUserPrincipal);
        authKrbRealmText.setText(authKrbRealm == null ? IMongoConstants.DEFAULT_KRB_REALM : authKrbRealm);
        authKrbKdcText.setText(authKrbKdc == null ? IMongoConstants.DEFAULT_KRB_KDC : authKrbKdc);
    }
    updateEncryptionGroup();
    initReplicaField();
    if (replicaTableView != null) {
        replicaTableView.getModel().registerDataList(replicaList);
    }
    updateReplicaField();
    updateAuthGroup();
}
Also used : NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection)

Example 14 with NoSQLConnection

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

the class Neo4jConnForm method 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()));
            updateAuthArea();
            if (Neo4jConnectionUtil.isVersionSince32(getConnection())) {
                serverURLTxt.setText(INeo4jConstants.DEFAULT_NEO4J_URL);
            } else {
                serverURLTxt.setText(INeo4jConstants.DEFAULT_SERVER_URL);
            }
        }
    });
    setUsernameBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getConnection().getAttributes().put(INeo4jAttributes.SET_USERNAME, String.valueOf(setUsernameBtn.getSelection()));
            updateAuthArea();
        }
    });
    browseDbPathBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dial = new DirectoryDialog(getShell(), SWT.NONE);
            String directory = dial.open();
            if (StringUtils.isNotEmpty(directory)) {
                String portableValue = Path.fromOSString(directory).toPortableString();
                dbPathTxt.setText(portableValue);
            }
        }
    });
    dbPathTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
        // if (localDbBtn.getSelection()) {
        // checkFieldsValue();
        // String originalDBPath = getConnection().getAttributes().get(INeo4jAttributes.DATABASE_PATH);
        // String currentDBPath = dbPathTxt.getText();
        // if (!StringUtils.equals(originalDBPath, currentDBPath)) {
        // getConnection().getAttributes().put(INeo4jAttributes.DATABASE_PATH, currentDBPath);
        // udpateConnectionConfig();
        // }
        // }
        }
    });
    serverURLTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            checkFieldsValue();
            String originalServerURL = getConnection().getAttributes().get(INeo4jAttributes.SERVER_URL);
            String currentServerURL = serverURLTxt.getText();
            if (!StringUtils.equals(originalServerURL, currentServerURL)) {
                getConnection().getAttributes().put(INeo4jAttributes.SERVER_URL, currentServerURL);
                udpateConnectionConfig();
            }
        }
    });
    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) 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) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 15 with NoSQLConnection

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

the class CassandraConnForm method initializeFields.

@Override
protected void initializeFields() {
    NoSQLConnection conn = getConnection();
    String dbVersion = conn.getAttributes().get(INoSQLCommonAttributes.DB_VERSION);
    String apiType = conn.getAttributes().get(INoSQLCommonAttributes.API_TYPE);
    String server = conn.getAttributes().get(INoSQLCommonAttributes.HOST);
    String port = conn.getAttributes().get(INoSQLCommonAttributes.PORT);
    String database = conn.getAttributes().get(INoSQLCommonAttributes.DATABASE);
    String user = conn.getAttributes().get(INoSQLCommonAttributes.USERNAME);
    String passwd = conn.getValue(conn.getAttributes().get(INoSQLCommonAttributes.PASSWORD), false);
    Boolean isUseRequireAuth = Boolean.parseBoolean(conn.getAttributes().get(INoSQLCommonAttributes.REQUIRED_AUTHENTICATION));
    if (validText(dbVersion)) {
        dbVersionCombo.setText(repositoryTranslator.getLabel(dbVersion));
    } else {
        dbVersionCombo.select(0);
        if (apiTypeCombo != null && !apiTypeCombo.getCombo().isDisposed()) {
            apiTypeCombo.setHideWidgets(true);
        }
    }
    portText.setText(port == null ? ICassandraConstants.DEFAULT_PORT : port);
    if (validText(apiType)) {
        apiTypeCombo.setText(repositoryTranslator.getLabel(apiType));
    } else {
        apiTypeCombo.select(0);
        portText.setText(ICassandraConstants.DATASTAX_PORT);
    }
    serverText.setText(server == null ? ICassandraConstants.DEFAULT_HOST : server);
    // $NON-NLS-1$
    databaseText.setText(database == null ? "" : database);
    checkRequireAuthBtn.setSelection(isUseRequireAuth);
    if (checkRequireAuthBtn.getSelection()) {
        // $NON-NLS-1$
        userText.setText(user == null ? "" : user);
        // $NON-NLS-1$
        pwdText.setText(passwd == null ? "" : passwd);
    }
    updateAuthGroup();
}
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