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