use of org.talend.repository.nosql.model.INoSQLSchemaNode in project tbd-studio-se by Talend.
the class AbstractNoSQLRetrieveSchemaForm method udpateItemsStatus.
private void udpateItemsStatus(TreeItem treeItem, Map<TreeItem, AtomicInteger> checkedDBMap) {
Object data = treeItem.getData();
if (treeItem != null && data != null) {
INoSQLSchemaNode node = (INoSQLSchemaNode) treeItem.getData();
ENoSQLSchemaType schemaType = node.getSchemaType();
if (ENoSQLSchemaType.DATABASE.equals(schemaType)) {
AtomicInteger checkedCount = checkedDBMap.get(treeItem);
if (checkedCount == null) {
checkedDBMap.put(treeItem, new AtomicInteger(0));
}
schemaViewer.expandToLevel(node, 1);
for (TreeItem item : treeItem.getItems()) {
udpateItemsStatus(item, checkedDBMap);
}
} else if (ENoSQLSchemaType.TABLE.equals(schemaType)) {
boolean existTable = isExistTable(node, true);
if (!existTable) {
clearItemStatus(node);
}
schemaViewer.setChecked(node, existTable);
if (treeItem.getChecked()) {
TreeItem dbItem = getDBItem(treeItem);
if (dbItem != null) {
AtomicInteger checkedCount = checkedDBMap.get(dbItem);
if (checkedCount != null) {
checkedCount.incrementAndGet();
}
}
}
}
}
}
use of org.talend.repository.nosql.model.INoSQLSchemaNode in project tbd-studio-se by Talend.
the class AbstractNoSQLRetrieveSchemaForm method addSchemaFields.
protected void addSchemaFields(Composite parent) {
// $NON-NLS-1$
Group schemaGroup = Form.createGroup(parent, 1, Messages.getString("AbstractNoSQLRetrieveSchemaForm.schemaGroup"));
Composite filterComposite = new Composite(schemaGroup, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false);
filterComposite.setLayout(gridLayout);
GridData filterCompGridData = new GridData(GridData.FILL_HORIZONTAL);
filterComposite.setLayoutData(filterCompGridData);
// $NON-NLS-1$
filterText = new LabelledText(filterComposite, Messages.getString("AbstractNoSQLRetrieveSchemaForm.nameFilter"), 1);
ScrolledComposite scrolledComposite = new ScrolledComposite(schemaGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NONE);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
schemaViewer = new ContainerCheckedTreeViewer(scrolledComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION) {
@Override
protected void doCheckStateChanged(Object element) {
super.doCheckStateChanged(element);
performCheckStateChanged((INoSQLSchemaNode) element);
}
};
schemaViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
schemaViewer.setUseHashlookup(true);
schemaViewer.addFilter(new SchemaViewerFilter());
schemaTree = schemaViewer.getTree();
schemaTree.setHeaderVisible(true);
schemaTree.setLinesVisible(true);
scrolledComposite.setContent(schemaTree);
scrolledComposite.setMinSize(schemaTree.computeSize(SWT.DEFAULT, SWT.DEFAULT));
TreeColumnLayout tcLayout = new TreeColumnLayout();
scrolledComposite.setLayout(tcLayout);
TreeColumn column1 = new TreeColumn(schemaTree, SWT.LEFT);
// $NON-NLS-1$
column1.setText(Messages.getString("AbstractNoSQLRetrieveSchemaForm.name"));
column1.setWidth(300);
column1.setResizable(true);
tcLayout.setColumnData(column1, new ColumnWeightData(40, 150));
TreeColumn column2 = new TreeColumn(schemaTree, SWT.LEFT);
// $NON-NLS-1$
column2.setText(Messages.getString("AbstractNoSQLRetrieveSchemaForm.type"));
column2.setWidth(150);
column2.setResizable(true);
tcLayout.setColumnData(column2, new ColumnWeightData(25, 100));
TreeColumn column3 = new TreeColumn(schemaTree, SWT.LEFT);
// $NON-NLS-1$
column3.setText(Messages.getString("AbstractNoSQLRetrieveSchemaForm.colNum"));
column3.setWidth(130);
column3.setResizable(true);
tcLayout.setColumnData(column3, new ColumnWeightData(20, 50));
TreeColumn column4 = new TreeColumn(schemaTree, SWT.LEFT);
// $NON-NLS-1$
column4.setText(Messages.getString("AbstractNoSQLRetrieveSchemaForm.creationStauts"));
column4.setWidth(120);
column4.setResizable(true);
tcLayout.setColumnData(column4, new ColumnWeightData(15, 70));
try {
List<INoSQLSchemaNode> nodes = wizardPageProvider.createSchemaNodes(getConnection());
NoSQLSelectorTreeViewerProvider viewProvider = new NoSQLSelectorTreeViewerProvider();
schemaViewer.setContentProvider(viewProvider);
schemaViewer.setLabelProvider(viewProvider);
schemaViewer.setInput(nodes);
} catch (NoSQLExtractSchemaException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.repository.nosql.model.INoSQLSchemaNode in project tbd-studio-se by Talend.
the class NoSQLSelectorTreeViewerProvider method getColumnText.
@Override
public String getColumnText(Object element, int columnIndex) {
INoSQLSchemaNode node = (INoSQLSchemaNode) element;
if (columnIndex == 0) {
return node.getName();
}
if (columnIndex == 1) {
return node.getNodeType();
}
boolean isRetrievedTable = node.getSchemaType() == ENoSQLSchemaType.TABLE && node.isRetrieved();
if (columnIndex == 2 && isRetrievedTable) {
return String.valueOf(node.getColNum());
}
if (columnIndex == 3 && isRetrievedTable) {
return node.getStatus();
}
return INoSQLSchemaNode.EMPTY_STR;
}
use of org.talend.repository.nosql.model.INoSQLSchemaNode 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.INoSQLSchemaNode in project tbd-studio-se by Talend.
the class CassandraMetadataProvider method extractColumns.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.nosql.metadata.AbstractMetadataProvider#extractColumns(org.talend.repository.model.nosql
* .NoSQLConnection, org.talend.repository.nosql.model.INoSQLSchemaNode)
*/
@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 (ICassandraConstants.COLUMN_FAMILY.equals(node.getNodeType()) || ICassandraConstants.SUPER_COLUMN_FAMILY.equals(node.getNodeType())) {
String dbName = null;
INoSQLSchemaNode parent = node.getParent();
if (parent != null && ICassandraConstants.KEY_SPACE.equals(parent.getNodeType())) {
dbName = parent.getName();
} else {
dbName = connection.getAttributes().get(ICassandraAttributies.DATABASE);
}
if (dbName == null) {
return metadataColumns;
}
String collectionName = node.getName();
metadataColumns.addAll(extractTheColumns(connection, dbName, collectionName));
}
} catch (Exception e) {
throw new NoSQLExtractSchemaException(e);
}
return metadataColumns;
}
Aggregations