getprocessdefinitionscommand.java

来自「workflow first jbpm」· Java 代码 · 共 54 行

JAVA
54
字号
package org.jbpm.command;

import java.util.Iterator;
import java.util.List;

import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;

/**
 * This Command returns all process definitions (or only the latest if
 * onlyLatest is true)
 * 
 * @author Bernd Ruecker (bernd.ruecker@camunda.com)
 */
public class GetProcessDefinitionsCommand extends AbstractGetObjectBaseCommand {

    private static final long serialVersionUID = -1908847549444051495L;

    private boolean onlyLatest = true;

    public GetProcessDefinitionsCommand() {
    }

    public GetProcessDefinitionsCommand(boolean onlyLatest) {
        this.onlyLatest = onlyLatest;
    }

    public Object execute(JbpmContext jbpmContext) throws Exception {
        setJbpmContext(jbpmContext);
        List result = (onlyLatest ? jbpmContext.getGraphSession().findLatestProcessDefinitions() : jbpmContext.getGraphSession().findAllProcessDefinitions());

        /*
         * traverse and access property if it is missing in the default
         * fetchgroup
         */
        Iterator iter = result.iterator();
        while (iter.hasNext()) {
            ProcessDefinition pd = (ProcessDefinition) iter.next();
            retrieveProcessDefinition(pd);
        }

        return result;
    }

    public boolean isOnlyLatest() {
        return onlyLatest;
    }

    public void setOnlyLatest(boolean onlyLatest) {
        this.onlyLatest = onlyLatest;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?