此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【zhangfengsummer】截止到2008-06-24 10:06:23的历史汇总数据(不包括此帖):
发帖数:1                  发帖分:20                 
结贴数:1                  结贴分:20                 
未结数:0                  未结分:0                  
结贴率:100.00%            结分率:100.00%            
敬礼!

解决方案 »

  1.   

    继续,我的流程定义文件为: leave_apply.xml<?xml version="1.0" encoding="GBK"?>
    <!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.6//EN" "http://www.opensymphony.com/osworkflow/workflow_2_8.dtd">
    <workflow>
    <initial-actions>
    <action id="100" name="启动请假申请工作流">
    <results>
    <unconditional-result old-status="Finished"
    status="Underway" step="1" />
    </results>
    </action>
    </initial-actions>
    <steps>
    <step id="1" name="请假申请">
    <actions>
    <action id="1" name="提交需求申请">
    <restrict-to>
    <conditions type="AND">
    <condition type="class">
    <arg name="class.name">
    com.opensymphony.workflow.util.OSUserGroupCondition
    </arg>
    <arg name="group">employee</arg>
    </condition>
    </conditions>
    </restrict-to>
    <pre-functions>
    <function type="class">
    <arg name="class.name">
    com.osworkflow.leave.ApplyFunction
    </arg>
    </function>
    </pre-functions>
    <results>
    <result old-status="Finished" status="Underway"
    step="2" owner="manager1">
    <conditions type="AND">
    <condition type="beanshell">
    <arg name="script">
    propertySet.getInt("dayCount")>3
    </arg>
    </condition>
    </conditions>
    <post-functions>
    <function type="beanshell">
    <arg name="script">
    System.out.println("步骤 1 提交需求申请满足条件结果 需部门经理审批...");
    </arg>
    </function>
    </post-functions>
    </result>
    <unconditional-result old-status="Finished"
    status="Underway" step="3" owner="hr1" />
    </results>
    </action>
    </actions>
    </step>
    <step id="2" name="请假申请审核">
    <actions>
    <action id="2" name="部门主管审批请假申请">
    <restrict-to>
    <conditions type="AND">
    <condition type="beanshell">
    <arg name="script">true</arg>
    </condition>
    <condition type="class">
    <arg name="class.name">
    com.opensymphony.workflow.util.StatusCondition
    </arg>
    <arg name="status">Underway</arg>
    </condition>
    <condition type="class">
    <arg name="class.name">
    com.opensymphony.workflow.util.OSUserGroupCondition
    </arg>
    <arg name="group">manager</arg>
    </condition>
    </conditions>
    </restrict-to>
    <pre-functions>
    <function type="class">
    <arg name="class.name">
    com.osworkflow.leave.ApproveFunction
    </arg>
    </function>
    </pre-functions>
    <results>
    <result old-status="Finished" status="Underway"
    step="5">
    <conditions type="AND">
    <condition type="beanshell">
    <arg name="script">
    propertySet.getInt("opinion")==2
    </arg>
    </condition>
    </conditions>
    <post-functions>
    <function type="beanshell">
    <arg name="script">
    System.out.println("步骤 2 请假申请审核部门经理审批没有通过 ...");
    </arg>
    </function>
    </post-functions>
    </result>
    <unconditional-result old-status="Finished"
    status="Underway" step="3" owner="hr1" />
    </results>
    </action>
    </actions>
    </step>
    <step id="3" name="请假申请审核">
    <actions>
    <action id="3" name="人力资源主管审批请假申请">
    <pre-functions>
    <function type="class">
    <arg name="class.name">
    com.osworkflow.leave.ApproveFunction
    </arg>
    </function>
    </pre-functions>
    <results>
    <result old-status="Finished" status="Underway"
    step="5">
    <conditions type="AND">
    <condition type="beanshell">
    <arg name="script">
    propertySet.getInt("opinion")==2
    </arg>
    </condition>
    </conditions>
    </result>
    <unconditional-result old-status="Finished"
    status="Underway" step="5" />
    </results>
    </action>
    </actions>
    </step>
    <step id="4" name="请假申请结果通知">
    <actions>
    <action id="4" auto="true" name="请假申请获准邮件通知">
    <pre-functions>
    <function type="beanshell">
    <arg name="script">
    System.out.println("步骤 4 自动动作 请假申请获准邮件通知Send mail 祝贺你");
    </arg>
    </function>
    </pre-functions>
    <results>
    <unconditional-result old-status="Finished"
    status="Finished" step="6" />
    </results>
    </action>
    </actions>
    </step>
    <step id="5" name="请假申请结果通知">
    <actions>
    <action id="5" auto="true" name="请假申请没能获准邮件通知">
    <pre-functions>
    <function type="beanshell"> 
    <arg name="script">
    System.out.println("步骤 5 自动动作 请假申请未获准邮件通知Send mail ");
    </arg> 
    </function>
    </pre-functions>
    <results>
    <unconditional-result old-status="Finished" status="Finished" step="6" />
    </results>
    </action>
    </actions>
    </step>
    <step id="6" name="flow over"></step>
    </steps>
    </workflow>osworkflow.xml文件为: 
    <osworkflow>
    <persistence class="com.opensymphony.workflow.spi.jdbc.MySQLWorkflowStore">
     <property key="datasource" value="jdbc/osworkflow"/>
     
        <property key="step.sequence.increment"  value="INSERT INTO OS_STEPIDS (ID) values (null)"/>
        <property key="step.sequence.retrieve"   value="SELECT count(ID) FROM OS_STEPIDS"/>
        <property key="entry.sequence.increment" value="INSERT INTO OS_ENTRYIDS (ID) values (null)"/>
        <property key="entry.sequence.retrieve"  value="SELECT count(ID) FROM OS_ENTRYIDS"/>
       
     <property key="entry.table" value="OS_WFENTRY"/>
     <property key="entry.id" value="ID"/>
     <property key="entry.name" value="NAME"/>
     <property key="entry.state" value="STATE"/>
     
     <property key="history.table" value="OS_HISTORYSTEP"/>
     <property key="current.table" value="OS_CURRENTSTEP"/>
     <property key="historyPrev.table" value="OS_HISTORYSTEP_PREV"/>
     <property key="currentPrev.table" value="OS_CURRENTSTEP_PREV"/>
     <property key="step.id" value="ID"/>
     <property key="step.entryId" value="ENTRY_ID"/>
     <property key="step.stepId" value="STEP_ID"/>
     <property key="step.actionId" value="ACTION_ID"/>
     <property key="step.owner" value="OWNER"/>
     <property key="step.caller" value="CALLER"/>
     <property key="step.startDate" value="START_DATE"/>
     <property key="step.finishDate" value="FINISH_DATE"/>
     <property key="step.dueDate" value="DUE_DATE"/>
     <property key="step.status" value="STATUS"/>
     <property key="step.previousId" value="PREVIOUS_ID"/>    
     </persistence>
     
     <factory class="com.opensymphony.workflow.loader.XMLWorkflowFactory">
      <property key="resource" value="workflows.xml"/>
     </factory>
    </osworkflow>还有一楼,,,
      

  2.   

    项目默认的页面: default.jsp <%@ page import="com.opensymphony.util.TextUtils"%>
    <%@ page contentType="text/html;charset=GBK"%>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK" /> <html>
        <head>
            <title>OSWorkflow Example App</title>
        </head>    <body>    <p>
        请假申请管理系统
        <form method="POST" action="myprocess/login.jsp">
        <table border="0">
            <tr><td>用户名:</td><td><input type="text" name="username"></td></tr>
            <tr><td>密码:</td><td><input type="password" name="password"></td></tr>
            <tr><td colspan="2"><input type="submit" value=" 登陆 "></td></tr>
        </table>
        </form>    <hr>    </body>
    </html>
    login.jsp代码:<%@ page import="com.opensymphony.user.UserManager,
                     com.opensymphony.user.EntityNotFoundException"%>
    <%
        String username = request.getParameter("username");
        String password = request.getParameter("password");    System.out.println("=================username:" + username);
        System.out.println("=================password:" + password);
        
        UserManager um = UserManager.getInstance();
        
        boolean authenticated = true;    if (authenticated) {
            session.setAttribute("username", username);
            response.sendRedirect("nav.jsp");
        } else {
            response.sendRedirect("../default.jsp?auth_failed=true");
        }
    %>
    nav.jsp代码:
    <%@ page contentType="text/html;charset=GBK"%>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
    <hr><a href="default.jsp">首页</a> |
    <a href="leaveApply.jsp">申请请假</a> | <a href="underway.jsp">处理请假申请</a>
    leaveApply.jsp代码:<%@ page import="com.opensymphony.util.TextUtils"%>
    <%@ page contentType="text/html;charset=GBK"%>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
     <html>
        <head>
            <title>OSWorkflow Example App</title>
        </head>    <body>    <p>
        请假申请,请填写下面请假申请单
        <form method="POST" action="leaveApplyCreate.jsp">
        <table border="0">
            <tr><td>请假原因:</td><td><input type="text" name="reason"></td></tr>
            <tr><td>请假天数:</td><td><input type="text" name="dayCount"> 整数</td></tr>
            <tr><td colspan="2"><input type="submit" value="提交申请"></td></tr>
        </table>
        </form>
        <hr>
        </body>
    </html>
    leaveApplyCreate.jsp代码:<%@ page import="java.util.*,
                     com.opensymphony.user.UserManager,
                     com.opensymphony.user.EntityNotFoundException,
                     com.opensymphony.workflow.Workflow,
                     com.opensymphony.workflow.config.DefaultConfiguration,
                     com.opensymphony.workflow.basic.BasicWorkflow"%>
    <%@ page contentType="text/html;charset=GBK"%><%
        String reason = request.getParameter("reason");
        int dayCount = Integer.parseInt((String)request.getParameter("dayCount"));
        String applicant = (String)session.getAttribute("username");
        
        System.out.println("=======从页面得到的数据:=====");
        System.out.println("reason: " + reason);
        System.out.println("dayCount: " + dayCount);
        System.out.println("applicant: " + applicant);
        
        
        Workflow wf = new BasicWorkflow((String) session.getAttribute("username"));
        DefaultConfiguration config1 = new DefaultConfiguration();
        wf.setConfiguration(config1);
        
        Map map = new HashMap();
        map.put("applicant", applicant);
        map.put("reason", reason);
        map.put("dayCount", new Integer(dayCount)); 
        
        
        System.out.println("放进map的值" );
        System.out.println("========= map.applicant:  " + map.get("applicant") );
        System.out.println("========= map.reason:  " + map.get("reason") );
        System.out.println("========= map.dayCount:  " + map.get("dayCount") );
        
          
        try {
          long wfid = wf.initialize("leave", 100, null);
          
          
          wf.doAction(wfid, 1, map);
          out.print("请假申请已经成功提交,请等待审批!");
        } catch (Exception ex){
          //out.print("提交请假申请时出现异常,可能没有增加您提交需求的权限!");
          
           ex.printStackTrace();
        }%>
    <%@ include file="nav.jsp" %>当执行到 long wfid = wf.initialize("leave", 100, null);这一句的时候,tomcat报出如下错误:
    com.opensymphony.workflow.StoreException: Unable to create current step for work
    flow instance #3: root cause: Cannot add or update a child row: a foreign key co
    nstraint fails (`osworkflow`.`os_currentstep`, CONSTRAINT `os_currentstep_ibfk_2
    ` FOREIGN KEY (`OWNER`) REFERENCES `os_user` (`USERNAME`))
    at com.opensymphony.workflow.spi.jdbc.JDBCWorkflowStore.createCurrentSte
    p(JDBCWorkflowStore.java:166)
    at com.opensymphony.workflow.AbstractWorkflow.createNewCurrentStep(Abstr
    actWorkflow.java:1509)
    at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(Abstrac
    tWorkflow.java:1256)
    at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflo
    w.java:618)
    at org.apache.jsp.myprocess.leaveApplyCreate_jsp._jspService(leaveApplyC
    reate_jsp.java:87)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
    .java:324)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
    92)
    请问哥们儿们,为什么会有外键约束冲突呢,我的数据库表os_user和os_group、os_memership里有对应的流程定义的owner和caller啊,郁闷了好几天了,谢谢啊