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

📄 processdefinition.java

📁 一个工作流设计及定义的系统,可以直接与数据库结合进行系统工作流程的定义及应用.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /*     * Returns a new child id.     * Returns -1 if the expression cannot have children.     */    private int newChildId (final FlowExpression fe)    {        if (fe instanceof CompositeFlowExpression)        {            final java.util.List children =                 ((CompositeFlowExpression)fe).getChildren();            if (children == null || children.size() < 1) return 0;            int result = 0;            final java.util.Iterator it = children.iterator();            while (it.hasNext())            {                int c = getChildId((FlowExpressionId)it.next());                if (c > result) result = c;            }            result++;            //log.debug("newChildId() returning "+result);            return result;        }        if (fe instanceof OneChildExpression)        {            final OneChildExpression oce = (OneChildExpression)fe;            if (oce.getChildExpressionId() == null) return 0;            return 1;        }        return -1;    }    public FlowExpression getRootExpression ()    {        final java.util.Iterator it = getExpressions().values().iterator();        while (it.hasNext())        {            final FlowExpression fe = (FlowExpression)it.next();            if ( ! (fe instanceof DefineExpression)) return fe;        }        return null;    }    public FlowExpression getExpression (final String expId)    {        log.debug("getExpression() expId >"+expId+"<");        final java.util.Iterator it = getExpressions().values().iterator();        while (it.hasNext())        {            final FlowExpression fe = (FlowExpression)it.next();            //log.debug            //    ("getExpression() considering '"+            //     fe.getId().getExpressionId()+"'");            if (expId.equals(fe.getId().getExpressionId()))                return fe;        }        return null;    }    public FlowExpressionId getFlowExpressionId (final String expId)    {        final FlowExpression fe = getExpression(expId);        if (fe == null) return null;        return fe.getId();    }    public void changeSubProcessDefinitionName        (final String defineExpId, final String newName)    {        final DefineExpression def =             (DefineExpression)getExpression(defineExpId);        def.getAttributes().put("name", newName);    }    public void createSubDefinition         (final String parentExpId,          final String subDefName)    {        final DefineExpression def =             (DefineExpression)getExpression(parentExpId);        final DefineExpression subDef = new DefineExpression();        final FlowExpressionId subId = def.getId().copy();        subId.setExpressionName            ("subprocess-definition");        subId.setExpressionId            (subId.getExpressionId()+"."+def.getChildren().size());        subDef.setParent(def.getId());        subDef.setId(subId);        def.getChildren().add(subId);        this.add(subDef);    }    public void removeSubDefinition (final String defineExpId)    {        final DefineExpression def =             (DefineExpression)getExpression(defineExpId);        this.removeChild(def.getId());    }    /**     * Returns this process definition as an XML string     */    public String outputAsXmlString ()    {        return XmlUtils.toString(toXml(getSelf(), true));    }    private org.jdom.Element toXml         (final FlowExpression fe, final boolean workflowDefinition)    {        final String expName = getExpressionMap().getName(fe.getClass());        log.debug("toXml() expressionName >"+expName+"<");        final org.jdom.Element elt = new org.jdom.Element(expName);        XmlUtils.setAttributes(elt, fe.getAttributes());        if (fe instanceof CompositeFlowExpression)        {            final CompositeFlowExpression cfe = (CompositeFlowExpression)fe;            final java.util.Iterator it = cfe.getChildren().iterator();            while (it.hasNext())            {                final FlowExpressionId fei = (FlowExpressionId)it.next();                elt.addContent(toXml(get(fei), false));            }        }        else if (fe instanceof OneChildExpression)        {            final OneChildExpression oce = (OneChildExpression)fe;            elt.addContent(toXml(get(oce.getChildExpressionId()), false));        }        return elt;    }    //    // METHODS from FlowExpression    /* *     * No implementation needed as a process definition is solely     * used for droflo purposes.     * /    public void release ()    {        // nothing to do, a process definition is never stored in an         // expression pool as it's just used by droflo for edtion and        // display    }    */    /**     * Nothing to do.     */    public InFlowWorkItem cancel ()         throws ApplyException    {        // really nothing.                return null;    }    /**     * No implementation needed as a process definition is solely     * used for droflo purposes.     */    public void apply (InFlowWorkItem wi)         throws ApplyException    {        // nada    }    /**     * No implementation needed as a process definition is solely     * used for droflo purposes.     */    public void reply (InFlowWorkItem wi)         throws ReplyException    {        // nada    }    /*    public Object clone ()    {        return null;    }    */    /**     * Outputs the process definition and its content in a human     * readable format.     */    public String toString ()    {        final StringBuffer sb = new StringBuffer();        sb.append(getClass().getName());        sb.append(" :\n");        sb.append("   - id                 : ");         sb.append(this.getId());         sb.append("\n");        sb.append(" expression ids [\n");        final java.util.Iterator it = getExpressions().keySet().iterator();        while (it.hasNext())        {            final FlowExpressionId k = (FlowExpressionId)it.next();            sb.append("     - ");            sb.append(k);            sb.append("\n");        }        sb.append(" ]");        return sb.toString();    }    /**     * This method awaits a ProcessDefinition or a DefineExpression as     * input, it then returns a list of the direct subDefinitions held     * by the input (or the input's root in the case of a ProcessDefinition).     */    public java.util.List getSubDefinitions (final FlowExpression fe)    {        DefineExpression def = null;        if (fe instanceof DefineExpression)        {            def = (DefineExpression)fe;        }        else if (fe instanceof ProcessDefinition)        {            def = ((ProcessDefinition)fe).getSelf();        }        else        {            throw new IllegalArgumentException                ("Illegal input : class "+fe.getClass().getName());        }        final java.util.List result =             new java.util.ArrayList(def.getChildren().size());        final java.util.Iterator it = def.getChildren().iterator();        while (it.hasNext())        {            final FlowExpressionId fei = (FlowExpressionId)it.next();            final FlowExpression fee = this.get(fei);            log.debug("getSubDefintions() considering "+fee+" "+fei);            if (fee instanceof DefineExpression) result.add(fee);        }        return result;    }    public FlowExpression getBody (final DefineExpression de)    {        final java.util.Iterator it = de.getChildren().iterator();        while (it.hasNext())        {            final FlowExpressionId fei = (FlowExpressionId)it.next();            final FlowExpression fe = this.get(fei);            if (fe instanceof DefinitionExpression) continue;            return fe;        }                return null;    }    //    // STATIC METHODS}

⌨️ 快捷键说明

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