use of com.amalto.workbench.webservices.WSGetItemPKsByCriteria 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) {
}
}
}
use of com.amalto.workbench.webservices.WSGetItemPKsByCriteria in project tmdm-studio-se by Talend.
the class ExportItemsWizard method exportCluster.
protected TreeObject exportCluster(List<TreeObject> exports, WSDataClusterPK pk, TMDMService service) {
String encodedID = null;
try {
List<String> items1 = new ArrayList<String>();
List<WSItemPKsByCriteriaResponseResults> results = service.getItemPKsByCriteria(new WSGetItemPKsByCriteria(null, encodedID, (long) -1, encodedID, encodedID, Integer.MAX_VALUE, 0, (long) -1, pk)).getResults();
if (results == null) {
return null;
}
for (WSItemPKsByCriteriaResponseResults item : results) {
if (item.getWsItemPK().getIds() == null) {
continue;
}
WSItem wsitem = service.getItem(new WSGetItem(item.getWsItemPK()));
// Marshal
StringWriter sw1 = new StringWriter();
Marshaller.marshal(wsitem, sw1);
// $NON-NLS-1$
String uniqueId = pk.getPk() + "." + wsitem.getConceptName();
for (String id : wsitem.getIds()) {
// $NON-NLS-1$
uniqueId = uniqueId + "." + id;
}
// $NON-NLS-1$
encodedID = URLEncoder.encode(uniqueId, "UTF-8");
// $NON-NLS-1$//$NON-NLS-2$
writeString(sw1.toString(), TreeObject.DATACONTAINER_COTENTS + "/" + pk.getPk() + "/" + encodedID);
// $NON-NLS-1$//$NON-NLS-2$
items1.add(TreeObject.DATACONTAINER_COTENTS + "/" + pk.getPk() + "/" + encodedID);
}
TreeObject obj1 = new TreeObject(pk.getPk(), null, TreeObject.DATA_CLUSTER_CONTENTS, null, null);
obj1.setItems(items1.toArray(new String[items1.size()]));
exports.add(obj1);
return obj1;
} catch (Exception e) {
}
return null;
}
Aggregations