Search in sources :

Example 1 with LockedDirtyObjectDialog

use of org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog in project tmdm-studio-se by Talend.

the class MDMValidationRunner method init.

private void init(List<IRepositoryViewObject> viewObjs) {
    viewObjMap.clear();
    Project talendProject = ProjectManager.getInstance().getCurrentProject();
    if (talendProject != null) {
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(talendProject.getTechnicalLabel());
        Set<IResource> files = new HashSet<IResource>();
        for (IRepositoryViewObject viewObj : viewObjs) {
            IFile file = null;
            ERepositoryObjectType type = viewObj.getRepositoryObjectType();
            if (type == IServerObjectRepositoryType.TYPE_DATAMODEL) {
                Item item = viewObj.getProperty().getItem();
                // $NON-NLS-1$
                file = RepositoryResourceUtil.findReferenceFile(type, item, "xsd");
                if (file != null) {
                    files.add(file);
                }
            // 
            // file = RepositoryResourceUtil.findReferenceFile(type, item, "mapinfo"); //$NON-NLS-1$
            // if (file != null) {
            // files.add(file);
            // }
            }
            if (type == IServerObjectRepositoryType.TYPE_VIEW) {
                Item item = viewObj.getProperty().getItem();
                // $NON-NLS-1$
                file = RepositoryResourceUtil.findReferenceFile(type, item, "item");
                if (file != null) {
                    files.add(file);
                }
            }
            if (type == IServerObjectRepositoryType.TYPE_WORKFLOW) {
                Item item = viewObj.getProperty().getItem();
                // $NON-NLS-1$
                file = RepositoryResourceUtil.findReferenceFile(type, item, "conf");
                if (file != null) {
                    files.add(file);
                }
            }
            viewObjMap.put(viewObj, file);
        }
        toValidate.put(project, files);
        if (UIUtil.isWorkInUI()) {
            lockDirtyDialog = new LockedDirtyObjectDialog(null, Messages.MDMValidationRunner_promptToSaveEditors, viewObjs);
        }
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) Item(org.talend.core.model.properties.Item) IFile(org.eclipse.core.resources.IFile) LockedDirtyObjectDialog(org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Example 2 with LockedDirtyObjectDialog

use of org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog in project tmdm-studio-se by Talend.

the class DeployToAction method doBeforeDeploy.

protected boolean doBeforeDeploy(List<IRepositoryViewObject> viewObjs) {
    LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, viewObjs);
    if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
        return false;
    }
    lockDirtyDialog.saveDirtyObjects();
    return true;
}
Also used : LockedDirtyObjectDialog(org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog)

Example 3 with LockedDirtyObjectDialog

use of org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog in project tmdm-studio-se by Talend.

the class DeployToLastServerAction method doRun.

@Override
protected void doRun() {
    boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
    if (!checkMissingJar) {
        return;
    }
    List<IRepositoryViewObject> viewObjs = getSelectedRepositoryViewObject();
    if (exAdapter != null) {
        viewObjs = exAdapter.showDependencyConfigDialog(viewObjs);
        if (viewObjs == null) {
            return;
        }
        // TO add match rule object
        viewObjs = getSelectedRepositoryViewObject(viewObjs);
        filterMatchRuleObjs(viewObjs);
    }
    LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, viewObjs);
    if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
        return;
    }
    lockDirtyDialog.saveDirtyObjects();
    // 
    MDMServerDef currentServerDef = getLastServer(viewObjs);
    // handle last server is null case
    boolean isLostedServer = false;
    if (currentServerDef == null) {
        isLostedServer = true;
        boolean isDeployToAnother = MessageDialog.openQuestion(getShell(), null, Messages.DeployToLastServerAction_askReselectServerMsg);
        if (isDeployToAnother) {
            SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
            if (dialog.open() == IDialogConstants.OK_ID) {
                currentServerDef = dialog.getSelectedServerDef();
            } else {
                return;
            }
        } else {
            return;
        }
    }
    // check last server
    if (!currentServerDef.isEnabled()) {
        MessageDialog.openWarning(Display.getDefault().getActiveShell(), null, Messages.DeployService_CanNotDeployToDisabledServer);
        return;
    }
    // deploy
    IStatus status = deploy(currentServerDef, viewObjs, ICommand.CMD_MODIFY);
    if (status.getSeverity() != IStatus.CANCEL) {
        if (status.isMultiStatus()) {
            showDeployStatus(status);
        }
        if (isLostedServer) {
            updateLastServer(status, new NullProgressMonitor());
        }
        DeployService.getInstance().updateChangedStatus(status, false);
        for (IRepositoryViewObject viewObject : viewObjs) {
            commonViewer.refresh(viewObject);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) LockedDirtyObjectDialog(org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 4 with LockedDirtyObjectDialog

use of org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog 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);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) LockedDirtyObjectDialog(org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) LinkedList(java.util.LinkedList)

Example 5 with LockedDirtyObjectDialog

use of org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog 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)

Aggregations

LockedDirtyObjectDialog (org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 IStatus (org.eclipse.core.runtime.IStatus)4 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 SelectServerDefDialog (org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog)3 LinkedList (java.util.LinkedList)2 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)2 XtentisException (com.amalto.workbench.utils.XtentisException)1 HashSet (java.util.HashSet)1 WebServiceException (javax.xml.ws.WebServiceException)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 Project (org.talend.core.model.general.Project)1 Item (org.talend.core.model.properties.Item)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 CommandManager (org.talend.mdm.repository.core.command.CommandManager)1 ICommand (org.talend.mdm.repository.core.command.ICommand)1 ICommandParameter (org.talend.mdm.repository.core.command.param.ICommandParameter)1