Search in sources :

Example 1 with WSStoredProcedure

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

the class EditXObjectAction method run.

@Override
public void run() {
    try {
        super.run();
        if (xobject == null || !xobject.isXObject()) {
            return;
        }
        // Access to server and get port
        TMDMService service = Util.getMDMService(new URL(xobject.getEndpointAddress()), xobject.getUsername(), xobject.getPassword());
        switch(xobject.getType()) {
            case TreeObject.DATA_MODEL:
                WSDataModel wsDataModel = service.getDataModel(new WSGetDataModel((WSDataModelPK) xobject.getWsKey()));
                xobject.setWsObject(wsDataModel);
                // XSDEditorUtil.openDataModel(xobject, false);
                return;
            case TreeObject.VIEW:
                WSView wsView = service.getView(new WSGetView((WSViewPK) xobject.getWsKey()));
                xobject.setWsObject(wsView);
                break;
            case TreeObject.DATA_CLUSTER:
                WSDataCluster wsDataCluster = service.getDataCluster(new WSGetDataCluster((WSDataClusterPK) xobject.getWsKey()));
                xobject.setWsObject(wsDataCluster);
                break;
            case TreeObject.STORED_PROCEDURE:
                WSStoredProcedure wsStoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) xobject.getWsKey()));
                xobject.setWsObject(wsStoredProcedure);
                break;
            case TreeObject.ROUTING_RULE:
                WSRoutingRule wsRoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) xobject.getWsKey()));
                xobject.setWsObject(wsRoutingRule);
                break;
            case TreeObject.TRANSFORMER:
                WSTransformerV2 wsTranformer = service.getTransformerV2(new WSGetTransformerV2((WSTransformerV2PK) xobject.getWsKey()));
                xobject.setWsObject(wsTranformer);
                break;
            case TreeObject.MENU:
                WSMenu wsMenu = service.getMenu(new WSGetMenu((WSMenuPK) xobject.getWsKey()));
                xobject.setWsObject(wsMenu);
                break;
            case TreeObject.SERVICE_CONFIGURATION:
                break;
            case TreeObject.JOB_REGISTRY:
                // System.out.println("JOB_REGISTRY "+ xobject.getDisplayName());
                break;
            case TreeObject.JOB:
                // System.out.println("JOB "+ xobject.getDisplayName()+" "+xobject.getWsKey());
                xobject.setWsObject(xobject.getDisplayName());
                break;
            case TreeObject.ROLE:
                if (exAdapter != null) {
                    exAdapter.run(service, xobject);
                }
                break;
            case TreeObject.RESOURCES:
            case TreeObject.CUSTOM_TYPE:
            case TreeObject.DATA_MODEL_RESOURCE:
            case TreeObject.DATA_MODEL_TYPES_RESOURCE:
            case TreeObject.CUSTOM_TYPES_RESOURCE:
            case TreeObject.PICTURES_RESOURCE:
                break;
            default:
                MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg1, IConstants.TALEND, xobject.getType()));
                return;
        }
        if (page == null) {
            this.page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        }
        this.page.openEditor(new XObjectEditorInput(xobject, xobject.getDisplayName()), // $NON-NLS-1$
        "com.amalto.workbench.editors.XObjectEditor");
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException(getShell(), e, Messages.EditXObjectAction_ErrorMsg2)) {
            MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg2, e.getLocalizedMessage()));
        }
    }
}
Also used : WSGetStoredProcedure(com.amalto.workbench.webservices.WSGetStoredProcedure) WSMenuPK(com.amalto.workbench.webservices.WSMenuPK) WSGetTransformerV2(com.amalto.workbench.webservices.WSGetTransformerV2) WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) URL(java.net.URL) WSView(com.amalto.workbench.webservices.WSView) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) 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) WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 2 with WSStoredProcedure

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

the class StoredProcedureMainPage method refreshData.

// createCharacteristicsContent
@Override
protected void refreshData() {
    if (this.comitting) {
        return;
    }
    this.refreshing = true;
    WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
    String s;
    // $NON-NLS-1$
    s = wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription();
    if (!s.equals(descriptionText.getText())) {
        descriptionText.setText(s);
    }
    Document doc = new Document(wsStoredProcedure.getProcedure());
    procedureViewer.setDocument(doc);
    refreshCacheBtn.setSelection(wsStoredProcedure.isRefreshCache() != null && wsStoredProcedure.isRefreshCache() ? true : false);
    initDataClusterCombo();
    this.refreshing = false;
}
Also used : WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) Document(org.eclipse.jface.text.Document)

Example 3 with WSStoredProcedure

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

the class StoredProcedureMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
        // description
        Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
        // $NON-NLS-1$
        descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
        descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        // $NON-NLS-1$
        descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
        descriptionText.addModifyListener(this);
        // Procedure
        Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
        storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
        storedProcedureGroup.setLayout(new GridLayout(1, true));
        storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        ((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
        procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
        procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        procedureViewer.addTextListener(this);
        WidgetUtils.initRedoUndo(procedureViewer);
        refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
        refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        refreshCacheBtn.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                markDirty();
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                markDirty();
            }
        });
        /**
         **********************************************************
         * Execute Stored Procedure
         ***********************************************************
         */
        createCompDropTarget();
        Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
        resultsGroup.setLayout(new GridLayout(4, false));
        // data cluster
        Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
        dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {

            public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                if (!isLocalInput()) {
                    TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
                    TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
                    (new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
                }
            }
        });
        dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
        Button executeButton = new Button(resultsGroup, SWT.PUSH);
        executeButton.setText(Messages.StoredProcedureMainPage_9);
        executeButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
                executeProcedure();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
            }
        });
        resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
        "                                                                                                           ", SWT.NULL);
        resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
        resultsViewer = new TableViewer(resultsGroup);
        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new XMLTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
            }
        });
        hookContextMenu();
        refreshData();
        dataClusterCombo.select(0);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) SourceViewer(org.eclipse.jface.text.source.SourceViewer) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) EditXObjectAction(com.amalto.workbench.actions.EditXObjectAction) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Example 4 with WSStoredProcedure

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

the class StoredProcedureMainPage method commit.

@Override
protected void commit() {
    if (this.refreshing) {
        return;
    }
    this.comitting = true;
    WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
    wsStoredProcedure.setDescription(descriptionText.getText());
    wsStoredProcedure.setProcedure(procedureViewer.getDocument().get());
    wsStoredProcedure.setRefreshCache(refreshCacheBtn.getSelection());
    this.comitting = false;
}
Also used : WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure)

Example 5 with WSStoredProcedure

use of com.amalto.workbench.webservices.WSStoredProcedure 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)

Aggregations

WSStoredProcedure (com.amalto.workbench.webservices.WSStoredProcedure)7 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)5 TMDMService (com.amalto.workbench.webservices.TMDMService)4 WSStoredProcedurePK (com.amalto.workbench.webservices.WSStoredProcedurePK)4 TreeObject (com.amalto.workbench.models.TreeObject)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)3 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)3 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)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 WSGetTransformerV2 (com.amalto.workbench.webservices.WSGetTransformerV2)3 WSGetView (com.amalto.workbench.webservices.WSGetView)3 WSMenu (com.amalto.workbench.webservices.WSMenu)3 WSMenuPK (com.amalto.workbench.webservices.WSMenuPK)3 WSRoutingRule (com.amalto.workbench.webservices.WSRoutingRule)3 WSRoutingRulePK (com.amalto.workbench.webservices.WSRoutingRulePK)3 WSTransformerV2 (com.amalto.workbench.webservices.WSTransformerV2)3