Search in sources :

Example 1 with WSGetItemPKsByFullCriteria

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) {
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) LineItem(com.amalto.workbench.utils.LineItem) Cursor(org.eclipse.swt.graphics.Cursor) Date(java.util.Date) XtentisException(com.amalto.workbench.utils.XtentisException) ServerException(java.rmi.ServerException) ParseException(java.text.ParseException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WebServiceException(javax.xml.ws.WebServiceException) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) ParseException(java.text.ParseException) WSGetItemPKsByFullCriteria(com.amalto.workbench.webservices.WSGetItemPKsByFullCriteria) WSGetItemPKsByCriteria(com.amalto.workbench.webservices.WSGetItemPKsByCriteria) WSItemPKsByCriteriaResponseResults(com.amalto.workbench.webservices.WSItemPKsByCriteriaResponseResults)

Aggregations

LineItem (com.amalto.workbench.utils.LineItem)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1 WSGetItemPKsByCriteria (com.amalto.workbench.webservices.WSGetItemPKsByCriteria)1 WSGetItemPKsByFullCriteria (com.amalto.workbench.webservices.WSGetItemPKsByFullCriteria)1 WSItemPKsByCriteriaResponseResults (com.amalto.workbench.webservices.WSItemPKsByCriteriaResponseResults)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ServerException (java.rmi.ServerException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 WebServiceException (javax.xml.ws.WebServiceException)1 Cursor (org.eclipse.swt.graphics.Cursor)1