使用Maven集成Activiti Modeler [英] Integrate Activiti Modeler using Maven

查看:174
本文介绍了使用Maven集成Activiti Modeler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Activiti Modeler集成到自己的Web应用程序中并保持Maven建议的所有优势?

How one can integrate Activiti Modeler into their own web application and keep all the advantages Maven suggests?

该问题是Maven中的Activiti Modeler是Activiti Explorer的一部分.那些想开发自己的Web应用程序,使用Modeler编辑流程但不需要其他Explorer功能的人在线上有几个问题.

The probem is that Activiti Modeler in Maven is part of Activiti Explorer. There are several questions online from people who want to develop their own web applications, use Modeler to edit the processes, but don't need other Explorer features.

例如,没有activiti-explorer的Activiti BPM 推荐答案

我已经设法使用Maven覆盖功能来做到这一点:

I have managed to do this using Maven overlay feature:

1)包括Explorer Web应用程序的叠加层,但仅包括Modeler文件:

1) include overlay of Explorer web app, but include only the Modeler files:

pom.xml:

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-webapp-explorer2</artifactId>
        <version>${activiti-version}</version>
        <type>war</type>
        <scope>compile</scope>
    </dependency>
....
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <overlays>
                    <overlay>
                        <groupId>org.activiti</groupId>
                        <artifactId>activiti-webapp-explorer2</artifactId>
                        <includes>
                            <include>WEB-INF/classes/stencilset.json</include>   
                            <include>editor-app/**</include>   
                            <include>modeler.html</include>   
                        </includes>
                    </overlay>
                </overlays>
            </configuration>
        </plugin>

2)添加Modeler Spring资源.它们用于检索和保存模型(注意:不是过程定义,这有点不同),还用于模具集:

2) add modeler Spring resources. They are used to retrieve and to save models (note: not process definitions, it's kinda different thing) and also to serve the stencilset:

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-modeler</artifactId>
        <version>${activiti-version}</version>
    </dependency>

3)就是这样,但是除非它被称为"activiti-explorer",否则它实际上不会在您的应用程序中工作.在您的项目中添加一个名为"editor-app/app-cfg.js"的文件,并在其中添加以下内容:

3) that would be it but it won't actually work in your application unless it is called "activiti-explorer". Add a file to your project called "editor-app/app-cfg.js", and add the following content there:

editor-app/app-cfg.js:

editor-app/app-cfg.js:

'use strict';
var ACTIVITI = ACTIVITI || {};
ACTIVITI.CONFIG = {
        'contextRoot' : window.location.pathname.substring(0,window.location.pathname.lastIndexOf('/')),
};

这实际上是本机app-cfg的副本,其中包含用于上下文根的奇怪的"/activiti-explorer/service"设置.我们将其更改为更通用的设置.它将用于从存储库中检索模型.我们的文件将覆盖资源管理器webapp附带的文件.

This is actually a copy of the native app-cfg, which contains the strange "/activiti-explorer/service" setting for context root. We change it to more generic setting. It will be used to retrieve models from the repository. Our file will overlay the one that ships with explorer webapp.

注意:

a)您必须自己管理流程定义到模型的转换.有关想法,请参阅

a) you have to manage conversion of process definitions to models by yourselves. For an idea, see https://github.com/Activiti/Activiti/blob/activiti-5.19.0.1/modules/activiti-explorer/src/main/java/org/activiti/editor/ui/ConvertProcessDefinitionPopupWindow.java

b)我必须避免对所有内容都使用一个Jackson Object Mapper,但我还没有研究为什么这种方法不起作用:

b) I had to avoid using one Jackson Object Mapper for everything, I haven't research why this didn't work:

<bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper">
</bean>    
<mvc:annotation-driven>
    <!-- using the same objectMapper leads to stencilset resource being served as string -->
    <mvc:message-converters register-defaults="true">
        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="objectMapper" ref="objectMapper"/>
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>

不要做或做更多的研究,因为这实际上破坏了为活动建模者"提供服务的模板库.它开始将模板集作为格式错误的字符串而不是普通的json服务.

Don't do this or research more, as this actually breaks the stencilcet resurce serving part of the "activiti-modeler". It starts serving stencilset as a malformed string instead normal json.

c)我不知道如何在Modeler保存功能中注入CSRF安全标头,因此我将其关闭-如果您不使用Spring Security,则将其丢弃

c) I had no idea how to inject CSRF security headers in the Modeler saving function, so I switched it off - if you don't use Spring Security, discard this

这篇关于使用Maven集成Activiti Modeler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆