Search in sources :

Example 1 with AbstractDeployCommand

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

the class WaitToDeployDialog method needShowObject.

private boolean needShowObject(IRepositoryViewObject viewObj) {
    String id = viewObj.getId();
    CommandStack commandStack = CommandManager.getInstance().findCommandStack(id);
    if (commandStack != null) {
        ICommand validCommand = commandStack.getValidDeployCommand();
        if (validCommand instanceof AbstractDeployCommand) {
            if (validCommand.getCommandType() == ICommand.CMD_DELETE) {
                return RepositoryResourceUtil.getLastServerDef(viewObj) != null;
            }
            return true;
        }
    }
    return false;
}
Also used : CommandStack(org.talend.mdm.repository.core.command.CommandStack) ICommand(org.talend.mdm.repository.core.command.ICommand) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)

Example 2 with AbstractDeployCommand

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

the class DeployService method removeInvalidCommands.

public void removeInvalidCommands(List<IRepositoryViewObject> invalidObjects, List<AbstractDeployCommand> selectededCommands) {
    if (invalidObjects == null || invalidObjects.isEmpty()) {
        return;
    }
    for (Iterator<AbstractDeployCommand> il = selectededCommands.iterator(); il.hasNext(); ) {
        AbstractDeployCommand cmd = il.next();
        IRepositoryViewObject viewObject = cmd.getViewObject();
        if (viewObject != null && invalidObjects.contains(viewObject)) {
            il.remove();
        }
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)

Example 3 with AbstractDeployCommand

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

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

the class DeployService method deployAnotherVersion.

public IStatus deployAnotherVersion(MDMServerDef serverDef, List<IRepositoryViewObject> viewObjs) {
    CommandManager manager = CommandManager.getInstance();
    List<AbstractDeployCommand> commands = manager.getDeployCommandsWithoutHistory(viewObjs);
    try {
        // insert impact dialog
        Map<IRepositoryViewObject, ImpactOperation> analyzeModelImpact = ModelImpactAnalyseService.analyzeCommandImpact(serverDef, commands);
        Map<IRepositoryViewObject, ICommandParameter> paramMap = null;
        if (analyzeModelImpact != null) {
            ModelImpactAnalyseService.shrinkDeployCommands(analyzeModelImpact, commands);
            paramMap = ModelImpactAnalyseService.convertToParameters(analyzeModelImpact);
            manager.attachParameterToCommand(commands, paramMap);
        }
    } catch (InterruptedException ex) {
        return Status.CANCEL_STATUS;
    }
    return runCommands(commands, serverDef);
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)

Example 5 with AbstractDeployCommand

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

the class CommandManager method getDeployCommands.

/**
 * DOC hbhong Comment method "getDeployCommands".
 *
 * @param viewObjs
 * @param defaultCmdType if none then assign -1
 * @return
 */
public List<AbstractDeployCommand> getDeployCommands(List<IRepositoryViewObject> viewObjs, int defaultCmdType, Map<IRepositoryViewObject, ICommandParameter> paramMap) {
    List<AbstractDeployCommand> cmds = new LinkedList<AbstractDeployCommand>();
    for (IRepositoryViewObject viewObj : viewObjs) {
        CommandStack stack = findCommandStack(viewObj.getId());
        if (stack == null) {
            stack = new CommandStack();
            ICommand cmd = getNewCommand(viewObj, defaultCmdType);
            cmd.init(viewObj);
            stack.pushCommand(cmd);
        }
        ICommand validCommand = stack.getValidDeployCommand();
        if (validCommand != null) {
            if (validCommand instanceof AbstractDeployCommand) {
                fillViewObjectToCommand(validCommand);
                AbstractDeployCommand deployCommand = (AbstractDeployCommand) validCommand;
                if (paramMap != null) {
                    ICommandParameter param = paramMap.get(viewObj);
                    deployCommand.setParameter(param);
                }
                cmds.add(deployCommand);
            } else if (validCommand instanceof NOPCommand && defaultCmdType > 0) {
                ICommand cmd = getNewCommand(defaultCmdType);
                if (cmd instanceof AbstractDeployCommand) {
                    cmd.init(viewObj);
                    cmds.add((AbstractDeployCommand) cmd);
                }
            }
        }
    }
    return cmds;
}
Also used : NOPCommand(org.talend.mdm.repository.core.command.impl.NOPCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) LinkedList(java.util.LinkedList)

Aggregations

AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)21 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 CommandManager (org.talend.mdm.repository.core.command.CommandManager)8 IStatus (org.eclipse.core.runtime.IStatus)7 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)7 ArrayList (java.util.ArrayList)6 LinkedList (java.util.LinkedList)6 ICommand (org.talend.mdm.repository.core.command.ICommand)6 ICommandParameter (org.talend.mdm.repository.core.command.param.ICommandParameter)5 ImpactOperation (org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation)4 Test (org.junit.Test)3 ConsistencyCheckResult (org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyCheckResult)3 IModelValidateResult (org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult)3 XtentisException (com.amalto.workbench.utils.XtentisException)2 HashSet (java.util.HashSet)2 WebServiceException (javax.xml.ws.WebServiceException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Property (org.talend.core.model.properties.Property)2 CommandStack (org.talend.mdm.repository.core.command.CommandStack)2