在jBpm中,如何获取流程/流程中发生的所有转换?

发布于 2024-08-01 19:09:18 字数 401 浏览 6 评论 0原文

jboss jBpm 是否可以获取一个进程执行期间发生的所有转换?


用例是:我们现在希望了解“用户”已经经历过的所有节点、任务节点、...以及他们进行了哪些转换

这显示了从当前活动令牌/节点到开始任务之前已完成的任务实例列表。

已经探索了一些不可行的想法

  • 获取活动令牌及其相应的节点,并通过到达的转换沿着转换向上移动。 这不起作用,因为可以传入多个转换,因此我们不知道已进行哪个转换。

也许我应该调查 JBPM_LOG 表,但我没有找到查询此表的正确方法(API)。 对任何在线文档的任何建议也将受到欢迎。

注意:我们使用的是jBpm版本:3.3.1

Is it possible in jboss jBpm to fetch all transitions that has been taken during one process execution?


The use case is: We would like to now all nodes, tasknodes, ... that 'users' has been through and which transition they took.

This to show a list of task instances that have been finished previously from the current active token/node till the start task.

Some not working ideas already explored:

  • Take the active tokens and their corresponding node and travel up the transitions through the arriving transitions. This does not work as multiple transitions can be incoming, so we do not know which transition has been taken.

Probably I should investigate the JBPM_LOG table, but I didn't found a proper way (API) to query this. Any suggestions to any online documentation would also be welcome.

Note: We are using jBpm version:3.3.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风情万种。 2024-08-08 19:09:18

是的,如果需要获取转换,则需要使用 jbpm_log 表。 要获取所有进行的节点,您只需要 jbpm_taskInstance 表。
我们使用 HQL 来获取所有用户的转换过程。 我有一个关于“了解给定任务实例选择的转换用户”的任务。 这不是做这样的事情的明显方法,但我无法发明更清晰的东西。 就我而言,这在应用程序中不是一个非常常见的操作,因此它以“最快编码”的方式实现。 显然,在您的情况下,对单个任务实例进行 3 个查询并不是一个好的选择。
我需要的唯一文档是: http://docs.jboss.org/jbpm/v3/ javadoc/ 有关 Jbpm 类和包以及鉴别器类列表的帮助:jbpm-jpdl.jar/org.jbpm.logging.log/ProcessLog.hbm.xml(有关于 jbpm 对象 - DB 表映射的描述)
这是该方法的代码。 CriteriaSQL 是我们的 CriteriaParams 包装器。
正如我所说,这不是最好的例子,但如果您需要的话,我还保存了 Oracle DB 的纯 sql 查询。

    private String getTaskTransition(LFTaskInstance instance) {     
        CriteriaSQL csql = new CriteriaSQL(new CriteriaParams());


        String query = "SELECT l " +
            " FROM org.jbpm.taskmgmt.log.TaskCreateLog l " +
            " WHERE l.taskInstance = " + instance.getId();      

        Query c =((HibernateSession)em).getHibernateSession().createQuery(csql.getQueryString(query));
        TaskCreateLog logEntry  = (TaskCreateLog) c.uniqueResult(); 
        int index = logEntry.getIndex();
        Long token = logEntry.getToken().getId();

        //Find bottom log index of transition which greater then log index of current instance creation
        String subQuery = "SELECT min(jbpmLog.index) " + 
                " FROM org.jbpm.graph.log.TransitionLog as jbpmLog " +
                " where jbpmLog.token = trLog.token AND " + //reference to query below
                        " jbpmLog.index > " + index; 

        //Find transition name from its Definition by log index of made transition
        query = " SELECT trans.name FROM org.jbpm.graph.def.Transition as trans " +
                " WHERE trans.id = " +
        " (SELECT min(transition.id) " +
        " FROM org.jbpm.graph.log.TransitionLog trLog " +
        " WHERE trLog.token = " + token + 
        "       and trLog.index = (" + subQuery + "))";

        c =((HibernateSession)em).getHibernateSession().createQuery(csql.getQueryString(query));
        return (String) c.uniqueResult();
    }

Yes, you need to use jbpm_log table if you need to get transitions. To get all proceeded nodes you only need jbpm_taskInstance table.
We use HQL to get all user's transition in process. I had a task about "to know wich transition user choosed for given taskInstance". It's not a obvious way to do such thing, but i cannot invent something more clear. In my case it's not a very common action in app so it's realized in "fastest-to-code-it" way. Obviously 3 queries for single task instance in your case is not a good choose.
The only docs i needed were: http://docs.jboss.org/jbpm/v3/javadoc/ for help on Jbpm classes and packages and discriminator's class list: jbpm-jpdl.jar/org.jbpm.logging.log/ProcessLog.hbm.xml (has desciption about jbpm objects - DB table mapping)
This is the method's code. CriteriaSQL is our CriteriaParams wrapper.
As i said it isn't best example but I also have saved plain sql queries for oracle DB if you needs it.

    private String getTaskTransition(LFTaskInstance instance) {     
        CriteriaSQL csql = new CriteriaSQL(new CriteriaParams());


        String query = "SELECT l " +
            " FROM org.jbpm.taskmgmt.log.TaskCreateLog l " +
            " WHERE l.taskInstance = " + instance.getId();      

        Query c =((HibernateSession)em).getHibernateSession().createQuery(csql.getQueryString(query));
        TaskCreateLog logEntry  = (TaskCreateLog) c.uniqueResult(); 
        int index = logEntry.getIndex();
        Long token = logEntry.getToken().getId();

        //Find bottom log index of transition which greater then log index of current instance creation
        String subQuery = "SELECT min(jbpmLog.index) " + 
                " FROM org.jbpm.graph.log.TransitionLog as jbpmLog " +
                " where jbpmLog.token = trLog.token AND " + //reference to query below
                        " jbpmLog.index > " + index; 

        //Find transition name from its Definition by log index of made transition
        query = " SELECT trans.name FROM org.jbpm.graph.def.Transition as trans " +
                " WHERE trans.id = " +
        " (SELECT min(transition.id) " +
        " FROM org.jbpm.graph.log.TransitionLog trLog " +
        " WHERE trLog.token = " + token + 
        "       and trLog.index = (" + subQuery + "))";

        c =((HibernateSession)em).getHibernateSession().createQuery(csql.getQueryString(query));
        return (String) c.uniqueResult();
    }
佞臣 2024-08-08 19:09:18

我们像这样使用 sql select(必须在文件 jbpm.cfg.xml 中启用登录表 JBPM_LOG):

select distinct *
  from (select level,
               l.date_,
               pd1.name_ p1,
               n1.name_ n1,
               pd2.name_ p2,
               n2.name_ n2
          from juser.jbpm_log               l,
               juser.jbpm_node              n1,
               juser.jbpm_node              n2,
               juser.jbpm_processdefinition pd1,
               juser.jbpm_processdefinition pd2,
               juser.jbpm_token             t,
               juser.jbpm_processinstance   pi,
               juser.jbpm_token             t2
         where l.class_ = 'T'
           and n1.id_ = l.sourcenode_
           and n2.id_ = l.destinationnode_
           and n1.processdefinition_ = pd1.id_
           and n2.processdefinition_ = pd2.id_
           and t.id_ = l.token_
           and t.processinstance_ = pi.id_
           and pi.superprocesstoken_ = t2.id_
        connect by prior pi.id_ = t2.processinstance_
         start with pi.id_ =
                    (select id_
                       from (select pi.id_
                               from juser.jbpm_processinstance pi,
                                    juser.jbpm_token           t
                              where pi.superprocesstoken_ = t.id_
                             connect by prior t.processinstance_ = pi.id_
                              start with pi.id_ = <<<ID_OF_PROCESSINSTANCE>>>
                              order by pi.id_)
                      where rownum = 1)
         order by l.date_)
 order by date_;

这使用事先连接 - 我不知道这是否适用于除 oracle 之外的其他任何东西。

We use sql select like this (logging into table JBPM_LOG must be enabled in file jbpm.cfg.xml):

select distinct *
  from (select level,
               l.date_,
               pd1.name_ p1,
               n1.name_ n1,
               pd2.name_ p2,
               n2.name_ n2
          from juser.jbpm_log               l,
               juser.jbpm_node              n1,
               juser.jbpm_node              n2,
               juser.jbpm_processdefinition pd1,
               juser.jbpm_processdefinition pd2,
               juser.jbpm_token             t,
               juser.jbpm_processinstance   pi,
               juser.jbpm_token             t2
         where l.class_ = 'T'
           and n1.id_ = l.sourcenode_
           and n2.id_ = l.destinationnode_
           and n1.processdefinition_ = pd1.id_
           and n2.processdefinition_ = pd2.id_
           and t.id_ = l.token_
           and t.processinstance_ = pi.id_
           and pi.superprocesstoken_ = t2.id_
        connect by prior pi.id_ = t2.processinstance_
         start with pi.id_ =
                    (select id_
                       from (select pi.id_
                               from juser.jbpm_processinstance pi,
                                    juser.jbpm_token           t
                              where pi.superprocesstoken_ = t.id_
                             connect by prior t.processinstance_ = pi.id_
                              start with pi.id_ = <<<ID_OF_PROCESSINSTANCE>>>
                              order by pi.id_)
                      where rownum = 1)
         order by l.date_)
 order by date_;

This uses connect by prior - I don't know if this work on anything other than oracle.

又怨 2024-08-08 19:09:18

这是针对已经完成或部分处理的流程吗? 如果没有,那么您可以在每个退出转换上放置一个操作处理程序,通过在当前标记中查找来记录转换的名称。

Is this for Processes that have already been completed or partially processed? If not, then you could put an action handler on every exit transition that records the name of the transition by looking for it in the current token.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文