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);
}
}
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);
}
}
}
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);
}
}
}
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);
}
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;
}
Aggregations