`
- 浏览:
191283 次
- 来自:
...
-
基于开源工作流引擎OSWorkflow的业务系统实例——请假审批系统2
java 代码
- package com.qiny.leave;
-
- import java.util.Map;
- import com.opensymphony.module.propertyset.PropertySet;
- import com.opensymphony.workflow.FunctionProvider;
- import com.opensymphony.workflow.spi.WorkflowEntry;
-
- import com.qiny.dao.LeaveDAO;
- import org.apache.log4j.Logger;
-
- public class ApplyFunction implements FunctionProvider {
-
- private static Logger logger = (Logger) Logger.getInstance(ApplyFunction.class);
-
- public void execute(Map transientVars, Map args, PropertySet ps) {
- logger.info("execute ......");
- WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry");
- long wfid = entry.getId();
- int actionId = ((Integer) transientVars.get("actionId")).intValue();
- logger.info("execute actionId=" + actionId);
- String applicant = (String) transientVars.get("applicant");
- String reason = (String) transientVars.get("reason");
- int dayCount = ((Integer) transientVars.get("dayCount")).intValue();
- LeaveApply leaveApply = new LeaveApply(applicant, reason, dayCount);
- leaveApply.setWfid(wfid);
- LeaveDAO leaveDao = new LeaveDAO();
- leaveDao.addLeaveApply(leaveApply);
- ps.setInt("dayCount", dayCount);
- logger.info("execute leaveDao has added leaveApply!");
- }
- }
-
-
-
-
- package com.qiny.leave;
-
- import java.util.Map;
- import com.opensymphony.module.propertyset.PropertySet;
- import com.opensymphony.workflow.FunctionProvider;
- import com.opensymphony.workflow.spi.WorkflowEntry;
-
- import com.qiny.dao.LeaveDAO;
- import org.apache.log4j.Logger;
-
- public class ApproveFunction implements FunctionProvider {
-
- private static Logger logger = (Logger) Logger.getInstance(ApproveFunction.class);
-
- public void execute(Map transientVars, Map args, PropertySet ps) {
- logger.info("execute ......");
- WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry");
- long wfid = entry.getId();
- int actionId = ((Integer) transientVars.get("actionId")).intValue();
- logger.info("execute actionId=" + actionId);
- int applyID = ((Integer) transientVars.get("applyID")).intValue();
- String approver = (String) transientVars.get("approver");
- int opinion = ((Integer) transientVars.get("opinion")).intValue();
- LeaveApprove LeaveApprove = new LeaveApprove(applyID, approver, opinion);
- LeaveDAO leaveDao = new LeaveDAO();
- leaveDao.addLeaveApprove(LeaveApprove);
- ps.setInt("opinion", opinion);
- logger.info("execute leaveDao has added leaveApprove!");
- }
- }
-
-
- package com.qiny.leave;
-
- public class LeaveApply {
-
- private int applyID;
- private String applicant;
- private String reason;
- private String applyTime;
- private int dayCount;
- private long wfid;
-
- public LeaveApply(){
- }
-
- public LeaveApply(String applicant,String reason,int dayCount){
- this.applicant = applicant;
- this.reason = reason;
- this.dayCount = dayCount;
- }
-
- public int getApplyID() {
- return applyID;
- }
-
- public String getApplicant() {
- return applicant;
- }
-
- public String getReason() {
- return reason;
- }
-
- public String getApplyTime() {
- return applyTime;
- }
-
- public int getDayCount() {
- return dayCount;
- }
-
- public long getWfid() {
- return wfid;
- }
-
- public void setApplyID(int applyID) {
- this.applyID = applyID;
- }
-
- public void setApplicant(String applicant) {
- this.applicant = applicant;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- public void setApplyTime(String applyTime) {
- this.applyTime = applyTime;
- }
-
- public void setDayCount(int dayCount) {
- this.dayCount = dayCount;
- }
-
- public void setWfid(long wfid) {
- this.wfid = wfid;
- }
-
- }
-
-
- package com.qiny.leave;
-
- public class LeaveApprove {
-
- private int applyID;
- private String approver;
- private String approveTime;
- private int opinion;
-
- public LeaveApprove(){
- }
-
- public LeaveApprove(int applyID,String approver,int opinion){
- this.applyID = applyID;
- this.approver = approver;
- this.opinion = opinion;
- }
-
- public String getOpinionString(){
- return opinion == 1 ? "批准" : "拒绝";
- }
-
- public int getApplyID() {
- return applyID;
- }
-
- public String getApprover() {
- return approver;
- }
-
- public String getApproveTime() {
- return approveTime;
- }
-
- public int getOpinion() {
- return opinion;
- }
-
- public void setApplyID(int applyID) {
- this.applyID = applyID;
- }
-
- public void setApprover(String approver) {
- this.approver = approver;
- }
-
- public void setApproveTime(String approveTime) {
- this.approveTime = approveTime;
- }
-
- public void setOpinion(int opinion) {
- this.opinion = opinion;
- }
-
-
- }
-
-
-
-
- package com.qiny.dao;
-
- import java.util.List;
- import java.util.ArrayList;
-
- import java.sql.Connection;
- import java.sql.Statement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import javax.sql.DataSource;
-
- import javax.naming.InitialContext;
- import javax.naming.NamingException;
-
- import com.qiny.leave.LeaveApply;
- import com.qiny.leave.LeaveApprove;
-
- public class LeaveDAO {
-
- protected static DataSource ds = null;
-
- public LeaveDAO() {
- if (ds == null) {
- try {
- InitialContext ic = new InitialContext();
- ds = (DataSource) ic.lookup("java:JSQLConnectDB_LeaveApply");
- } catch (NamingException ne) {
- throw new RuntimeException("NamingException while looking");
- }
- }
- }
-
- public void addLeaveApply(LeaveApply leaveApply) {
- try {
- String exeSql = ""
- + " INSERT INTO bus_leaveApply (applicant,reason,applyTime,dayCount,wfid)"
- + " VALUES ('" + leaveApply.getApplicant() + "','" + leaveApply.getReason()
- + " ',CONVERT(VARCHAR(20),GETDATE(),121 ),'" + leaveApply.getDayCount()
- + " '," + leaveApply.getWfid() + ")";
- Connection connection = ds.getConnection();
- Statement statement = connection.createStatement();
- statement.execute(exeSql);
- statement.close();
- connection.close();
- } catch (SQLException ex) {
- throw new RuntimeException("DAO addLeaveApply failed!\n" + ex.getMessage());
- }
- }
-
- public void addLeaveApprove(LeaveApprove leaveApproval) {
- try {
- String exeSql = ""
- + " INSERT INTO bus_leaveApprove (applyID,approver,approveTime,opinion)"
- + " VALUES ('" + leaveApproval.getApplyID() + "','" + leaveApproval.getApprover()
- + " ',CONVERT(VARCHAR(20),GETDATE(),121 )," + leaveApproval.getOpinion() + ")";
- Connection connection = ds.getConnection();
- Statement statement = connection.createStatement();
- statement.execute(exeSql);
- statement.close();
- connection.close();
- } catch (SQLException ex) {
- throw new RuntimeException("DAO addLeaveApprove failed!\n" + ex.getMessage());
- }
- }
-
- public LeaveApply getLeaveApply(long wfid) {
- LeaveApply leaveApply = new LeaveApply();
- try {
- String querySql = ""
- + " SELECT applyID,applicant,reason,applyTime,dayCount,wfid "
- + " FROM bus_leaveApply WHERE wfid=" + wfid;
- Connection connection = ds.getConnection();
- Statement statement = connection.createStatement();
- ResultSet rs = statement.executeQuery(querySql);
- if (rs.next()) {
- leaveApply.setApplyID(rs.getInt("applyID"));
- leaveApply.setApplicant(rs.getString("applicant"));
- leaveApply.setReason(rs.getString("reason"));
- leaveApply.setApplyTime(rs.getString("applyTime"));
- leaveApply.setDayCount(rs.getInt("dayCount"));
- leaveApply.setWfid(rs.getLong("wfid"));
- }
- rs.close();
- statement.close();
- connection.close();
- } catch (SQLException ex) {
- throw new RuntimeException("DAO getLeaveApply failed!\n" + ex.getMessage());
- }
- return leaveApply;
- }
-
- public List getLeaveAprovals(int applyID) {
- List approvals = new ArrayList();
- try {
- String querySql = ""
- + " SELECT applyID,approver,approveTime,opinion "
- + " FROM bus_leaveApprove WHERE applyID=" + applyID;
- Connection connection = ds.getConnection();
- Statement statement = connection.createStatement();
- ResultSet rs = statement.executeQuery(querySql);
- while (rs.next()) {
- LeaveApprove leaveApproval = new LeaveApprove();
- leaveApproval.setApplyID(rs.getInt("applyID"));
- leaveApproval.setApprover(rs.getString("approver"));
- leaveApproval.setApproveTime(rs.getString("approveTime"));
- leaveApproval.setOpinion(rs.getInt("opinion"));
- approvals.add(leaveApproval);
- }
- rs.close();
- statement.close();
- connection.close();
- } catch (SQLException ex) {
- throw new RuntimeException("DAO getLeaveAprovals failed!\n" + ex.getMessage());
- }
- return approvals;
- }
-
- }
-
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
这个开源项目为开发者提供了灵活的工作流定义和执行能力,使得在系统中实现如请假审批这样的业务流程变得简单。在这个"OSWorkflow——请假审批系统(代码全,数据库mysql)"中,我们能看到一个基于OSWorkflow实现的请假...
OsWorkflow是一款开源的工作流引擎,它为应用程序提供了一种灵活且可扩展的方式来管理业务流程。在本实例中,我们将深入探讨OsWorkflow的核心概念、主要功能以及如何创建和测试一个工作流实例。 工作流引擎是软件...
这个示例提供了一个完整的osworkflow与Eclipse结合的请假审批流程,它不仅展示了osworkflow的工作流管理能力,还演示了如何将工作流引擎与实际业务逻辑相结合,为实际的企业应用提供了参考。通过学习和实践这个示例...
OSworkflow(OpenSymphony Workflow)是一个开源的工作流管理系统,它提供了强大的流程定义和执行的能力,广泛应用于企业级应用中,如请假流程等业务场景。在本实例中,我们将深入探讨如何利用OSworkflow来实现一个...
OSWorkFlow是一个强大的工作流引擎,它在IT领域中被广泛应用来实现业务流程自动化。工作流,简单来说,就是一系列相互关联的任务,按照特定的顺序执行,以完成一个业务过程。OSWorkFlow作为开源的工作流解决方案,为...
osWorkflow(简称OSW)是一个开源的工作流引擎,它允许开发者在应用程序中定义、管理和执行工作流程。这个实例是基于OSW的请假申请流程,使用了Tomcat 6.0作为应用服务器,Oracle数据库作为数据存储,并且可以方便地...
OSWorkflow(OpenSymphony Workflow)是一个开源的工作流引擎,它提供了一种灵活的方式来设计、实施和管理业务流程。本篇文章将深入探讨OSWorkflow的工作原理及其应用实例。 OSWorkflow的核心概念包括工作流定义、...
标题提到的"yy.rar_DEMO_demo osworkflow_流程引擎_请假流程引擎"是一个基于osWorkflow的工作流引擎的演示项目,专门设计用来展示如何实现请假流程。osWorkflow是一款开源的工作流引擎,它允许开发者定义、执行和...
通过基于osworkflow的OA系统DEMO,我们可以学习到如何利用工作流引擎实现业务流程自动化,提高办公效率。同时,osworkflow的灵活性和强大功能,使其成为构建复杂OA系统时的理想选择。理解并掌握osworkflow的使用,...
Osworkflow 是一个开源的工作流引擎,它为应用程序提供了一种灵活的方式来管理业务流程。这个入门级的例子将带你了解 Osworkflow2.8 的基本概念和如何在项目中简单地实现工作流。 Osworkflow 提供了一个强大的框架...
2. **osWorkFlow架构**:了解osWorkFlow的设计原理和组件,如流程定义、流程实例、任务服务、持久化机制等,这有助于你构建和维护工作流系统。 3. **流程定义**:学习如何使用XML或图形工具(如FlowDesigner)来...
osWorkflow 是一个开源的工作流引擎,它主要用于设计和执行复杂的业务流程。这个“osworkflow 工作流demo”提供了一个具体的应用示例,演示了如何使用 osWorkflow 实现请假审批这样的工作流程。osWorkflow 提供了...
osworkflow是一款开源的工作流引擎,它提供了灵活的工作流程定义和执行管理功能。在Java应用中,osworkflow常常与Spring和Hibernate这两个主流的框架结合使用,以实现业务流程的自动化处理。本篇文章将深入探讨如何...
在"osworkflow_leaveApprove_mysql"项目中,我们看到的是一个基于OSWorkflow的请假审批流程示例,专为初学者设计,帮助他们快速理解和掌握工作流系统的运作原理。 MySQL作为全球最受欢迎的开源关系型数据库管理系统...
OSWorkflow 是一个开源的工作流引擎,它允许开发者在应用程序中实现复杂的业务流程。这个中文手册是为了解决中文用户在理解和使用OSWorkflow时的语言障碍,提供详细的指南和实例解析。 工作流引擎是软件系统中一个...
OSWorkflow,全称为OpenSymphony Workflow,是一款开源的工作流引擎,用于在应用程序中实现复杂的业务流程。这个项目由OpenSymphony Group开发,现在已经并入到Atlassian的Confluence产品中。OSWorkflow提供了一种...
OSWorkflow 是一个强大的工作流引擎,它允许开发者在应用程序中实现复杂的业务流程。在这个"可以请假的小例子"中,我们将探讨如何使用OSWorkflow与MySQL数据库、Tomcat应用服务器以及Eclipse开发环境集成,来创建一...
OSWorkflow 是一个开源的工作流引擎,它允许开发者在应用程序中实现复杂的业务流程。这个框架提供了灵活的流程定义、状态跟踪、任务分配以及事件通知等功能,使得开发人员能够轻松地创建和管理动态工作流程。本文将...
osWorkflow是一款开源的工作流管理系统,专为Java环境设计,用于处理业务流程中的任务分配、状态跟踪以及流程控制。它提供了强大的API和灵活的配置,使得开发者能够轻松地在应用程序中集成工作流功能。这份...