一个用数据库实现的工作流

2008-02-23 09:55:08来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

package com.highcom.workflow.dao.JDBC;

import org.springFramework.dao.*;

import org.springframework.jdbc.core.*;
import org.springframework.jdbc.core.support.*;

import Java.sql.*;

import java.util.*;
import com.highcom.workflow.domain.*;
import com.highcom.workflow.dao.*;
import com.highcom.seqgen.*;


public class WorkflowDaoJdbcImpl extends JdbcDaoSupport implements WorkflowDao {
private SequenceService sequenceService = null;
private String WORKFLOW_TEMPLATE_SEQ =
"com.highcom.workflow.template";
private String WORKFLOW_TEMPLATE_NODE_SEQ =
"com.highcom.workflow.template.node";
private String WORKFLOW_TEMPLATE_NODE_MAN_SEQ =
"com.highcom.workflow.template.node.man";
//
private String WORKFLOW_SEQ =
"com.highcom.workflow";
private String WORKFLOW_NODE_SEQ =
"com.highcom.workflow.node";
private String WORKFLOW_NODE_MAN_SEQ =
"com.highcom.workflow.node.man";
//
public WorkflowDaoJdbcImpl() {
}

/**
* 新建立一个工作流模板
* @param template WorkflowTemplate
*/
public void addNewTemplate(WorkflowTemplate template) {
String id = sequenceService.getValue(WORKFLOW_TEMPLATE_SEQ);
this.getJdbcTemplate().update("insert into workflow_template(id,name,description,createDate,createMan,status,defaultworkflow) values(?,?,?,?,?,?,?)",
new Object[] {
id, template.getName(),
template.getDescription(),
template.getCreateDate(),
template.getCreateMan(),
new Integer(template.getStatus()),
new Integer(template.getDefaultWorkflow())
},
new int[] {
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.DATE,
Types.VARCHAR, Types.INTEGER, Types.INTEGER
});
}

public void addNewTemplateNode(WorkflowTemplateNode flowNode) {
String id = this.sequenceService.getValue(this.
WORKFLOW_TEMPLATE_NODE_SEQ);
int maxseq = getTemplateNodeMaxSequence(flowNode.getWorkId());
maxseq = 1;
this.getJdbcTemplate().update("insert into workflow_template_flow(id,template_id,sequence,name,description) values(?,?,?,?,?)",
new Object[] {
id, flowNode.getWorkId(),
new Integer(maxseq),
flowNode.getName(),
flowNode.getDescription()
},
new int[] {
Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.VARCHAR,
Types.VARCHAR
});

//插入人员信息
if (flowNode.getMans() != null) {
List mans = flowNode.getMans();

for (int i = 0; i < mans.size(); i ) {
String man_id = this.sequenceService.getValue(this.
WORKFLOW_TEMPLATE_NODE_MAN_SEQ);
String account_id = (String) mans.get(i);
this.getJdbcTemplate().update("insert into workflow_template_man(id,template_flow_id,account_id) values(?,?,?)",
new Object[] {man_id, id,
account_id},
new int[] {Types.VARCHAR,
Types.VARCHAR,
Types.VARCHAR});
}
}
}

/**
* 生成新的工作流实例 调用程序需要本身设置这些信息 1)本身信息 2)结点信息
* 3)结点人员信息
* status:-1,待启动,-2:强制终止,-3:退回到原始状态(需要修改),0:正在运行,1:已经完成.
* flow_id:当前运行结点id.-9999:已经没有当前结点.
*
* @param workflow Workflow
* @return String
*/
public String addNewWorkflow(Workflow workflow) {
//
String id = sequenceService.getValue(WORKFLOW_SEQ);
this.getJdbcTemplate().update(
"insert into workflow_work(id,doc_id,status,"
"flow_id,start_date,end_date,v_comment) values(?,?,?,?,?,?,?)",
new Object[] {
id, workflow.getDocId(),
new Integer(workflow.getStatus()),
workflow.getFlowId(), workflow.getStartDate(),
workflow.getEndDate(),

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:[学习小记]Java的反射机制

下一篇:我的J2ME编程联系(1)——List