Search in sources :

Example 56 with MDMServerDef

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

the class DeployAnotherVersionAction method doRun.

@Override
protected void doRun() {
    boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
    if (!checkMissingJar) {
        return;
    }
    List<IRepositoryViewObject> viewObjs = getSelectedRepositoryViewObject();
    if (viewObjs.size() == 0) {
        return;
    }
    String originVersion = viewObjs.get(0).getProperty().getVersion();
    // open the version dialog
    SelectVersionDialog versionDialog = new SelectVersionDialog(getShell(), Messages.DeployAnotherVersionAction_selectAnother, viewObjs.get(0));
    versionDialog.create();
    if (versionDialog.open() == IDialogConstants.OK_ID) {
        if (versionDialog.getSelection() != null) {
            viewObjs = new ArrayList<IRepositoryViewObject>();
            IRepositoryViewObject modelviewObj = versionDialog.getSelection();
            viewObjs.add(modelviewObj);
            viewObjs.addAll(getAssociatedObjects(modelviewObj));
        }
        SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
        if (dialog.open() == IDialogConstants.OK_ID) {
            // save editors
            LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, viewObjs);
            if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
                return;
            }
            lockDirtyDialog.saveDirtyObjects();
            // deploy
            MDMServerDef serverDef = dialog.getSelectedServerDef();
            if (doCheckServerConnection(serverDef)) {
                IStatus status = DeployService.getInstance().deployAnotherVersion(serverDef, viewObjs);
                if (status.isMultiStatus()) {
                    showDeployStatus(status);
                }
                if (isLatestVersion(viewObjs.get(0), originVersion)) {
                    updateChangedStatus(status);
                    updateLastServer(status, new NullProgressMonitor());
                }
            }
        }
    }
}
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) SelectVersionDialog(org.talend.mdm.repository.ui.dialogs.SelectVersionDialog)

Example 57 with MDMServerDef

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

the class DeployToAction method initializeSelection.

/**
 * set the default selection in SelectServerDefDialog
 *
 * @param viewObjs current selected view objects
 * @param dialog
 */
private void initializeSelection(List<IRepositoryViewObject> viewObjs, SelectServerDefDialog dialog) {
    MDMServerDef defServer = null;
    for (IRepositoryViewObject viewObject : viewObjs) {
        MDMServerDef tmpServer = RepositoryResourceUtil.getLastServerDef(viewObject);
        if (defServer == null) {
            defServer = tmpServer;
        } else if (tmpServer != null && !RepositoryResourceUtil.isSameMDMServerDef(defServer, tmpServer)) {
            defServer = null;
            break;
        }
    }
    dialog.create();
    dialog.setSelectServer(defServer);
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 58 with MDMServerDef

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

the class DeployToAction method doRun.

@Override
protected void doRun() {
    boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
    if (!checkMissingJar) {
        return;
    }
    List<IRepositoryViewObject> viewObjs = getSelectedRepositoryViewObject();
    viewObjs = doCheckDependency(viewObjs);
    if (viewObjs == null) {
        return;
    }
    SelectServerDefDialog dialog = getSelectServerDefDialog(viewObjs);
    if (dialog.open() == IDialogConstants.OK_ID) {
        // save editors
        if (!doBeforeDeploy(viewObjs)) {
            return;
        }
        // deploy
        MDMServerDef serverDef = dialog.getSelectedServerDef();
        IStatus status = deploy(serverDef, viewObjs, ICommand.CMD_MODIFY);
        if (status.getSeverity() != IStatus.CANCEL) {
            updateChangedStatus(status);
            if (status.isMultiStatus()) {
                showDeployStatus(status);
            }
            doPostDeploy(status);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) 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 59 with MDMServerDef

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

the class DeployService method updateForStatus.

private void updateForStatus(boolean isUpdateServer, List<DeployStatus> deployStatuses) {
    if (deployStatuses == null || deployStatuses.size() == 0) {
        return;
    }
    for (DeployStatus deployStatus : deployStatuses) {
        if (deployStatus != null && deployStatus.isOK()) {
            ICommand command = deployStatus.getCommand();
            if (command != null) {
                CommandManager manager = CommandManager.getInstance();
                manager.removeCommandStack(command, ICommand.PHASE_DEPLOY);
                if (isUpdateServer) {
                    MDMServerDef serverDef = null;
                    if (command instanceof AbstractDeployCommand) {
                        serverDef = ((AbstractDeployCommand) command).getServerDef();
                    } else if (command instanceof DeployCompoundCommand) {
                        serverDef = ((DeployCompoundCommand) command).getServerDef();
                    }
                    if (command instanceof BatchDeployJobCommand) {
                        BatchDeployJobCommand deployJobCommand = (BatchDeployJobCommand) command;
                        pushRestoreCommand(manager, deployJobCommand.getSubCmds(), serverDef);
                        pushRestoreCommand(manager, deployJobCommand.getSubDeleteCmds(), serverDef);
                    } else {
                        // updateserver
                        pushRestoreCommand(manager, command, serverDef);
                    }
                }
            }
        }
    }
}
Also used : DeployCompoundCommand(org.talend.mdm.repository.core.command.deploy.DeployCompoundCommand) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) BatchDeployJobCommand(org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 60 with MDMServerDef

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

the class CopyUrlAction method multiCopy.

private void multiCopy() {
    StringBuilder result = new StringBuilder();
    List<Object> selectedObject = getSelectedObject();
    for (Object obj : selectedObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        // picture file info
        Item item = viewObject.getProperty().getItem();
        WSResourceE wsItem = null;
        if (!(item instanceof WSResourceItem)) {
            continue;
        }
        wsItem = ((WSResourceItem) item).getResource();
        String catalog = wsItem.getImageCatalog();
        if (catalog == null) {
            continue;
        }
        String fileName = viewObject.getLabel() + '.' + wsItem.getFileExtension();
        // MDMServerDef thing
        MDMServerDef serverDef = RepositoryResourceUtil.getLastServerDef(viewObject);
        if (serverDef == null) {
            continue;
        }
        // all picture url string
        String contextPath = Util.getContextPath(serverDef.getPath());
        String uripre = serverDef.getProtocol() + serverDef.getHost() + ':' + serverDef.getPort() + contextPath;
        result.append(uripre);
        // $NON-NLS-1$
        result.append("/imageserver/upload/" + catalog + '/' + fileName);
        result.append('\n');
    }
    // copy url to clipboard
    if (result.length() != 0) {
        Clipboard cb = new Clipboard(Display.getCurrent());
        String textData = result.toString();
        TextTransfer transfer = TextTransfer.getInstance();
        cb.setContents(new Object[] { textData }, new Transfer[] { transfer });
        cb.dispose();
    }
}
Also used : Item(org.talend.core.model.properties.Item) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) Clipboard(org.eclipse.swt.dnd.Clipboard) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

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