Search in sources :

Example 1 with NoSQLSchemaNode

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

the class CassandraWizardPageProvider method createSchemaNodes.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.repository.nosql.ui.provider.IWizardPageProvider#createSchemaNodes(org.talend.repository.model.nosql
     * .NoSQLConnection)
     */
@Override
public List<INoSQLSchemaNode> createSchemaNodes(NoSQLConnection connection) throws NoSQLExtractSchemaException {
    List<INoSQLSchemaNode> schemaNodes = new ArrayList<INoSQLSchemaNode>();
    try {
        String ksName = connection.getAttributes().get(ICassandraAttributies.DATABASE);
        if (connection.isContextMode()) {
            ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connection);
            ksName = ContextParameterUtils.getOriginalValue(contextType, ksName);
        }
        if (StringUtils.isEmpty(ksName)) {
            List<String> databaseNames = CassandraConnectionUtil.getMetadataHandler(connection).getKeySpaceNames(connection);
            for (String dbn : databaseNames) {
                INoSQLSchemaNode dbNode = new NoSQLSchemaNode();
                dbNode.setName(dbn);
                dbNode.setNodeType(ICassandraConstants.KEY_SPACE);
                dbNode.setSchemaType(ENoSQLSchemaType.DATABASE);
                dbNode.addChildren(addSchemaNodes(connection, dbNode));
                schemaNodes.add(dbNode);
            }
        } else {
            schemaNodes.addAll(addSchemaNodes(connection, null));
        }
    } catch (Exception e) {
        throw new NoSQLExtractSchemaException(e);
    }
    return schemaNodes;
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ArrayList(java.util.ArrayList) NoSQLExtractSchemaException(org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException) NoSQLSchemaNode(org.talend.repository.nosql.model.NoSQLSchemaNode) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) NoSQLServerException(org.talend.repository.nosql.exceptions.NoSQLServerException) NoSQLExtractSchemaException(org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)

Example 2 with NoSQLSchemaNode

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

the class CassandraWizardPageProvider method addNode.

private void addNode(String nodeName, List<INoSQLSchemaNode> schemaNodes, INoSQLSchemaNode parentNode, boolean isSuper) {
    NoSQLSchemaNode node = new NoSQLSchemaNode();
    node.setName(nodeName);
    if (isSuper) {
        node.setNodeType(ICassandraConstants.SUPER_COLUMN_FAMILY);
        node.getParameters().put(ICassandraAttributies.COLUMN_FAMILY_TYPE, ICassandraAttributies.COLUMN_FAMILY_TYPE_SUPER);
    } else {
        node.setNodeType(ICassandraConstants.COLUMN_FAMILY);
        node.getParameters().put(ICassandraAttributies.COLUMN_FAMILY_TYPE, ICassandraAttributies.COLUMN_FAMILY_TYPE_STANDARD);
    }
    node.setSchemaType(ENoSQLSchemaType.TABLE);
    if (parentNode != null) {
        node.setParent(parentNode);
        parentNode.addChild(node);
    } else {
        schemaNodes.add(node);
    }
}
Also used : NoSQLSchemaNode(org.talend.repository.nosql.model.NoSQLSchemaNode) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode)

Example 3 with NoSQLSchemaNode

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

the class CassandraWizardPageProvider method collectNodes.

private void collectNodes(List<INoSQLSchemaNode> schemaNodes, INoSQLSchemaNode parentNode, Set<String> cfNames, Set<String> scfNames) {
    for (String name : cfNames) {
        NoSQLSchemaNode node = new NoSQLSchemaNode();
        node.setName(name);
        node.setNodeType(ICassandraConstants.COLUMN_FAMILY);
        node.getParameters().put(ICassandraAttributies.COLUMN_FAMILY_TYPE, ICassandraAttributies.COLUMN_FAMILY_TYPE_STANDARD);
        if (scfNames.size() > 0) {
            for (String scfName : scfNames) {
                if (name.equals(scfName)) {
                    node.setNodeType(ICassandraConstants.SUPER_COLUMN_FAMILY);
                    node.getParameters().put(ICassandraAttributies.COLUMN_FAMILY_TYPE, ICassandraAttributies.COLUMN_FAMILY_TYPE_SUPER);
                    break;
                }
            }
        }
        node.setSchemaType(ENoSQLSchemaType.TABLE);
        if (parentNode != null) {
            node.setParent(parentNode);
            parentNode.addChild(node);
        } else {
            schemaNodes.add(node);
        }
    }
}
Also used : NoSQLSchemaNode(org.talend.repository.nosql.model.NoSQLSchemaNode) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode)

Example 4 with NoSQLSchemaNode

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

the class MongoDBWizardPageProvider method addSchemaNodes.

private List<INoSQLSchemaNode> addSchemaNodes(NoSQLConnection connection, Object mongoClient, INoSQLSchemaNode parentNode) throws NoSQLServerException {
    List<INoSQLSchemaNode> schemaNodes = new ArrayList<INoSQLSchemaNode>();
    Set<String> collectionNames = null;
    String dbName = null;
    if (parentNode != null && StringUtils.isNotEmpty(parentNode.getName())) {
        dbName = parentNode.getName();
    }
    if (dbName != null) {
        collectionNames = MongoDBConnectionUtil.getCollectionNames(connection, dbName, mongoClient);
    } else {
        collectionNames = MongoDBConnectionUtil.getCollectionNames(connection, null, mongoClient);
    }
    for (String name : collectionNames) {
        NoSQLSchemaNode node = new NoSQLSchemaNode();
        node.setName(name);
        node.setNodeType(IMongoConstants.COLLECTION);
        node.setSchemaType(ENoSQLSchemaType.TABLE);
        if (parentNode != null) {
            node.setParent(parentNode);
            parentNode.addChild(node);
        } else {
            schemaNodes.add(node);
        }
    }
    return schemaNodes;
}
Also used : INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ArrayList(java.util.ArrayList) NoSQLSchemaNode(org.talend.repository.nosql.model.NoSQLSchemaNode) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode)

Example 5 with NoSQLSchemaNode

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

the class MongoDBWizardPageProvider method createSchemaNodes.

@Override
public List<INoSQLSchemaNode> createSchemaNodes(NoSQLConnection connection) throws NoSQLExtractSchemaException {
    List<INoSQLSchemaNode> schemaNodes = new ArrayList<INoSQLSchemaNode>();
    try {
        String dbName = connection.getAttributes().get(IMongoDBAttributes.DATABASE);
        if (connection.isContextMode()) {
            ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connection);
            dbName = ContextParameterUtils.getOriginalValue(contextType, dbName);
        }
        Object mongoClient = MongoDBConnectionUtil.getMongoVersioned(connection);
        if (StringUtils.isEmpty(dbName)) {
            List<String> databaseNames = MongoDBConnectionUtil.getDatabaseNames(connection, mongoClient);
            for (String dbn : databaseNames) {
                INoSQLSchemaNode dbNode = new NoSQLSchemaNode();
                dbNode.setName(dbn);
                dbNode.setNodeType(IMongoConstants.DATABASE);
                dbNode.setSchemaType(ENoSQLSchemaType.DATABASE);
                dbNode.addChildren(addSchemaNodes(connection, mongoClient, dbNode));
                schemaNodes.add(dbNode);
            }
        } else {
            schemaNodes.addAll(addSchemaNodes(connection, mongoClient, null));
        }
    } catch (Exception e) {
        throw new NoSQLExtractSchemaException(e);
    }
    return schemaNodes;
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ArrayList(java.util.ArrayList) NoSQLExtractSchemaException(org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException) NoSQLSchemaNode(org.talend.repository.nosql.model.NoSQLSchemaNode) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) NoSQLServerException(org.talend.repository.nosql.exceptions.NoSQLServerException) NoSQLExtractSchemaException(org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)

Aggregations

INoSQLSchemaNode (org.talend.repository.nosql.model.INoSQLSchemaNode)5 NoSQLSchemaNode (org.talend.repository.nosql.model.NoSQLSchemaNode)5 ArrayList (java.util.ArrayList)3 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)2 NoSQLExtractSchemaException (org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)2 NoSQLServerException (org.talend.repository.nosql.exceptions.NoSQLServerException)2