use of org.talend.mdm.repository.core.command.CommandManager in project tmdm-studio-se by Talend.
the class DeployService method runCommands.
public IStatus runCommands(List<AbstractDeployCommand> commands, MDMServerDef serverDef) {
reorderCommandObjects(commands);
CommandManager manager = CommandManager.getInstance();
List<ICommand> compundCommands = manager.convertToDeployCompundCommands(commands, serverDef);
manager.arrangeForJobCommands(compundCommands);
//
try {
IProgressService progressService = null;
if (PlatformUI.isWorkbenchRunning()) {
progressService = PlatformUI.getWorkbench().getProgressService();
} else {
progressService = ConsoleProgressService.getInstance();
}
DeployProcess runnable = new DeployProcess(compundCommands);
progressService.run(true, true, runnable);
return runnable.getStatus();
} catch (InvocationTargetException e) {
log.error(e.getMessage(), e);
} catch (InterruptedException e) {
}
return Status.CANCEL_STATUS;
}
use of org.talend.mdm.repository.core.command.CommandManager in project tmdm-studio-se by Talend.
the class DeployService method deploy.
public IStatus deploy(MDMServerDef serverDef, List<IRepositoryViewObject> viewObjs, int defaultCmdType, boolean removeLocked) {
if (removeLocked) {
removeLockedViewObj(viewObjs);
}
IModelValidateResult validateResult = validateModel(viewObjs);
int selectedButton = validateResult.getSelectedButton();
if (selectedButton == IModelValidationService.BUTTON_CANCEL) {
return Status.CANCEL_STATUS;
}
List<IRepositoryViewObject> validObjects = validateResult.getValidObjects(selectedButton);
List<IRepositoryViewObject> invalidObjects = validateResult.getInvalidObjects(selectedButton);
try {
// consistency check
ConsistencyCheckResult consistencyCheckResult = ConsistencyService.getInstance().checkConsistency(serverDef, validObjects);
if (consistencyCheckResult == null || consistencyCheckResult.isCanceled()) {
return Status.CANCEL_STATUS;
}
validObjects = consistencyCheckResult.getToDeployObjects();
//
CommandManager manager = CommandManager.getInstance();
List<AbstractDeployCommand> commands = manager.getDeployCommands(validObjects, defaultCmdType);
// insert impact dialog
List<AbstractDeployCommand> canceledCommandAfterImpactAnalysis = new LinkedList<AbstractDeployCommand>(commands);
if (UIUtil.isWorkInUI()) {
try {
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);
}
canceledCommandAfterImpactAnalysis.removeAll(commands);
} catch (InterruptedException ex) {
return Status.CANCEL_STATUS;
}
}
IStatus mainStatus = runCommands(commands, serverDef);
// update consistency value
try {
updateServerConsistencyStatus(serverDef, mainStatus);
} catch (XtentisException e) {
log.error(e.getMessage(), e);
} catch (WebServiceException e) {
log.error(e.getMessage(), e);
}
//
generateValidationFailedDeployStatus(mainStatus, invalidObjects);
if (UIUtil.isWorkInUI()) {
generateConsistencyCancelDeployStatus(mainStatus, consistencyCheckResult.getToSkipObjects().toArray(new IRepositoryViewObject[0]));
for (AbstractDeployCommand cmd : canceledCommandAfterImpactAnalysis) {
generateConsistencyCancelDeployStatus(mainStatus, cmd.getViewObject());
}
}
return mainStatus;
} catch (Exception e) {
log.error(e.getMessage(), e);
String url = // $NON-NLS-1$
serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + serverDef.getPath();
String title = Messages.bind(Messages.Server_cannot_connected, url);
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, Messages.AbstractDataClusterAction_ConnectFailed);
return Status.CANCEL_STATUS;
}
}
use of org.talend.mdm.repository.core.command.CommandManager in project tmdm-studio-se by Talend.
the class DeployService method updateForStatus.
private void updateForStatus(boolean isUpdateServer, List<DeployStatus> deployStatuses) {
if (deployStatuses == null || deployStatuses.size() == 0) {
return;
}
for (DeployStatus deployStatus : deployStatuses) {
if (deployStatus != null && deployStatus.isOK()) {
ICommand command = deployStatus.getCommand();
if (command != null) {
CommandManager manager = CommandManager.getInstance();
manager.removeCommandStack(command, ICommand.PHASE_DEPLOY);
if (isUpdateServer) {
MDMServerDef serverDef = null;
if (command instanceof AbstractDeployCommand) {
serverDef = ((AbstractDeployCommand) command).getServerDef();
} else if (command instanceof DeployCompoundCommand) {
serverDef = ((DeployCompoundCommand) command).getServerDef();
}
if (command instanceof BatchDeployJobCommand) {
BatchDeployJobCommand deployJobCommand = (BatchDeployJobCommand) command;
pushRestoreCommand(manager, deployJobCommand.getSubCmds(), serverDef);
pushRestoreCommand(manager, deployJobCommand.getSubDeleteCmds(), serverDef);
} else {
// updateserver
pushRestoreCommand(manager, command, serverDef);
}
}
}
}
}
}
use of org.talend.mdm.repository.core.command.CommandManager 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;
}
}
use of org.talend.mdm.repository.core.command.CommandManager in project tmdm-studio-se by Talend.
the class DeployCompoundCommand method breakUpRenameCommand.
protected void breakUpRenameCommand() {
CommandManager manager = CommandManager.getInstance();
// delete
AbstractDeployCommand deleteCmd = (AbstractDeployCommand) manager.getNewCommand(CMD_DELETE);
deleteCmd.init(commandId, getObjName());
deleteCmd.updateViewObject(getViewObject());
deleteCmd.setServerDef(serverDef);
// modify
AbstractDeployCommand modifyCmd = (AbstractDeployCommand) manager.getNewCommand(CMD_MODIFY);
modifyCmd.init(commandId, getObjLastName());
modifyCmd.updateViewObject(getViewObject());
modifyCmd.setServerDef(serverDef);
//
subCmds.add(deleteCmd);
subCmds.add(modifyCmd);
}
Aggregations