Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-3813

Process Instance Diagram in jBPM Console shows wrong multiple markers due to the ordering of JPAProcessInstanceDbLog.findNodeInstances()

XMLWordPrintable

      A customer reports that they see wrong multiple markers for Process Instance Diagram in jBPM Console. (See attached testprocess.png)

      The result of JPAProcessInstanceDbLog.findNodeInstances() are ordered by the date of NodeInstanceLog:

          public static List<NodeInstanceLog> findNodeInstances(long processInstanceId) {
              EntityManager em = getEntityManager();
              UserTransaction ut = joinTransaction(em);
              List<NodeInstanceLog> result = getEntityManager()
                  .createQuery("FROM NodeInstanceLog n WHERE n.processInstanceId = :processInstanceId ORDER BY date")
                      .setParameter("processInstanceId", processInstanceId).getResultList();
              closeEntityManager(em, ut);
              return result;
          }
      

      And GraphViewerPluginImpl.getActiveNodeInfo() assumes that an ENTER log should comes before an EXIT log.

      	public List<ActiveNodeInfo> getActiveNodeInfo(String instanceId) {
      		ProcessInstanceLog processInstance = JPAProcessInstanceDbLog.findProcessInstance(new Long(instanceId));
      		if (processInstance == null) {
      			throw new IllegalArgumentException("Could not find process instance " + instanceId);
      		} 
      		Map<String, NodeInstanceLog> nodeInstances = new HashMap<String, NodeInstanceLog>();
      		for (NodeInstanceLog nodeInstance: JPAProcessInstanceDbLog.findNodeInstances(new Long(instanceId))) {
      			if (nodeInstance.getType() == NodeInstanceLog.TYPE_ENTER) {
      				nodeInstances.put(nodeInstance.getNodeInstanceId(), nodeInstance);
      			} else {
      				nodeInstances.remove(nodeInstance.getNodeInstanceId());
      			}
      		}
      

      But usual database timestamp has only millisecond precision (NOTE: MySQL has only second precision!) so you may get the same value for ENTER and EXIT logs. It results in the Diagram appearance.

      Example from customer's Oracle 11.2

      SQL> select LOG_DATE from NODEINSTANCELOG;
      
      LOG_DATE
      ---------------------------------------------------------------------------
      12-09-29 16:48:06.870000
      12-09-29 16:48:06.870000
      12-09-29 16:48:06.870000
      12-09-29 16:48:06.870000
      12-09-29 16:48:06.886000
      12-09-29 16:48:06.886000
      12-09-29 16:48:06.886000
      12-09-29 16:48:06.886000
      12-09-29 16:48:06.886000
      

              swiderski.maciej Maciej Swiderski (Inactive)
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: