- 浏览: 38455 次
- 性别:
- 来自: 绵阳
文章分类
最新评论
-
adm889486:
mazhi4562qq 写道java.lang.Unsuppo ...
openfire研究及使用遇到的问题 -
mazhi4562qq:
java.lang.UnsupportedOperationE ...
openfire研究及使用遇到的问题 -
dxcsingle:
可否详细说一下,如何配置? 我按文档上的配置完成,可仍然在登陆 ...
openfire研究及使用遇到的问题 -
tangzlboy:
...
org.apache.jasper.JasperException: File "/struts-tags" not found
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;
/**
* 用户表 MesUser
*
* @version 1.0
*
*/
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;
}
/**
* 显示用户姓名+工号
*
* @return
*/
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;
/**
* @author zhangkai
* @version 1.0
*
*/
@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"));
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;
/**
* 用户表 MesUser
*
* @version 1.0
*
*/
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;
}
/**
* 显示用户姓名+工号
*
* @return
*/
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;
/**
* @author zhangkai
* @version 1.0
*
*/
@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"));
相关推荐
在学习和使用JPBM时,理解JPDL的语法和结构至关重要,因为它是实现流程逻辑的关键。此外,还需要掌握如何在实际项目中集成JPBM,利用其提供的API和工具进行流程的部署、启动、监控和调试。通过阅读这份文档,开发者...
jBPM学习资料个人总结 jBPM是一个开源的工作流管理系统,最初独立开发,后来成为JBoss组织的一部分。它被设计用于处理业务流程自动化,支持复杂的业务流程管理和执行。jBPM并不局限于与JBoss应用服务器一起使用,它...
《深入浅出JPBM》是一本专注于Java流程管理...通过深入学习和分析这些源代码,读者可以不仅理解JPBM的基本概念,还能掌握如何设计、实现和测试业务流程,从而在实际工作中运用这些技术提高企业的流程管理水平。
2. 入门 为了开始使用JBPM,你需要完成以下步骤: 2.1 下载 首先,访问JBPM官方网站下载最新版本的JBPM发行包,包含所需的库和工具。 2.2 资源 了解并熟悉JBPM的官方文档,这将是你学习过程中最重要的资源。此外,...
这个开发手册集合了多个版本的文档,包括jbpm4.4的开发手册、jbpm4.x开发手册、jpbm用户手册、jpbm3.x开发手册、jpbm3安装配置手册、jpbm4安装手册以及jpbm学习笔记和最佳实践,为开发者提供全面的参考和指导。...
在文件名称列表中提到的“SSH2”,通常是指Secure Shell(SSH)的第二版本,这是一个网络协议,用于安全地远程登录服务器、传输数据以及执行命令。在与JPBM结合使用时,SSH2可能被用作远程管理系统或服务的一部分,...
总的来说,JPBM实例报销和采购源代码是一个很好的学习平台,通过实践你可以掌握如何利用JPBM进行业务流程的建模和管理,提升你的Java BPM开发能力。在深入研究源代码的过程中,不仅要注意流程定义的逻辑,还要关注...
jbpm4.4入门学习的好文档 1.工作流基础 2.开发环境 3.核心概念与相关api 4.processenginee serviceapi 5.管理流程定义 6.执行流程实例 7.流程定义语言 8.应用 与其他框架的集成
2. **持久化框架**:JBPM 4.0 引入了基于Hibernate的持久化机制,使得流程实例和任务数据能够轻松地存储在数据库中,增强了系统的可扩展性和可靠性。 3. **工作流引擎**:JBPM 4.0 提供了一个强大的工作流引擎,...
描述中的"欢迎各位下载"意味着这些资源是共享的,供对jpbm感兴趣的用户学习和使用。 **标签"jpbm"** 标签"jpbm"可能是"Jboss Process Business Manager"的缩写,这是一个用于业务流程管理(Business Process ...
学习这部分内容,你将了解如何使用JPBM设计流程、集成业务逻辑、调用服务和进行流程实例的管理。同时,通过源代码分析,你可以掌握如何在实际项目中运用JPBM来提升企业的业务流程效率。这个过程将涵盖Java编程、BPMN...
2. **实例化流程图对象**:使用"jpbm"库创建流程图实例,并传入配置数据。 3. **监听事件**:设置事件监听器以响应用户的交互操作。 4. **保存和加载状态**:当需要保存流程图时,调用库提供的方法将图形状态转换为...
**JBPM3安装与入门教程** JBPM,全称Java Business Process Management,是一个开源的工作流管理系统,用于...同时,也可以学习如何配置数据库存储流程实例、监控流程状态以及集成其他系统,实现全面的业务流程管理。
【标题】"JPBM 会签 示例" 涉及的知识点主要集中在企业流程管理和Java平台业务模型(Java Business Process Management,简称JBPM)的应用上。JBPM 是一个开源的工作流管理系统,它允许开发者和业务分析师设计、部署...
标题 "springmvc_jpbm5_document.zip_spring mvc" 提供的信息暗示了这是一个关于Spring MVC框架的学习资源压缩包,包含文档和代码示例。描述中提到“spring学习,java spring mvc 学习代码,文档”,这表明内容涵盖...
#### 二、JBPM的特点 1. **灵活性**:JBPM支持多种类型的流程定义,包括但不限于工作流、事件驱动流程以及服务协调。 2. **可扩展性**:用户可以根据需要添加自定义的插件或组件来扩展JBPM的功能。 3. **集成能力**...
接着,"jBPM工作流应用开发指南目录.pdf"可能是整个jBPM开发文档的大纲,涵盖了从入门到进阶的所有主题,包括流程定义语言BPMN2的解析、jBPM的工作原理、流程实例的创建与管理、任务服务的使用、监听器和事件处理、...
这个“完整的工作流jbpm实例”是一个包含了所有必要组件的示例项目,你可以直接在其中进行学习和实践。它提供的核心功能包括: 1. **流程建模**:jbpm使用BPMN(Business Process Model and Notation)2.0标准,这...
2. **jPDL语法**:手册详细讲解了jPDL的语法规则,包括流程定义的基本元素如开始节点、结束节点、任务、子流程、决策节点、事件等,以及它们之间的连接和条件表达式。 3. **流程设计**:手册会指导如何使用jPDL设计...