Search in sources :

Example 1 with ICommand

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

the class RestoreAction method executeRestoreCommand.

protected void executeRestoreCommand(IRepositoryViewObject viewObj) {
    CommandManager manager = CommandManager.getInstance();
    String id = viewObj.getId();
    CommandStack stack = manager.findCommandStack(id);
    if (stack != null) {
        List<ICommand> deployCommands = stack.getCommands(ICommand.PHASE_DEPLOY);
        if (deployCommands.size() > 0) {
            manager.pushCommand(ICommand.CMD_RESTORE, viewObj);
        }
        IProgressMonitor monitor = new NullProgressMonitor();
        List<ICommand> commands = stack.getCommands(ICommand.PHASE_RESTORE);
        for (ICommand cmd : commands) {
            cmd.updateViewObject(viewObj);
            cmd.execute(null, monitor);
        }
        manager.removeCommandStack(id, ICommand.PHASE_RESTORE);
    }
}
Also used : CommandStack(org.talend.mdm.repository.core.command.CommandStack) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand)

Example 2 with ICommand

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

the class WaitToDeployDialog method needShowObject.

private boolean needShowObject(IRepositoryViewObject viewObj) {
    String id = viewObj.getId();
    CommandStack commandStack = CommandManager.getInstance().findCommandStack(id);
    if (commandStack != null) {
        ICommand validCommand = commandStack.getValidDeployCommand();
        if (validCommand instanceof AbstractDeployCommand) {
            if (validCommand.getCommandType() == ICommand.CMD_DELETE) {
                return RepositoryResourceUtil.getLastServerDef(viewObj) != null;
            }
            return true;
        }
    }
    return false;
}
Also used : CommandStack(org.talend.mdm.repository.core.command.CommandStack) ICommand(org.talend.mdm.repository.core.command.ICommand) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)

Example 3 with ICommand

use of org.talend.mdm.repository.core.command.ICommand 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 4 with ICommand

use of org.talend.mdm.repository.core.command.ICommand 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 5 with ICommand

use of org.talend.mdm.repository.core.command.ICommand 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)

Aggregations

ICommand (org.talend.mdm.repository.core.command.ICommand)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)8 CommandManager (org.talend.mdm.repository.core.command.CommandManager)8 IStatus (org.eclipse.core.runtime.IStatus)6 CommandStack (org.talend.mdm.repository.core.command.CommandStack)6 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)6 MultiStatus (org.eclipse.core.runtime.MultiStatus)5 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 BatchDeployJobCommand (org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 DeployStatus (org.talend.mdm.repository.core.service.DeployService.DeployStatus)2 SelectServerDefDialog (org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IProgressService (org.eclipse.ui.progress.IProgressService)1