activiti - 将任务分配给组或用户

时间:2018-01-23 11:27:34

标签: groovy activiti bpmn alfresco-enterprise

根据他们在群组/人员选择器中选择的值,找出如何将一个简单的任务分配给一个人组件时,我遇到了一些麻烦。

因此,在我的界面中,用户可以使用相关的人/组选择器控件选择

picker controls

使用激活分配属性,我将受让人设置为${selectedPerson},将候选组设置为${selectedGroup}。这些变量与上面提到的选择器控件的值有关:

assignment

总体目标是用户能够将任务分配给个人或组,但上述设计存在以下问题:

  • 当用户选择一个组时,该任务会成功分配给一个组,可能是受理人的值可以为空。
  • 但是,当用户选择一个人而不是一个组时,Activiti会抛出以下异常,因为它需要一个组;
  

org.activiti.engine.ActivitiIllegalArgumentException:表达式确实如此   不解析为字符串或字符串集合

这样做的正确方法是什么?

完整Stacktrace

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.activiti.engine.ActivitiIllegalArgumentException: Expression did not resolve to a string or collection of strings
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:97)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:149)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:168)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    com.activiti.security.CustomStatelessCSRFFilter.doFilterInternal(CustomStatelessCSRFFilter.java:68)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)

2 个答案:

答案 0 :(得分:1)

这是因为Activiti接受Candidate Group的ID作为字符串或逗号分隔的字符串值。但是表单元素(如您所选)将所选组的组ID存储为Long,因此IllegalArgumentException。尝试在用户选择变量后将其存储为字符串,然后将此字符串作为候选组传递。

您使用的方法仅在${selectedPerson}${selectedGroup}都具有非空值时才会满足。

或者,您可以在要分配的任务上创建任务侦听器并执行逻辑。

类似的东西:

public class CustomTaskListener implements TaskListener {
    @Override
    public void notify(DelegateTask delegateTask) {
    // get required variables
        String selectedPerson = (String) delegateTask.getVariable("selectedPerson");
        String selectedGroup = (String) delegateTask.getVariable("selectedGroup");
    // check for the condition
        if (null != selectedPerson && !selectedPerson.isEmpty()) {
    // set values
            delegateTask.setAssignee(selectedPerson);
        } else {
            delegateTask.addCandidateGroup(selectedGroup);
        }
    }
}

答案 1 :(得分:0)

如果您想要将任务分配给用户或某个群组,您无法将两个受让人分别作为受让人和候选人群组

然后使用候选用户作为受让人,如果您的第一个条件需要为true然后将该用户添加到数组<,则接受用户数组将变量设置为数组/ strong> else 迭代组成员并将所有组成员添加到数组,并将此数组变量作为受让人传递给候选用户。< / p>