Search in sources :

Example 41 with MDMServerDef

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

the class BrowseViewAction method doRun.

@Override
protected void doRun() {
    Object obj = getSelectedObject().get(0);
    if (obj instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        WSViewItem item = (WSViewItem) viewObject.getProperty().getItem();
        WSViewE wsView = item.getWsView();
        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
        SelectServerDefDialog dlg = new SelectServerDefDialog(getShell());
        dlg.create();
        dlg.setSelectServer(lastServerDef);
        if (dlg.open() == IDialogConstants.OK_ID) {
            ViewBrowserInput input = new ViewBrowserInput(viewObject);
            input.setServerDef(dlg.getSelectedServerDef());
            if (page == null) {
                page = commonViewer.getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
            }
            try {
                IEditorPart oldEditor = page.findEditor(input);
                if (oldEditor != null) {
                    page.closeEditor(oldEditor, false);
                }
                page.openEditor(input, XObjectBrowser2.EDITOR_ID);
            } catch (PartInitException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}
Also used : WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) ViewBrowserInput(org.talend.mdm.repository.ui.editors.ViewBrowserInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) WSViewE(org.talend.mdm.repository.model.mdmserverobject.WSViewE) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 42 with MDMServerDef

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

the class RenameProcessAction method renameProcessObject.

private void renameProcessObject(IRepositoryViewObject viewObj) {
    MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
    MDMServerObject serverObject = item.getMDMServerObject();
    int type = getType(item);
    if (serverObject != null) {
        String oldName = serverObject.getName();
        RenameProcessDialog dialog = getRenameDialog(getSite(), oldName, type, getInputValidator());
        int returnCode = dialog.open();
        if (returnCode == Window.OK) {
            IProxyRepositoryFactory factory = getFactory();
            String newName = dialog.getValue();
            transformPath(viewObj, newName);
            try {
                if (factory.isEditableAndLockIfPossible(item)) {
                    serverObject.setName(newName);
                    viewObj.getProperty().setLabel(newName);
                    viewObj.getProperty().setDisplayName(newName);
                    factory.save(item, false);
                    MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
                    if (lastServerDef != null) {
                        CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
                    }
                }
                commonViewer.refresh(viewObj);
            } 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) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 43 with MDMServerDef

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

the class ViewMainPage2 method getLastServerDef.

private MDMServerDef getLastServerDef() {
    XObjectEditorInput2 input = (XObjectEditorInput2) getEditor().getEditorInput();
    Item item = input.getInputItem();
    MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
    return lastServerDef;
}
Also used : Item(org.talend.core.model.properties.Item) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 44 with MDMServerDef

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

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

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