AnsweredAssumed Answered

Read private dataInputAssociations from CallActivityBehaviour

Question asked by artur on Jun 18, 2013
Latest reply on Jun 19, 2013 by jbarrez

Have experience to share.
My issue was to read data input asscoiations on call activity from deployed process definition.
For now Activity API dosen't allow to access such info directly. There is a way to do that using reflection.
Code below shows how to use reflection to access data input associations.

//is it call activity task?
                       if ("callActivity".equals(activiti.getProperty("type"))) {
                        CallActivityBehavior callactivityBehavior = (CallActivityBehavior) activiti.getActivityBehavior();
// if calling 'SendSignal' process
      if (!"SendSignal".equals(callactivityBehavior.getProcessDefinitonKey())) {
          try {
//use reflection to read private field dataInputAssociations
         privDataInputAssociationsField = CallActivityBehavior.class.getDeclaredField("dataInputAssociations");
         dataInputAssociations = (List<AbstractDataAssociation>) privDataInputAssociationsField.get(callactivityBehavior);

         for (AbstractDataAssociation data : dataInputAssociations) {
// is it 'taskId' input parameter?
             if ("taskId".equals(data.getTarget())) {
                HashMap<String, Object> values = new HashMap();
// remember idTask and its value
                values.put("IDTask", idTask);
                values.put("IDPreviousTask", data.getSourceExpression().getExpressionText());

Remember it works according local JVM security settings.
Hope is usefull for someone who faceses same problem.

Best regards,