1 2 Previous Next 20 Replies Latest reply on Mar 4, 2013 5:41 AM by obon Go to original post
      • 15. Re: JBPM 5.4.0-Final: Human Task variable mapping is not working
        swiderski.maciej

        Alright the problem seems to be in declaration of variables. As 5.4 is now aware of data types you need to specify correct data types. for instance you have variable:

             <variable name="isApproved" >

                <type name="org.drools.process.core.datatype.impl.type.ObjectDataType" className="java.lang.String" />

              </variable>

         

        but as you can see data type (name attribute) refers to ObjectDataType and that's why xstream comes into play. if you define correct data type:

         

             <variable name="isApproved" >

                <type name="org.drools.process.core.datatype.impl.type.StringDataType" />

              </variable>

        it should work properly. Same should be done for boolean, integer and float data types.

         

        When using droolsjbpm eclipse plugin to edit variables it should be enough to select String as type from dropdown.

         

        HTH

        1 of 1 people found this helpful
        • 16. Re: JBPM 5.4.0-Final: Human Task variable mapping is not working
          vchmakov

          OK, I see… Thanks you your help!

           

          Vladimir

           

          • 17. Re: JBPM 5.4.0-Final: Human Task variable mapping is not working
            maq99

            Hallo,

            I have simmilar problem and decide to add my post to this topic instead create new one. Something wrong is with saveing variables. I already spend some time on it and have not found sollution. All base on seam framework (web app) + EJB3 as jbpm managment layer. Persistence is made on Postgres.

             

            What I wont to achieve is to add serializable object as Human task result variable which should be maped to process variables and persisted. Then it should be available as process parameter to next human task.

             

            Here is my diagram:

            Diagram.gif

            .....

            Have not get suport - created new topic https://community.jboss.org/thread/220416

            • 18. Re: JBPM 5.4.0-Final: Human Task variable mapping is not working

              Hi Vladimir,

               

              would it be possible to publish the source code of your LocalHTWorkItemHandler extention?

               

              I am having the same problem, I have implemented the workaround, but the task status still not get tested as "completed" .

               

               

              Here is my class:

               

               

              import java.util.HashMap;

              import java.util.Map;

               

              import javax.persistence.EntityManagerFactory;

               

              import org.drools.SystemEventListenerFactory;

              import org.drools.runtime.KnowledgeRuntime;

              import org.drools.runtime.StatefulKnowledgeSession;

              import org.jbpm.eventmessaging.EventResponseHandler;

              import org.jbpm.eventmessaging.Payload;

              import org.jbpm.process.workitem.wsht.LocalHTWorkItemHandler;

              import org.jbpm.task.Content;

              import org.jbpm.task.Status;

              import org.jbpm.task.Task;

              import org.jbpm.task.event.TaskEventKey;

              import org.jbpm.task.event.entity.TaskCompletedEvent;

              import org.jbpm.task.event.entity.TaskEvent;

              import org.jbpm.task.event.entity.TaskFailedEvent;

              import org.jbpm.task.event.entity.TaskSkippedEvent;

              import org.jbpm.task.service.TaskService;

              import org.jbpm.task.service.local.LocalTaskService;

              import org.jbpm.task.service.responsehandlers.AbstractBaseResponseHandler;

              import org.jbpm.task.utils.ContentMarshallerHelper;

               

              public class MyLocalHTWorkItemHandler extends LocalHTWorkItemHandler {

               

                  private EntityManagerFactory emf;

               

                  public MyLocalHTWorkItemHandler(KnowledgeRuntime session) {

                      super(session);

                  }

               

                  public MyLocalHTWorkItemHandler(LocalTaskService localTaskService,

                          StatefulKnowledgeSession ksession) {

                      super(localTaskService, ksession);

                  }

               

                  public MyLocalHTWorkItemHandler(LocalTaskService localTaskService,

                          StatefulKnowledgeSession ksession, EntityManagerFactory emf) {

                      super(localTaskService, ksession);

                      this.emf = emf;

                  }

               

                  @Override

                  protected void registerTaskEvents() {

                      TaskCompletedHandler eventResponseHandler = new TaskCompletedHandler();

                      TaskEventKey key = new TaskEventKey(TaskCompletedEvent.class, -1);

                      getClient().registerForEvent(key, false, eventResponseHandler);

                      eventHandlers.put(key, eventResponseHandler);

                      key = new TaskEventKey(TaskFailedEvent.class, -1);

                      getClient().registerForEvent(key, false, eventResponseHandler);

                      eventHandlers.put(key, eventResponseHandler);

                      key = new TaskEventKey(TaskSkippedEvent.class, -1);

                      getClient().registerForEvent(key, false, eventResponseHandler);

                      eventHandlers.put(key, eventResponseHandler);

                  }

                 

                  private class TaskCompletedHandler extends AbstractBaseResponseHandler implements EventResponseHandler {

               

                      public void execute(Payload payload) {

                          TaskEvent event = (TaskEvent) payload.get();

                          final long taskId = event.getTaskId();

                         

                          if (isOwningSessionOnly() && (session instanceof StatefulKnowledgeSession)) {

                              if (((StatefulKnowledgeSession) session).getId() != event.getSessionId()) {

                                  return;

                              }

                          }

                         

                          TaskService taskService = new org.jbpm.task.service.TaskService(

                                  emf, SystemEventListenerFactory.getSystemEventListener());

                         

                          handleCompletedTask(taskId, new LocalTaskService(taskService));

                      }

               

                      public boolean isRemove() {

                          return false;

                      }

               

                      public void handleCompletedTask(long taskId, LocalTaskService localTaskService) {

                          Task task = localTaskService.getTask(taskId);

                          long workItemId = task.getTaskData().getWorkItemId();

                          if (task.getTaskData().getStatus() == Status.Completed) {

                              String userId = task.getTaskData().getActualOwner().getId();

                              Map<String, Object> results = new HashMap<String, Object>();

                              results.put("ActorId", userId);

                              long contentId = task.getTaskData().getOutputContentId();

                              if (contentId != -1) {

                                  Content content = localTaskService.getContent(contentId);

                                  Object result = ContentMarshallerHelper.unmarshall( content.getContent(),

                                          session.getEnvironment(), getClassLoader());

                                  results.put("Result", result);

                                  if (result instanceof Map) {

                                      Map<?, ?> map = (Map<?, ?>) result;

                                      for (Map.Entry<?, ?> entry : map.entrySet()) {

                                          if (entry.getKey() instanceof String) {

                                              results.put((String) entry.getKey(), entry.getValue());

                                          }

                                      }

                                  }

               

                                  session.getWorkItemManager().completeWorkItem(task.getTaskData().getWorkItemId(), results);

                              } else {

                                  session.getWorkItemManager().completeWorkItem(workItemId, results);

                              }

                          } else {

                              session.getWorkItemManager().abortWorkItem(workItemId);

                          }

                      }

                  }

                 

              }

              • 19. Re: JBPM 5.4.0-Final: Human Task variable mapping is not working
                vchmakov

                Hi Oleg,

                 

                Well, unfortunately I do not have one. I use the standard one LocalHTWorkItemHandler  and do setClient(). I’m trying to utilize the container-scoped transactions, so to achieve that I’m implementing TaskTransactionManager and TaskSessionFactory interfaces.  Although, now I’m not so sure that the approach is 100% valid…

                 

                Thanks,

                 

                Vladimir

                • 20. Re: JBPM 5.4.0-Final: Human Task variable mapping is not working

                  ok, I got it to work, one should not wrap the complete method in a new transaction.

                   

                  thanks, anyway.

                  1 2 Previous Next