Search in sources :

Example 16 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project tmdm-studio-se by Talend.

the class ImportDataClusterAction method doRun.

@Override
protected void doRun() {
    FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
    // $NON-NLS-1$
    fd.setFilterExtensions(new String[] { "*.zip" });
    String fPath = fd.open();
    if (fPath != null) {
        DataClusterService dataClusterService = DataClusterService.getIntance();
        File tempFolder = IOUtil.getTempFolder();
        String tempFolderPath = tempFolder.getAbsolutePath();
        dataClusterService.unZipFile(fPath, tempFolderPath);
        String dName = dataClusterService.loadIndexFile(tempFolderPath);
        if (dName == null) {
            MessageDialog.openError(getShell(), Messages.Common_Error, Messages.ImportDataClusterAction_errorFormat);
            return;
        }
        tempFolderPath += File.separator + dName;
        // 
        SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
        if (dialog.open() == IDialogConstants.OK_ID) {
            MDMServerDef serverDef = dialog.getSelectedServerDef();
            try {
                TMDMService service = RepositoryWebServiceAdapter.getMDMService(serverDef);
                service.ping(new WSPing(Messages.ImportDataClusterAction_importTitle));
                if (!dataClusterService.isExistDataCluster(service, dName)) {
                    if (MessageDialog.openQuestion(getShell(), Messages.ImportDataClusterAction_createDataClusterTitle, Messages.bind(Messages.ImportDataClusterAction_createConfirm, dName))) {
                        dataClusterService.createDataCluster(service, dName);
                    } else {
                        return;
                    }
                }
                IDataContentProcess process = dataClusterService.getNewImportContentProcess(serverDef, dName, tempFolderPath);
                try {
                    process.run();
                } catch (InterruptedException e) {
                    // do nothing
                    return;
                }
                MultiStatus multiStatus = process.getResult();
                if (multiStatus != null && multiStatus.getChildren().length > 0) {
                    MultiStatusDialog statusDialog = new MultiStatusDialog(getShell(), multiStatus.getMessage(), multiStatus);
                    statusDialog.open();
                } else {
                    // show success info
                    MessageDialog.openInformation(getShell(), Messages.ImportDataClusterAction_importTitle, Messages.bind(Messages.ImportDataClusterAction_successImport, dName));
                }
            } catch (XtentisException e) {
                log.error(e.getMessage(), e);
            } catch (WebServiceException e) {
                MessageDialog.openError(getShell(), Messages.ImportDataClusterAction_importTitle, Messages.AbstractDataClusterAction_ConnectFailed);
            } finally {
                IOUtil.cleanFolder(tempFolder);
            }
        }
    }
}
Also used : WSPing(com.amalto.workbench.webservices.WSPing) DataClusterService(org.talend.mdm.repository.core.service.DataClusterService) WebServiceException(javax.xml.ws.WebServiceException) IDataContentProcess(org.talend.mdm.repository.core.datacontent.IDataContentProcess) MultiStatusDialog(org.talend.mdm.repository.ui.dialogs.message.MultiStatusDialog) MultiStatus(org.eclipse.core.runtime.MultiStatus) TMDMService(com.amalto.workbench.webservices.TMDMService) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 17 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project tmdm-studio-se by Talend.

the class DeployService method updateServerConsistencyStatus.

public void updateServerConsistencyStatus(MDMServerDef serverDef, IStatus mainStatus) throws XtentisException, WebServiceException {
    if (!UIUtil.isWorkInUI()) {
        return;
    }
    if (mainStatus.isMultiStatus()) {
        Set<IRepositoryViewObject> viewObjs = new HashSet<IRepositoryViewObject>();
        for (IStatus childStatus : mainStatus.getChildren()) {
            DeployStatus deployStatus = null;
            if (childStatus instanceof DeployStatus) {
                deployStatus = (DeployStatus) childStatus;
                if (deployStatus.isOK()) {
                    AbstractDeployCommand command = (AbstractDeployCommand) deployStatus.getCommand();
                    if (command instanceof BatchDeployJobCommand) {
                        for (ICommand subCmd : ((BatchDeployJobCommand) command).getSubCmds()) {
                            if (subCmd instanceof AbstractDeployCommand) {
                                IRepositoryViewObject viewObj = ((AbstractDeployCommand) subCmd).getViewObject();
                                if (viewObj != null) {
                                    viewObjs.add(viewObj);
                                }
                            }
                        }
                    } else {
                        if (command != null) {
                            IRepositoryViewObject viewObj = command.getViewObject();
                            if (viewObj != null) {
                                viewObjs.add(viewObj);
                            }
                        }
                    }
                }
            } else if (childStatus instanceof MultiStatus) {
                updateServerConsistencyStatus(serverDef, childStatus);
            }
        }
        updateServerConsistencyStatus(serverDef, viewObjs);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ICommand(org.talend.mdm.repository.core.command.ICommand) BatchDeployJobCommand(org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MultiStatus(org.eclipse.core.runtime.MultiStatus) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) HashSet(java.util.HashSet)

Example 18 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project tmdm-studio-se by Talend.

the class DeployService method updateAutoStatus.

protected void updateAutoStatus(IStatus status) {
    if (status.isMultiStatus()) {
        for (IStatus childStatus : status.getChildren()) {
            DeployStatus deployStatus = null;
            if (childStatus instanceof DeployStatus) {
                deployStatus = (DeployStatus) childStatus;
            } else if (childStatus instanceof MultiStatus) {
                deployStatus = (DeployStatus) ((MultiStatus) childStatus).getChildren()[0];
            }
            ICommand command = deployStatus.getCommand();
            CommandManager manager = CommandManager.getInstance();
            manager.removeCommandStack(command, ICommand.PHASE_DEPLOY);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 19 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project tmdm-studio-se by Talend.

the class DeployService method generateConsistencyCancelDeployStatus.

public void generateConsistencyCancelDeployStatus(IStatus mainStatus, IRepositoryViewObject... cancelViewObjs) {
    if (cancelViewObjs != null) {
        for (IRepositoryViewObject viewObj : cancelViewObjs) {
            ICommand cancelCmd = CommandManager.getInstance().getNewCommand(ICommand.CMD_NOP);
            cancelCmd.updateViewObject(viewObj);
            DeployStatus cancelStatus = DeployStatus.getInfoStatus(cancelCmd, Messages.DeployService_conflictCancelStatus + viewObj.getLabel());
            ((MultiStatus) mainStatus).add(cancelStatus);
        }
    }
}
Also used : ICommand(org.talend.mdm.repository.core.command.ICommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 20 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project tmdm-studio-se by Talend.

the class BatchDeployJobCommand method execute.

@Override
public IStatus execute(Object params, IProgressMonitor monitor) {
    IStatus status = super.execute(params, monitor);
    // 
    MultiStatus ms = new MultiStatus(RepositoryPlugin.PLUGIN_ID, status.getSeverity(), Messages.BatchDeployJobCommand_deployJob, null);
    IInteractiveHandler handler = InteractiveService.findHandler(getViewObjectType());
    String typeLabel = handler.getLabel();
    if (status.isOK()) {
        runDeleteCmds(params, monitor, ms);
    }
    collectDeployStatus(status, ms, typeLabel);
    return ms;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) MultiStatus(org.eclipse.core.runtime.MultiStatus) IInteractiveHandler(org.talend.mdm.repository.core.service.IInteractiveHandler)

Aggregations

MultiStatus (org.eclipse.core.runtime.MultiStatus)140 IStatus (org.eclipse.core.runtime.IStatus)98 Status (org.eclipse.core.runtime.Status)60 CoreException (org.eclipse.core.runtime.CoreException)41 ArrayList (java.util.ArrayList)29 File (java.io.File)24 SubMonitor (org.eclipse.core.runtime.SubMonitor)24 IOException (java.io.IOException)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 List (java.util.List)11 HashMap (java.util.HashMap)10 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)10 IPath (org.eclipse.core.runtime.IPath)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 FileNotFoundException (java.io.FileNotFoundException)7 HashSet (java.util.HashSet)7 IProject (org.eclipse.core.resources.IProject)7 IContainer (org.eclipse.core.resources.IContainer)6 URI (java.net.URI)5