use of org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation in project tmdm-studio-se by Talend.
the class ImpactResultDialog method initTree.
private void initTree() {
treeViewer.setInput(input.keySet());
Tree tree = treeViewer.getTree();
TreeItem[] tableItems = tree.getItems();
System.out.println(tableItems.length);
for (TreeItem item : tableItems) {
Object data = item.getData();
if (data != null && data instanceof IRepositoryViewObject) {
final IRepositoryViewObject viewObj = (IRepositoryViewObject) data;
final TreeEditor editor = new TreeEditor(tree);
final CCombo combo = new CCombo(tree, SWT.READ_ONLY);
// combo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
String[] items = getDefaultComboItems(viewObj);
combo.setItems(items);
ImpactOperation operation = getOperation(viewObj);
combo.setText(operation.getDescription());
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
modifyOperationValue(viewObj, combo.getSelectionIndex());
}
});
editor.grabHorizontal = true;
editor.setEditor(combo, item, 2);
}
}
//
treeViewer.expandAll();
}
use of org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation in project tmdm-studio-se by Talend.
the class ImpactResultDialog method modifyOperationValue.
private void modifyOperationValue(IRepositoryViewObject viewObj, int index) {
if (index < 0) {
return;
}
int severity = getCurrentTopSeverityLevel(viewObj);
switch(severity) {
case ModelImpactAnalyseService.LOW:
index += 1;
break;
case ModelImpactAnalyseService.MEDIUM:
break;
case ModelImpactAnalyseService.HIGH:
if (index > 0) {
index = 2;
}
break;
}
ImpactOperation operation = ImpactOperation.getOperation(index);
result.put(viewObj, operation);
}
use of org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation in project tmdm-studio-se by Talend.
the class DataModelInteractiveHandler method callModelService.
private void callModelService(AbstractDeployCommand cmd) throws XtentisException {
ICommandParameter parameter = cmd.getParameter();
if (parameter != null) {
ImpactOperation operation = (ImpactOperation) parameter.getParameter();
Boolean force = null;
if (operation == ImpactOperation.APPLY_LOW_CHANGE) {
force = false;
} else if (operation == ImpactOperation.RECREATE_TABLE) {
force = true;
}
ModelImpactAnalyseService.updateModel(cmd.getServerDef(), cmd.getViewObject(), force);
}
}
use of org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation 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.service.ModelImpactAnalyseService.ImpactOperation in project tmdm-studio-se by Talend.
the class DeployServiceTest method testDeployAnotherVersion.
@Test
public void testDeployAnotherVersion() {
try {
MDMServerDef mockServerDef = PowerMockito.mock(MDMServerDef.class);
IRepositoryViewObject mockViewObj = PowerMockito.mock(IRepositoryViewObject.class);
Property mockProperty = PowerMockito.mock(Property.class);
PowerMockito.when(mockViewObj.getProperty()).thenReturn(mockProperty);
List<IRepositoryViewObject> repositoryViewObjs = new ArrayList<IRepositoryViewObject>(Arrays.asList(mockViewObj));
PowerMockito.mockStatic(CommandManager.class);
CommandManager mockCommandManager = PowerMockito.mock(CommandManager.class);
PowerMockito.when(CommandManager.getInstance()).thenReturn(mockCommandManager);
List<AbstractDeployCommand> deployCommands = new ArrayList<AbstractDeployCommand>();
deployCommands.add(PowerMockito.mock(AbstractDeployCommand.class));
PowerMockito.when(mockCommandManager.getDeployCommandsWithoutHistory(anyListOf(IRepositoryViewObject.class))).thenReturn(deployCommands);
PowerMockito.mockStatic(ModelImpactAnalyseService.class);
DeployService mockDeployService = PowerMockito.mock(DeployService.class);
PowerMockito.when(mockDeployService.deployAnotherVersion(any(MDMServerDef.class), anyListOf(IRepositoryViewObject.class))).thenCallRealMethod();
// //
mockDeployService.deployAnotherVersion(mockServerDef, repositoryViewObjs);
// //
Mockito.verify(mockDeployService).runCommands(deployCommands, mockServerDef);
PowerMockito.verifyStatic();
ModelImpactAnalyseService.analyzeCommandImpact(any(MDMServerDef.class), anyListOf(AbstractDeployCommand.class));
// ---------
Map<IRepositoryViewObject, ImpactOperation> analyzeModelImpact = new HashMap<IRepositoryViewObject, ModelImpactAnalyseService.ImpactOperation>();
ImpactOperation mockImpactOperation = PowerMockito.mock(ImpactOperation.class);
analyzeModelImpact.put(mockViewObj, mockImpactOperation);
PowerMockito.when(ModelImpactAnalyseService.analyzeCommandImpact(any(MDMServerDef.class), anyListOf(AbstractDeployCommand.class))).thenReturn(analyzeModelImpact);
// //
mockDeployService.deployAnotherVersion(mockServerDef, repositoryViewObjs);
// //
Mockito.verify(mockDeployService, times(2)).runCommands(deployCommands, mockServerDef);
PowerMockito.verifyStatic(times(2));
ModelImpactAnalyseService.analyzeCommandImpact(any(MDMServerDef.class), anyListOf(AbstractDeployCommand.class));
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Aggregations