use of org.talend.repository.nosql.db.handler.cassandra.ICassandraMetadataHandler in project tbd-studio-se by Talend.
the class CassandraWizardPageProvider method addSchemaNodes.
private List<INoSQLSchemaNode> addSchemaNodes(NoSQLConnection connection, INoSQLSchemaNode parentNode) throws NoSQLServerException {
List<INoSQLSchemaNode> schemaNodes = new ArrayList<INoSQLSchemaNode>();
Set<String> cfNames = null;
Set<String> scfNames = null;
String ksName = connection.getAttributes().get(ICassandraAttributies.DATABASE);
if (parentNode != null && StringUtils.isNotEmpty(parentNode.getName())) {
ksName = parentNode.getName();
}
ICassandraMetadataHandler metadataHandler = CassandraConnectionUtil.getMetadataHandler(connection);
if (ksName != null) {
cfNames = metadataHandler.getColumnFamilyNames(connection, ksName);
if (!CassandraConnectionUtil.isUpgradeVersion(connection)) {
scfNames = metadataHandler.getSuperColumnFamilyNames(connection, ksName);
} else {
scfNames = new HashSet<String>();
metadataHandler.closeConnections();
}
} else {
cfNames = metadataHandler.getColumnFamilyNames(connection);
if (!CassandraConnectionUtil.isUpgradeVersion(connection)) {
scfNames = metadataHandler.getSuperColumnFamilyNames(connection);
} else {
scfNames = new HashSet<String>();
metadataHandler.closeConnections();
}
}
if (CassandraConnectionUtil.isOldVersion(connection)) {
collectNodesForOldVersion(schemaNodes, parentNode, cfNames, scfNames);
} else {
collectNodes(schemaNodes, parentNode, cfNames, scfNames);
}
return schemaNodes;
}
use of org.talend.repository.nosql.db.handler.cassandra.ICassandraMetadataHandler in project tbd-studio-se by Talend.
the class CassandraMetadataProvider method extractTheColumns.
private List<MetadataColumn> extractTheColumns(NoSQLConnection connection, String ksName, String cfName) throws NoSQLExtractSchemaException {
List<MetadataColumn> metadataColumns = new ArrayList<MetadataColumn>();
ICassandraMetadataHandler metadataHandler = CassandraConnectionUtil.getMetadataHandler(connection);
try {
List<Object> columndfs = metadataHandler.getColumns(connection, ksName, cfName);
for (Object columndf : columndfs) {
MetadataColumn column = ConnectionFactory.eINSTANCE.createMetadataColumn();
String colName = metadataHandler.getColumnName(connection, columndf);
colName = MetadataToolHelper.validateValue(colName);
column.setName(colName);
column.setLabel(colName);
String talendType = metadataHandler.getColumnTalendType(columndf);
column.setTalendType(talendType);
String dbType = metadataHandler.getColumnDbType(columndf);
column.setSourceType(dbType);
metadataColumns.add(column);
}
} catch (Exception e) {
throw new NoSQLExtractSchemaException(e);
}
return metadataColumns;
}
Aggregations