use of com.amalto.workbench.webservices.WSGetItemPKsByFullCriteria in project tmdm-studio-se by Talend.
the class DataClusterComposite method getResults.
protected LineItem[] getResults(boolean showResultInfo) {
Cursor waitCursor = null;
try {
waitCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
getSite().getShell().setCursor(waitCursor);
TMDMService service = Util.getMDMService(getXObject());
long from = -1;
long to = -1;
// $NON-NLS-1$
Pattern pattern = Pattern.compile("^\\d{4}\\d{2}\\d{2} \\d{2}:\\d{2}:\\d{2}$");
if (!"".equals(fromText.getText())) {
// $NON-NLS-1$
String dateTimeText = fromText.getText().trim();
Matcher matcher = pattern.matcher(dateTimeText);
if (!matcher.matches()) {
MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.DataClusterBrowserMainPage_21);
return new LineItem[0];
}
try {
Date d = sdf.parse(fromText.getText());
from = d.getTime();
} catch (ParseException pe) {
}
}
if (!"".equals(toText.getText())) {
// $NON-NLS-1$
String dateTimeText = toText.getText().trim();
Matcher matcher = pattern.matcher(dateTimeText);
if (!matcher.matches()) {
MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.DataClusterBrowserMainPage_23);
return new LineItem[0];
}
try {
Date d = sdf.parse(toText.getText());
to = d.getTime();
} catch (ParseException pe) {
}
}
String concept = conceptCombo.getText();
if ("*".equals(concept) | "".equals(concept)) {
// $NON-NLS-1$ //$NON-NLS-2$
concept = null;
}
if (concept != null) {
// $NON-NLS-1$//$NON-NLS-2$
concept = concept.replaceAll("\\[.*\\]", "").trim();
}
String keys = keyText.getText();
if ("*".equals(keys) | "".equals(keys)) {
// $NON-NLS-1$ //$NON-NLS-2$
keys = null;
}
boolean useFTSearch = isMaster ? checkFTSearchButton.getSelection() : false;
String search = searchText.getText();
if ("*".equals(search) | "".equals(search)) {
// $NON-NLS-1$ //$NON-NLS-2$
search = null;
}
int start = pageToolBar.getStart();
int limit = pageToolBar.getLimit();
// see 0015909
// $NON-NLS-1$
String clusterName = URLEncoder.encode(getXObject().toString(), "utf-8");
WSDataClusterPK clusterPk = new WSDataClusterPK(clusterName + getPkAddition());
// @temp yguo, get item with taskid or get taskid by specify wsitempk.
List<WSItemPKsByCriteriaResponseResults> results = service.getItemPKsByFullCriteria(new WSGetItemPKsByFullCriteria(useFTSearch, new WSGetItemPKsByCriteria(concept, search, from, null, keys, limit, start, to, clusterPk))).getResults();
if (showResultInfo && (results.size() == 1)) {
MessageDialog.openInformation(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_24, Messages.DataClusterBrowserMainPage_25);
return new LineItem[0];
}
if (results.size() == 1) {
return new LineItem[0];
}
int totalSize = 0;
List<LineItem> ress = new ArrayList<LineItem>();
for (int i = 0; i < results.size(); i++) {
WSItemPKsByCriteriaResponseResults result = results.get(i);
if (i == 0) {
totalSize = Integer.parseInt(Util.parse(result.getWsItemPK().getConceptName()).getDocumentElement().getTextContent());
continue;
}
ress.add(new LineItem(result.getDate(), result.getWsItemPK().getConceptName(), result.getWsItemPK().getIds().toArray(new String[0]), result.getTaskId()));
}
pageToolBar.setTotalsize(totalSize);
pageToolBar.refreshUI();
return ress.toArray(new LineItem[ress.size()]);
} catch (Exception e) {
log.error(e.getMessage(), e);
if ((e.getLocalizedMessage() != null) && e.getLocalizedMessage().contains("10000")) {
// $NON-NLS-1$
MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_26, Messages.DataClusterBrowserMainPage_27);
} else if (!Util.handleConnectionException(this.getSite().getShell(), e, Messages.DataClusterBrowserMainPage_28)) {
MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_28, e.getLocalizedMessage());
}
return null;
} finally {
try {
this.getSite().getShell().setCursor(null);
waitCursor.dispose();
} catch (Exception e) {
}
}
}
Aggregations