1 Reply Latest reply on Nov 23, 2016 11:42 AM by chadiem

    Identifying one of several Send tasks of a business process in a Work Item handler

    chadiem Newbie

      Hello,

       

      I'm currently using jBPM 6.4.0.Final and would like to know if there is a way to identify one of several Send tasks of a business process in a work item handler.

       

      I found another thread that asks the same question, but with an answer only from the asker.

       

      My attempt was to use

       ((WorkItemImpl) workItem).getNodeId()
      

      to uniquely identify the send task in question.

       

      It seems to work, but I am not sure if this is the way to go, or if this id is really unique after all.

      It also makes it harder for code readability to base my conditions on a numeric that I am unaware where it came from, and would prefer if it was a string or an identifier that I can control.

       

      Thanks!

        • 1. Re: Identifying one of several Send tasks of a business process in a Work Item handler
          chadiem Newbie
              
          ProcessInstance processInstance = kieSession.getProcessInstance(workItem.getProcessInstanceId());
              
          RuleFlowProcessInstance ruleFlowProcessInstance = (RuleFlowProcessInstance) processInstance;
              
          Collection<NodeInstance> processNodeInstances = ruleFlowProcessInstance.getNodeInstances();
          
          
              
          for (NodeInstance nodeInstance : processNodeInstances) {
                  
          if (nodeInstance.getNodeId() == ((WorkItemImpl) workItem).getNodeId()) {
                      
          return ruleFlowProcessInstance.getRuleFlowProcess().getNode(nodeInstance.getNodeId()).getName();
                  
          }
              
          }
              
          return null;
          
          
          
          

           

          This should do it.