Search in sources :

Example 1 with WSWhereItem

use of com.amalto.workbench.webservices.WSWhereItem in project tmdm-studio-se by Talend.

the class ViewBrowserMainPage method getResults.

public String[] getResults() {
    Cursor waitCursor = null;
    try {
        Display display = getEditor().getSite().getPage().getWorkbenchWindow().getWorkbench().getDisplay();
        waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
        this.getSite().getShell().setCursor(waitCursor);
        TMDMService service = getMDMService();
        java.util.List<String> results = null;
        int maxItem = 10;
        // $NON-NLS-1$ //$NON-NLS-2$
        String search = "".equals(searchText.getText()) ? "*" : searchText.getText();
        WSDataClusterPK wsDataClusterPK = new WSDataClusterPK(dataClusterCombo.getText() + getPkAddition());
        if (FULL_TEXT.equals(searchItemCombo.getText())) {
            boolean matchAllWords = matchAllWordsBtn.getSelection();
            results = service.quickSearch(new WSQuickSearch(null, matchAllWords, maxItem, null, search, 0, Integer.MAX_VALUE, wsDataClusterPK, getViewPK())).getStrings();
        } else {
            WSView wsview = (WSView) wcListViewer.getInput();
            java.util.List<WSWhereCondition> array = wsview.getWhereConditions();
            java.util.List<WSWhereItem> conditions = new ArrayList<WSWhereItem>();
            for (WSWhereCondition condition : array) {
                WSWhereItem item = new WSWhereItem(null, condition, null);
                conditions.add(item);
            }
            WSWhereCondition condition = new WSWhereCondition(searchItemCombo.getText(), WSWhereOperator.CONTAINS, search, true, WSStringPredicate.AND);
            WSWhereItem item = new WSWhereItem(null, condition, null);
            conditions.add(item);
            WSWhereAnd and = new WSWhereAnd(conditions);
            WSWhereItem wi = new WSWhereItem(and, null, null);
            results = service.viewSearch(new WSViewSearch("ascending", maxItem, null, 0, -1, wi, wsDataClusterPK, getViewPK())).getStrings();
        }
        resultsLabel.setText(Messages.bind(Messages.ViewBrowserMainPage_Results, results.size() - 1));
        if (results.size() > 1) {
            return results.subList(1, results.size()).toArray(new String[0]);
        }
        return new String[0];
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if ((e.getLocalizedMessage() != null) && e.getLocalizedMessage().contains("10000")) {
            MessageDialog.openError(this.getSite().getShell(), Messages.ViewBrowserMainPage_ErrorTitle4, Messages.ViewBrowserMainPage_ErrorMsg4);
        } else if (!Util.handleConnectionException(this.getSite().getShell(), e, Messages.ViewBrowserMainPage_ErrorTitle5)) {
            MessageDialog.openError(this.getSite().getShell(), Messages.ViewBrowserMainPage_ErrorTitle5, e.getLocalizedMessage());
        }
        return null;
    } finally {
        try {
            this.getSite().getShell().setCursor(null);
            waitCursor.dispose();
        } catch (Exception e) {
        }
    }
}
Also used : WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition) ArrayList(java.util.ArrayList) WSWhereItem(com.amalto.workbench.webservices.WSWhereItem) Cursor(org.eclipse.swt.graphics.Cursor) WSView(com.amalto.workbench.webservices.WSView) WSWhereAnd(com.amalto.workbench.webservices.WSWhereAnd) XtentisException(com.amalto.workbench.utils.XtentisException) MalformedURLException(java.net.MalformedURLException) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) WSQuickSearch(com.amalto.workbench.webservices.WSQuickSearch) TMDMService(com.amalto.workbench.webservices.TMDMService) WSViewSearch(com.amalto.workbench.webservices.WSViewSearch) Display(org.eclipse.swt.widgets.Display)

Aggregations

XtentisException (com.amalto.workbench.utils.XtentisException)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1 WSQuickSearch (com.amalto.workbench.webservices.WSQuickSearch)1 WSView (com.amalto.workbench.webservices.WSView)1 WSViewSearch (com.amalto.workbench.webservices.WSViewSearch)1 WSWhereAnd (com.amalto.workbench.webservices.WSWhereAnd)1 WSWhereCondition (com.amalto.workbench.webservices.WSWhereCondition)1 WSWhereItem (com.amalto.workbench.webservices.WSWhereItem)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Cursor (org.eclipse.swt.graphics.Cursor)1 Display (org.eclipse.swt.widgets.Display)1