欢迎进入www.kb88.com_凯时娱乐官网_凯时登录平台官网!

springboot集成flowable-modeler 实现免登__凤凰网
栏目导航
www.kb88.com_凯时娱乐官网_凯时登录平台
www.kb88.com
凯时娱乐官网
凯时登录平台
springboot集成flowable-modeler 实现免登__凤凰网
浏览:94 发布日期:2019-08-15

背景

因公司需求需要将flowable的流程设计器集成到项目中,下面将最近的研究成果记录一下。

步骤

这里用的是官网最新6.4.1(2019-3-14)

1. 下载flowable-modeler源码,把flowable-ui-modeler-appsrcmainesourcesstatic下面的代码拷贝至我们自己的工程。

2 . 添加相关maven包

3. 重写两个配置类

@Configuration

@EnableConfigurationProperties({FlowableModelerAppProperties.class})

@ComponentScan(basePackages = {

"org.flowable.ui.modeler.repository",

"org.flowable.ui.modeler.service",

"org.flowable.ui.common.service",

"org.flowable.ui.common.repository",

"org.flowable.ui.common.tenant"},

excludeFilters = {

@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, 乐橙agapp value = RemoteIdmService.class)

})

public class ApplicationConfiguration {

@Bean

public ServletRegistrationBean apiServlet(ApplicationContext applicationContext) {

AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();

dispatcherServletConfiguration.setParent(applicationContext);

dispatcherServletConfiguration.register(ApiDispatcherServletConfiguration.class);

DispatcherServlet servlet = new DispatcherServlet(dispatcherServletConfiguration);

ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, "/api/*");

registrationBean.setName("Flowable IDM App API Servlet");

registrationBean.setLoadOnStartup(1);

registrationBean.setAsyncSupported(true);

return registrationBean;

}

}

@Configuration

@ComponentScan(value = {"org.flowable.ui.modeler.rest.app"},

excludeFilters = {

@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,www.kb88.com value = EditorUsersResource.class),

@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = EditorGroupsResource.class),

})

@EnableAsync

public class AppDispatcherServletConfiguration implements WebMvcRegistrations {

private static final Logger LOGGER = LoggerFactory.getLogger(AppDispatcherServletConfiguration.class);

@Bean

public SessionLocaleResolver localeResolver() {

return new SessionLocaleResolver();

}

@Bean

public LocaleChangeInterceptor localeChangeInterceptor() {

LOGGER.debug("Configuring localeChangeInterceptor");

LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();

localeChangeInterceptor.setParamName("language");

return localeChangeInterceptor;

}

@Override

public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {

LOGGER.debug("Creating requestMappingHandlerMapping");

RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();

requestMappingHandlerMapping.setUseSuffixPatternMatch(false);

requestMappingHandlerMapping.setRemoveSemicolonContent(false);

Object[] interceptors = { localeChangeInterceptor() };

requestMappingHandlerMapping.setInterceptors(interceptors);

return requestMappingHandlerMapping;

}

}

4. Springboot启动类Import两个配置类,并排除springsecurity认证

5. flowable获取用户是调用idm服务,这里前端修改获取用户信息接口自己实现接口

@RestController

@RequestMapping("/demo")

public class DemoController {

@RequestMapping(value = "/rest/account", method = RequestMethod.GET, produces = "application/json")

public UserRepresentation getAccount() {

UserRepresentation userRepresentation = new UserRepresentation();

userRepresentation.setId("admin");

userRepresentation.setEmail("admin@flowable.org");

userRepresentation.setFullName("Test Administrator");

userRepresentation.setLastName("Administrator");

userRepresentation.setFirstName("Test");

List<String> privileges = new ArrayList<>();

privileges.add(DefaultPrivileges.ACCESS_MODELER);

privileges.add(DefaultPrivileges.ACCESS_IDM);

privileges.add(DefaultPrivileges.ACCESS_ADMIN);

privileges.add(DefaultPrivileges.ACCESS_TASK);

privileges.add(DefaultPrivileges.ACCESS_REST_API);

userRepresentation.setPrivileges(privileges);

return userRepresentation;

}

}

6. 添加流程时会用到用户id,这里重构SecurityUtils.getCurrentUserObject 获取用户信息

7. 指定 flowable的mapper文件的classpath路径

效果图

---------------------

,,