Search in sources :

Example 1 with ImpactOperation

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();
}
Also used : TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CCombo(org.eclipse.swt.custom.CCombo) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 2 with ImpactOperation

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);
}
Also used : ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) Point(org.eclipse.swt.graphics.Point)

Example 3 with ImpactOperation

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);
    }
}
Also used : ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter)

Example 4 with ImpactOperation

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);
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)

Example 5 with ImpactOperation

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);
    }
}
Also used : HashMap(java.util.HashMap) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) ArrayList(java.util.ArrayList) CommandManager(org.talend.mdm.repository.core.command.CommandManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) Property(org.talend.core.model.properties.Property) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ImpactOperation (org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)4 ICommandParameter (org.talend.mdm.repository.core.command.param.ICommandParameter)4 CommandManager (org.talend.mdm.repository.core.command.CommandManager)3 XtentisException (com.amalto.workbench.utils.XtentisException)2 LinkedList (java.util.LinkedList)2 WebServiceException (javax.xml.ws.WebServiceException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Point (org.eclipse.swt.graphics.Point)2 ConsistencyCheckResult (org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyCheckResult)2 IModelValidateResult (org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult)2 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 CCombo (org.eclipse.swt.custom.CCombo)1 TreeEditor (org.eclipse.swt.custom.TreeEditor)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1