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) {
}
}
}
Aggregations