Search in sources :

Example 1 with DeployService

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

the class ViewMainPage2 method deployAndRefresh.

private void deployAndRefresh() {
    DeployService deployService = DeployService.getInstance();
    if (!deployService.isAutoDeploy()) {
        autoDeployProcess(deployService);
        // refresh after deploy
        MDMRepositoryView view = MDMRepositoryView.show();
        if (view != null) {
            view.refreshRootNode(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
        }
    }
}
Also used : DeployService(org.talend.mdm.repository.core.service.DeployService) MDMRepositoryView(org.talend.mdm.repository.ui.navigator.MDMRepositoryView)

Example 2 with DeployService

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

the class XObjectEditor2 method saveResourceToRepository.

private boolean saveResourceToRepository() {
    XObjectEditorInput2 editorInput = (XObjectEditorInput2) this.getEditorInput();
    TreeObject xobject = (TreeObject) editorInput.getModel();
    IRepositoryViewObject viewObject = editorInput.getViewObject();
    IRepositoryViewObject refreshViewObject = RepositoryResourceUtil.assertViewObject(viewObject);
    if (viewObject != refreshViewObject) {
        editorInput.updateViewObject(refreshViewObject);
    }
    MDMServerObjectItem serverObjectItem = (MDMServerObjectItem) editorInput.getInputItem();
    MDMServerObject serverObject = serverObjectItem.getMDMServerObject();
    EObject eObj = Bean2EObjUtil.getInstance().convertFromBean2EObj(xobject.getWsObject(), serverObject);
    if (eObj != null) {
        IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        try {
            factory.save(serverObjectItem);
            // TODO should call the following,but the page in editor has many call to remote webService ,it will
            // search ServerRoot which cause a NPE
            // xobject.fireEvent(IXObjectModelListener.SAVE, xobject.getParent(), xobject);
            editorDirtyStateChanged();
            refreshDirtyCue();
            DeployService deployService = DeployService.getInstance();
            if (deployService.isAutoDeploy()) {
                autoDeployProcess(deployService);
            } else {
                MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(serverObjectItem);
                if (lastServerDef != null) {
                    CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, editorInput.getViewObject());
                }
            }
            return true;
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        }
    }
    return false;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) TreeObject(com.amalto.workbench.models.TreeObject) DeployService(org.talend.mdm.repository.core.service.DeployService) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 3 with DeployService

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

the class XSDEditor2 method innerSave.

private void innerSave(final IProgressMonitor monitor) {
    IRepositoryViewObject viewObject = getCurrentViewObject();
    final Item item = viewObject.getProperty().getItem();
    int activePage = getActivePage();
    // 
    final TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) getAdapter(TransactionalEditingDomain.class);
    if (editingDomain != null && (activePage != MODEL_PAGE_INDEX && activePage != SOURCE_PAGE_INDEX)) {
        editingDomain.getCommandStack().execute(new AbstractCommand() {

            @Override
            public boolean canExecute() {
                return true;
            }

            @Override
            public void redo() {
            // do nothing
            }

            @Override
            public void execute() {
                doSave(item, monitor);
            }
        });
    } else {
        doSave(item, monitor);
    }
    DeployService deployService = DeployService.getInstance();
    if (deployService.isAutoDeploy()) {
        deployService.autoDeploy(getSite().getShell(), viewObject);
    } else {
        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
        if (lastServerDef != null) {
            CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, viewObject);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AbstractCommand(org.eclipse.emf.common.command.AbstractCommand) DeployService(org.talend.mdm.repository.core.service.DeployService) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 4 with DeployService

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

the class TransformerMainPage2 method deployAndRefresh.

private void deployAndRefresh() {
    DeployService deployService = DeployService.getInstance();
    if (!deployService.isAutoDeploy()) {
        editor2.autoDeployProcess(deployService);
        // refresh after deploy
        MDMRepositoryView view = MDMRepositoryView.show();
        if (view != null) {
            view.refreshRootNode(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
        }
    }
}
Also used : DeployService(org.talend.mdm.repository.core.service.DeployService) MDMRepositoryView(org.talend.mdm.repository.ui.navigator.MDMRepositoryView)

Example 5 with DeployService

use of org.talend.mdm.repository.core.service.DeployService 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

DeployService (org.talend.mdm.repository.core.service.DeployService)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)4 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)2 MDMRepositoryView (org.talend.mdm.repository.ui.navigator.MDMRepositoryView)2 TreeObject (com.amalto.workbench.models.TreeObject)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 WebServiceException (javax.xml.ws.WebServiceException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 AbstractCommand (org.eclipse.emf.common.command.AbstractCommand)1 EObject (org.eclipse.emf.ecore.EObject)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Item (org.talend.core.model.properties.Item)1 CommandManager (org.talend.mdm.repository.core.command.CommandManager)1 CommandStack (org.talend.mdm.repository.core.command.CommandStack)1