Search in sources :

Example 1 with MDMServerDef

use of com.amalto.workbench.utils.MDMServerDef in project tmdm-studio-se by Talend.

the class DataClusterDialog method hookService.

private void hookService() {
    serverComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            refreshDataContainerCombo();
            MDMServerDef serverDef = getSelectedMdmServerDef();
            if (serverDef != oldServerDef) {
                oldServerDef = serverDef;
                clusterComposite.changeToServer(serverDef);
                changeWidgetColor(greyColor);
            }
            selectDefaultContainer();
        }
    });
    containerComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection ssel = (IStructuredSelection) containerComboViewer.getSelection();
            TreeObject dataContainer = (TreeObject) ssel.getFirstElement();
            boolean refreshed = clusterComposite.changeToDataContainer(dataContainer);
            if (refreshed) {
                changeWidgetColor(defaultColor);
            } else {
                changeWidgetColor(greyColor);
                containerComboViewer.setInput(dataContainers);
            }
            model = clusterComposite.getDataContainer();
        }
    });
    TableViewer resultsViewer = clusterComposite.getResultsViewer();
    resultsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection structedSelection = (IStructuredSelection) event.getSelection();
            selected = (LineItem) structedSelection.getFirstElement();
            showInTextWidget(selected);
        }
    });
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TreeObject(com.amalto.workbench.models.TreeObject) LineItem(com.amalto.workbench.utils.LineItem) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableViewer(org.eclipse.jface.viewers.TableViewer) MDMServerDef(com.amalto.workbench.utils.MDMServerDef)

Example 2 with MDMServerDef

use of com.amalto.workbench.utils.MDMServerDef in project tmdm-studio-se by Talend.

the class DataClusterDialog method createFirstLine.

private Composite createFirstLine(Composite parent) {
    Composite firstLine = new Composite(parent, SWT.NONE);
    firstLine.setLayout(new GridLayout(4, false));
    Label serverLabel = new Label(firstLine, SWT.NONE);
    serverLabel.setText(Messages.DataClusterDialog_1);
    serverLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    serverComboViewer = new ComboViewer(firstLine, SWT.DROP_DOWN | SWT.READ_ONLY);
    Combo combo = serverComboViewer.getCombo();
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    data.widthHint = 200;
    combo.setLayoutData(data);
    serverComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            MDMServerDef serverDef = (MDMServerDef) element;
            // $NON-NLS-1$ //$NON-NLS-2$;
            return serverDef.getName() + " (" + serverDef.getHost() + ")";
        }
    });
    serverComboViewer.setContentProvider(new ArrayContentProvider());
    serverComboViewer.setInput(getAllServerDefs());
    Label containerLabel = new Label(firstLine, SWT.NONE);
    containerLabel.setText(Messages.DataClusterDialog_2);
    containerLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    containerComboViewer = new ComboViewer(firstLine, SWT.DROP_DOWN | SWT.READ_ONLY);
    Combo containerCombo = containerComboViewer.getCombo();
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    layoutData.widthHint = 200;
    containerCombo.setLayoutData(layoutData);
    containerComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            TreeObject treeObj = (TreeObject) element;
            return treeObj.getName();
        }
    });
    containerComboViewer.setContentProvider(new ArrayContentProvider());
    containerComboViewer.setInput(new TreeObject[0]);
    containerComboViewer.getCombo().setEnabled(false);
    return firstLine;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TreeObject(com.amalto.workbench.models.TreeObject) LabelProvider(org.eclipse.jface.viewers.LabelProvider) MDMServerDef(com.amalto.workbench.utils.MDMServerDef)

Example 3 with MDMServerDef

use of com.amalto.workbench.utils.MDMServerDef in project tmdm-studio-se by Talend.

the class DataClusterDialog method getAllDataContainers.

private boolean getAllDataContainers(List<TreeObject> dataContainers) {
    MDMServerDef serverDef = getSelectedMdmServerDef();
    String username = serverDef.getUser();
    String password = serverDef.getPasswd();
    String serverName = serverDef.getName();
    String endpointaddress = serverDef.getUrl();
    boolean canConnect = checkConnection(endpointaddress, username, password);
    if (!canConnect) {
        MessageDialog.openError(site.getShell(), Messages.DataClusterDialog_7, Messages.DataClusterDialog_8);
        return false;
    }
    List<WSDataClusterPK> xdcPKs = null;
    try {
        TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
        TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
        (password == null ? "" : password));
        // $NON-NLS-1$
        xdcPKs = service.getDataClusterPKs(new WSRegexDataClusterPKs("*")).getWsDataClusterPKs();
        for (WSDataClusterPK pk : xdcPKs) {
            String name = pk.getPk();
            if (!("CACHE".equals(name))) {
                // $NON-NLS-1$
                WSDataCluster wsObject = null;
                boolean retriveWSObject = false;
                try {
                    if (retriveWSObject) {
                        wsObject = service.getDataCluster(new WSGetDataCluster(pk));
                    }
                    TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_CLUSTER, pk, wsObject);
                    dataContainers.add(obj);
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return false;
    }
    return true;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) URL(java.net.URL) XtentisException(com.amalto.workbench.utils.XtentisException) MalformedURLException(java.net.MalformedURLException) WebServiceException(javax.xml.ws.WebServiceException) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerDef(com.amalto.workbench.utils.MDMServerDef) WSRegexDataClusterPKs(com.amalto.workbench.webservices.WSRegexDataClusterPKs)

Example 4 with MDMServerDef

use of com.amalto.workbench.utils.MDMServerDef in project tmdm-studio-se by Talend.

the class DeployOnMDMExportWizardPage method deployJobProcess.

private boolean deployJobProcess(String context, IProgressMonitor monitor) {
    // retrieve user, password, host, port from selected server
    MDMServerDef server = null;
    if (mdmServer == null) {
        String selectedSpagoBiEngineName = selectedServer;
        List<MDMServerDef> listServerSapgo = com.amalto.workbench.utils.MDMServerHelper.getServers();
        for (MDMServerDef serv : listServerSapgo) {
            if (selectedSpagoBiEngineName.equals(serv.getName())) {
                server = serv;
                break;
            }
        }
    } else {
        server = getServerDefFromList(mdmServer.getShortDescription());
    }
    if (null == server) {
        setDeploySucceed(false);
        return false;
    }
    String user = server.getUser();
    String password = server.getPasswd();
    String host = server.getHost();
    String port = server.getPort();
    // check connection before sending data
    monitor.setTaskName(Messages.DeployOnMDMExportWizardPage_checkConnection);
    boolean success = checkConnection(server.getUrl(), user, password);
    if (!success) {
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                String msg = Messages.DeployOnMDMExportWizardPage_UnableConnect;
                MessageDialog.openError(getContainer().getShell(), Messages.DeployOnMDMExportWizardPage_publishResourceError, msg);
            }
        });
        setDeploySucceed(false);
        return false;
    }
    // modified by xie to fix bug 20084 ,do the multi jobs deployment in one time.
    for (JobDeploymentInfo jobInfo : jobInfoList) {
        monitor.setTaskName(Messages.bind(Messages.DeployOnMDMExportWizardPage_DeployJobOnServer, jobInfo.getJobLabelName(), server.getName()));
        String filename = jobInfo.getDescValue();
        String contextPath = Util.getContextPath(server.getPath());
        String mdmServerUploadURL = server.getProtocol() + host + ":" + port + contextPath + // $NON-NLS-1$ //$NON-NLS-2$
        "/services/uploadFile?deployjob=" + new File(filename).getName() + "&jobpath=" + jobInfo.getJobPath() + "&contextStr=" + // $NON-NLS-1$//$NON-NLS-2$
        context;
        try {
            HttpClientUtil.uploadFileToAppServer(mdmServerUploadURL, filename, user, password);
            monitor.worked(W_DEPLOY_PROCESS);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    MessageDialog.openError(getContainer().getShell(), Messages.DeployOnMDMExportWizardPage_publishResourceError, Messages.DeployOnMDMExportWizardPage_ErrorDeployMsg);
                }
            });
            recordDeployException(new RuntimeException(e.getMessage(), e));
            setDeploySucceed(false);
            return false;
        }
    }
    mdmServer = toSpagoBiServer(server);
    setDeploySucceed(true);
    return true;
}
Also used : ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) MDMServerDef(com.amalto.workbench.utils.MDMServerDef) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProcessorException(org.talend.designer.runprocess.ProcessorException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 5 with MDMServerDef

use of com.amalto.workbench.utils.MDMServerDef in project tmdm-studio-se by Talend.

the class DeployOnMDMExportWizardPage method createOptions.

/**
 * Create the buttons for the group that determine if the entire or selected directory structure should be created.
 *
 * @param optionsGroup
 * @param font
 */
protected void createOptions(Composite optionsGroup, Font font) {
    // create directory structure radios
    List<MDMServerDef> listServerSapgo = com.amalto.workbench.utils.MDMServerHelper.getServers();
    List<String> listEngine = new ArrayList<String>();
    if (mdmServer == null) {
        for (MDMServerDef serv : listServerSapgo) {
            listEngine.add(serv.getName());
        }
        serverSpagoBi = new LabelledCombo(optionsGroup, Messages.DeployOnMDMExportWizardPage_SpagoBI_Server, Messages.DeployOnMDMExportWizardPage_SpecifyServer_PublishJob, listEngine);
        serverSpagoBi.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                updateSelectedServer();
            }
        });
        serverSpagoBi.select(0);
    }
    Composite typeComp = new Composite(optionsGroup, SWT.NONE);
    typeComp.setLayout(new FillLayout(SWT.HORIZONTAL));
    typeComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    Label typeLabel = new Label(typeComp, SWT.NONE);
    typeLabel.setText(Messages.DeployOnMDMExportWizardPage_ExportType);
    Label contentLabel = new Label(typeComp, SWT.NONE);
    contentLabel.setText(Messages.DeployOnMDMExportWizardPage_hostedZip);
    contextButton = new Button(optionsGroup, SWT.CHECK | SWT.LEFT);
    contextButton.setText(Messages.JobScriptsExportWizardPage_contextPerlScripts);
    contextButton.setSelection(true);
    contextButton.setFont(font);
    contextCombo = new Combo(optionsGroup, SWT.PUSH);
}
Also used : LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) FillLayout(org.eclipse.swt.layout.FillLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) MDMServerDef(com.amalto.workbench.utils.MDMServerDef)

Aggregations

MDMServerDef (com.amalto.workbench.utils.MDMServerDef)5 TreeObject (com.amalto.workbench.models.TreeObject)3 GridData (org.eclipse.swt.layout.GridData)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 TreeParent (com.amalto.workbench.models.TreeParent)1 LineItem (com.amalto.workbench.utils.LineItem)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)1 WSRegexDataClusterPKs (com.amalto.workbench.webservices.WSRegexDataClusterPKs)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 WebServiceException (javax.xml.ws.WebServiceException)1