Search in sources :

Example 51 with MDMServerDef

use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.

the class UpdateLastServerService method updateLastServerDefInfo.

public void updateLastServerDefInfo(Object serverDef, IRepositoryViewObject ViewObject) {
    if (serverDef == null || ViewObject == null || !(serverDef instanceof MDMServerDef)) {
        return;
    }
    CommandManager cmdManager = CommandManager.getInstance();
    DeployService deployService = DeployService.getInstance();
    ICommand deployCmd = cmdManager.getNewCommand(ICommand.CMD_MODIFY);
    deployCmd.init(ViewObject);
    // $NON-NLS-1$ //$NON-NLS-2$
    MultiStatus mStatus = new MultiStatus("PLUGIN_ID", Status.OK, "", null);
    // $NON-NLS-1$
    DeployStatus deployStatus = DeployStatus.getOKStatus(deployCmd, "");
    mStatus.add(deployStatus);
    cmdManager.removeCommandStack(deployCmd, ICommand.PHASE_DEPLOY);
    deployService.pushRestoreCommand(cmdManager, deployCmd, (MDMServerDef) serverDef);
    deployService.updateLastServer(mStatus, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) DeployStatus(org.talend.mdm.repository.core.service.DeployService.DeployStatus) MultiStatus(org.eclipse.core.runtime.MultiStatus) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 52 with MDMServerDef

use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.

the class OpenObjectAction method doOpen.

public boolean doOpen() {
    List<Object> sels = getSelectedObject();
    if (selObjects != null) {
        sels = selObjects;
    }
    if (sels.isEmpty()) {
        return false;
    }
    Object obj = sels.get(0);
    if (obj instanceof IRepositoryViewObject) {
        if (obj instanceof WSRootRepositoryObject) {
            return false;
        }
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        Item item = viewObject.getProperty().getItem();
        if (item instanceof ContainerItem) {
            if (viewObject.getRepositoryObjectType().equals(IServerObjectRepositoryType.TYPE_SERVICECONFIGURATION)) {
                // service
                boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
                if (!checkMissingJar) {
                    return false;
                }
                // configuration
                MDMServerDef serverDef = openServerDialog(null);
                openServiceConfig(serverDef);
            } else {
                getCommonViewer().expandToLevel(obj, 1);
            }
        } else {
            IEditorReference editorRef = RepositoryResourceUtil.isOpenedInEditor(viewObject);
            if (editorRef != null) {
                if (page == null) {
                    page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
                }
                if (page != null) {
                    page.bringToTop(editorRef.getPart(false));
                }
                if (marker != null) {
                    IDE.gotoMarker(editorRef.getEditor(true), marker);
                }
                return false;
            } else {
                openItem(viewObject);
                return true;
            }
        }
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IEditorReference(org.eclipse.ui.IEditorReference) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject)

Example 53 with MDMServerDef

use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef 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 54 with MDMServerDef

use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.

the class RenameObjectAction method doRun.

@Override
protected void doRun() {
    Object obj = getSelectedObject().get(0);
    if (obj instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
        MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
        MDMServerObject serverObject = item.getMDMServerObject();
        IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
        if (configuration != null) {
            ERepositoryObjectType type = configuration.getResourceProvider().getRepositoryObjectType(item);
            IRepositoryViewObject parentViewObj = ContainerCacheService.get(type, item.getState().getPath());
            try {
                if (serverObject != null) {
                    String oldName = serverObject.getName();
                    String newName = showRenameDlg(type, (ContainerItem) parentViewObj.getProperty().getItem(), oldName);
                    if (newName != null && factory.isEditableAndLockIfPossible(item)) {
                        serverObject.setName(newName);
                        viewObj.getProperty().setLabel(newName);
                        viewObj.getProperty().setDisplayName(newName);
                        factory.save(viewObj.getProperty().getItem(), false);
                        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
                        if (lastServerDef != null) {
                            CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
                        }
                    }
                }
                commonViewer.refresh(obj);
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            } finally {
                try {
                    factory.unlock(item);
                } catch (PersistenceException e) {
                    log.error(e.getMessage(), e);
                } catch (LoginException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) LoginException(org.talend.commons.exception.LoginException) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 55 with MDMServerDef

use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef 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

MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)66 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)36 SelectServerDefDialog (org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog)15 Item (org.talend.core.model.properties.Item)11 MDMServerDefItem (org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem)10 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)10 IStatus (org.eclipse.core.runtime.IStatus)8 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)8 PersistenceException (org.talend.commons.exception.PersistenceException)7 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)7 TMDMService (com.amalto.workbench.webservices.TMDMService)6 CommandManager (org.talend.mdm.repository.core.command.CommandManager)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 TreeObject (com.amalto.workbench.models.TreeObject)5 XtentisException (com.amalto.workbench.utils.XtentisException)5 ArrayList (java.util.ArrayList)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 LinkedList (java.util.LinkedList)4