Search in sources :

Example 16 with MDMServerDef

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

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

the class RepositoryResourceUtil method getLastServerDef.

/**
 * @param item
 * @return A decrypted serverDef
 */
public static MDMServerDef getLastServerDef(Item item) {
    if (item != null) {
        if (item instanceof MDMServerObjectItem) {
            MDMServerObject mdmServerObject = ((MDMServerObjectItem) item).getMDMServerObject();
            String lastServerName = mdmServerObject.getLastServerName();
            if (lastServerName == null) {
                MDMServerDef lastServerDef = mdmServerObject.getLastServerDef();
                if (lastServerDef != null) {
                    lastServerName = lastServerDef.getName();
                }
            }
            if (lastServerName != null) {
                return ServerDefService.findServerDefByName(lastServerName);
            }
        } else {
            Property property = item.getProperty();
            if (property != null) {
                Object value = property.getAdditionalProperties().get(PROP_LAST_SERVER_DEF);
                if (value != null) {
                    return ServerDefService.findServerDefByName((String) value);
                }
            }
        }
    }
    return null;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) Property(org.talend.core.model.properties.Property) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 18 with MDMServerDef

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

the class ServerExplorer method reInputPassword.

private void reInputPassword() {
    List<IRepositoryViewObject> viewObjects = ServerDefService.getAllServerDefViewObjects();
    for (IRepositoryViewObject viewObj : viewObjects) {
        MDMServerDefItem serverDefItem = getMDMItem(viewObj);
        MDMServerDef serverDef = serverDefItem.getServerDef();
        if (serverDef.getPasswd().equals("")) {
            // $NON-NLS-1$
            MessageDialog.openInformation(null, Messages.ServerExplorer_WarningText, Messages.bind(Messages.Reinput_Password, serverDef.getName()));
            editServerDef(viewObj);
        }
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 19 with MDMServerDef

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

the class ServerExplorer method getMenuListener.

private IMenuListener getMenuListener() {
    return new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            ISelection selection = treeViewer.getSelection();
            boolean isEmpty = selection.isEmpty();
            if (isEmpty) {
                manager.add(addServerDefAction);
            } else {
                addAllActions(manager);
                IRepositoryViewObject viewObject = getCurSelectedViewObject();
                if (viewObject != null) {
                    MDMServerDefItem mdmItem = getMDMItem(viewObject);
                    if (mdmItem != null) {
                        MDMServerDef serverDef = mdmItem.getServerDef();
                        manager.add(new Separator());
                        if (serverDef.isEnabled()) {
                            manager.add(toDisableServerAction);
                        } else {
                            manager.add(toEnableServerAction);
                        }
                    }
                }
            }
        }
    };
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuListener(org.eclipse.jface.action.IMenuListener) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) Separator(org.eclipse.jface.action.Separator)

Example 20 with MDMServerDef

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

the class ServerDefService method getAllServerDefs.

public static List<MDMServerDef> getAllServerDefs(boolean includeDisabledServer) {
    List<IRepositoryViewObject> viewObjects = getAllServerDefViewObjects(includeDisabledServer);
    if (viewObjects != null) {
        List<MDMServerDef> serverDefs = new ArrayList<MDMServerDef>(viewObjects.size());
        for (IRepositoryViewObject viewObj : viewObjects) {
            Item item = viewObj.getProperty().getItem();
            MDMServerDef serverDef = ((MDMServerDefItem) item).getServerDef();
            if (serverDef != null && (includeDisabledServer || serverDef.isEnabled())) {
                serverDefs.add(serverDef.getDecryptedServerDef());
            }
        }
        return serverDefs;
    }
    return null;
}
Also used : MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) 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