Search in sources :

Example 1 with ICassandraMetadataHandler

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;
}
Also used : INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ArrayList(java.util.ArrayList) ICassandraMetadataHandler(org.talend.repository.nosql.db.handler.cassandra.ICassandraMetadataHandler)

Example 2 with ICassandraMetadataHandler

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;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ArrayList(java.util.ArrayList) NoSQLExtractSchemaException(org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException) ICassandraMetadataHandler(org.talend.repository.nosql.db.handler.cassandra.ICassandraMetadataHandler) NoSQLServerException(org.talend.repository.nosql.exceptions.NoSQLServerException) NoSQLExtractSchemaException(org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)

Aggregations

ArrayList (java.util.ArrayList)2 ICassandraMetadataHandler (org.talend.repository.nosql.db.handler.cassandra.ICassandraMetadataHandler)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 NoSQLExtractSchemaException (org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)1 NoSQLServerException (org.talend.repository.nosql.exceptions.NoSQLServerException)1 INoSQLSchemaNode (org.talend.repository.nosql.model.INoSQLSchemaNode)1