use of org.talend.repository.model.nosql.NoSQLConnectionItem in project tbd-studio-se by Talend.
the class CreateNoSQLSchemaAction method doRun.
@Override
protected void doRun() {
if (repositoryNode == null) {
repositoryNode = getCurrentRepositoryNode();
}
NoSQLConnection connection = null;
MetadataTable metadataTable = null;
boolean creation = false;
if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
NoSQLConnectionItem item = null;
if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
item = (NoSQLConnectionItem) repositoryNode.getObject().getProperty().getItem();
connection = (NoSQLConnection) item.getConnection();
metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
creation = false;
} else if (nodeType == NoSQLRepositoryNodeType.METADATA_NOSQL_CONNECTIONS) {
item = (NoSQLConnectionItem) repositoryNode.getObject().getProperty().getItem();
connection = (NoSQLConnection) item.getConnection();
creation = true;
} else {
return;
}
boolean isOK = true;
if (creation) {
isOK = checkNoSQLConnection((NoSQLConnection) item.getConnection());
}
if (isOK) {
openNoSQLSchemaWizard(item, metadataTable, false, creation);
}
}
}
use of org.talend.repository.model.nosql.NoSQLConnectionItem 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.NoSQLConnectionItem 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.NoSQLConnectionItem in project tbd-studio-se by Talend.
the class NoSQLDragAndDropHandler method getCorrespondingComponentName.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IComponentName getCorrespondingComponentName(Item item, ERepositoryObjectType type) {
RepositoryComponentSetting setting = null;
if (item instanceof NoSQLConnectionItem) {
NoSQLConnection connection = (NoSQLConnection) ((NoSQLConnectionItem) item).getConnection();
String repType = getRepType(connection);
setting = new RepositoryComponentSetting();
setting.setName(repType);
setting.setRepositoryType(repType);
setting.setWithSchema(true);
setting.setInputComponent(getInputComponentName(connection));
setting.setOutputComponent(getOutputComponentName(connection));
List<Class<Item>> list = new ArrayList<Class<Item>>();
Class clazz = null;
try {
clazz = Class.forName(NoSQLConnectionItem.class.getName());
} catch (ClassNotFoundException e) {
ExceptionHandler.process(e);
}
list.add(clazz);
setting.setClasses(list.toArray(new Class[0]));
}
return setting;
}
use of org.talend.repository.model.nosql.NoSQLConnectionItem in project tbd-studio-se by Talend.
the class NoSQLRepositoryContentHandler method create.
@Override
public Resource create(IProject project, Item item, int classifierID, IPath path) throws PersistenceException {
Resource itemResource = null;
if (item.eClass() == NosqlPackage.Literals.NO_SQL_CONNECTION_ITEM) {
ERepositoryObjectType type = NoSQLRepositoryNodeType.METADATA_NOSQL_CONNECTIONS;
itemResource = create(project, (NoSQLConnectionItem) item, path, type);
}
return itemResource;
}
Aggregations