Search in sources :

Example 6 with DBDAttributeConstraint

use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.

the class FilterSettingsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText(ResultSetMessages.controls_resultset_filter_title);
    getShell().setImage(DBeaverIcons.getImage(UIIcon.FILTER));
    Composite composite = (Composite) super.createDialogArea(parent);
    TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    TreeColumn criteriaColumn;
    {
        Composite columnsGroup = UIUtils.createPlaceholder(tabFolder, 1);
        FilteredTree filteredTree = new FilteredTree(columnsGroup, SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK, new NamedObjectPatternFilter(), true) {

            @Override
            protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
                columnsViewer = new CheckboxTreeViewer(parent, style);
                return columnsViewer;
            }
        };
        columnsViewer.setContentProvider(new TreeContentProvider() {

            @Override
            public Object[] getChildren(Object parentElement) {
                final java.util.List<DBDAttributeBinding> nestedBindings = ((DBDAttributeBinding) parentElement).getNestedBindings();
                if (nestedBindings == null || nestedBindings.isEmpty()) {
                    return null;
                }
                final DBDAttributeBinding[] res = nestedBindings.toArray(new DBDAttributeBinding[0]);
                Arrays.sort(res, activeSorter);
                return res;
            }

            @Override
            public boolean hasChildren(Object element) {
                final java.util.List<DBDAttributeBinding> nestedBindings = ((DBDAttributeBinding) element).getNestedBindings();
                return nestedBindings != null && !nestedBindings.isEmpty();
            }
        });
        columnsViewer.setLabelProvider(new ColumnLabelProvider());
        columnsViewer.setCheckStateProvider(new CheckStateProvider());
        final Tree columnsTree = columnsViewer.getTree();
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        columnsTree.setLayoutData(gd);
        columnsTree.setHeaderVisible(true);
        columnsTree.setLinesVisible(true);
        UIUtils.createTreeColumn(columnsTree, SWT.LEFT, ResultSetMessages.controls_resultset_filter_column_name);
        UIUtils.createTreeColumn(columnsTree, SWT.LEFT, "#");
        UIUtils.createTreeColumn(columnsTree, SWT.LEFT, ResultSetMessages.controls_resultset_filter_column_order);
        criteriaColumn = UIUtils.createTreeColumn(columnsTree, SWT.LEFT, ResultSetMessages.controls_resultset_filter_column_criteria);
        treeEditor = new FilterSettingsTreeEditor(columnsTree);
        columnsViewer.addCheckStateListener(event -> {
            DBDAttributeConstraint constraint = getBindingConstraint((DBDAttributeBinding) event.getElement());
            constraint.setVisible(event.getChecked());
        });
        {
            ToolBar toolbar = new ToolBar(columnsGroup, SWT.HORIZONTAL | SWT.RIGHT);
            gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.verticalIndent = 3;
            toolbar.setLayoutData(gd);
            toolbar.setLayout(new FillLayout());
            moveTopButton = createToolItem(toolbar, ResultSetMessages.dialog_toolbar_move_to_top, UIIcon.ARROW_TOP, () -> {
                int selectionIndex = getSelectionIndex(columnsViewer.getTree());
                moveColumns(selectionIndex, 0);
            });
            moveTopButton.setEnabled(false);
            moveUpButton = createToolItem(toolbar, ResultSetMessages.dialog_toolbar_move_up, UIIcon.ARROW_UP, () -> {
                int selectionIndex = getSelectionIndex(columnsViewer.getTree());
                swapColumns(selectionIndex, selectionIndex - 1);
            });
            moveUpButton.setEnabled(false);
            moveDownButton = createToolItem(toolbar, ResultSetMessages.dialog_toolbar_move_down, UIIcon.ARROW_DOWN, () -> {
                int selectionIndex = getSelectionIndex(columnsViewer.getTree());
                swapColumns(selectionIndex, selectionIndex + 1);
            });
            moveDownButton.setEnabled(false);
            moveBottomButton = createToolItem(toolbar, ResultSetMessages.dialog_toolbar_move_to_bottom, UIIcon.ARROW_BOTTOM, () -> {
                int selectionIndex = getSelectionIndex(columnsViewer.getTree());
                moveColumns(selectionIndex, getItemsCount() - 1);
            });
            moveBottomButton.setEnabled(false);
            UIUtils.createToolBarSeparator(toolbar, SWT.VERTICAL);
            createToolItem(toolbar, ResultSetMessages.dialog_toolbar_sort, UIIcon.SORT, () -> {
                attributes.sort(ALPHA_SORTER);
                for (int i = 0; i < attributes.size(); i++) {
                    final DBDAttributeConstraint constraint = getBindingConstraint(attributes.get(i));
                    constraint.setVisualPosition(i);
                }
                columnsViewer.refresh();
            });
            UIUtils.createToolBarSeparator(toolbar, SWT.VERTICAL);
            ToolItem showAllButton = createToolItem(toolbar, ResultSetMessages.dialog_toolbar_show_all, null, () -> {
                for (DBDAttributeConstraint constraint : constraints) {
                    constraint.setVisible(true);
                }
                columnsViewer.refresh();
            });
            showAllButton.setImage(UIUtils.getShardImage(ISharedImages.IMG_ETOOL_DEF_PERSPECTIVE));
            ToolItem showNoneButton = createToolItem(toolbar, ResultSetMessages.dialog_toolbar_show_none, null, () -> {
                for (DBDAttributeConstraint constraint : constraints) {
                    constraint.setVisible(false);
                }
                columnsViewer.refresh();
            });
            showNoneButton.setImage(UIUtils.getShardImage(ISharedImages.IMG_ELCL_REMOVEALL));
            createToolItem(toolbar, ResultSetMessages.dialog_toolbar_reset, UIIcon.REFRESH, () -> {
                dataFilter.reset();
                constraints = new ArrayList<>(dataFilter.getConstraints());
                refreshData();
                // columnsViewer.refresh();
                // $NON-NLS-1$
                orderText.setText("");
                // $NON-NLS-1$
                whereText.setText("");
            });
            columnsViewer.addSelectionChangedListener(event -> {
                int selectionIndex = getSelectionIndex(columnsViewer.getTree());
                moveTopButton.setEnabled(selectionIndex > 0);
                moveUpButton.setEnabled(selectionIndex > 0);
                moveDownButton.setEnabled(selectionIndex >= 0 && selectionIndex < getItemsCount() - 1);
                moveBottomButton.setEnabled(selectionIndex >= 0 && selectionIndex < getItemsCount() - 1);
            });
        }
        TabItem libsTab = new TabItem(tabFolder, SWT.NONE);
        libsTab.setText(ResultSetMessages.controls_resultset_filter_group_columns);
        libsTab.setToolTipText("Set criteria and order for individual column(s)");
        libsTab.setControl(columnsGroup);
    }
    createCustomFilters(tabFolder);
    // Fill columns
    columnsViewer.setInput(attributes);
    refreshData();
    // Pack UI
    UIUtils.asyncExec(() -> UIUtils.packColumns(columnsViewer.getTree(), true, new float[] { .45f, .05f, .05f, .45f }));
    if (criteriaColumn.getWidth() < 200) {
        criteriaColumn.setWidth(200);
    }
    if (!resultSetViewer.supportsDataFilter()) {
        Label warnLabel = new Label(composite, SWT.NONE);
        warnLabel.setText(ResultSetMessages.controls_resultset_filter_warning_custom_order_disabled);
        warnLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
    }
    return parent;
}
Also used : java.util(java.util) Image(org.eclipse.swt.graphics.Image) CustomTreeEditor(org.jkiss.dbeaver.ui.controls.CustomTreeEditor) ControlEnableState(org.eclipse.jface.dialogs.ControlEnableState) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Nullable(org.jkiss.code.Nullable) DBDDataFilter(org.jkiss.dbeaver.model.data.DBDDataFilter) DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) NotNull(org.jkiss.code.NotNull) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) DBeaverIcons(org.jkiss.dbeaver.ui.DBeaverIcons) UIUtils(org.jkiss.dbeaver.ui.UIUtils) UIIcon(org.jkiss.dbeaver.ui.UIIcon) ResultSetMessages(org.jkiss.dbeaver.ui.controls.resultset.internal.ResultSetMessages) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) HelpEnabledDialog(org.jkiss.dbeaver.ui.dialogs.HelpEnabledDialog) TreeContentProvider(org.jkiss.dbeaver.ui.controls.TreeContentProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) DBValueFormatting(org.jkiss.dbeaver.model.DBValueFormatting) DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) org.eclipse.swt.widgets(org.eclipse.swt.widgets) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) org.eclipse.jface.viewers(org.eclipse.jface.viewers) ISharedImages(org.eclipse.ui.ISharedImages) List(java.util.List) DBIcon(org.jkiss.dbeaver.model.DBIcon) SWT(org.eclipse.swt.SWT) IHelpContextIds(org.jkiss.dbeaver.ui.IHelpContextIds) SQLUtils(org.jkiss.dbeaver.model.sql.SQLUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridLayout(org.eclipse.swt.layout.GridLayout) NamedObjectPatternFilter(org.jkiss.dbeaver.ui.controls.NamedObjectPatternFilter) DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) NamedObjectPatternFilter(org.jkiss.dbeaver.ui.controls.NamedObjectPatternFilter) FillLayout(org.eclipse.swt.layout.FillLayout) DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) TreeContentProvider(org.jkiss.dbeaver.ui.controls.TreeContentProvider) java.util(java.util) GridData(org.eclipse.swt.layout.GridData)

Example 7 with DBDAttributeConstraint

use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.

the class SchedulerJobLogEditor method getEditorDataFilter.

@Override
protected DBDDataFilter getEditorDataFilter() {
    OracleSchedulerJob job = getDatabaseObject();
    OracleTableBase logView = getJobLogView();
    if (logView == null) {
        return null;
    }
    List<DBDAttributeConstraint> constraints = new ArrayList<>();
    try {
        DBRProgressMonitor monitor = new VoidProgressMonitor();
        OracleTableColumn ownerAttr = logView.getAttribute(monitor, "OWNER");
        if (ownerAttr != null) {
            DBDAttributeConstraint ac = new DBDAttributeConstraint(ownerAttr, ownerAttr.getOrdinalPosition());
            ac.setVisible(false);
            ac.setOperator(DBCLogicalOperator.EQUALS);
            ac.setValue(job.getOwner());
            constraints.add(ac);
        }
        OracleTableColumn jobNameAttr = logView.getAttribute(monitor, "JOB_NAME");
        if (jobNameAttr != null) {
            DBDAttributeConstraint ac = new DBDAttributeConstraint(jobNameAttr, jobNameAttr.getOrdinalPosition());
            ac.setVisible(false);
            ac.setOperator(DBCLogicalOperator.EQUALS);
            ac.setValue(job.getName());
            constraints.add(ac);
        }
        OracleTableColumn logDateAttr = logView.getAttribute(monitor, "LOG_DATE");
        if (logDateAttr != null) {
            DBDAttributeConstraint ac = new DBDAttributeConstraint(logDateAttr, logDateAttr.getOrdinalPosition());
            ac.setOrderPosition(1);
            ac.setOrderDescending(true);
            ac.setVisible(true);
            constraints.add(ac);
        }
    } catch (DBException e) {
        log.error(e);
    }
    return new DBDDataFilter(constraints);
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBDDataFilter(org.jkiss.dbeaver.model.data.DBDDataFilter) DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) ArrayList(java.util.ArrayList) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)

Example 8 with DBDAttributeConstraint

use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.

the class VirtualAttributeAddAction method run.

@Override
public void run() {
    DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(false);
    DBVEntityAttribute vAttr = new DBVEntityAttribute(vEntity, null, "vcolumn");
    if (new EditVirtualAttributePage(resultSetViewer, vAttr).edit(resultSetViewer.getControl().getShell())) {
        vAttr.setCustom(true);
        vEntity.addVirtualAttribute(vAttr);
        vEntity.persistConfiguration();
        resultSetViewer.refreshMetaData();
        DBDAttributeConstraint vAttrConstr = resultSetViewer.getModel().getDataFilter().getConstraint(vAttr, false);
        if (vAttrConstr != null) {
        }
    }
}
Also used : DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 9 with DBDAttributeConstraint

use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.

the class GenericFilterValueEdit method loadMultiValueList.

private void loadMultiValueList(@NotNull Collection<DBDLabelValuePair> values, boolean mergeResultsWithData) {
    if (tableViewer == null || tableViewer.getControl() == null || tableViewer.getControl().isDisposed()) {
        return;
    }
    Pattern pattern = null;
    if (!CommonUtils.isEmpty(filterPattern) && attribute.getDataKind() == DBPDataKind.STRING) {
        pattern = Pattern.compile(SQLUtils.makeLikePattern("%" + filterPattern + "%"), Pattern.CASE_INSENSITIVE);
    }
    // Get all values from actual RSV data
    boolean hasNulls = false;
    Map<Object, DBDLabelValuePair> rowData = new HashMap<>();
    for (DBDLabelValuePair pair : values) {
        final DBDLabelValuePair oldLabel = rowData.get(pair.getValue());
        if (oldLabel != null) {
            // Duplicate label for single key - may happen in case of composite foreign keys
            String multiLabel = oldLabel.getLabel() + "," + pair.getLabel();
            if (multiLabel.length() > 200) {
                multiLabel = multiLabel.substring(0, 200) + MULTI_KEY_LABEL;
            }
            rowData.put(pair.getValue(), new DBDLabelValuePair(multiLabel, pair.getValue()));
        } else {
            rowData.put(pair.getValue(), pair);
        }
    }
    if (mergeResultsWithData) {
        // Add values from fetched rows
        for (ResultSetRow row : viewer.getModel().getAllRows()) {
            Object cellValue = viewer.getModel().getCellValue(attribute, row);
            if (DBUtils.isNullValue(cellValue)) {
                hasNulls = true;
                continue;
            }
            if (!keyPresents(rowData, cellValue)) {
                String itemString = attribute.getValueHandler().getValueDisplayString(attribute, cellValue, DBDDisplayFormat.UI);
                rowData.put(cellValue, new DBDLabelValuePair(itemString, cellValue));
            }
        }
    }
    List<DBDLabelValuePair> sortedList = new ArrayList<>(rowData.values());
    if (pattern != null) {
        for (Iterator<DBDLabelValuePair> iter = sortedList.iterator(); iter.hasNext(); ) {
            final DBDLabelValuePair valuePair = iter.next();
            String itemString = attribute.getValueHandler().getValueDisplayString(attribute, valuePair.getValue(), DBDDisplayFormat.UI);
            if (!pattern.matcher(itemString).matches() && (valuePair.getLabel() == null || !pattern.matcher(valuePair.getLabel()).matches())) {
                iter.remove();
            }
        }
    } else if (filterPattern != null && attribute.getDataKind() == DBPDataKind.NUMERIC) {
        // Filter numeric values
        double minValue = CommonUtils.toDouble(filterPattern);
        for (Iterator<DBDLabelValuePair> iter = sortedList.iterator(); iter.hasNext(); ) {
            final DBDLabelValuePair valuePair = iter.next();
            String itemString = attribute.getValueHandler().getValueDisplayString(attribute, valuePair.getValue(), DBDDisplayFormat.EDIT);
            double itemValue = CommonUtils.toDouble(itemString);
            if (itemValue < minValue) {
                iter.remove();
            }
        }
    }
    try {
        Collections.sort(sortedList);
    } catch (Exception e) {
        // FIXME: This may happen in some crazy cases -
        // FIXME: error "Comparison method violates its general contract!" happens in case of long strings sorting
        // FIXME: Test on sakila.film.description
        log.error("Error sorting value collection", e);
    }
    if (hasNulls) {
        boolean nullPresents = false;
        for (DBDLabelValuePair val : rowData.values()) {
            if (DBUtils.isNullValue(val.getValue())) {
                nullPresents = true;
                break;
            }
        }
        if (!nullPresents) {
            sortedList.add(0, new DBDLabelValuePair(DBValueFormatting.getDefaultValueDisplayString(null, DBDDisplayFormat.UI), null));
        }
    }
    Set<Object> checkedValues = new HashSet<>();
    for (ResultSetRow row : rows) {
        Object value = viewer.getModel().getCellValue(attribute, row);
        checkedValues.add(value);
    }
    DBDAttributeConstraint constraint = viewer.getModel().getDataFilter().getConstraint(attribute);
    if (constraint != null && constraint.getOperator() == DBCLogicalOperator.IN) {
        // checkedValues.add(constraint.getValue());
        if (constraint.getValue() instanceof Object[]) {
            Collections.addAll(checkedValues, (Object[]) constraint.getValue());
        }
    }
    checkedValues.addAll(savedValues);
    tableViewer.setInput(sortedList);
    DBDLabelValuePair firstVisibleItem = null;
    if (isCheckedTable)
        for (DBDLabelValuePair row : sortedList) {
            Object cellValue = row.getValue();
            if (checkedValues.contains(cellValue)) {
                TableItem t = (TableItem) tableViewer.testFindItem(row);
                t.setChecked(true);
                // ((CheckboxTableViewer) tableViewer).setChecked(row, true);
                if (firstVisibleItem == null) {
                    firstVisibleItem = row;
                }
            }
        }
    ViewerColumnController vcc = ViewerColumnController.getFromControl(tableViewer.getTable());
    if (vcc != null) {
        vcc.repackColumns();
    } else {
        UIUtils.packColumns(tableViewer.getTable(), true);
    }
    if (firstVisibleItem != null) {
        final Widget item = tableViewer.testFindItem(firstVisibleItem);
        if (item != null) {
            tableViewer.getTable().setSelection((TableItem) item);
            tableViewer.getTable().showItem((TableItem) item);
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) ViewerColumnController(org.jkiss.dbeaver.ui.controls.ViewerColumnController) DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) ResultSetRow(org.jkiss.dbeaver.ui.controls.resultset.ResultSetRow) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBException(org.jkiss.dbeaver.DBException) DBDLabelValuePair(org.jkiss.dbeaver.model.data.DBDLabelValuePair)

Example 10 with DBDAttributeConstraint

use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.

the class SearchDataQuery method findRows.

private DBCStatistics findRows(@NotNull DBCSession session, @NotNull DBSDataContainer dataContainer, @NotNull TestDataReceiver dataReceiver) throws DBCException {
    DBSEntity entity;
    if (dataContainer instanceof DBSEntity) {
        entity = (DBSEntity) dataContainer;
    } else {
        log.warn("Data container " + dataContainer + " isn't entity");
        return null;
    }
    try {
        List<DBDAttributeConstraint> constraints = new ArrayList<>();
        for (DBSEntityAttribute attribute : CommonUtils.safeCollection(entity.getAttributes(session.getProgressMonitor()))) {
            if (params.fastSearch) {
                if (DBUtils.findAttributeIndex(session.getProgressMonitor(), attribute) == null) {
                    continue;
                }
            }
            if (DBUtils.isPseudoAttribute(attribute) || DBUtils.isHiddenObject(attribute)) {
                continue;
            }
            DBCLogicalOperator[] supportedOperators = DBUtils.getAttributeOperators(attribute);
            DBCLogicalOperator operator;
            Object value;
            switch(attribute.getDataKind()) {
                case BOOLEAN:
                    continue;
                case NUMERIC:
                    if (!params.searchNumbers) {
                        continue;
                    }
                    if (!ArrayUtils.contains(supportedOperators, DBCLogicalOperator.EQUALS)) {
                        continue;
                    }
                    operator = DBCLogicalOperator.EQUALS;
                    try {
                        value = Integer.valueOf(params.searchString);
                    } catch (NumberFormatException e) {
                        try {
                            value = Long.valueOf(params.searchString);
                        } catch (NumberFormatException e1) {
                            try {
                                value = Double.valueOf(params.searchString);
                            } catch (NumberFormatException e2) {
                                try {
                                    value = new BigDecimal(params.searchString);
                                } catch (Exception e3) {
                                    // Not a number
                                    continue;
                                }
                            }
                        }
                    }
                    break;
                case CONTENT:
                case BINARY:
                    if (!params.searchLOBs) {
                        continue;
                    }
                case STRING:
                    if (!params.isCaseSensitive() && ArrayUtils.contains(supportedOperators, DBCLogicalOperator.ILIKE)) {
                        operator = DBCLogicalOperator.ILIKE;
                        value = "%" + params.searchString + "%";
                    } else if (ArrayUtils.contains(supportedOperators, DBCLogicalOperator.LIKE)) {
                        operator = DBCLogicalOperator.LIKE;
                        value = "%" + params.searchString + "%";
                    } else if (ArrayUtils.contains(supportedOperators, DBCLogicalOperator.EQUALS)) {
                        operator = DBCLogicalOperator.EQUALS;
                        value = params.searchString;
                    } else {
                        continue;
                    }
                    break;
                default:
                    {
                        // On success search by exact match
                        if (!ArrayUtils.contains(supportedOperators, DBCLogicalOperator.EQUALS)) {
                            continue;
                        }
                        String typeName = attribute.getTypeName();
                        if (typeName.equals(DBConstants.TYPE_NAME_UUID) || typeName.equals(DBConstants.TYPE_NAME_UUID2)) {
                            try {
                                UUID uuid = UUID.fromString(params.searchString);
                                operator = DBCLogicalOperator.EQUALS;
                                value = uuid.toString();
                            } catch (Exception e) {
                                // No a UUID
                                continue;
                            }
                        } else {
                            continue;
                        }
                    }
            }
            DBDAttributeConstraint constraint = new DBDAttributeConstraint(attribute, constraints.size());
            constraint.setOperator(operator);
            constraint.setValue(value);
            constraint.setVisible(true);
            constraints.add(constraint);
        }
        if (constraints.isEmpty()) {
            return null;
        }
        dataReceiver.filter = new DBDDataFilter(constraints);
        dataReceiver.filter.setAnyConstraint(true);
        DBCExecutionSource searchSource = new AbstractExecutionSource(dataContainer, session.getExecutionContext(), this);
        return dataContainer.readData(searchSource, session, dataReceiver, dataReceiver.filter, -1, -1, 0, 0);
    } catch (DBException e) {
        throw new DBCException("Error finding rows", e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) BigDecimal(java.math.BigDecimal) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) DBException(org.jkiss.dbeaver.DBException) DBDDataFilter(org.jkiss.dbeaver.model.data.DBDDataFilter) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) AbstractExecutionSource(org.jkiss.dbeaver.model.impl.AbstractExecutionSource) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity)

Aggregations

DBDAttributeConstraint (org.jkiss.dbeaver.model.data.DBDAttributeConstraint)28 DBDDataFilter (org.jkiss.dbeaver.model.data.DBDDataFilter)13 DBException (org.jkiss.dbeaver.DBException)7 Expression (net.sf.jsqlparser.expression.Expression)4 AndExpression (net.sf.jsqlparser.expression.operators.conditional.AndExpression)4 Table (net.sf.jsqlparser.schema.Table)4 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)4 ArrayList (java.util.ArrayList)3 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)3 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 java.util (java.util)2 List (java.util.List)2 Pattern (java.util.regex.Pattern)2 ControlEnableState (org.eclipse.jface.dialogs.ControlEnableState)2 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 org.eclipse.jface.viewers (org.eclipse.jface.viewers)2 SWT (org.eclipse.swt.SWT)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2