Search in sources :

Example 1 with NOPCommand

use of org.talend.mdm.repository.core.command.impl.NOPCommand 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

LinkedList (java.util.LinkedList)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)1 NOPCommand (org.talend.mdm.repository.core.command.impl.NOPCommand)1 ICommandParameter (org.talend.mdm.repository.core.command.param.ICommandParameter)1