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

📄 workflowprocess.java

📁 Fire-Workflow-Engine-All-In-One-20090208 包含全部文档
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * Copyright 2003-2008 非也
 * All rights reserved. 
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation。
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses. *
 */
package org.fireflow.model;

import java.util.ArrayList;
import java.util.List;

import org.fireflow.model.net.Activity;
import org.fireflow.model.net.EndNode;
import org.fireflow.model.net.Node;
import org.fireflow.model.net.StartNode;
import org.fireflow.model.net.Synchronizer;
import org.fireflow.model.net.Transition;

/**
 * @author 非也,nychen2000@163.com
 *
 */
public class WorkflowProcess extends AbstractWFElement {

    //子元素
//    private List formalParameters = new ArrayList();
    private List<DataField> dataFields = new ArrayList<DataField>();
    private List<Activity> activities = new ArrayList<Activity>();
    private List<Transition> transitions = new ArrayList<Transition>();
    private List<Synchronizer> synchronizers = new ArrayList<Synchronizer>();
    private StartNode startNode = null;
    private List<EndNode> endNodes = new ArrayList<EndNode>();
    //其他属性
    private String resourceFile = null;
    private String resourceManager = null;
//    private int version = 1;//version在流程定义中不需要,只有在流程存储中需要,每次updatge数据库,都需要增加Version值
    /**
     * 构造函数
     * @param id
     * @param name
     * @param pkg
     */
    public WorkflowProcess(String name) {
        super(null, name);
    }
//    public List getFormalParameters() {
//        return formalParameters;
//    }
    /**
     * 返回所有的流程变量
     * @return
     */
    public List<DataField> getDataFields() {
        return dataFields;
    }

    /**
     * 返回所有的环节
     * @return
     */
    public List<Activity> getActivities() {
        return activities;
    }

    /**
     * 返回所有的转移
     * @return
     */
    public List<Transition> getTransitions() {
        return transitions;
    }

//    public int getVersion() {
//        return version;
//    }
//
//    public void setVersion(int version) {
//        this.version = version;
//    }
    
    /**
     * 返回开始节点
     * @return
     */
    public StartNode getStartNode() {
        return startNode;
    }

    public void setStartNode(StartNode startNode) {
        this.startNode = startNode;
    }

    /**
     * 返回所有的结束节点
     * @return
     */
    public List<EndNode> getEndNodes() {
        return endNodes;
    }

    /**
     * 返回所有的同步器
     * @return
     */
    public List<Synchronizer> getSynchronizers() {
        return synchronizers;
    }

    /**
     * 保留
     * @return
     */
    public String getResourceFile() {
        return resourceFile;
    }

    /**
     * 保留
     * @return
     */
    public void setResourceFile(String resourceFile) {
        this.resourceFile = resourceFile;
    }
    /**
     * 保留
     * @return
     */
    public String getResourceManager() {
        return resourceManager;
    }
    /**
     * 保留
     * @return
     */
    public void setResourceManager(String resourceMgr) {
        this.resourceManager = resourceMgr;
    }

    /**
     * 通过ID查找该流程中的任意元素
     * @param id
     * @return
     */
    public IWFElement findWFElementById(String id) {
        if (this.getId().equals(id)) {
            return this;
        }

        List activityList = this.getActivities();
        for (int i = 0; i < activityList.size(); i++) {
            IWFElement wfElement = (IWFElement) activityList.get(i);
            if (wfElement.getId().equals(id)) {
                return wfElement;
            }
            List taskList = ((Activity) wfElement).getTasks();
            for (int j = 0; j < taskList.size(); j++) {
                IWFElement wfElement2 = (IWFElement) taskList.get(j);
                if (wfElement2.getId().equals(id)) {
                    return wfElement2;
                }
            }
        }
        if (this.getStartNode().getId().equals(id)) {
            return this.getStartNode();
        }
        List synchronizerList = this.getSynchronizers();
        for (int i = 0; i < synchronizerList.size(); i++) {
            IWFElement wfElement = (IWFElement) synchronizerList.get(i);
            if (wfElement.getId().equals(id)) {
                return wfElement;
            }
        }

        List endNodeList = this.getEndNodes();
        for (int i = 0; i < endNodeList.size(); i++) {
            IWFElement wfElement = (IWFElement) endNodeList.get(i);
            if (wfElement.getId().equals(id)) {
                return wfElement;
            }
        }

        List transitionList = this.getTransitions();
        for (int i = 0; i < transitionList.size(); i++) {
            IWFElement wfElement = (IWFElement) transitionList.get(i);
            if (wfElement.getId().equals(id)) {
                return wfElement;
            }
        }

        List dataFieldList = this.getDataFields();
        for (int i = 0; i < dataFieldList.size(); i++) {
            IWFElement wfElement = (IWFElement) dataFieldList.get(i);
            if (wfElement.getId().equals(id)) {
                return wfElement;
            }
        }
        return null;
    }

    /**
     * 通过Id查找任意元素的序列号
     * @param id
     * @return
     */
    public String findSnById(String id) {
        IWFElement elem = this.findWFElementById(id);
        if (elem != null) {
            return elem.getSn();
        }
        return null;
    }

    /**
     * 验证workflow process是否完整正确
     * @return null表示流程正确;否则表示流程错误,返回值是错误原因
     */
    public String validate() {
        String errHead = "Workflow process is invalid:";
        if (this.getStartNode() == null) {
            return errHead + "must have one start node";
        }
        if (this.getStartNode().getLeavingTransitions().size() == 0) {
            return errHead + "start node must have leaving transitions.";
        }

⌨️ 快捷键说明

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