Search in sources :

Example 11 with WSDataClusterPK

use of com.amalto.workbench.webservices.WSDataClusterPK 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 12 with WSDataClusterPK

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

the class ViewBrowserMainPage method refreshData.

// createCharacteristicsContent
@Override
protected void refreshData() {
    try {
        if (viewableBEsList.isDisposed() || searchableBEsList.isDisposed() || wcListViewer.getList().isDisposed() || searchItemCombo.isDisposed() || dataClusterCombo.isDisposed()) {
            return;
        }
        WSView view = null;
        if (getXObject().getWsObject() == null) {
            // then fetch from server
            TMDMService port = getMDMService();
            view = port.getView(new WSGetView((WSViewPK) getXObject().getWsKey()));
            getXObject().setWsObject(view);
        } else {
            // it has been opened by an editor - use the object there
            view = (WSView) getXObject().getWsObject();
        }
        java.util.List<String> paths = view.getViewableBusinessElements();
        // Fill the vbe List
        viewableBEsList.removeAll();
        for (String path : paths) {
            viewableBEsList.add(path);
        }
        paths = view.getSearchableBusinessElements();
        searchableBEsList.removeAll();
        searchItemCombo.removeAll();
        if (paths != null) {
            for (String path : paths) {
                searchableBEsList.add(path);
                searchItemCombo.add(path);
            }
        }
        searchItemCombo.add(FULL_TEXT);
        searchItemCombo.setText(FULL_TEXT);
        wcListViewer.setInput(view);
        wcListViewer.refresh();
        dataClusterCombo.removeAll();
        java.util.List<WSDataClusterPK> dataClusterPKs = getDataClusterPKs();
        if ((dataClusterPKs == null) || (dataClusterPKs.size() == 0)) {
            MessageDialog.openError(this.getSite().getShell(), Messages._Error, Messages.ViewBrowserMainPage_ErrorMsg1);
            return;
        }
        for (WSDataClusterPK pk : dataClusterPKs) {
            dataClusterCombo.add(pk.getPk());
        }
        dataClusterCombo.select(0);
        clusterTypeCombo.setItems(getClusterTypes());
        clusterTypeCombo.select(0);
        this.getManagedForm().reflow(true);
        searchText.setFocus();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException(this.getSite().getShell(), e, Messages.ViewBrowserMainPage_ErrorTitle2)) {
            MessageDialog.openError(this.getSite().getShell(), Messages.ViewBrowserMainPage_ErrorTitle2, Messages.bind(Messages.ViewBrowserMainPage_ErrorMsg2, e.getLocalizedMessage()));
        }
    }
}
Also used : WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) WSGetView(com.amalto.workbench.webservices.WSGetView) WSView(com.amalto.workbench.webservices.WSView) XtentisException(com.amalto.workbench.utils.XtentisException) MalformedURLException(java.net.MalformedURLException)

Example 13 with WSDataClusterPK

use of com.amalto.workbench.webservices.WSDataClusterPK 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) {
        }
    }
}
Also used : WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition) ArrayList(java.util.ArrayList) WSWhereItem(com.amalto.workbench.webservices.WSWhereItem) Cursor(org.eclipse.swt.graphics.Cursor) WSView(com.amalto.workbench.webservices.WSView) WSWhereAnd(com.amalto.workbench.webservices.WSWhereAnd) XtentisException(com.amalto.workbench.utils.XtentisException) MalformedURLException(java.net.MalformedURLException) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) WSQuickSearch(com.amalto.workbench.webservices.WSQuickSearch) TMDMService(com.amalto.workbench.webservices.TMDMService) WSViewSearch(com.amalto.workbench.webservices.WSViewSearch) Display(org.eclipse.swt.widgets.Display)

Example 14 with WSDataClusterPK

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

the class ExportItemsWizard method doexport.

public void doexport(Object[] selectedObjs, IProgressMonitor monitor) {
    TreeObject[] objs = null;
    if (selectedObjs.length > 0 && selectedObjs[0] instanceof TreeObject) {
        objs = Arrays.asList(selectedObjs).toArray(new TreeObject[0]);
    }
    if (objs == null || objs.length == 0) {
        return;
    }
    monitor.beginTask(Messages.ExportItemsWizard_Export, IProgressMonitor.UNKNOWN);
    Exports eps = new Exports();
    List<TreeObject> exports = new ArrayList<TreeObject>();
    TMDMService service;
    try {
        service = Util.getMDMService(objs[0]);
        try {
            LocalTreeObjectRepository.getInstance().parseElementForOutput(objs);
        } catch (Exception e) {
        }
        for (TreeObject obj : objs) {
            StringWriter sw;
            ArrayList<String> items;
            String encodedID = null;
            switch(obj.getType()) {
                case TreeObject.DATA_CLUSTER:
                    monitor.subTask(Messages.ExportItemsWizard_2);
                    items = new ArrayList<String>();
                    // dataclusters
                    WSDataClusterPK pk = (WSDataClusterPK) obj.getWsKey();
                    try {
                        WSDataCluster cluster = service.getDataCluster(new WSGetDataCluster(pk));
                        // Marshal
                        sw = new StringWriter();
                        Marshaller.marshal(cluster, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(cluster.getName(), "UTF-8");
                        // $NON-NLS-1$
                        writeString(sw.toString(), TreeObject.DATACONTAINER + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.DATACONTAINER + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                    }
                    monitor.worked(1);
                    // datacluster contents
                    monitor.subTask(Messages.bind(Messages.ExportItemsWizard_3, pk.getPk()));
                    exportCluster(exports, pk, service);
                    monitor.worked(1);
                    break;
                case TreeObject.DATA_MODEL:
                    monitor.subTask(Messages.ExportItemsWizard_5);
                    items = new ArrayList<String>();
                    // datamodels
                    try {
                        WSDataModel model = service.getDataModel(new WSGetDataModel((WSDataModelPK) obj.getWsKey()));
                        sw = new StringWriter();
                        Marshaller.marshal(model, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(model.getName(), "UTF-8");
                        // $NON-NLS-1$
                        writeString(sw.toString(), TreeObject.DATAMODEL_ + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.DATAMODEL_ + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                    }
                    monitor.worked(1);
                    break;
                case TreeObject.MENU:
                    monitor.subTask(Messages.ExportItemsWizard_6);
                    // ExportItem exportItem=new ExportItem();
                    items = new ArrayList<String>();
                    // menu
                    try {
                        WSMenu menu = service.getMenu(new WSGetMenu((WSMenuPK) obj.getWsKey()));
                        // Marshal
                        sw = new StringWriter();
                        Marshaller.marshal(menu, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(menu.getName(), "UTF-8");
                        // $NON-NLS-1$
                        writeString(sw.toString(), TreeObject.MENU_ + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.MENU_ + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                    }
                    monitor.worked(1);
                    break;
                case TreeObject.PICTURES_RESOURCE:
                    monitor.subTask(Messages.ExportItemsWizard_7);
                    // ExportItem exportItem=new ExportItem();
                    items = new ArrayList<String>();
                    // picture
                    try {
                        String endpointIpAddress = obj.getEndpointIpAddress();
                        // $NON-NLS-1$
                        int index = endpointIpAddress.indexOf("/services/soap");
                        if (index != -1) {
                            endpointIpAddress = endpointIpAddress.substring(0, index);
                        }
                        String picUrl = endpointIpAddress + ResourcesUtil.getResourcesMapFromURI(endpointIpAddress + TreeObject.PICTURES_URI, objs[0]).get(obj.getDisplayName());
                        // Marshal
                        sw = new StringWriter();
                        byte[] content = HttpClientUtil.getByteArrayContentByHttpget(picUrl);
                        Marshaller.marshal(content, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(obj.getDisplayName(), "UTF-8");
                        // $NON-NLS-1$
                        writeInputStream(new ByteArrayInputStream(content), TreeObject.PICTURES_ + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.PICTURES_ + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                    monitor.worked(1);
                    break;
                case TreeObject.ROUTING_RULE:
                    monitor.subTask(Messages.ExportItemsWizard_10);
                    // ExportItem exportItem=new ExportItem();
                    items = new ArrayList<String>();
                    // routing rule
                    try {
                        WSRoutingRule RoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) obj.getWsKey()));
                        // Marshal
                        sw = new StringWriter();
                        Marshaller.marshal(RoutingRule, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(RoutingRule.getName(), "UTF-8");
                        // $NON-NLS-1$
                        writeString(sw.toString(), TreeObject.ROUTINGRULE_ + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.ROUTINGRULE_ + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                    }
                    monitor.worked(1);
                    break;
                case TreeObject.STORED_PROCEDURE:
                    monitor.subTask(Messages.ExportItemsWizard_11);
                    items = new ArrayList<String>();
                    // stored procedure
                    try {
                        WSStoredProcedure StoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) obj.getWsKey()));
                        // Marshal
                        sw = new StringWriter();
                        Marshaller.marshal(StoredProcedure, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(StoredProcedure.getName(), "UTF-8");
                        // $NON-NLS-1$
                        writeString(sw.toString(), TreeObject.STOREDPROCEDURE_ + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.STOREDPROCEDURE_ + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                    }
                    monitor.worked(1);
                    break;
                case TreeObject.TRANSFORMER:
                    monitor.subTask(Messages.ExportItemsWizard_13);
                    items = new ArrayList<String>();
                    // TODO:check the pk
                    try {
                        WSTransformerV2 transformer = service.getTransformerV2(new WSGetTransformerV2(new WSTransformerV2PK(((WSTransformerV2PK) obj.getWsKey()).getPk())));
                        // Marshal
                        sw = new StringWriter();
                        Marshaller.marshal(transformer, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(transformer.getName(), "UTF-8");
                        // $NON-NLS-1$
                        writeString(sw.toString(), TreeObject.TRANSFORMER_ + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.TRANSFORMER_ + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                    }
                    monitor.worked(1);
                    break;
                case TreeObject.VIEW:
                    monitor.subTask(Messages.ExportItemsWizard_15);
                    items = new ArrayList<String>();
                    // view
                    try {
                        WSView View = service.getView(new WSGetView((WSViewPK) obj.getWsKey()));
                        // Marshal
                        sw = new StringWriter();
                        Marshaller.marshal(View, sw);
                        // $NON-NLS-1$
                        encodedID = URLEncoder.encode(View.getName(), "UTF-8");
                        // $NON-NLS-1$
                        writeString(sw.toString(), TreeObject.VIEW_ + "/" + encodedID);
                        // $NON-NLS-1$
                        items.add(TreeObject.VIEW_ + "/" + encodedID);
                        obj.setItems(items.toArray(new String[items.size()]));
                        exports.add(obj);
                    } catch (Exception e) {
                    }
                    monitor.worked(1);
                    break;
                default:
                    IExportItemsWizardAdapter exAdapter = ExAdapterManager.getAdapter(this, IExportItemsWizardAdapter.class);
                    if (exAdapter != null) {
                        exAdapter.doexport(service, obj.getType(), exports, obj, monitor);
                    }
                    break;
            }
        }
        // store the content xml
        eps.setItems(exports.toArray(new TreeObject[exports.size()]));
        eps.setSchemas(LocalTreeObjectRepository.getInstance().outPutSchemas());
        // export autoincrement
        try {
            WSAutoIncrement auto = service.getAutoIncrement(null);
            if (auto != null && auto.getAutoincrement() != null) {
                eps.setAutoIncrement(auto.getAutoincrement());
            }
        } catch (Exception e) {
        }
        StringWriter sw = new StringWriter();
        try {
            Marshaller.marshal(eps, sw);
            // $NON-NLS-1$
            writeString(sw.toString(), "exportitems.xml");
        } catch (Exception e) {
        }
        monitor.done();
    } catch (Exception e) {
    }
}
Also used : WSGetStoredProcedure(com.amalto.workbench.webservices.WSGetStoredProcedure) WSAutoIncrement(com.amalto.workbench.webservices.WSAutoIncrement) WSMenuPK(com.amalto.workbench.webservices.WSMenuPK) WSGetTransformerV2(com.amalto.workbench.webservices.WSGetTransformerV2) WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) ArrayList(java.util.ArrayList) WSView(com.amalto.workbench.webservices.WSView) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) StringWriter(java.io.StringWriter) TMDMService(com.amalto.workbench.webservices.TMDMService) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) WSGetView(com.amalto.workbench.webservices.WSGetView) WSGetMenu(com.amalto.workbench.webservices.WSGetMenu) WSRoutingRulePK(com.amalto.workbench.webservices.WSRoutingRulePK) WSGetRoutingRule(com.amalto.workbench.webservices.WSGetRoutingRule) WSMenu(com.amalto.workbench.webservices.WSMenu) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) ByteArrayInputStream(java.io.ByteArrayInputStream) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) TreeObject(com.amalto.workbench.models.TreeObject) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 15 with WSDataClusterPK

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

the class XtentisServerObjectsRetriever method run.

public synchronized void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    try {
        if (password == null || password.length() == 0) {
            throw new Exception(Messages.XtentisServerObjectsRetriever_0);
        }
        monitor.beginTask(Messages.bind(Messages.XtentisServerObjectsRetriever_1, IConstants.TALEND), Messages.XtentisServerObjectsRetriever_3.equals(username) ? 12 : 9);
        // server
        serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
        (password == null ? "" : password));
        // init load category
        monitor.subTask(Messages.XtentisServerObjectsRetriever_4);
        LocalTreeObjectRepository.getInstance().startUp(endpointaddress, username, password);
        LocalTreeObjectRepository.getInstance().switchOnListening();
        LocalTreeObjectRepository.getInstance().setLazySaveStrategy(true, serverRoot);
        monitor.worked(1);
        // Access to server and get port
        TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
        // viewer user can't use studio
        service.ping(new WSPing(Messages.XtentisServerObjectsRetriever_5));
        monitor.worked(1);
        // fetch version info
        try {
            WSVersion version = service.getComponentVersion(new WSGetComponentVersion(WSComponent.DATA_MANAGER, null));
            String versionStr = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            version.getMajor() + "." + version.getMinor() + "." + version.getRevision() + "_" + version.getBuild();
            // $NON-NLS-1$
            log.info("Server version = " + versionStr);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_6);
        }
        monitor.subTask(Messages.XtentisServerObjectsRetriever_7);
        UserInfo user = new UserInfo();
        user.setUsername(username);
        user.setPassword(password);
        user.setServerUrl(endpointaddress);
        serverRoot.setUser(user);
        // String uriPre=serverRoot.getEndpointIpAddress();
        // Data Models
        TreeParent models = new TreeParent(EXtentisObjects.DataMODEL.getDisplayName(), serverRoot, TreeObject.DATA_MODEL, null, null);
        List<WSDataModelPK> xdmPKs = null;
        try {
            // $NON-NLS-1$
            xdmPKs = service.getDataModelPKs(new WSRegexDataModelPKs("")).getWsDataModelPKs();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (xdmPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_8);
            for (WSDataModelPK pk : xdmPKs) {
                String name = pk.getPk();
                if (!name.startsWith("XMLSCHEMA")) {
                    // $NON-NLS-1$
                    WSDataModel wsobj = null;
                    if (retriveWSObject) {
                        wsobj = service.getDataModel(new WSGetDataModel(pk));
                    }
                    TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_MODEL, pk, wsobj);
                    models.addChild(obj);
                }
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_9);
        }
        // DataClusters
        TreeParent dataClusters = new TreeParent(EXtentisObjects.DataCluster.getDisplayName(), serverRoot, TreeObject.DATA_CLUSTER, null, null);
        List<WSDataClusterPK> xdcPKs = null;
        try {
            // $NON-NLS-1$
            xdcPKs = service.getDataClusterPKs(new WSRegexDataClusterPKs("*")).getWsDataClusterPKs();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (xdcPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_10);
            for (WSDataClusterPK pk : xdcPKs) {
                String name = pk.getPk();
                if (!("CACHE".equals(name))) {
                    // FIXME: Hardcoded CACHE//$NON-NLS-1$
                    WSDataCluster wsObject = null;
                    try {
                        if (retriveWSObject) {
                            wsObject = service.getDataCluster(new WSGetDataCluster(pk));
                        }
                        TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_CLUSTER, pk, wsObject);
                        dataClusters.addChild(obj);
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_11);
        }
        // event management
        TreeParent eventManagement = new TreeParent(EXtentisObjects.EventManagement.getDisplayName(), serverRoot, TreeObject.EVENT_MANAGEMENT, null, null);
        // subscript engine
        TreeObject engine = new TreeObject(EXtentisObjects.SubscriptionEngine.getDisplayName(), serverRoot, TreeObject.SUBSCRIPTION_ENGINE, null, null);
        eventManagement.addChild(engine);
        // transformer
        List<WSTransformerV2PK> transformerPKs = null;
        try {
            // $NON-NLS-1$
            transformerPKs = service.getTransformerV2PKs(new WSGetTransformerV2PKs("")).getWsTransformerV2PK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        TreeParent transformers = null;
        transformers = new TreeParent(EXtentisObjects.Transformer.getDisplayName(), serverRoot, TreeObject.TRANSFORMER, null, null);
        eventManagement.addChild(transformers);
        if (transformerPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_12);
            for (WSTransformerV2PK pk : transformerPKs) {
                String id = pk.getPk();
                WSTransformerV2 wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getTransformerV2(new WSGetTransformerV2(pk));
                }
                TreeObject obj = new TreeObject(id, serverRoot, TreeObject.TRANSFORMER, new WSTransformerV2PK(id), wsobject);
                transformers.addChild(obj);
            }
        }
        monitor.worked(1);
        // routing rule
        List<WSRoutingRulePK> routingRulePKs = null;
        try {
            // $NON-NLS-1$
            routingRulePKs = service.getRoutingRulePKs(new WSGetRoutingRulePKs("")).getWsRoutingRulePKs();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        TreeParent rules = null;
        rules = new TreeParent(EXtentisObjects.RoutingRule.getDisplayName(), serverRoot, TreeObject.ROUTING_RULE, null, null);
        eventManagement.addChild(rules);
        if (routingRulePKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_13);
            for (WSRoutingRulePK pk : routingRulePKs) {
                String id = pk.getPk();
                WSRoutingRule wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getRoutingRule(new WSGetRoutingRule(pk));
                }
                TreeObject obj = new TreeObject(id, serverRoot, TreeObject.ROUTING_RULE, new WSRoutingRulePK(id), wsobject);
                rules.addChild(obj);
            }
        }
        monitor.worked(1);
        // add event management to serverRoot
        serverRoot.addChild(eventManagement);
        // Views
        TreeParent views = new TreeParent(EXtentisObjects.View.getDisplayName(), serverRoot, TreeObject.VIEW, null, null);
        List<WSViewPK> viewPKs = null;
        try {
            // $NON-NLS-1$
            viewPKs = service.getViewPKs((new WSGetViewPKs(""))).getWsViewPK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (viewPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_14);
            for (WSViewPK pk : viewPKs) {
                String name = pk.getPk();
                WSView wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getView(new WSGetView(pk));
                }
                TreeObject obj = new TreeObject(name, serverRoot, TreeObject.VIEW, new WSViewPK(name), wsobject);
                views.addChild(obj);
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_15);
        }
        // Stored Procedures
        TreeParent storedProcedures = new TreeParent(EXtentisObjects.StoredProcedure.getDisplayName(), serverRoot, TreeObject.STORED_PROCEDURE, null, null);
        List<WSStoredProcedurePK> spk = null;
        try {
            // $NON-NLS-1$
            spk = service.getStoredProcedurePKs(new WSRegexStoredProcedure("")).getWsStoredProcedurePK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (spk != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_16);
            for (WSStoredProcedurePK pk : spk) {
                String name = pk.getPk();
                WSStoredProcedure wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getStoredProcedure(new WSGetStoredProcedure(pk));
                }
                TreeObject obj = new TreeObject(name, serverRoot, TreeObject.STORED_PROCEDURE, new WSStoredProcedurePK(name), wsobject);
                storedProcedures.addChild(obj);
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_17);
        }
        // Service Configuration
        TreeObject serviceConfiguration = new TreeObject(EXtentisObjects.ServiceConfiguration.getDisplayName(), serverRoot, TreeObject.SERVICE_CONFIGURATION, null, null);
        // serviceConfiguration.setXObject(false);
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_18);
        }
        // Menus
        List<WSMenuPK> menuPKs = null;
        boolean hasMenus = true;
        try {
            // $NON-NLS-1$
            menuPKs = service.getMenuPKs(new WSGetMenuPKs("*")).getWsMenuPK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            // This server IS old
            hasMenus = false;
        }
        TreeParent menus = null;
        if (hasMenus) {
            menus = new TreeParent(EXtentisObjects.Menu.getDisplayName(), serverRoot, TreeObject.MENU, null, null);
            if (menuPKs != null) {
                monitor.subTask(Messages.XtentisServerObjectsRetriever_19);
                for (WSMenuPK pk : menuPKs) {
                    String id = pk.getPk();
                    WSMenu wsobject = null;
                    try {
                        if (retriveWSObject) {
                            wsobject = service.getMenu(new WSGetMenu(pk));
                        }
                        TreeObject obj = new TreeObject(id, serverRoot, TreeObject.MENU, new WSMenuPK(id), wsobject);
                        menus.addChild(obj);
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
            monitor.worked(1);
            if (monitor.isCanceled()) {
                throw new InterruptedException(Messages.XtentisServerObjectsRetriever_20);
            }
        }
        // move Job from EE to CE.
        monitor.worked(1);
        serverRoot.addChild(models);
        serverRoot.addChild(dataClusters);
        serverRoot.addChild(views);
        serverRoot.addChild(storedProcedures);
        serverRoot.addChild(serviceConfiguration);
        if (hasMenus) {
            serverRoot.addChild(menus);
        }
        // available models
        List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels();
        for (IAvailableModel model : availablemodels) {
            model.addTreeObjects(service, monitor, serverRoot);
        }
        monitor.done();
    } catch (Exception e) {
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_21);
        }
        log.error(e.getMessage(), e);
        throw new InvocationTargetException(e);
    }
}
Also used : WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) WSView(com.amalto.workbench.webservices.WSView) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) WSGetMenuPKs(com.amalto.workbench.webservices.WSGetMenuPKs) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSRegexDataModelPKs(com.amalto.workbench.webservices.WSRegexDataModelPKs) WSGetView(com.amalto.workbench.webservices.WSGetView) WSGetComponentVersion(com.amalto.workbench.webservices.WSGetComponentVersion) WSGetMenu(com.amalto.workbench.webservices.WSGetMenu) WSRoutingRulePK(com.amalto.workbench.webservices.WSRoutingRulePK) WSGetRoutingRulePKs(com.amalto.workbench.webservices.WSGetRoutingRulePKs) WSVersion(com.amalto.workbench.webservices.WSVersion) InvocationTargetException(java.lang.reflect.InvocationTargetException) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) TreeObject(com.amalto.workbench.models.TreeObject) WSRegexDataClusterPKs(com.amalto.workbench.webservices.WSRegexDataClusterPKs) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) WSViewPK(com.amalto.workbench.webservices.WSViewPK) WSGetStoredProcedure(com.amalto.workbench.webservices.WSGetStoredProcedure) WSPing(com.amalto.workbench.webservices.WSPing) WSMenuPK(com.amalto.workbench.webservices.WSMenuPK) TreeParent(com.amalto.workbench.models.TreeParent) WSGetTransformerV2(com.amalto.workbench.webservices.WSGetTransformerV2) UserInfo(com.amalto.workbench.utils.UserInfo) URL(java.net.URL) WSGetTransformerV2PKs(com.amalto.workbench.webservices.WSGetTransformerV2PKs) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) IAvailableModel(com.amalto.workbench.availablemodel.IAvailableModel) InvocationTargetException(java.lang.reflect.InvocationTargetException) WSGetRoutingRule(com.amalto.workbench.webservices.WSGetRoutingRule) WSGetViewPKs(com.amalto.workbench.webservices.WSGetViewPKs) WSMenu(com.amalto.workbench.webservices.WSMenu) WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSRegexStoredProcedure(com.amalto.workbench.webservices.WSRegexStoredProcedure)

Aggregations

WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)17 TMDMService (com.amalto.workbench.webservices.TMDMService)10 TreeObject (com.amalto.workbench.models.TreeObject)5 XtentisException (com.amalto.workbench.utils.XtentisException)5 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)5 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)5 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)5 WSStoredProcedure (com.amalto.workbench.webservices.WSStoredProcedure)5 WSView (com.amalto.workbench.webservices.WSView)5 TreeParent (com.amalto.workbench.models.TreeParent)4 WSGetView (com.amalto.workbench.webservices.WSGetView)4 WSRoutingRulePK (com.amalto.workbench.webservices.WSRoutingRulePK)4 WSStoredProcedurePK (com.amalto.workbench.webservices.WSStoredProcedurePK)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 URL (java.net.URL)4 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)3 WSGetMenu (com.amalto.workbench.webservices.WSGetMenu)3 WSGetRoutingRule (com.amalto.workbench.webservices.WSGetRoutingRule)3 WSGetStoredProcedure (com.amalto.workbench.webservices.WSGetStoredProcedure)3