jbpmsshdejutiyongfaWord文档格式.docx

上传人:b****6 文档编号:22228764 上传时间:2023-02-03 格式:DOCX 页数:15 大小:21.84KB
下载 相关 举报
jbpmsshdejutiyongfaWord文档格式.docx_第1页
第1页 / 共15页
jbpmsshdejutiyongfaWord文档格式.docx_第2页
第2页 / 共15页
jbpmsshdejutiyongfaWord文档格式.docx_第3页
第3页 / 共15页
jbpmsshdejutiyongfaWord文档格式.docx_第4页
第4页 / 共15页
jbpmsshdejutiyongfaWord文档格式.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

jbpmsshdejutiyongfaWord文档格式.docx

《jbpmsshdejutiyongfaWord文档格式.docx》由会员分享,可在线阅读,更多相关《jbpmsshdejutiyongfaWord文档格式.docx(15页珍藏版)》请在冰豆网上搜索。

jbpmsshdejutiyongfaWord文档格式.docx

false"

*/

publicclassArticleTypeAddSubActionextendsAction{

privatestaticfinalLoglog=LogFactory.getLog(MainAction.class);

/**

*JBPM服务接口实现对象

*/

privateJbpmConfigurationjbpmConfiguration;

//参见spring的配置文件applicationContext.xml

*文章类型服务接口实现对象

privateArticleTypeServicearticleTypeService;

*Methodexecute

*@parammapping

*@paramform

*@paramrequest

*@paramresponse

*@returnActionForward

publicActionForwardexecute(ActionMappingmapping,ActionFormform,

HttpServletRequestrequest,HttpServletResponseresponse){

log.debug("

MainAction.execute()"

);

UploadDeployFormtheForm=(UploadDeployForm)form;

FormFilefile=theForm.getFiles();

//取得上传的文件

//得到JBPM环境

JbpmContextjbpmContext=jbpmConfiguration.createJbpmContext();

try{

//解压zip文件流

ZipInputStreamzipInputStream=newZipInputStream(file

.getInputStream());

ProcessDefinitionprocessDefinition=ProcessDefinition

.parseParZipInputStream(zipInputStream);

//发布流程文件

jbpmContext.deployProcessDefinition(processDefinition);

jbpmContext.close();

zipInputStream.close();

//增加文章类型

ArticleTypearticleType=newArticleType();

articleType.setPdName(processDefinition.getName());

articleType.setTypeName(theForm.getTypeName());

articleTypeService.addArticleType(articleType);

}catch(IOExceptione){

log.error("

exception"

e);

}

request.setAttribute("

success"

"

发布成功"

returnmapping.findForward("

*得到JBPM服务接口实现对象

*@returnjbpmConfiguration

publicJbpmConfigurationgetJbpmConfiguration(){

returnjbpmConfiguration;

*设置JBPM服务接口实现对象

*@paramjbpmConfiguration

要设置的jbpmConfiguration

publicvoidsetJbpmConfiguration(JbpmConfigurationjbpmConfiguration){

this.jbpmConfiguration=jbpmConfiguration;

*得到文章类型服务接口实现对象

*@returnarticleTypeService

publicArticleTypeServicegetArticleTypeService(){

returnarticleTypeService;

*设置文章类型服务接口实现对象

*@paramarticleTypeService要设置的articleTypeService

publicvoidsetArticleTypeService(ArticleTypeServicearticleTypeService){

this.articleTypeService=articleTypeService;

执行到这步后,你可以去查看下数据库中表jbpm_processdifinition,你会发现表中多出里一条记录,并且名字就是你上传的压缩文件中processdifinition.xml中的name属性的值。

其他的表也会有相应的变化,具体看字段的定义就会大概明白了。

好了,流程已经发布到了系统中了。

当然你还可以增加其他的文章类型并且指定不同的流程定义。

我们退出系统,以guest用户登录系统,然后编写文章,这里需要说明的是,当你选择不同的文章类型后,该文章的审批过程就会与你刚才定义的执行流程相关了。

点击保存,

系统调用的ACTION为:

MyArticleAddSubAction.java

.........

importorg.jbpm.graph.exe.ProcessInstance;

importorg.jbpm.graph.exe.Token;

*撰写文章操作Action类

/myarticleaddsub"

publicclassMyArticleAddSubActionextendsAction{

privatestaticfinalLoglog=LogFactory.getLog(MyArticleAddSubAction.class);

*文章服务接口实现对象

privateArticleServicearticleService;

privateArticleTypeServicearticleTypeService;

privateJbpmConfigurationjbpmConfiguration;

MyArticleAction.execute()"

UserSessionuserSesssion=UserSession.getSession(request,response);

//得到文章信息

StringstypeNo=request.getParameter("

typeNo"

inttypeNo=ConvertUtil.convertInt(stypeNo);

StringarticleName=request.getParameter("

articleName"

Stringcontent=request.getParameter("

content"

Articlearticle=newArticle();

article.setArticleName(articleName);

article.setContent(content);

article.setState(Article.EDITED);

article.setTypeNo(newInteger(typeNo));

article.setUserNo(newInteger(userSesssion.getUserNo()));

//得到相应的文章类型

ArticleTypearticleType=articleTypeService.getArticleType(article.getTypeNo().intValue());

//得到相应的流程定义,启动流程实例

ProcessDefinitionprocessDefinition=jbpmContext.getGraphSession().findLatestProcessDefinition(articleType.getPdName());

ProcessInstanceprocessInstance=newProcessInstance(processDefinition);

//让流程往下进行一步

Tokentoken=processInstance.getRootToken();

token.signal();

//保存流程实例与状态

jbpmContext.save(processInstance);

jbpmContext.save(token);

jbpmContext.close();

article.setPiId(processInstance.getId());

//增加文章

articleService.addArticle(article);

returnmapping.findForward("

*得到文章服务接口实现对象

*@returnarticleService

publicArticleServicegetArticleService(){

returnarticleService;

*设置文章服务接口实现对象

*@paramarticleService要设置的articleService

publicvoidsetArticleService(ArticleServicearticleService){

this.articleService=articleService;

*@paramjbpmConfiguration要设置的jbpmConfiguration

执行该action后,则就创建了一个与之匹配的流程实例。

查看数据库中article表的变化。

可以发现

PiId记录了一个数字编号,同时jbpm_processinstance表中最大的一个id号与之匹配,这说明当保存文章时,系统后台创建了一个流程实例,该流程实例就是记录该文章的审批过程的JBPM实例。

(你可以运行一个文章的审批全过程来跟踪与之匹配的流程实例变化情况)。

下一步就是发布该文章了。

到你的文章列表中点击&

ldquo;

发布&

rdquo;

系统调用ACTION:

MyArticlePubAction.java继而转到MyArticlePubSubAction.java

.......

importorg.jbpm.graph.def.Transition;

*发布文章操作Action类

/myarticle"

publicclassMyArticlePubActionextendsAction{

privatestaticfinalLoglog=LogFactory.getLog(MyArticlePubAction.class);

//得到文章号

StringsarticleNo=request.getParameter("

articleNo"

intarticleNo=ConvertUtil.convertInt(sarticleNo);

Articlearticle=articleService.getArticle(articleNo);

article"

article);

//判断是否是此用户文章

if(article.getUserNo()!

=null&

&

article.getUserNo().intValue()==userSesssion.getUserNo()){

//创建相应的流程实例

//得到相应的文章类型

ArticleTypearticleType=articleTypeService.getArticleType(article.getTypeNo().intValue());

request.setAttribute("

articleType"

articleType);

//得到相应的流程

JbpmContextjbpmContext=jbpmConfiguration.createJbpmContext();

ProcessInstanceprocessInstance=jbpmContext.getProcessInstance(article.getPiId());

instance:

"

+processInstance.getId());

//得到当前的执行令牌

Tokentoken=processInstance.getRootToken();

//得到当前的可执行转换

//Settransitions=token.getNode().getArrivingTransitions();

Listtransitions=token.getNode().getLeavingTransitions();

Settransitionnames=newHashSet();

if(transitions!

=null){

for(inti=0;

i<

transitions.size();

i++){

Transitiontransition=(Transition)transitions.get(i);

System.err.println("

transition.getName()"

+transition.getName());

transitionnames.add(transition.getName());

}

transitionnames"

transitionnames);

}

publicArticleServicegetArticleService(){

publicvoidsetArticleService(ArticleServicearticleService){

publicJbpmConfigurationgetJbpmConfiguration(){

publicvoidsetJbpmConfiguration(JbpmConfigurationjbpmConfiguration){

publicArticleTypeServicegetArticleTypeService(){

publicvoidsetArticleTypeService(ArticleTypeServicearticleTypeService){

ok,到这里,你仍然可以去查看数据库中article表的变化情况。

你会发现表中的Auditstate字段

由null变成了一级审批,这是为什么,因为该文章对应的流程的下一个节点就是一级审批。

然后我们以one(一级审批)用户登录,就可以看到需要一级审批用户审批的

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1