首页 > 代码库 > Liferay7 BPM门户开发之44: 集成Activiti展示流程列表

Liferay7 BPM门户开发之44: 集成Activiti展示流程列表

集成Activiti之前,必须搞清楚其中的依赖关系,才能在Gradle里进行配置.

依赖关系:

例如,其中activiti-engine依赖于activiti-bpmn-converter,而activiti-bpmn-converter又依赖于activiti-bpmn-model

那么这以下的引用都是要设置的,缺一不可,否则portlet会无法注入进OSGi容器

org.activiti:activiti-engine:jar:5.xx.0
+- org.activiti:activiti-bpmn-converter:jar:5.xx.0:compile
| \- org.activiti:activiti-bpmn-model:jar:5.xx.0:compile
| +- com.fasterxml.jackson.core:jackson-core:jar:2.2.3:compile
| \- com.fasterxml.jackson.core:jackson-databind:jar:2.2.3:compile
| \- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.3:compile
+- org.activiti:activiti-process-validation:jar:5.xx.0:compile
+- org.activiti:activiti-image-generator:jar:5.xx.0:compile
+- org.apache.commons:commons-email:jar:1.2:compile
| +- javax.mail:mail:jar:1.4.1:compile
| \- javax.activation:activation:jar:1.1:compile
+- org.apache.commons:commons-lang3:jar:3.3.2:compile
+- org.mybatis:mybatis:jar:3.2.5:compile
+- org.springframework:spring-beans:jar:4.0.6.RELEASE:compile
| \- org.springframework:spring-core:jar:4.0.6.RELEASE:compile
+- joda-time:joda-time:jar:2.6:compile
+- org.slf4j:slf4j-api:jar:1.7.6:compile
+- org.slf4j:jcl-over-slf4j:jar:1.7.6:compile

 

接下来,需要完成Gradle的设置,

全部:

dependencies {    compile com.liferay.portal:com.liferay.portal.kernel:2.0.0    compile com.liferay.portal:com.liferay.util.bridges:2.0.0    compile com.liferay.portal:com.liferay.util.taglib:2.0.0    compile com.liferay:com.liferay.application.list.api:1.0.0    compile javax.portlet:portlet-api:2.0    compile javax.servlet:javax.servlet-api:3.0.1    compile org.osgi:org.osgi.service.component.annotations:1.3.0    compile org.osgi:org.osgi.compendium:5.0.0            compile group: com.fasterxml.jackson.core, name: jackson-databind, version: 2.2.3    compile group: com.fasterxml.jackson.core, name: jackson-core, version: 2.2.3    compileOnly group: "jstl", name: "jstl", version: "1.2"        compile group: org.apache.commons, name: commons-lang3, version: 3.3.2    compile group: org.slf4j, name: slf4j-api, version: 1.7.6    compile group: org.slf4j, name: jcl-over-slf4j, version: 1.7.6    compile group: commons-logging, name: commons-logging, version: 1.2    compile group: org.joda, name: joda-convert, version: 1.2    compile group: joda-time, name: joda-time, version: 2.6    compile group: org.apache.commons, name: commons-email, version: 1.4        compile group: com.sun.mail, name: javax.mail, version: 1.5.2    compile group: javax.activation, name: activation, version: 1.1.1    compile group: org.mybatis, name: mybatis, version: 3.3.0    compile group: org.springframework, name: spring-core, version: 4.1.5.RELEASE    compile group: org.springframework, name: spring-beans, version: 4.1.5.RELEASE    compile org.springframework:spring-webmvc:4.1.5.RELEASE    compile org.springframework:spring-webmvc-portlet:4.1.5.RELEASE    compile group: org.activiti, name: activiti-bpmn-model, version: 5.21.0    compile group: org.activiti, name: activiti-bpmn-converter, version: 5.21.0    compile group: org.activiti, name: activiti-engine, version: 5.21.0        testCompile junit:junit:4.+    }

 

Portlet java:

ProcessListPortlet:

package com.lifiti.portlet;import java.io.IOException;import java.util.List;import javax.portlet.Portlet;import javax.portlet.PortletException;import javax.portlet.RenderRequest;import javax.portlet.RenderResponse;import org.activiti.engine.repository.ProcessDefinition;import org.osgi.service.component.annotations.Component;import com.liferay.portal.kernel.log.Log;import com.liferay.portal.kernel.log.LogFactoryUtil;import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;import com.liferay.portal.kernel.util.ParamUtil;@Component(immediate = true, property = { "com.liferay.portlet.display-category=category.sample",        "com.liferay.portlet.instanceable=true",         "javax.portlet.display-name=Process List",        "javax.portlet.init-param.template-path=/",         "javax.portlet.init-param.view-template=/process/processList.jsp",        "javax.portlet.resource-bundle=content.Language",        "javax.portlet.security-role-ref=power-user,user" },service = Portlet.class)public class ProcessListPortlet extends BpmBasePortlet {    @Override    public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException {                List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery().list();        request.setAttribute("processDefinitionList", processDefinitionList);         super.render(request, response);    }}

 

jsp页面

<%@ include file="/init.jsp" %><portlet:renderURL var="render">    <portlet:param name="mvcRenderCommandName" value="/porcess/bpmn" /></portlet:renderURL><table width="100%" class="table table-bordered table-hover table-condensed">        <thead>            <tr>                <th><liferay-ui:message key="ProcessDef"/></th>                <th><liferay-ui:message key="DeplyID"/></th>                <th><liferay-ui:message key="ProcessName"/></th>                <th><liferay-ui:message key="ProcessDefKey"/></th>                <th><liferay-ui:message key="Version"/></th>                <th>BPMN</th>                <th><liferay-ui:message key="ImageResource"/></th>                <th width="80"><liferay-ui:message key="Operation"/></th>                <th width="80"><liferay-ui:message key="Start"/></th>            </tr>        </thead>        <tbody>            <c:forEach items="${processDefinitionList }" var="pd">                <tr>                    <td>${pd.id }</td>                    <td>${pd.deploymentId }</td>                    <td>${pd.name }</td>                    <td>${pd.key }</td>                    <td>${pd.version }</td>                    <td></td>                    <td></td>                    <td><liferay-ui:message key="Delete"/></td>                    <td></td>                </tr>            </c:forEach>        </tbody></table>    

需要注意的是,还需要把jar文件放置在osgi的modules目录下,非常重要

技术分享

这样一个Portlet就开发出来了,感觉靠拖拽放在页面,再设置访问权限有些繁琐,我们还想把它直接放进控制面板里。

 

Liferay7 BPM门户开发之44: 集成Activiti展示流程列表