use of org.talend.repository.nosql.model.INoSQLSchemaNode 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.INoSQLSchemaNode 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.INoSQLSchemaNode 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.model.INoSQLSchemaNode in project tbd-studio-se by Talend.
the class MongoDBMetadataProvider method extractColumns.
@Override
public List<MetadataColumn> extractColumns(NoSQLConnection connection, INoSQLSchemaNode node) throws NoSQLExtractSchemaException {
List<MetadataColumn> metadataColumns = new ArrayList<MetadataColumn>();
if (connection == null || node == null) {
return metadataColumns;
}
try {
if (IMongoConstants.COLLECTION.equals(node.getNodeType())) {
String dbName = null;
INoSQLSchemaNode parent = node.getParent();
if (parent != null && IMongoConstants.DATABASE.equals(parent.getNodeType())) {
dbName = parent.getName();
} else {
dbName = ConnectionContextHelper.getParamValueOffContext(connection, connection.getAttributes().get(IMongoDBAttributes.DATABASE));
}
if (dbName == null) {
return metadataColumns;
}
String collectionName = node.getName();
if (MongoDBConnectionUtil.isUpgradeLatestVersion(connection)) {
metadataColumns.addAll(extractTheColumns4Upgrade(connection, dbName, collectionName));
} else {
metadataColumns.addAll(extractTheColumns(connection, dbName, collectionName));
}
}
} catch (Exception e) {
throw new NoSQLExtractSchemaException(e);
}
return metadataColumns;
}
use of org.talend.repository.nosql.model.INoSQLSchemaNode in project tbd-studio-se by Talend.
the class AbstractNoSQLRetrieveSchemaForm method addTable.
private void addTable(TreeItem item) {
INoSQLSchemaNode node = (INoSQLSchemaNode) item.getData();
if (isExistTable(node, false)) {
MetadataTable table = getTable(node, false);
orgomg.cwm.objectmodel.core.Package pack = (orgomg.cwm.objectmodel.core.Package) table.eContainer();
boolean confirm = MessageDialog.openConfirm(Display.getDefault().getActiveShell(), // $NON-NLS-1$
Messages.getString("AbstractNoSQLRetrieveSchemaForm.confirm"), // $NON-NLS-1$
Messages.getString("AbstractNoSQLRetrieveSchemaForm.ConfirmMessage", pack.getName()));
if (confirm) {
TreeItem existItem = getExistItem(table);
if (existItem != null) {
existItem.setChecked(false);
deleteTable(existItem);
}
} else {
item.setChecked(false);
return;
}
}
if (!retrieveSchemaExecutor.isThreadRunning(node) && node.getSchemaType() == ENoSQLSchemaType.TABLE) {
RetrieveColumnRunnable runnable = new RetrieveColumnRunnable(metadataProvider, getConnection(), node, hitTablesMap) {
@Override
protected void refresh(INoSQLSchemaNode schemaNode) {
refreshTable(schemaNode);
}
};
retrieveSchemaExecutor.execute(runnable);
}
}
Aggregations