Search in sources :

Example 1 with WSStringArray

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

the class DataClusterComposite method refreshData.

protected boolean refreshData() {
    try {
        if (conceptCombo.isDisposed()) {
            return false;
        }
        if (getXObject().getEndpointAddress() == null) {
            return false;
        }
        TMDMService service = Util.getMDMService(getXObject());
        WSDataCluster cluster = null;
        if (getXObject().getWsObject() == null) {
            // then fetch from server
            cluster = service.getDataCluster(new WSGetDataCluster((WSDataClusterPK) getXObject().getWsKey()));
            getXObject().setWsObject(cluster);
        } else {
            // it has been opened by an editor - use the object there
            // added for TMDM-3064
            // the following may throw ServerException to identify the data continer not exist on the server
            cluster = service.getDataCluster(new WSGetDataCluster(new WSDataClusterPK(getXObject().getName())));
            // if you could go to next line, that means the data container is on the server specified
            cluster = (WSDataCluster) getXObject().getWsObject();
        }
        // add by myli; fix the bug:0013077: if the data is too much, just get the entities from the model instead
        // of from the container.
        // $NON-NLS-1$
        String clusterName = URLEncoder.encode(cluster.getName(), "utf-8");
        // WSString countStr = port.count(new WSCount(new WSDataClusterPK(cluster.getName()), "*", null, 100)); //$NON-NLS-1$
        // long count = Long.parseLong(countStr.getValue());
        WSStringArray conceptsInDataCluster = service.getConceptsInDataCluster(new WSGetConceptsInDataCluster(new WSDataClusterPK(clusterName)));
        if (conceptsInDataCluster != null) {
            List<String> concepts = conceptsInDataCluster.getStrings();
            conceptCombo.removeAll();
            // $NON-NLS-1$
            conceptCombo.add("*");
            for (String concept : concepts) {
                conceptCombo.add(concept);
            }
        } else {
            boolean selected = doSelectDataModelForEntityRecords(clusterName);
            if (!selected) {
                return false;
            }
        }
        conceptCombo.select(0);
        searchText.setFocus();
    } catch (ServerException e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(getSite().getShell(), Messages._Error, Messages.DataClusterBrowser_dataContainerError);
        return false;
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException(getSite().getShell(), e, null)) {
            MessageDialog.openError(getSite().getShell(), Messages._Error, Messages.DataClusterBrowser_connectionError);
        }
        return false;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages._Error, Messages.bind(Messages.DataClusterBrowser_error, e.getLocalizedMessage()));
        return false;
    }
    return true;
}
Also used : WSStringArray(com.amalto.workbench.webservices.WSStringArray) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) ServerException(java.rmi.ServerException) WSGetConceptsInDataCluster(com.amalto.workbench.webservices.WSGetConceptsInDataCluster) WebServiceException(javax.xml.ws.WebServiceException) TMDMService(com.amalto.workbench.webservices.TMDMService) XtentisException(com.amalto.workbench.utils.XtentisException) ServerException(java.rmi.ServerException) ParseException(java.text.ParseException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WebServiceException(javax.xml.ws.WebServiceException) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster)

Example 2 with WSStringArray

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

the class StoredProcedureMainPage method executeProcedure.

protected void executeProcedure() {
    boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
    if (!checkMissingJar) {
        return;
    }
    BusyIndicator.showWhile(this.getPartControl().getDisplay(), new Runnable() {

        public void run() {
            WSDataClusterPK dcpk = null;
            if (!"[ALL]".equals(dataClusterCombo.getText())) {
                dcpk = new WSDataClusterPK(dataClusterCombo.getText());
            }
            try {
                String proc = procedureViewer.getDocument().get();
                // read parameters
                int number = 0;
                while (true) {
                    // $NON-NLS-1$//$NON-NLS-2$
                    Pattern p = Pattern.compile(".*[^\\\\]%" + number + "[^\\d]*.*", Pattern.DOTALL);
                    Matcher m = p.matcher(proc);
                    if (!m.matches()) {
                        break;
                    } else {
                        ++number;
                    }
                }
                String[] ps = null;
                if (number > 0) {
                    // transfer current parameters to new array
                    ps = new String[number];
                    for (int i = 0; i < number; i++) {
                        if (i < currentParameters.size()) {
                            ps[i] = currentParameters.get(i);
                        } else {
                            // $NON-NLS-1$
                            ps[i] = "";
                        }
                    }
                    // call parameters window
                    QueryParametersDialog dialog = new QueryParametersDialog(StoredProcedureMainPage.this.getSite().getShell(), ps);
                    dialog.setBlockOnOpen(true);
                    dialog.open();
                    if (dialog.getButtonPressed() == QueryParametersDialog.BUTTON_CANCEL) {
                        return;
                    }
                    ps = dialog.getParameters();
                    // Apply parameters
                    for (int i = 0; i < ps.length; i++) {
                        // transfer parameters back into current parameters
                        if (i < currentParameters.size()) {
                            currentParameters.set(i, ps[i]);
                        } else {
                            currentParameters.add(ps[i]);
                        }
                    }
                }
                // perform call
                TMDMService service = getMDMService();
                if (service != null) {
                    WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
                    service.putStoredProcedure(new WSPutStoredProcedure(wsStoredProcedure));
                    WSStringArray array = service.executeStoredProcedure(new WSExecuteStoredProcedure(currentParameters, dcpk, new WSStoredProcedurePK(wsStoredProcedure.getName())));
                    List<String> results = array.getStrings();
                    resultsLabel.setText(Messages.StoredProcedureMainPage_15 + results.size() + Messages.StoredProcedureMainPage_16);
                    resultsViewer.setInput(results);
                }
            } catch (Exception ex) {
                if (!Util.handleConnectionException(StoredProcedureMainPage.this.getSite().getShell(), ex, null)) {
                    String message = ex.getMessage();
                    Set<String> messages = getMessages(message);
                    StringBuilder builder = new StringBuilder();
                    for (String currentMessage : messages) {
                        builder.append(currentMessage + '\n');
                    }
                    MessageDialog.openError(StoredProcedureMainPage.this.getSite().getShell(), Messages._Error, builder.toString());
                }
            }
        }
    });
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) WSPutStoredProcedure(com.amalto.workbench.webservices.WSPutStoredProcedure) WSStringArray(com.amalto.workbench.webservices.WSStringArray) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) QueryParametersDialog(com.amalto.workbench.dialogs.QueryParametersDialog) TMDMService(com.amalto.workbench.webservices.TMDMService) WSExecuteStoredProcedure(com.amalto.workbench.webservices.WSExecuteStoredProcedure) List(java.util.List) LinkedList(java.util.LinkedList) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure)

Example 3 with WSStringArray

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

the class DataProcessRuleFactory method createProcessRouterFromRemote.

/**
 * if using XML DB and the return records exceed limit, it will return null;
 *
 * @param port
 * @param dataClusterName
 * @return
 */
public static DataProcessRule createProcessRouterFromRemote(TMDMService service, String dataClusterName) {
    WSGetConceptsInDataCluster param = new WSGetConceptsInDataCluster(new WSDataClusterPK(dataClusterName));
    WSStringArray concepts = service.getConceptsInDataCluster(param);
    if (concepts != null) {
        DataProcessRule rule = new DataProcessRule();
        for (String concept : concepts.getStrings()) {
            rule.addNewEnityUnit(concept);
        }
        return rule;
    }
    return null;
}
Also used : WSStringArray(com.amalto.workbench.webservices.WSStringArray) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) WSGetConceptsInDataCluster(com.amalto.workbench.webservices.WSGetConceptsInDataCluster)

Aggregations

WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)3 WSStringArray (com.amalto.workbench.webservices.WSStringArray)3 TMDMService (com.amalto.workbench.webservices.TMDMService)2 WSGetConceptsInDataCluster (com.amalto.workbench.webservices.WSGetConceptsInDataCluster)2 QueryParametersDialog (com.amalto.workbench.dialogs.QueryParametersDialog)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)1 WSExecuteStoredProcedure (com.amalto.workbench.webservices.WSExecuteStoredProcedure)1 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)1 WSPutStoredProcedure (com.amalto.workbench.webservices.WSPutStoredProcedure)1 WSStoredProcedure (com.amalto.workbench.webservices.WSStoredProcedure)1 WSStoredProcedurePK (com.amalto.workbench.webservices.WSStoredProcedurePK)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ServerException (java.rmi.ServerException)1 ParseException (java.text.ParseException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 WebServiceException (javax.xml.ws.WebServiceException)1