Search in sources :

Example 6 with ImpactOperation

use of org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation in project tmdm-studio-se by Talend.

the class ImpactResultDialog method getOperation.

private ImpactOperation getOperation(IRepositoryViewObject viewObj) {
    ImpactOperation operation = result.get(viewObj);
    if (operation == null) {
        int topLevel = getCurrentTopSeverityLevel(viewObj);
        if (topLevel == ModelImpactAnalyseService.LOW || topLevel == ModelImpactAnalyseService.MEDIUM) {
            operation = ImpactOperation.APPLY_LOW_CHANGE;
        } else {
            operation = ImpactOperation.CANCEL;
        }
        result.put(viewObj, operation);
    }
    return operation;
}
Also used : ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) Point(org.eclipse.swt.graphics.Point)

Example 7 with ImpactOperation

use of org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation 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);
            }
        }
    }
}
Also used : IModelValidateResult(org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) WebServiceException(javax.xml.ws.WebServiceException) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) DeployService(org.talend.mdm.repository.core.service.DeployService) DeployAllDialog(org.talend.mdm.repository.ui.dialogs.deploy.DeployAllDialog) LinkedList(java.util.LinkedList) XtentisException(com.amalto.workbench.utils.XtentisException) WebServiceException(javax.xml.ws.WebServiceException) LockedDirtyObjectDialog(org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ConsistencyCheckResult(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyCheckResult) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 8 with ImpactOperation

use of org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation 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;
    }
}
Also used : IModelValidateResult(org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult) IStatus(org.eclipse.core.runtime.IStatus) WebServiceException(javax.xml.ws.WebServiceException) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) LinkedList(java.util.LinkedList) XtentisException(com.amalto.workbench.utils.XtentisException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WebServiceException(javax.xml.ws.WebServiceException) CommandManager(org.talend.mdm.repository.core.command.CommandManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ConsistencyCheckResult(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyCheckResult) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) XtentisException(com.amalto.workbench.utils.XtentisException)

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