Search in sources :

Example 6 with DeployService

use of org.talend.mdm.repository.core.service.DeployService in project tmdm-studio-se by Talend.

the class UndeployAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.mdm.repository.core.bridge.AbstractBridgeRepositoryAction#doRun()
     */
@Override
protected void doRun() {
    DeployService deployService = DeployService.getInstance();
    CommandManager cmanager = CommandManager.getInstance();
    List<IRepositoryViewObject> viewObjs = getSelectedRepositoryViewObject();
    if (viewObjs.size() < 1) {
        return;
    }
    SelectServerDefDialog dialog = getServerDefDialog(viewObjs);
    if (dialog.open() == IDialogConstants.OK_ID) {
        MDMServerDef serverDef = dialog.getSelectedServerDef();
        List<AbstractDeployCommand> deleteCommands = new ArrayList<AbstractDeployCommand>(viewObjs.size());
        for (IRepositoryViewObject obj : viewObjs) {
            ICommand deleteCmd = cmanager.getNewCommand(obj, ICommand.CMD_DELETE);
            deleteCmd.init(obj);
            deleteCommands.add((AbstractDeployCommand) deleteCmd);
        }
        IStatus status = deployService.runCommands(deleteCommands, serverDef);
        IProgressMonitor monitor = new NullProgressMonitor();
        deployService.updateChangedStatus(status);
        if (status.isMultiStatus()) {
            new DeployStatusDialog(getShell(), status).open();
        }
        for (IRepositoryViewObject viewObj : viewObjs) {
            MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
            String id = viewObj.getId();
            CommandStack stack = cmanager.findCommandStack(id);
            if (stack != null) {
                if (RepositoryResourceUtil.isSameMDMServerDef(lastServerDef, serverDef)) {
                    List<ICommand> commands = stack.getCommands(ICommand.PHASE_RESTORE);
                    for (ICommand cmd : commands) {
                        cmd.execute(null, monitor);
                    }
                }
                cmanager.removeCommandStack(id, ICommand.PHASE_RESTORE);
                commonViewer.refresh(viewObj);
            }
        }
    } else {
        return;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CommandStack(org.talend.mdm.repository.core.command.CommandStack) IStatus(org.eclipse.core.runtime.IStatus) DeployStatusDialog(org.talend.mdm.repository.ui.dialogs.deploy.DeployStatusDialog) ArrayList(java.util.ArrayList) DeployService(org.talend.mdm.repository.core.service.DeployService) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Aggregations

DeployService (org.talend.mdm.repository.core.service.DeployService)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)4 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)2 MDMRepositoryView (org.talend.mdm.repository.ui.navigator.MDMRepositoryView)2 TreeObject (com.amalto.workbench.models.TreeObject)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 WebServiceException (javax.xml.ws.WebServiceException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 AbstractCommand (org.eclipse.emf.common.command.AbstractCommand)1 EObject (org.eclipse.emf.ecore.EObject)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Item (org.talend.core.model.properties.Item)1 CommandManager (org.talend.mdm.repository.core.command.CommandManager)1 CommandStack (org.talend.mdm.repository.core.command.CommandStack)1