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));
}
});
}
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;
}
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;
}
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;
}
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));
}
Aggregations