Search in sources :

Example 1 with BatchDeployJobCommand

use of org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand in project tmdm-studio-se by Talend.

the class DeployService method updateServerConsistencyStatus.

public void updateServerConsistencyStatus(MDMServerDef serverDef, IStatus mainStatus) throws XtentisException, WebServiceException {
    if (!UIUtil.isWorkInUI()) {
        return;
    }
    if (mainStatus.isMultiStatus()) {
        Set<IRepositoryViewObject> viewObjs = new HashSet<IRepositoryViewObject>();
        for (IStatus childStatus : mainStatus.getChildren()) {
            DeployStatus deployStatus = null;
            if (childStatus instanceof DeployStatus) {
                deployStatus = (DeployStatus) childStatus;
                if (deployStatus.isOK()) {
                    AbstractDeployCommand command = (AbstractDeployCommand) deployStatus.getCommand();
                    if (command instanceof BatchDeployJobCommand) {
                        for (ICommand subCmd : ((BatchDeployJobCommand) command).getSubCmds()) {
                            if (subCmd instanceof AbstractDeployCommand) {
                                IRepositoryViewObject viewObj = ((AbstractDeployCommand) subCmd).getViewObject();
                                if (viewObj != null) {
                                    viewObjs.add(viewObj);
                                }
                            }
                        }
                    } else {
                        if (command != null) {
                            IRepositoryViewObject viewObj = command.getViewObject();
                            if (viewObj != null) {
                                viewObjs.add(viewObj);
                            }
                        }
                    }
                }
            } else if (childStatus instanceof MultiStatus) {
                updateServerConsistencyStatus(serverDef, childStatus);
            }
        }
        updateServerConsistencyStatus(serverDef, viewObjs);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ICommand(org.talend.mdm.repository.core.command.ICommand) BatchDeployJobCommand(org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MultiStatus(org.eclipse.core.runtime.MultiStatus) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) HashSet(java.util.HashSet)

Example 2 with BatchDeployJobCommand

use of org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand in project tmdm-studio-se by Talend.

the class DeployStatusDialog method getType.

private ERepositoryObjectType getType(IStatus status) {
    IStatus queryStatus = status;
    if (status.isMultiStatus()) {
        IStatus[] childrenStatus = status.getChildren();
        if (childrenStatus != null && childrenStatus.length > 0) {
            queryStatus = childrenStatus[0];
        }
    }
    if (queryStatus != null && queryStatus instanceof DeployStatus) {
        ICommand command = ((DeployStatus) queryStatus).getCommand();
        IRepositoryViewObject viewObject = null;
        if (command != null) {
            if (command instanceof BatchDeployJobCommand) {
                return ERepositoryObjectType.PROCESS;
            } else {
                viewObject = command.getViewObject();
            }
        }
        if (viewObject == null) {
            return null;
        }
        return viewObject.getRepositoryObjectType();
    }
    return null;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ICommand(org.talend.mdm.repository.core.command.ICommand) BatchDeployJobCommand(org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand) DeployStatus(org.talend.mdm.repository.core.service.DeployService.DeployStatus) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 3 with BatchDeployJobCommand

use of org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand 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 4 with BatchDeployJobCommand

use of org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand in project tmdm-studio-se by Talend.

the class DeployService method updateChangedStatus.

public void updateChangedStatus(IStatus status, boolean isUpdateServer) {
    if (status.isMultiStatus()) {
        for (IStatus childStatus : status.getChildren()) {
            List<DeployStatus> deployStatuses = new ArrayList<DeployStatus>();
            if (childStatus instanceof DeployStatus) {
                deployStatuses.add((DeployStatus) childStatus);
            } else if (childStatus instanceof MultiStatus) {
                IStatus[] childrenStatus = ((MultiStatus) childStatus).getChildren();
                if (childrenStatus.length > 0) {
                    for (IStatus cstatus : childrenStatus) {
                        if (cstatus instanceof DeployStatus) {
                            deployStatuses.add((DeployStatus) cstatus);
                            if (((DeployStatus) cstatus).getCommand() instanceof BatchDeployJobCommand) {
                                break;
                            }
                        }
                    }
                }
            }
            updateForStatus(isUpdateServer, deployStatuses);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) BatchDeployJobCommand(org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand) ArrayList(java.util.ArrayList) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 5 with BatchDeployJobCommand

use of org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand in project tmdm-studio-se by Talend.

the class JobInteractiveHandler method deploy.

@Override
public boolean deploy(AbstractDeployCommand cmd) throws XtentisException {
    setToDefaultValue();
    if (cmd instanceof BatchDeployJobCommand) {
        BatchDeployJobCommand deployJobCommand = (BatchDeployJobCommand) cmd;
        List<IRepositoryViewObject> viewObjects = deployJobCommand.getViewObjects();
        if (viewObjects.isEmpty()) {
            return true;
        }
        IStructuredSelection selection = getSelection(viewObjects);
        // 
        final DeployOnMDMExportWizard publishWizard = new DeployOnMDMExportWizard();
        SpagoBiServer server = getServer(deployJobCommand.getServerDef());
        publishWizard.setMdmServer(server);
        IWorkbench workbench = RepositoryPlugin.getDefault().getWorkbench();
        publishWizard.setWindowTitle(Messages.JobInteractiveHandler_wizardTitle);
        publishWizard.init(workbench, selection);
        final Display display = Display.getDefault();
        display.syncExec(new Runnable() {

            public void run() {
                Shell activeShell = display.getActiveShell();
                WizardDialog dialog = new WizardDialog(activeShell, publishWizard);
                int open = dialog.open();
                if (open == IDialogConstants.CANCEL_ID) {
                    setDeployCancelled(true);
                } else {
                    setResult(publishWizard.isDeploySucceed());
                    RuntimeException e = publishWizard.getDeployException();
                    if (e != null) {
                        setException(e);
                    }
                }
            }
        });
    }
    if (deployCancelled) {
        throw new OperationCanceledException();
    }
    if (deployException != null) {
        throw deployException;
    }
    return result;
}
Also used : SpagoBiServer(org.talend.core.model.properties.SpagoBiServer) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkbench(org.eclipse.ui.IWorkbench) Shell(org.eclipse.swt.widgets.Shell) BatchDeployJobCommand(org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WizardDialog(org.eclipse.jface.wizard.WizardDialog) DeployOnMDMExportWizard(org.talend.mdm.engines.client.ui.wizards.DeployOnMDMExportWizard) Display(org.eclipse.swt.widgets.Display)

Aggregations

BatchDeployJobCommand (org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 IStatus (org.eclipse.core.runtime.IStatus)3 ICommand (org.talend.mdm.repository.core.command.ICommand)3 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)2 DeployCompoundCommand (org.talend.mdm.repository.core.command.deploy.DeployCompoundCommand)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 IWorkbench (org.eclipse.ui.IWorkbench)1 SpagoBiServer (org.talend.core.model.properties.SpagoBiServer)1 DeployOnMDMExportWizard (org.talend.mdm.engines.client.ui.wizards.DeployOnMDMExportWizard)1 CommandManager (org.talend.mdm.repository.core.command.CommandManager)1 DeployStatus (org.talend.mdm.repository.core.service.DeployService.DeployStatus)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1