use of org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand in project tmdm-studio-se by Talend.
the class AbstractInteractiveHandlerTest method testDeploy.
@Test
public void testDeploy() {
MDMServerObject mockServerObject = PowerMockito.mock(MDMServerObject.class);
MDMServerObjectItem mockServerObjectItem = PowerMockito.mock(MDMServerObjectItem.class);
PowerMockito.when(mockServerObjectItem.getMDMServerObject()).thenReturn(mockServerObject);
Property mockProperty = PowerMockito.mock(Property.class);
PowerMockito.when(mockProperty.getItem()).thenReturn(mockServerObjectItem);
IRepositoryViewObject mockViewObj = PowerMockito.mock(IRepositoryViewObject.class);
PowerMockito.when(mockViewObj.getProperty()).thenReturn(mockProperty);
AbstractDeployCommand mockDeployCommand = PowerMockito.mock(AbstractDeployCommand.class);
PowerMockito.when(mockDeployCommand.getViewObject()).thenReturn(mockViewObj);
AbstractInteractiveHandler mockInteractiveHandler = PowerMockito.mock(AbstractInteractiveHandler.class);
try {
PowerMockito.when(mockInteractiveHandler.deploy(any(AbstractDeployCommand.class))).thenCallRealMethod();
PowerMockito.when(mockInteractiveHandler.doDeployWSObject(any(TMDMService.class), any())).thenReturn(true);
TMDMService mockService = PowerMockito.mock(TMDMService.class);
// $NON-NLS-1$
PowerMockito.when(mockInteractiveHandler, "getService", any(MDMServerDef.class)).thenReturn(mockService);
Object mockWsObj = new Object();
PowerMockito.when(mockInteractiveHandler.convert(any(Item.class), any(MDMServerObject.class))).thenReturn(mockWsObj);
boolean deployed = mockInteractiveHandler.deploy(mockDeployCommand);
assertTrue(deployed);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand in project tmdm-studio-se by Talend.
the class DeployAllDialog method createDialogArea.
/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
mainContainer = (Composite) super.createDialogArea(parent);
GridLayout mainContainerLayout = (GridLayout) mainContainer.getLayout();
mainContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
mainContainerLayout.numColumns = 2;
Label lblNewLabel_selserver = new Label(mainContainer, SWT.NONE);
lblNewLabel_selserver.setText(Messages.DeployAllDialog_label_selectserver);
lblNewLabel_selserver.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
errorLabel = new Label(mainContainer, SWT.NONE);
errorLabelLayoutData = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
errorLabelLayoutData.exclude = true;
errorLabel.setLayoutData(errorLabelLayoutData);
errorLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
comboViewer = new ComboViewer(mainContainer, SWT.DROP_DOWN | SWT.READ_ONLY);
Combo combo = comboViewer.getCombo();
GridData data = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
combo.setLayoutData(data);
comboViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
MDMServerDef serverDef = (MDMServerDef) element;
// $NON-NLS-1$ //$NON-NLS-2$;
return serverDef.getName() + " (" + serverDef.getHost() + ")";
}
});
comboViewer.setContentProvider(new ArrayContentProvider());
Label emptyLabel = new Label(mainContainer, SWT.NONE);
GridData emptydata = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
emptydata.widthHint = 98;
emptyLabel.setLayoutData(emptydata);
List<MDMServerDef> allServerDefs = ServerDefService.getAllServerDefs();
comboViewer.setInput(allServerDefs);
comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
serverDef = (MDMServerDef) ((IStructuredSelection) comboViewer.getSelection()).getFirstElement();
treeViewer.updateCurrentServerDef(null, serverDef);
updateErrorMsgArea(treeViewer.isServerOk());
}
});
final Button reconciliationBun = new Button(mainContainer, SWT.CHECK);
reconciliationBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
treeViewer.enableReconciliation(reconciliationBun.getSelection());
}
});
reconciliationBun.setText(Messages.DeployAllDialog_reconciliation);
reconciliationBun.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
Composite container = new Composite(mainContainer, SWT.BORDER);
container.setLayout(new GridLayout(2, false));
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
Label lblNewLabel = new Label(container, SWT.NONE);
lblNewLabel.setText(Messages.DeployAllDialog_label);
new Label(container, SWT.NONE);
List<AbstractDeployCommand> commands = CommandManager.getInstance().getAllDeployCommands();
treeViewer = new RepositoryViewObjectCheckedWidget(container, initType, commands);
treeViewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
Button selAllButton = new Button(container, SWT.NONE);
selAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
treeViewer.selectAll(true);
}
});
selAllButton.setText(Messages.DeployAllDialog_selectAll);
Button deselAllBun = new Button(container, SWT.NONE);
deselAllBun.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
deselAllBun.setText(Messages.DeployAllDialog_deselectAll);
deselAllBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
treeViewer.selectAll(false);
}
});
Button skipDeployedBun = new Button(container, SWT.NONE);
skipDeployedBun.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
skipDeployedBun.setText(Messages.DeployAllDialog_skipDeployed);
skipDeployedBun.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
treeViewer.skipDeployedObjects();
}
});
initComboSelect();
return container;
}
use of org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand in project tmdm-studio-se by Talend.
the class ModelImpactAnalyseService method shrinkDeployCommands.
public static void shrinkDeployCommands(Map<IRepositoryViewObject, ImpactOperation> impactResult, List<AbstractDeployCommand> commands) {
Set<IRepositoryViewObject> toRemoveKeys = new HashSet<IRepositoryViewObject>();
Iterator<AbstractDeployCommand> il = commands.iterator();
while (il.hasNext()) {
AbstractDeployCommand cmd = il.next();
IRepositoryViewObject viewObject = cmd.getViewObject();
if (viewObject != null) {
ERepositoryObjectType type = viewObject.getRepositoryObjectType();
if (type == IServerObjectRepositoryType.TYPE_DATAMODEL) {
ImpactOperation operation = impactResult.get(viewObject);
if (operation == ImpactOperation.CANCEL) {
il.remove();
toRemoveKeys.add(viewObject);
}
} else if (type == IServerObjectRepositoryType.TYPE_MATCH_RULE_MAPINFO || type == IServerObjectRepositoryType.TYPE_TDS) {
String label = viewObject.getLabel();
for (IRepositoryViewObject modelViewObj : impactResult.keySet()) {
if (modelViewObj.getLabel().equals(label)) {
ImpactOperation operation = impactResult.get(modelViewObj);
if (operation == ImpactOperation.CANCEL) {
il.remove();
}
}
}
}
}
}
for (IRepositoryViewObject key : toRemoveKeys) {
impactResult.remove(key);
}
}
use of org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand in project tmdm-studio-se by Talend.
the class RemoveFromServerAction method doRun.
protected void doRun() {
SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
if (dialog.open() == IDialogConstants.OK_ID) {
// save editors
LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, getSelectedRepositoryViewObject());
if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
return;
}
lockDirtyDialog.saveDirtyObjects();
// remove
MDMServerDef serverDef = dialog.getSelectedServerDef();
List<AbstractDeployCommand> commands = new LinkedList<AbstractDeployCommand>();
CommandManager commandManager = CommandManager.getInstance();
for (Object obj : getSelectedObject()) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
ICommand deleteCommand = commandManager.getNewCommand(ICommand.CMD_DELETE);
deleteCommand.init(viewObj);
commands.add((AbstractDeployCommand) deleteCommand);
}
//
IStatus status = DeployService.getInstance().runCommands(commands, serverDef);
if (status.isMultiStatus()) {
showDeployStatus(status);
}
}
}
use of org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand in project tmdm-studio-se by Talend.
the class DeployAllAction method runWithType.
public void runWithType(ERepositoryObjectType type) {
DeployAllDialog dialog = new DeployAllDialog(getShell(), type);
if (dialog.open() == IDialogConstants.OK_ID) {
List<AbstractDeployCommand> selectededCommands = dialog.getSelectedCommands();
if (selectededCommands.size() >= 0) {
DeployService deployService = DeployService.getInstance();
deployViewObject = deployService.getDeployViewObject(selectededCommands);
// validate object
IModelValidateResult validateResult = deployService.validateModel(deployViewObject);
int selectedButton = validateResult.getSelectedButton();
if (selectedButton == IModelValidationService.BUTTON_CANCEL) {
return;
}
List<IRepositoryViewObject> validObjects = validateResult.getValidObjects(selectedButton);
List<IRepositoryViewObject> invalidObjects = validateResult.getInvalidObjects(selectedButton);
//
MDMServerDef serverDef = dialog.getServerDef();
try {
// consistency check
ConsistencyCheckResult consistencyCheckResult = deployService.checkConsistency(serverDef, validObjects, selectededCommands);
if (consistencyCheckResult.isCanceled()) {
return;
} else {
validObjects = consistencyCheckResult.getToDeployObjects();
}
deployService.removeInvalidCommands(invalidObjects, selectededCommands);
deployService.removeInvalidCommands(consistencyCheckResult.getToSkipObjects(), selectededCommands);
// save editors
LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, validObjects);
if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
return;
}
lockDirtyDialog.saveDirtyObjects();
// insert impact dialog
List<AbstractDeployCommand> canceledCommandAfterImpactAnalysis = new LinkedList<AbstractDeployCommand>(selectededCommands);
try {
Map<IRepositoryViewObject, ImpactOperation> analyzeModelImpact = ModelImpactAnalyseService.analyzeCommandImpact(serverDef, selectededCommands);
Map<IRepositoryViewObject, ICommandParameter> paramMap = null;
if (analyzeModelImpact != null) {
ModelImpactAnalyseService.shrinkDeployCommands(analyzeModelImpact, selectededCommands);
paramMap = ModelImpactAnalyseService.convertToParameters(analyzeModelImpact);
CommandManager.getInstance().attachParameterToCommand(selectededCommands, paramMap);
}
canceledCommandAfterImpactAnalysis.removeAll(selectededCommands);
} catch (InterruptedException ex) {
return;
}
IStatus status = deployService.runCommands(selectededCommands, serverDef);
// update consistency value
try {
deployService.updateServerConsistencyStatus(serverDef, status);
} catch (XtentisException e) {
log.error(e.getMessage(), e);
} catch (WebServiceException e) {
log.error(e.getMessage(), e);
}
// add canceled object to status
deployService.generateValidationFailedDeployStatus(status, invalidObjects);
deployService.generateConsistencyCancelDeployStatus(status, consistencyCheckResult.getToSkipObjects().toArray(new IRepositoryViewObject[0]));
for (AbstractDeployCommand cmd : canceledCommandAfterImpactAnalysis) {
deployService.generateConsistencyCancelDeployStatus(status, cmd.getViewObject());
}
//
updateChangedStatus(status);
if (status.isMultiStatus()) {
showDeployStatus(status);
}
updateLastServer(status, new NullProgressMonitor());
} catch (Exception 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(getShell(), title, Messages.AbstractDataClusterAction_ConnectFailed);
}
}
}
}
Aggregations