Search in sources :

Example 6 with INoSQLSchemaNode

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();
                    }
                }
            }
        }
    }
}
Also used : INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) ENoSQLSchemaType(org.talend.repository.nosql.model.ENoSQLSchemaType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 7 with INoSQLSchemaNode

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);
    }
}
Also used : LabelledText(org.talend.commons.ui.swt.formtools.LabelledText) ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) NoSQLSelectorTreeViewerProvider(org.talend.repository.nosql.ui.provider.NoSQLSelectorTreeViewerProvider) Group(org.eclipse.swt.widgets.Group) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) NoSQLExtractSchemaException(org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)

Example 8 with INoSQLSchemaNode

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;
}
Also used : INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode)

Example 9 with INoSQLSchemaNode

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);
        }
    }
}
Also used : NoSQLSchemaNode(org.talend.repository.nosql.model.NoSQLSchemaNode) INoSQLSchemaNode(org.talend.repository.nosql.model.INoSQLSchemaNode)

Example 10 with INoSQLSchemaNode

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

Aggregations

INoSQLSchemaNode (org.talend.repository.nosql.model.INoSQLSchemaNode)17 ArrayList (java.util.ArrayList)6 NoSQLExtractSchemaException (org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)6 TreeItem (org.eclipse.swt.widgets.TreeItem)5 NoSQLSchemaNode (org.talend.repository.nosql.model.NoSQLSchemaNode)5 NoSQLServerException (org.talend.repository.nosql.exceptions.NoSQLServerException)4 ENoSQLSchemaType (org.talend.repository.nosql.model.ENoSQLSchemaType)3 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)2 RetrieveColumnRunnable (org.talend.repository.nosql.ui.thread.RetrieveColumnRunnable)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 TreeColumnLayout (org.eclipse.jface.layout.TreeColumnLayout)1 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1