Uploaded image for project: 'Red Hat Process Automation Manager'
  1. Red Hat Process Automation Manager
  2. RHPAM-107

'getProcessInstancesByVariableNameAndValue' does not work with multiple process variables

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.0.GA
    • 6.x.x
    • jBPM Core
    • None
    • ER3
    • 2017 Week 36-37

      This endpoint:

      /kie-server/services/rest/server/queries/processes/instances/variables/<VAR_NAME>?varValue=<VAR_VALUE>
      

      Is using this named sql query - getProcessInstancesByVariableNameAndValue -
      https://github.com/kiegroup/jbpm/blob/6.5.x/jbpm-services/jbpm-kie-services/src/main/resources/META-INF/Servicesorm.xml#L349

      Due to the specific usage of 'max' aggregate function it functions only when one process variable is present in the given process instance.

      Imagine following content of VariableInstanceLog table:

      52	2017-08-01 10:15:50.589	MultiVars		MultiVars.MultiVars	33	value1	var1	var1
      53	2017-08-01 10:15:50.59	MultiVars		MultiVars.MultiVars	33	value2	var2	var2
      

      If you call this:

      localhost:8280/kie-server/services/rest/server/queries/processes/instances/variables/var1?varValue=value1
      
      

      It will return empty response, because the SQL query which has run behind the scene filtered variable with id '52' and only included id '53', so it's possible to successfully query var2 and not var1.

      I managed to workaround this issue by replacing Servicesorm.xml file like this:

      diff Servicesorm-old.xml Servicesorm-new.xml
      349c349
      <       and vlog.id in (select max(vlog2.id) from VariableInstanceLog vlog2 group by vlog2.processInstanceId))
      ---
      >       and vlog.id in (select max(vlog2.id) from VariableInstanceLog vlog2 where vlog2.value like :variableValue and vlog2.variableId=:variable group by vlog2.processInstanceId))
      

      Not submitting PR since there may be more effective way to fix this.

            swiderski.maciej Maciej Swiderski (Inactive)
            rhn-support-agiertli Anton Giertli
            Daniel Cihak Daniel Cihak
            Daniel Cihak Daniel Cihak
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: