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

    Details

    • Type: Bug
    • Status: Verified (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 6.x.x
    • Fix Version/s: 7.0.0.GA
    • Component/s: jBPM Core
    • Labels:
      None
    • Target Release:
    • Fix Build:
      ER3
    • Sprint:
      2017 Week 36-37

      Description

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  swiderski.maciej Maciej Swiderski
                  Reporter:
                  anton.giertli Anton Giertli
                  Tester:
                  Daniel Cihak
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: