Search in sources :

Example 1 with CommandManager

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

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

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

the class DeployService method updateLastServer.

public void updateLastServer(IStatus status, IProgressMonitor monitor) {
    CommandManager manager = CommandManager.getInstance();
    Map<String, List<ICommand>> commandMap = manager.getAllCommandsByPhase(ICommand.PHASE_AFTER_DEPLOY);
    Set<String> ids = getValidUpdateIds(status);
    for (String id : commandMap.keySet()) {
        boolean canRun = false;
        if (ids == null) {
            canRun = true;
        } else {
            canRun = ids.contains(id);
        }
        if (canRun) {
            List<ICommand> cmds = commandMap.get(id);
            for (ICommand cmd : cmds) {
                cmd.execute(null, monitor);
            }
            manager.removeCommandStack(id, ICommand.PHASE_AFTER_DEPLOY);
        }
    }
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 4 with CommandManager

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

the class DeployService method deployAnotherVersion.

public IStatus deployAnotherVersion(MDMServerDef serverDef, List<IRepositoryViewObject> viewObjs) {
    CommandManager manager = CommandManager.getInstance();
    List<AbstractDeployCommand> commands = manager.getDeployCommandsWithoutHistory(viewObjs);
    try {
        // insert impact dialog
        Map<IRepositoryViewObject, ImpactOperation> analyzeModelImpact = ModelImpactAnalyseService.analyzeCommandImpact(serverDef, commands);
        Map<IRepositoryViewObject, ICommandParameter> paramMap = null;
        if (analyzeModelImpact != null) {
            ModelImpactAnalyseService.shrinkDeployCommands(analyzeModelImpact, commands);
            paramMap = ModelImpactAnalyseService.convertToParameters(analyzeModelImpact);
            manager.attachParameterToCommand(commands, paramMap);
        }
    } catch (InterruptedException ex) {
        return Status.CANCEL_STATUS;
    }
    return runCommands(commands, serverDef);
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)

Example 5 with CommandManager

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

the class RepositoryViewObjectCheckedWidget method getSelectedCommands.

public List<AbstractDeployCommand> getSelectedCommands() {
    List<AbstractDeployCommand> commands = new LinkedList<AbstractDeployCommand>();
    CommandManager commandManager = CommandManager.getInstance();
    for (Object obj : treeViewer.getCheckedElements()) {
        if (obj instanceof FolderRepositoryObject) {
            continue;
        }
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        String id = viewObject.getId();
        AbstractDeployCommand e = cmdMap.get(id);
        if (e == null) {
            List<IRepositoryViewObject> objs = new ArrayList<IRepositoryViewObject>();
            objs.add(viewObject);
            List<AbstractDeployCommand> newCommands = commandManager.getDeployCommands(objs, ICommand.CMD_MODIFY);
            if (!newCommands.isEmpty()) {
                e = newCommands.get(0);
            }
        }
        commands.add(e);
        List<AbstractDeployCommand> associatedCommands = getAssociatedObjectCommand(viewObject, ICommand.CMD_MODIFY);
        if (associatedCommands != null) {
            commands.addAll(associatedCommands);
        }
    }
    return commands;
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) LinkedList(java.util.LinkedList) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Aggregations

CommandManager (org.talend.mdm.repository.core.command.CommandManager)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)8 ICommand (org.talend.mdm.repository.core.command.ICommand)8 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)8 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)6 ArrayList (java.util.ArrayList)5 IStatus (org.eclipse.core.runtime.IStatus)5 LinkedList (java.util.LinkedList)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 ImpactOperation (org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 CommandStack (org.talend.mdm.repository.core.command.CommandStack)2 ICommandParameter (org.talend.mdm.repository.core.command.param.ICommandParameter)2 ConsistencyCheckResult (org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyCheckResult)2 IModelValidateResult (org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult)2 SelectServerDefDialog (org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog)2