use of org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand 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.deploy.AbstractDeployCommand 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.deploy.AbstractDeployCommand 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.deploy.AbstractDeployCommand in project tmdm-studio-se by Talend.
the class CommandManager method getAllDeployCommands.
public List<AbstractDeployCommand> getAllDeployCommands() {
List<AbstractDeployCommand> cmds = new ArrayList<AbstractDeployCommand>();
for (CommandStack stack : map.values()) {
ICommand validCommand = stack.getValidDeployCommand();
if (validCommand != null) {
if (validCommand instanceof AbstractDeployCommand) {
fillViewObjectToCommand(validCommand);
AbstractDeployCommand deployCommand = (AbstractDeployCommand) validCommand;
cmds.add(deployCommand);
}
}
}
return cmds;
}
use of org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand in project tmdm-studio-se by Talend.
the class CommandManager method convertToDeployCompundCommands.
public List<ICommand> convertToDeployCompundCommands(List<AbstractDeployCommand> validCommands, MDMServerDef serverDef) {
List<ICommand> cmds = new ArrayList<ICommand>(validCommands.size());
for (AbstractDeployCommand deployCommand : validCommands) {
deployCommand.setServerDef(serverDef);
ICommand newCmd = convertToDeployCompoundCommand(deployCommand);
cmds.add(newCmd);
}
return cmds;
}
Aggregations