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就开发出来了,感觉靠拖拽放在页面,再设置访问权限有些繁琐,我们还想把它直接放进控制面板里。

时间: 2024-10-10 18:51:38

Liferay7 BPM门户开发之44: 集成Activiti展示流程列表的相关文章

Liferay7 BPM门户开发之37: Liferay7下的OSGi Hook集成开发

hook开发是Liferay客制扩展的一种方式,比插件灵活,即可以扩展liferay门户,也能对原有特性进行更改,Liferay有许多内置的服务,比如用hook甚至可以覆盖Liferay服务. 可作为系统服务挂钩(Liferay Service Hook),还有其他类型的hook... Liferay6.2 时的hook开发比较有限,而在Liferay7则大为不同,OSGi services的彻底改进至Liferay的底层模型框架,使得Liferay可以支持更多的定制扩展!OSGi plugin

Liferay7 BPM门户开发之17: Portlet 生命周期

Portlet 生命周期 init() =〉 render() =〉 processAction() =〉 processEvent() =〉 serveResource() =〉destroy() init() 在Liferay容器部署portlet时,启动portlet实例化 init有两个写法: public void init() throws PortletException public void init(PortletConfig config) throws PortletEx

Liferay7 BPM门户开发之8: Activiti实用问题集合

1.如何实现审核的上级获取(任务逐级审批) 这个是必备功能,通过Spring的注入+Activiti表达式可以很容易解决. 可参考: http://blog.csdn.net/sunxing007/article/details/8491552 http://linhongyu.blog.51cto.com/6373370/1656596 2.如何设置流程发起人,并动态在其他任务中使用 通过变量,在启动的时候设置. activiti里设置流程发起人的功能很绕. activiti 指定发起人,并作

Liferay7 BPM门户开发之2: BPMN 2.0 开发入门 (Activiti BPMN extensions)

本文参考地址:http://activiti.org/userguide/index.html#bpmnConstructs BPMN 2.0中的重要概念: Events 事件 Sequence Flow 顺序流 Gateways 网关 Tasks 任务 Sub-Processes and Call Activities 子流程 Transactions and Concurrency 事务并发 Process Initiation Authorization 初始化认证 Data object

Liferay7 BPM门户开发之6: Activiti数据库换为mysql

第一步: 在mysql中创建数据库名字叫 'activiti' 执行D:\activiti-5.21.0\database\create下的脚本 第二步: 打开=> apache-tomcat/webapps/activiti-explorer/WEB-INF/classes/ db.properties 修改配置文件 db.properties db=activiti jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localho

Liferay7 BPM门户开发之4: Activiti事件处理和监听Event handlers

事件机制从Activiti 5.15开始引入,这非常棒,他可以让你实现委托. 可以通过配置添加事件监听器,也可以通过Runtime API加入注册事件. 所有的事件参数子类型都来自org.activiti.engine.delegate.event.ActivitiEvent 包含的信息: type executionId processInstanceId processDefinitionId 事件监听 其中,JOB_EXECUTION_SUCCESS 和JOB_EXECUTION_FAIL

Liferay7 BPM门户开发之3: Activiti开发环境搭建

下载地址: http://activiti.org/download.html 源码: https://github.com/Activiti/Activiti 环境准备(检查项): JDK 1.7 + JAVA_HOME :java -version 下载 Eclipse Indigo + 拷贝activiti-explorer.war 到 Tomcat/webapps目录 运行Tomcat/bin目录startup.bat or startup.sh 不修改Tomcat http端口情况下访

Liferay7 BPM门户开发之35: AssetTag的集成查询

Tag是liferay中的Asset特性,可以用来对信息进行分类,在iferay中的Asset类型为: 1. Web Content(自定义内容) 2. Documents and Media(文档库和媒体文件) 3. Blogs (博客文章) 4. Message Boards 5. Wiki Page 6. Bookmarks 可以根据tagName来对信息进行归类统计,演示代码: //查询Tag的数量(符合tagName=‘news’) ThemeDisplay themeDisplay

Liferay7 BPM门户开发之32: 实现自定义认证登陆(定制Authentication Hook)

优秀的平台必然松耦合.易扩展  -- 王昕 第一步:修改liferay-hook.xml <?xml version="1.0"?> <!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd"> <hook> <portal-properties>