- 浏览: 269267 次
- 性别:
- 来自: 新乡
文章分类
- 全部博客 (227)
- servciemix (10)
- db (18)
- javaTools (4)
- hibernate (31)
- web (3)
- spring (14)
- design pattern (4)
- java security (3)
- portal (1)
- ejb (6)
- session (2)
- java_lang (21)
- jbpm (29)
- struts (7)
- orgRights (2)
- project manager Jira (7)
- 跨库事务 (2)
- mysql (14)
- ubuntu (7)
- osgi (9)
- maven ant make (4)
- 分布式 高并发 高性能 (5)
- virgo-dm_server (0)
- osgi web (3)
- platform (1)
- smooks (1)
- business (1)
- 职场生涯 (14)
- Java编码格式 (2)
- web服务 (1)
- 计算机使用 (1)
- 健康工作生活的保障,工作中务必抛掉的不良心态 (4)
- 电信-网络监控 (1)
- 多线程-multithread (1)
- 海量数据-高性能 (2)
- Mybatis (1)
- web开发平台研发 (0)
- oracle (0)
- 应用服务器调优 (0)
- web前端 (0)
- servlet-jsp (0)
- tomcat (2)
- newtouch (1)
- portal_liferay (2)
- version control (1)
- apm-impact (2)
- tools (1)
- 研发管理 (1)
- 电商业务 (1)
- 生鲜电商市场调查 (0)
- PBX (0)
- 房东 (0)
最新评论
-
lifuchao:
...
权限问题 -
Branding:
谢谢,受教了,另外,CONN AS SYSDBA,必须是在操作 ...
Oracle密码忘记了怎么办? -
zhuchao_ko:
...
Portal实现原理 -
败类斯文:
不知道改哪里。。。木有见到红色。。表示悟性低了、、
jira error: Neither the JAVA_HOME nor the JRE_HOME environment variable is defin -
c__06:
正文:假如事务我是这样定义的: <tx:method n ...
Spring中Transactional配置
JBPM4.3总结三
(2010-05-05 11:54:56)
转载
标签:
it
分类: jbpm
2.5集成自定义用户表
2.5.1 Jbpm4提供了实现接口
1.interface User
2.Interface Group
3.Interface GroupMember
4.Interface IdentitySession
想要集成自己的表,首先需要实现jbpm提供的接口,然后再进行配置。
2.5.2 User 用户表
import java.io.Serializable;
import java.sql.Blob;
import org.jbpm.api.identity.User;
public class MesUser implements Serializable, User {
private static final long serialVersionUID = 1L;
private String id;
private String userNo;// 员工工号
private String userName;// 员工姓名
private String userSex;// 性别
private String userPassword;// 密码
private String userType;// 类型
private String userMail;// 电子邮件
private String isValid;// 是否有效Y/N
private Blob signaturePic;// 电子签名
private String remarks;// 备注
protected long dbid; // 数据库内部自生成的ID
protected int dbversion;
public int getDbversion() {
return dbversion;
}
public MesUser() {
}
public MesUser(String id, String userName, String userMail) {
this.id = id;
this.userName = userName;
this.userMail = userMail;
}
public void setDbversion(int dbversion) {
this.dbversion = dbversion;
}
public long getDbid() {
return dbid;
}
public void setDbid(long dbid) {
this.dbid = dbid;
}
public void setId(String id) {
this.id = id;
}
public String getUserNo() {
return userNo;
}
public void setUserNo(String userNo) {
this.userNo = userNo;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserSex() {
return userSex;
}
public void setUserSex(String userSex) {
this.userSex = userSex;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getUserMail() {
return userMail;
}
public void setUserMail(String userMail) {
this.userMail = userMail;
}
public String getIsValid() {
return isValid;
}
public void setIsValid(String isValid) {
this.isValid = isValid;
}
public Blob getSignaturePic() {
return signaturePic;
}
public void setSignaturePic(Blob signaturePic) {
this.signaturePic = signaturePic;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getDisplayName() {
return userName + "(" + id + ")";
}
// 实现User接口所必须实现的几个方法
public String getId() {
return this.id;
}
public String getGivenName() {
return null;
}
public String getFamilyName() {
return null;
}
public String getBusinessEmail() {
return this.userMail;
}
}
2.5.3 Group部门表
import java.io.Serializable;
import org.jbpm.api.identity.Group;
public class MesGroup implements Serializable,Group {
private static final long serialVersionUID = 1L;
private String id;
private String groupName;//组织名称
private String groupType;//组织类型
private MesGroup parentGroup;//父组织
private String remarks;//备注
protected long dbid;
protected int dbversion;
public int getDbversion() {
return dbversion;
}
public void setDbversion(int dbversion) {
this.dbversion = dbversion;
}
public long getDbid() {
return dbid;
}
public void setDbid(long dbid) {
this.dbid = dbid;
}
public String getParentGroupID() {
return parentGroup!=null?parentGroup.getId():null;
}
public String getParentGroupName() {
return parentGroup==null ? "xxx" : parentGroup.getGroupName();
}
public void setId(String id) {
this.id = id;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getGroupType() {
return groupType;
}
public void setGroupType(String groupType) {
this.groupType = groupType;
}
public MesGroup getParentGroup() {
return parentGroup;
}
public void setParentGroup(MesGroup parentGroup) {
this.parentGroup = parentGroup;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
//实现Group接口必须的几个方法
public String getName(){
return this.groupName;
}
public String getType(){
return this.groupType;
}
public String getId() {
return id;
}
}
2.5.4 GroupMember 用户部门关系表
import java.io.Serializable;
public class MesGroupMember implements Serializable {
private static final long serialVersionUID = 1L;
protected long dbid;
protected int dbversion;
private MesUser user;
private MesGroup group;
protected String role;
public int getDbversion() {
return dbversion;
}
public void setDbversion(int dbversion) {
this.dbversion = dbversion;
}
public long getDbid() {
return dbid;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public void setDbid(long dbid) {
this.dbid = dbid;
}
public MesGroup getGroup() {
return group;
}
public void setGroup(MesGroup group) {
this.group = group;
}
public String getUserNo() {
return user.getUserNo();
}
public String getUserID() {
return user.getId();
}
public String getUserName() {
return user.getUserName();
}
public MesUser getUser() {
return user;
}
public void setUser(MesUser user) {
this.user = user;
}
}
2.5.5 IdentitySession 实现类
import java.util.Arrays;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.jbpm.api.JbpmException;
import org.jbpm.api.identity.Group;
import org.jbpm.api.identity.User;
import org.jbpm.pvm.internal.env.BasicEnvironment;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.identity.spi.IdentitySession;
@SuppressWarnings("unchecked")
public class MesIdentitySessionImpl implements IdentitySession {
protected Session session;
public MesIdentitySessionImpl() {
this.session = BasicEnvironment.getFromCurrent(Session.class);
}
public String createH() {
Test t = new Test();
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
t.setDbid(dbid);
t.setId("abc");
return null;
}
public String createUser(String id, String userName,
String businessEmail, String familName) {
MesUser user = new MesUser(id, userName, businessEmail);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
user.setDbid(dbid);
session.save(user);
return user.getId();
}
public MesUser findUserById(String userId) {
return (MesUser) session.createCriteria(MesUser.class).add(
Restrictions.eq("id", userId)).uniqueResult();
}
public List<User> findUsersById(String... userIds) {
List<User> users = session.createCriteria(MesUser.class).add(
Restrictions.in("id", userIds)).list();
if (userIds.length != users.size()) {
throw new JbpmException("not all users were found: "
+ Arrays.toString(userIds));
}
return users;
}
public List<User> findUsers() {
return session.createCriteria(MesUser.class).list();
}
public void deleteUser(String userId) {
// lookup the user
MesUser user = findUserById(userId);
// cascade the deletion to the memberships
List<MesGroupMember> memberships = session.createCriteria(
MesGroupMember.class).add(Restrictions.eq("user", user)).list();
// delete the related memberships
for (MesGroupMember membership : memberships) {
session.delete(membership);
}
// delete the user
session.delete(user);
}
public String createGroup(String groupName, String groupType,
String parentGroupId) {
MesGroup group = new MesGroup();
String groupId = groupType != null ? groupType + "." + groupName
: groupName;
group.setId(groupId);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
group.setDbid(dbid);
group.setGroupName(groupName);
group.setGroupType(groupType);
if (parentGroupId != null) {
MesGroup parentGroup = findGroupById(parentGroupId);
group.setParentGroup(parentGroup);
}
session.save(group);
return group.getId();
}
public List<User> findUsersByGroup(String groupId) {
return session.createCriteria(MesGroupMember.class).createAlias(
"group", "g").add(Restrictions.eq("g.id", groupId))
.setProjection(Projections.property("user")).list();
}
public MesGroup findGroupById(String groupId) {
return (MesGroup) session.createCriteria(MesGroup.class).add(
Restrictions.eq("id", groupId)).uniqueResult();
}
public List<Group> findGroupsByUserAndGroupType(String userId,
String groupType) {
return session.createQuery(
"select distinct m.group" + " from "
+ MesGroupMember.class.getName()
+ " as m where m.user.id = :userId"
+ " and m.group.type = :groupType").setString("userId",
userId).setString("groupType", groupType).list();
}
public List<Group> findGroupsByUser(String userId) {
List<Group> gList = session.createQuery(
"select distinct m.group" + " from "
+ MesGroupMember.class.getName()
+ " as m where m.user.id = :userId").setString(
"userId", userId).list();
return gList;
}
public List<Group> findGroups() {
return session.createCriteria(MesGroup.class).list();
}
public void deleteGroup(String groupId) {
// look up the group
MesGroup group = findGroupById(groupId);
// cascade the deletion to the memberships
List<MesGroupMember> memberships = session.createCriteria(
MesGroupMember.class).add(Restrictions.eq("group", group))
.list();
// delete the related memberships
for (MesGroupMember membership : memberships) {
session.delete(membership);
}
// delete the group
session.delete(group);
}
public void createMembership(String userId, String groupId, String role) {
MesUser user = findUserById(userId);
if (user == null) {
throw new JbpmException("user " + userId + " doesn't exist");
}
MesGroup group = findGroupById(groupId);
if (group == null) {
throw new JbpmException("group " + groupId + " doesn't exist");
}
MesGroupMember membership = new MesGroupMember();
membership.setUser(user);
membership.setGroup(group);
membership.setRole(role);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
membership.setDbid(dbid);
session.save(membership);
}
public void deleteMembership(String userId, String groupId, String role) {
MesGroupMember membership = (MesGroupMember) session.createCriteria(
MesGroupMember.class).createAlias("user", "u").createAlias(
"group", "g").add(Restrictions.eq("u.id", userId)).add(
Restrictions.eq("g.id", groupId)).uniqueResult();
session.delete(membership);
}
}
2.5.6配置 jbpm.cfg.xml
使用自己的SessionImpl,在文件后面加上
<transaction-context>
<hibernate-session current="true"/>
<object class="xxx . Xxx . xxx . MesIdentitySessionImpl">
</object>
</transaction-context>
1.注释掉jbpm4自己的hbm.xml文件
<!--
<import resource="jbpm.identity.cfg.xml" />
-->
在jbpm.hibernate.cfg.xml 注入自己的
<mapping resource="customize.hbm.xml" />
2.5.7自定义hibernate映射文件
新建 customize.hbm.xml,内容如下
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.jbpm.pvm.internal.identity.impl" default-access="field">
<!-- ### USER ########################################################### -->
<class name="com.t.MesUser" table="JBPM4_CUSTOMIZE_USER">
<id name="dbid" column="DBID_">
<generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
<property name="id" column="USERID_" /> <!-- 登陆ID -->
<property name="userNo" column="USERNO_" /> <!-- 员工工号 -->
<property name="userName" column="USERNAME_" /> <!-- 姓名 -->
<property name="userSex" column="USERSEX_" /> <!-- 性别 -->
<property name="userPassword" column="USERPASSWORD_" /> <!-- 密码 -->
<property name="userType" column="USERTYPE_" /> <!-- 类型 -->
<property name="userMail" column="USERMAIL_" /> <!-- 电子邮件 -->
<property name="signaturePic" column="SIGNATUREPIC_" /> <!-- 电子签名 -->
<property name="remarks" column="REMARKS_" /> <!-- 备注 -->
</class>
<!-- ### MEMBERSHIP ##################################################### -->
<class name="com.t.MesGroupMember" table="JBPM4_CUSTOMIZE_MEMBERSHIP">
<id name="dbid" column="DBID_">
<generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
<many-to-one name="user"
column="USER_"
class="com.t.MesUser"
foreign-key="FK_MEM_USER"
index="IDX_MEM_USER"/>
<many-to-one name="group"
column="GROUP_"
class="com.t.MesGroup"
foreign-key="FK_MEM_GROUP"
index="IDX_MEM_GROUP"/>
<property name="role" column="NAME_" />
</class>
<!-- ### GROUP ########################################################### -->
<class name="com.t.MesGroup" table="JBPM4_CUSTOMIZE_GROUP">
<id name="dbid" column="DBID_">
<generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
<!--
private String groupID;//数据库内部ID号
private String groupName;//组织名称
private String groupType;//组织类型
private MesGroup parentGroup;//父组织
private String remarks;//备注
-->
<property name="id" column="ID_" />
<property name="groupName" column="NAME_" />
<property name="groupType" column="TYPE_" />
<property name="remarks" column="REMARKS_" />
<many-to-one name="parentGroup"
column="PARENT_"
class="com.t.MesGroup"
foreign-key="FK_GROUP_PARENT"
index="IDX_GROUP_PARENT"/>
</class>
</hibernate-mapping>
集成自己的表就完成了。当你调用 identityService.createUser()方法时,就往你自定义的user表里插入了一条记录。
2.6新建用户和组
identityService.createGroup("user_dept"); // 部门
identityService.createUser("user1", "test1", "test1"); // 新建用户1
identityService.createUser("user2", "test2", "test2"); /./新建用户2
identityService.createMembership("user1", "user_dept"); // 绑定用户和部门的关系
identityService.createMembership("user2", "user_dept");
2.7发布流程
发布流程:
ProcessEngine processEngine = Configuration.getProcessEngine();
RepositoryService repositoryService = processEngine
.getRepositoryService();
String deployId = repositoryService.createDeployment().addResourceFromClasspath("com/contract/contract.jpdl.xml").deploy();
删除流程:repositoryService.deleteDeploymentCascade(deployId));
2.8开始流程实例
executionService.startProcessInstanceById(request.getParameter("id"));
(2010-05-05 11:54:56)
转载
标签:
it
分类: jbpm
2.5集成自定义用户表
2.5.1 Jbpm4提供了实现接口
1.interface User
2.Interface Group
3.Interface GroupMember
4.Interface IdentitySession
想要集成自己的表,首先需要实现jbpm提供的接口,然后再进行配置。
2.5.2 User 用户表
import java.io.Serializable;
import java.sql.Blob;
import org.jbpm.api.identity.User;
public class MesUser implements Serializable, User {
private static final long serialVersionUID = 1L;
private String id;
private String userNo;// 员工工号
private String userName;// 员工姓名
private String userSex;// 性别
private String userPassword;// 密码
private String userType;// 类型
private String userMail;// 电子邮件
private String isValid;// 是否有效Y/N
private Blob signaturePic;// 电子签名
private String remarks;// 备注
protected long dbid; // 数据库内部自生成的ID
protected int dbversion;
public int getDbversion() {
return dbversion;
}
public MesUser() {
}
public MesUser(String id, String userName, String userMail) {
this.id = id;
this.userName = userName;
this.userMail = userMail;
}
public void setDbversion(int dbversion) {
this.dbversion = dbversion;
}
public long getDbid() {
return dbid;
}
public void setDbid(long dbid) {
this.dbid = dbid;
}
public void setId(String id) {
this.id = id;
}
public String getUserNo() {
return userNo;
}
public void setUserNo(String userNo) {
this.userNo = userNo;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserSex() {
return userSex;
}
public void setUserSex(String userSex) {
this.userSex = userSex;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getUserMail() {
return userMail;
}
public void setUserMail(String userMail) {
this.userMail = userMail;
}
public String getIsValid() {
return isValid;
}
public void setIsValid(String isValid) {
this.isValid = isValid;
}
public Blob getSignaturePic() {
return signaturePic;
}
public void setSignaturePic(Blob signaturePic) {
this.signaturePic = signaturePic;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getDisplayName() {
return userName + "(" + id + ")";
}
// 实现User接口所必须实现的几个方法
public String getId() {
return this.id;
}
public String getGivenName() {
return null;
}
public String getFamilyName() {
return null;
}
public String getBusinessEmail() {
return this.userMail;
}
}
2.5.3 Group部门表
import java.io.Serializable;
import org.jbpm.api.identity.Group;
public class MesGroup implements Serializable,Group {
private static final long serialVersionUID = 1L;
private String id;
private String groupName;//组织名称
private String groupType;//组织类型
private MesGroup parentGroup;//父组织
private String remarks;//备注
protected long dbid;
protected int dbversion;
public int getDbversion() {
return dbversion;
}
public void setDbversion(int dbversion) {
this.dbversion = dbversion;
}
public long getDbid() {
return dbid;
}
public void setDbid(long dbid) {
this.dbid = dbid;
}
public String getParentGroupID() {
return parentGroup!=null?parentGroup.getId():null;
}
public String getParentGroupName() {
return parentGroup==null ? "xxx" : parentGroup.getGroupName();
}
public void setId(String id) {
this.id = id;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getGroupType() {
return groupType;
}
public void setGroupType(String groupType) {
this.groupType = groupType;
}
public MesGroup getParentGroup() {
return parentGroup;
}
public void setParentGroup(MesGroup parentGroup) {
this.parentGroup = parentGroup;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
//实现Group接口必须的几个方法
public String getName(){
return this.groupName;
}
public String getType(){
return this.groupType;
}
public String getId() {
return id;
}
}
2.5.4 GroupMember 用户部门关系表
import java.io.Serializable;
public class MesGroupMember implements Serializable {
private static final long serialVersionUID = 1L;
protected long dbid;
protected int dbversion;
private MesUser user;
private MesGroup group;
protected String role;
public int getDbversion() {
return dbversion;
}
public void setDbversion(int dbversion) {
this.dbversion = dbversion;
}
public long getDbid() {
return dbid;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public void setDbid(long dbid) {
this.dbid = dbid;
}
public MesGroup getGroup() {
return group;
}
public void setGroup(MesGroup group) {
this.group = group;
}
public String getUserNo() {
return user.getUserNo();
}
public String getUserID() {
return user.getId();
}
public String getUserName() {
return user.getUserName();
}
public MesUser getUser() {
return user;
}
public void setUser(MesUser user) {
this.user = user;
}
}
2.5.5 IdentitySession 实现类
import java.util.Arrays;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.jbpm.api.JbpmException;
import org.jbpm.api.identity.Group;
import org.jbpm.api.identity.User;
import org.jbpm.pvm.internal.env.BasicEnvironment;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.identity.spi.IdentitySession;
@SuppressWarnings("unchecked")
public class MesIdentitySessionImpl implements IdentitySession {
protected Session session;
public MesIdentitySessionImpl() {
this.session = BasicEnvironment.getFromCurrent(Session.class);
}
public String createH() {
Test t = new Test();
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
t.setDbid(dbid);
t.setId("abc");
return null;
}
public String createUser(String id, String userName,
String businessEmail, String familName) {
MesUser user = new MesUser(id, userName, businessEmail);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
user.setDbid(dbid);
session.save(user);
return user.getId();
}
public MesUser findUserById(String userId) {
return (MesUser) session.createCriteria(MesUser.class).add(
Restrictions.eq("id", userId)).uniqueResult();
}
public List<User> findUsersById(String... userIds) {
List<User> users = session.createCriteria(MesUser.class).add(
Restrictions.in("id", userIds)).list();
if (userIds.length != users.size()) {
throw new JbpmException("not all users were found: "
+ Arrays.toString(userIds));
}
return users;
}
public List<User> findUsers() {
return session.createCriteria(MesUser.class).list();
}
public void deleteUser(String userId) {
// lookup the user
MesUser user = findUserById(userId);
// cascade the deletion to the memberships
List<MesGroupMember> memberships = session.createCriteria(
MesGroupMember.class).add(Restrictions.eq("user", user)).list();
// delete the related memberships
for (MesGroupMember membership : memberships) {
session.delete(membership);
}
// delete the user
session.delete(user);
}
public String createGroup(String groupName, String groupType,
String parentGroupId) {
MesGroup group = new MesGroup();
String groupId = groupType != null ? groupType + "." + groupName
: groupName;
group.setId(groupId);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
group.setDbid(dbid);
group.setGroupName(groupName);
group.setGroupType(groupType);
if (parentGroupId != null) {
MesGroup parentGroup = findGroupById(parentGroupId);
group.setParentGroup(parentGroup);
}
session.save(group);
return group.getId();
}
public List<User> findUsersByGroup(String groupId) {
return session.createCriteria(MesGroupMember.class).createAlias(
"group", "g").add(Restrictions.eq("g.id", groupId))
.setProjection(Projections.property("user")).list();
}
public MesGroup findGroupById(String groupId) {
return (MesGroup) session.createCriteria(MesGroup.class).add(
Restrictions.eq("id", groupId)).uniqueResult();
}
public List<Group> findGroupsByUserAndGroupType(String userId,
String groupType) {
return session.createQuery(
"select distinct m.group" + " from "
+ MesGroupMember.class.getName()
+ " as m where m.user.id = :userId"
+ " and m.group.type = :groupType").setString("userId",
userId).setString("groupType", groupType).list();
}
public List<Group> findGroupsByUser(String userId) {
List<Group> gList = session.createQuery(
"select distinct m.group" + " from "
+ MesGroupMember.class.getName()
+ " as m where m.user.id = :userId").setString(
"userId", userId).list();
return gList;
}
public List<Group> findGroups() {
return session.createCriteria(MesGroup.class).list();
}
public void deleteGroup(String groupId) {
// look up the group
MesGroup group = findGroupById(groupId);
// cascade the deletion to the memberships
List<MesGroupMember> memberships = session.createCriteria(
MesGroupMember.class).add(Restrictions.eq("group", group))
.list();
// delete the related memberships
for (MesGroupMember membership : memberships) {
session.delete(membership);
}
// delete the group
session.delete(group);
}
public void createMembership(String userId, String groupId, String role) {
MesUser user = findUserById(userId);
if (user == null) {
throw new JbpmException("user " + userId + " doesn't exist");
}
MesGroup group = findGroupById(groupId);
if (group == null) {
throw new JbpmException("group " + groupId + " doesn't exist");
}
MesGroupMember membership = new MesGroupMember();
membership.setUser(user);
membership.setGroup(group);
membership.setRole(role);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class)
.getNextId();
membership.setDbid(dbid);
session.save(membership);
}
public void deleteMembership(String userId, String groupId, String role) {
MesGroupMember membership = (MesGroupMember) session.createCriteria(
MesGroupMember.class).createAlias("user", "u").createAlias(
"group", "g").add(Restrictions.eq("u.id", userId)).add(
Restrictions.eq("g.id", groupId)).uniqueResult();
session.delete(membership);
}
}
2.5.6配置 jbpm.cfg.xml
使用自己的SessionImpl,在文件后面加上
<transaction-context>
<hibernate-session current="true"/>
<object class="xxx . Xxx . xxx . MesIdentitySessionImpl">
</object>
</transaction-context>
1.注释掉jbpm4自己的hbm.xml文件
<!--
<import resource="jbpm.identity.cfg.xml" />
-->
在jbpm.hibernate.cfg.xml 注入自己的
<mapping resource="customize.hbm.xml" />
2.5.7自定义hibernate映射文件
新建 customize.hbm.xml,内容如下
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.jbpm.pvm.internal.identity.impl" default-access="field">
<!-- ### USER ########################################################### -->
<class name="com.t.MesUser" table="JBPM4_CUSTOMIZE_USER">
<id name="dbid" column="DBID_">
<generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
<property name="id" column="USERID_" /> <!-- 登陆ID -->
<property name="userNo" column="USERNO_" /> <!-- 员工工号 -->
<property name="userName" column="USERNAME_" /> <!-- 姓名 -->
<property name="userSex" column="USERSEX_" /> <!-- 性别 -->
<property name="userPassword" column="USERPASSWORD_" /> <!-- 密码 -->
<property name="userType" column="USERTYPE_" /> <!-- 类型 -->
<property name="userMail" column="USERMAIL_" /> <!-- 电子邮件 -->
<property name="signaturePic" column="SIGNATUREPIC_" /> <!-- 电子签名 -->
<property name="remarks" column="REMARKS_" /> <!-- 备注 -->
</class>
<!-- ### MEMBERSHIP ##################################################### -->
<class name="com.t.MesGroupMember" table="JBPM4_CUSTOMIZE_MEMBERSHIP">
<id name="dbid" column="DBID_">
<generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
<many-to-one name="user"
column="USER_"
class="com.t.MesUser"
foreign-key="FK_MEM_USER"
index="IDX_MEM_USER"/>
<many-to-one name="group"
column="GROUP_"
class="com.t.MesGroup"
foreign-key="FK_MEM_GROUP"
index="IDX_MEM_GROUP"/>
<property name="role" column="NAME_" />
</class>
<!-- ### GROUP ########################################################### -->
<class name="com.t.MesGroup" table="JBPM4_CUSTOMIZE_GROUP">
<id name="dbid" column="DBID_">
<generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
<!--
private String groupID;//数据库内部ID号
private String groupName;//组织名称
private String groupType;//组织类型
private MesGroup parentGroup;//父组织
private String remarks;//备注
-->
<property name="id" column="ID_" />
<property name="groupName" column="NAME_" />
<property name="groupType" column="TYPE_" />
<property name="remarks" column="REMARKS_" />
<many-to-one name="parentGroup"
column="PARENT_"
class="com.t.MesGroup"
foreign-key="FK_GROUP_PARENT"
index="IDX_GROUP_PARENT"/>
</class>
</hibernate-mapping>
集成自己的表就完成了。当你调用 identityService.createUser()方法时,就往你自定义的user表里插入了一条记录。
2.6新建用户和组
identityService.createGroup("user_dept"); // 部门
identityService.createUser("user1", "test1", "test1"); // 新建用户1
identityService.createUser("user2", "test2", "test2"); /./新建用户2
identityService.createMembership("user1", "user_dept"); // 绑定用户和部门的关系
identityService.createMembership("user2", "user_dept");
2.7发布流程
发布流程:
ProcessEngine processEngine = Configuration.getProcessEngine();
RepositoryService repositoryService = processEngine
.getRepositoryService();
String deployId = repositoryService.createDeployment().addResourceFromClasspath("com/contract/contract.jpdl.xml").deploy();
删除流程:repositoryService.deleteDeploymentCascade(deployId));
2.8开始流程实例
executionService.startProcessInstanceById(request.getParameter("id"));
发表评论
-
JBPM4的优秀博文链接
2011-08-31 22:39 13251 Jbpm4 IOC容器 http://www.it ... -
jbpm4 在tomcat6 下面ssh2 错误
2011-08-31 21:35 997异常:java.lang.LinkageError: load ... -
JBPM4表结构说明
2011-07-23 00:33 1295JBPM4表结构说明 (2010-05-05 14:10:02 ... -
jbpm流程文件的部署
2011-07-23 00:32 1192jbpm流程文件的部署 (2010-05-05 14:51:5 ... -
BPM4.3总结二 Jbpm4.3使用文档
2011-07-23 00:30 1154JBPM4.3总结二 [此博文包含图片] (2010-05-0 ... -
JBPM4.3总结五 合同审批实例
2011-07-23 00:27 1360JBPM4.3总结五 [此博文包含图片] (2010-05-0 ... -
JBPM4.3总结四 2.9任务管理
2011-07-23 00:26 1062JBPM4.3总结四 (2010-05-05 11:53:32 ... -
swing 实现JBPM 4.2例子
2011-07-22 13:20 1040swing 实现JBPM 4.2例子 http://blo ... -
JBPM4.3之任务管理
2011-07-22 12:37 1074JBPM4.3总结四(2010-05-05 11:53:32) ... -
jbpm frequently used url
2011-06-29 12:19 10681. http://old.family168.com/bb ... -
jbpm4 和 spring 的集成
2011-06-29 11:37 836jbpm4 内置了和 spring 的集成支持, 配置很简单, ... -
任务提交后为什么JBPM4_HIST_VAR不存在值
2011-06-29 11:05 1492JbpmProcessEngineUtil.getExecut ... -
权限问题
2011-06-29 09:05 1236机构 与 权限关系表:机构拥有与之关联的权限 应用 与 权限 ... -
jBPM4的运行期环境
2011-06-29 08:52 684一、运行期环境就是一个餐馆 二、jBPM4的运行期环境 E ... -
Jbpm4.3连接数据库配置
2011-06-29 08:35 1312Jbpm4.3连接数据库配置 收藏 1、我以mysql为例子 ... -
jbpm4 有18张表,简单介绍如下
2011-06-29 08:33 1814jbpm4 有18张表,简单介绍如下: JBPM4_DEP ... -
Drools
2011-06-28 20:59 1280Drools - The Business Logic int ... -
Activiti BPM Platform
2011-06-28 20:58 1122Activiti BPM Platform http://a ... -
jbpm之6 JBPM流程通过Aciton动态创建TaskInstance来实现“会签”
2011-06-28 20:57 834jbpm6(2007-03-14 23:32:38)转载 ... -
jbpm之6 JBPM流程通过Aciton动态创建TaskInstance来实现“会签”
2011-06-28 20:52 798jbpm6(2007-03-14 23:32:38)转载 ...
相关推荐
1. **jBPM 4视频教程01:配置开发环境** - 这一章节将引导学习者搭建JBPM4.3的开发环境,包括安装Eclipse IDE(集成开发环境)以及jbpm-gpd-site.zip这个插件。jbpm-gpd-site.zip是JBPM的图形过程设计器(Graphical ...
jbPM 4.3 可以无缝集成到其他Java EE应用中,例如EJB、JMS、JPA和Spring框架。此外,它还支持与外部系统(如ERP、CRM)的集成,通过服务代理(Service Task)实现服务调用。 **9. 持久化机制** jbPM 4.3 使用JPA...
4. **规则集成**:jbpm4.3集成了Drools规则引擎,允许在流程中嵌入决策逻辑。这使得流程可以根据预定义的规则动态地改变路径。 5. **事件处理**:jbpm4.3引入了事件处理机制,可以监听并响应流程中的特定事件,如...
其次,"jbpm+tomcat+oracle部署_百度文库.htm"文件则可能涉及的是jbpm4.3在Tomcat应用服务器上与Oracle数据库的集成部署教程。部署jbpm需要配置正确的数据源、环境变量以及web应用上下文。在Tomcat中,我们需要将...
根据提供的文件信息,可以归纳出以下关于JBPM 4.3中文用户手册的相关知识点: ### JBPM 4.3 概述 - **JBPM**(JBoss Business Process Management)是一个开源的工作流引擎,用于创建、管理和执行业务流程。 - **...
**jbpm4.3所需jar包** JBPM(Java Business Process Management)是一个开源的工作流管理系统,主要用于业务流程的建模、执行和管理。在JBPM 4.3版本中,为了实现完整功能,需要一系列的jar包来支持其运行环境。...
5. **监听器和事件**:jbpm4.3支持事件监听,可以在流程的不同阶段触发自定义逻辑,比如任务完成后发送通知。 6. **集成能力**:jbpm4.3可与Spring框架无缝集成,便于在企业级应用环境中使用。此外,还可以与其他...
jbpm4.3集成了规则引擎,如Drools,允许在流程中嵌入决策逻辑。这样,业务规则可以独立于代码进行维护,提高了灵活性和可维护性。 **8. 监控和调试** jbpm提供了丰富的监控工具,如工作流审计日志、流程实例跟踪等...
1. **Struts2与jbpm4.3的集成**:Struts2作为前端控制器,负责处理用户的请求,并转发到相应的Action。jbpm4.3可以通过Struts2的拦截器或者Action类来启动、暂停、继续或结束流程实例。 2. **Spring对jbpm4.3的管理...
6. **规则集成**:jbpm4.3集成了JBoss Drools,一个强大的规则引擎,使得业务流程能够根据预定义的规则进行决策。API中有关于如何触发规则执行和访问规则结果的接口。 7. **监控和调试**:jbpm4.3提供了丰富的监控...
本文将深入探讨jbpm4.3在Java环境中的实际应用,以及如何与Spring、Struts和Hibernate(SSH)框架进行集成。 1. **jbpm4.3核心概念** - **流程定义**:jbpm4.3支持BPMN 2.0标准,允许通过图形化方式设计业务流程,...
7. **集成能力(Integration Capabilities)**:JBPM4.3可以与其他Java应用无缝集成,例如Spring框架。此外,还支持服务调用,如EJB、Web服务等,这在实际业务场景中非常有用。 8. **监控与调试(Monitoring & ...
jbpm-4.3-src.rar_bdf-jbpm4 src _jboss 4.3_jboss jbpm4.3_jbpm-4.3 这个压缩包文件包含的是JBOSS jBPM4.3的源代码,这是一个用于业务流程管理(BPM)的开源框架。jBPM是一个强大的工具,它提供了流程定义、执行和...
2. **获取JBPM4.3**:可以从官方网站或者第三方源下载JBPM4.3的发布包。 3. **设置环境变量**:配置系统环境变量,包括JAVA_HOME和JBPM_HOME。 4. **启动服务器**:通常使用Tomcat或Jetty作为应用服务器,将JBPM的...
- **Drools集成**: jbPM4.3中的规则引擎,用于实现流程中的条件判断和业务决策。 - **规则定义**: 使用DRL(Drools Rule Language)编写规则,并在流程中引用执行。 - **规则测试**: 提供规则单元测试,确保规则正确...
【JBPM4.3 用户手册】是一份详细阐述JBPM工作流引擎的文档,由family168分享的CHM版。JBPM是一款开源的工作流程管理系统,它提供了业务流程建模、部署、执行和监控的一整套解决方案。下面将根据手册内容,详细解读...
1. **身份验证与授权**:SSJ负责用户的登录认证和权限分配,确保只有经过授权的用户可以访问特定的jBPM4.3流程或任务。这通常涉及到配置Spring Security的UserDetailsService,以及定义角色和权限。 2. **流程实例...
### jBPM4.3用户指南关键知识点解析 #### 一、导言 **1.1 许可证与最终用户许可协议** - **LGPL(GNU Lesser General Public License)**: 这是一种自由软件许可协议,允许用户自由地运行、研究、共享以及修改...
jbpm4.3-src.zip是一个包含jbpm 4.3版本源代码的压缩包,对于开发者来说,这是一个宝贵的资源,可以深入理解jbpm的工作原理,从而更好地利用它进行业务流程管理(BPM)系统的开发和定制。jbpm是一个开源的工作流管理...
- **概述**:提供了Spring框架与JBPM4.3集成的基本信息。 - **配置**:详细说明了如何配置Spring以支持JBPM4.3的集成。 - **使用**:介绍了如何在Spring环境中使用JBPM4.3的各种功能。 - **测试**:提供了测试Spring...