可以这么说史帝芬的http://my.so-net.net.tw/idealist/OSWorkflow/osworkflow资料是目前华文osworkflow资料中最好的一份入门教程。去面的时候在mssql中中实践过这份入门资料,感觉非常顺利。但感觉按作者的顺序把教程中的例子跑完了,还不完全清楚的明白osworkflow的架构。前些在mysql5.0中重做一次,遇到了挺多问题,我通过一步一步的跟踪原代码调试终于把这些问题搞定。下图是把osworkflow所提供的mysql下的数据表的ER图:
如果你的osworkflow持久化到mysql中你的osworkflow.xml文件内如必需按如下格式来写:
<osworkflow>
<persistence class="com.opensymphony.workflow.spi.jdbc.MySQLWorkflowStore">
<property key="datasource" value="jdbc/DefaultDS"/>
<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>
propertyset.xml文件格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<propertysets>
<propertyset name="jdbc"
class="com.opensymphony.module.propertyset.database.JDBCPropertySet">
<arg name="datasource" value="java:comp/env/jdbc/DefaultDS"/>
<arg name="table.name" value="OS_PROPERTYENTRY"/>
<arg name="col.globalKey" value="GLOBAL_KEY"/>
<arg name="col.itemKey" value="ITEM_KEY"/>
<arg name="col.itemType" value="ITEM_TYPE"/>
<arg name="col.string" value="STRING_VALUE"/>
<arg name="col.date" value="DATE_VALUE"/>
<arg name="col.data" value="DATA_VALUE"/>
<arg name="col.float" value="FLOAT_VALUE"/>
<arg name="col.number" value="NUMBER_VALUE"/>
</propertyset>
</propertysets>