⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workflowdescriptor.java

📁 osworkflow修改版本
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2002-2003 by OpenSymphony * All rights reserved. */package com.opensymphony.workflow.loader;import com.opensymphony.workflow.InvalidWorkflowDescriptorException;import com.opensymphony.workflow.util.Validatable;import org.w3c.dom.Element;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import org.xml.sax.*;import java.io.*;import java.util.*;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;/** * Describes a single workflow * * @author <a href="mailto:plightbo@hotmail.com">Pat Lightbody</a> * @version $Revision: 1.19 $ */public class WorkflowDescriptor extends AbstractDescriptor implements Validatable {    //~ Static fields/initializers /////////////////////////////////////////////    public static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";    public static final String DOCTYPE_DECL = "<!DOCTYPE workflow PUBLIC \"-//OpenSymphony Group//DTD OSWorkflow 2.7//EN\" \"http://www.opensymphony.com/osworkflow/workflow_2_7.dtd\">";    //~ Instance fields ////////////////////////////////////////////////////////    protected List commonActionsList = new ArrayList(); // for preserving order    protected List globalActions = new ArrayList();    protected List initialActions = new ArrayList();    protected List joins = new ArrayList();    protected List registers = new ArrayList();    protected List splits = new ArrayList();    protected List steps = new ArrayList();    protected Map commonActions = new HashMap();    protected Map metaAttributes = new HashMap();    protected Map timerFunctions = new HashMap();    //~ Constructors ///////////////////////////////////////////////////////////    public WorkflowDescriptor() {    }    public WorkflowDescriptor(Element root) {        init(root);    }    //~ Methods ////////////////////////////////////////////////////////////////    public ActionDescriptor getAction(int id) {        // check global actions        for (Iterator iterator = globalActions.iterator(); iterator.hasNext();) {            ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next();            if (actionDescriptor.getId() == id) {                return actionDescriptor;            }        }        // check steps        for (Iterator iterator = steps.iterator(); iterator.hasNext();) {            StepDescriptor stepDescriptor = (StepDescriptor) iterator.next();            ActionDescriptor actionDescriptor = stepDescriptor.getAction(id);            if (actionDescriptor != null) {                return actionDescriptor;            }        }        return null;    }    /**     * Get a Map of the common actions specified, keyed on actionId (an Integer)     * @return A list of {@link ActionDescriptor} objects     */    public Map getCommonActions() {        return commonActions;    }    /**     * Get a List of the global actions specified     * @return A list of {@link ActionDescriptor} objects     */    public List getGlobalActions() {        return globalActions;    }    public ActionDescriptor getInitialAction(int id) {        for (Iterator iterator = initialActions.iterator(); iterator.hasNext();) {            ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next();            if (actionDescriptor.getId() == id) {                return actionDescriptor;            }        }        return null;    }    /**     * Get a List of initial steps for this workflow     * @return A list of {@link ActionDescriptor} objects     */    public List getInitialActions() {        return initialActions;    }    public JoinDescriptor getJoin(int id) {        for (Iterator iterator = joins.iterator(); iterator.hasNext();) {            JoinDescriptor joinDescriptor = (JoinDescriptor) iterator.next();            if (joinDescriptor.getId() == id) {                return joinDescriptor;            }        }        return null;    }    /**     * Get a List of initial steps for this workflow     * @return A list of {@link JoinDescriptor} objects     */    public List getJoins() {        return joins;    }    public Map getMetaAttributes() {        return metaAttributes;    }    public List getRegisters() {        return registers;    }    public SplitDescriptor getSplit(int id) {        for (Iterator iterator = splits.iterator(); iterator.hasNext();) {            SplitDescriptor splitDescriptor = (SplitDescriptor) iterator.next();            if (splitDescriptor.getId() == id) {                return splitDescriptor;            }        }        return null;    }    /**     * Get a List of initial steps for this workflow     * @return A list of {@link SplitDescriptor} objects     */    public List getSplits() {        return splits;    }    public StepDescriptor getStep(int id) {        for (Iterator iterator = steps.iterator(); iterator.hasNext();) {            StepDescriptor step = (StepDescriptor) iterator.next();            if (step.getId() == id) {                return step;            }        }        return null;    }    /**     * Get a List of steps in this workflow     * @return a List of {@link StepDescriptor} objects     */    public List getSteps() {        return steps;    }    /**     * Update a trigger function     * @param id The id for the trigger function     * @param descriptor The descriptor for the trigger function     * @return The old trigger function with the specified ID, if any existed     */    public FunctionDescriptor setTriggerFunction(int id, FunctionDescriptor descriptor) {        return (FunctionDescriptor) timerFunctions.put(new Integer(id), descriptor);    }    public FunctionDescriptor getTriggerFunction(int id) {        return (FunctionDescriptor) this.timerFunctions.get(new Integer(id));    }    /**     * Get a Map of all trigger functions in this workflow     * @return a Map with Integer keys and {@link FunctionDescriptor} values     */    public Map getTriggerFunctions() {        return timerFunctions;    }    /**     * Add a common action     * @param descriptor The action descriptor to add     * @throws IllegalArgumentException if the descriptor's ID already exists in the workflow     */    public void addCommonAction(ActionDescriptor descriptor) {        addAction(commonActions, descriptor);        addAction(commonActionsList, descriptor);    }    /**     * Add a global action     * @param descriptor The action descriptor to add     * @throws IllegalArgumentException if the descriptor's ID already exists in the workflow     */    public void addGlobalAction(ActionDescriptor descriptor) {        addAction(globalActions, descriptor);    }    /**     * Add an initial action     * @param descriptor The action descriptor to add     * @throws IllegalArgumentException if the descriptor's ID already exists in the workflow     */    public void addInitialAction(ActionDescriptor descriptor) {        addAction(initialActions, descriptor);    }    /**     * Add a join     * @param descriptor The join descriptor to add     * @throws IllegalArgumentException if the descriptor's ID already exists in the workflow     */    public void addJoin(JoinDescriptor descriptor) {        if (getJoin(descriptor.getId()) != null) {            throw new IllegalArgumentException("Join with id " + descriptor.getId() + " already exists");        }        joins.add(descriptor);    }    /**     * Add a split     * @param descriptor The split descriptor to add     * @throws IllegalArgumentException if the descriptor's ID already exists in the workflow     */    public void addSplit(SplitDescriptor descriptor) {        if (getSplit(descriptor.getId()) != null) {            throw new IllegalArgumentException("Split with id " + descriptor.getId() + " already exists");        }        splits.add(descriptor);    }    /**     * Add a step     * @param descriptor The step descriptor to add     * @throws IllegalArgumentException if the descriptor's ID already exists in the workflow     */    public void addStep(StepDescriptor descriptor) {        if (getStep(descriptor.getId()) != null) {            throw new IllegalArgumentException("Step with id " + descriptor.getId() + " already exists");        }        steps.add(descriptor);    }    /**     * Remove an action from this workflow completely.     * <p>     * This method will check global actions and all steps.     *     * @return true if the action was successfully removed, false if it was not found     */    public boolean removeAction(ActionDescriptor actionToRemove) {        // global actions        for (Iterator iterator = getGlobalActions().iterator();                iterator.hasNext();) {            ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next();            if (actionDescriptor.getId() == actionToRemove.getId()) {                getGlobalActions().remove(actionDescriptor);                return true;            }        }        // steps        for (Iterator iterator = getSteps().iterator(); iterator.hasNext();) {            StepDescriptor stepDescriptor = (StepDescriptor) iterator.next();            ActionDescriptor actionDescriptor = stepDescriptor.getAction(actionToRemove.getId());            if (actionDescriptor != null) {                stepDescriptor.getActions().remove(actionDescriptor);                return true;            }        }        return false;    }    public void validate() throws InvalidWorkflowDescriptorException {        ValidationHelper.validate(this.getRegisters());

⌨️ 快捷键说明

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