首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

8、创建公文

2012-12-18 
八、创建公文1、创建公文对象public class Document {??? private Long id??? ??? private String title??

八、创建公文

1、创建公文对象

public class Document {

??? private Long id;
???
??? private String title;
???
??? private Long processInstanceId;

?

2、

@Test
??? public void createJbpmTabTest(){
??? ???
??? ??? JbpmContext context = null;
??? ???
??? ??? ?try {
??? ??? ??? ?
??? ??? ??? //默认从classpath中查找名为hibernate.cfg.xml的配置文件
??? ??? ??? JbpmConfiguration configuration = JbpmConfiguration.getInstance();
??? ??? ???
??? ??? ??? //JbpmContext是对hibernate session的封装,提供了对JBPM相关对象的持久化功能
??? ??? ??? context = configuration.createJbpmContext();
??? ??? ???
??? ??? ??? Document document = new Document();
??? ??? ??? document.setTitle("公文"+new Random().nextInt());
??? ??? ???
??? ??? ??? context.getSession().save(document);
??? ??? ???
??? ??? ??? //创建流程实例
??? ??? ??? //1、首先从数据库中加载ProcessDefinition对象
??? ??? ??? ProcessDefinition definition = context.getGraphSession().findLatestProcessDefinition("test");
??? ??? ??? //2、根据ProcessDefinition对象,创建流程实例对象
??? ??? ??? ProcessInstance instance = new ProcessInstance(definition);

??????????? instance.setKey(document.getId()+"");
??? ??? ??? context.save(instance);
??? ??? ??? //3、把公文对象和流程实例对象互相绑定
??? ??? ??? document.setProcessInstanceId(instance.getId());
??? ??? ??? instance.getContextInstance().setVariable("documentId", document.getId());
??? ??? } catch (RuntimeException e) {
??? ??? ??? e.printStackTrace();
??? ??? }finally{
??? ??? ??? context.close();
??? ??? }
??? ???
??? }

执行后,数据库情况如下:


8、创建公文
?
8、创建公文

实例变量表中,根据变量的类型,在不同的字段中保存值。

?

?

对应token如下:

?

8、创建公文

?

?

?

?

热点排行