0 Replies Latest reply on May 16, 2016 4:34 AM by imphilippesimo

    Retrieving jBPM user's Human Tasks

    imphilippesimo

      Hi everyone,

      i'm just starting with jbpm workflows. i'm using jBPM 6.4.0.Final

      I'm trying to set an example to test some flowchart i've been contructing with eclipse jBPMN2 modeler.

       

      In that flowchart, i have a user task to which i have associated the actorId "admin" via the properties tab. the file containing my flowchart is named "BonDeCommande.bpmn"

      Next to execute that, i have the following java code snippet:

       

             // create the entity manager factory and register it in the environment

              EntityManagerFactory emf =  Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");

              Environment env = KnowledgeBaseFactory.newEnvironment();

              env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

       

              // configure the environment that will be used by RuntimeManager

              RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory

                      .get()

                      .newDefaultInMemoryBuilder()

                      .addAsset(

                              ResourceFactory

                                      .newClassPathResource("BonDeCommande.bpmn"),

                              ResourceType.BPMN2).entityManagerFactory(emf).get();

       

              // Creating RuntimeManager

              RuntimeManager manager = RuntimeManagerFactory.Factory.get()

                      .newSingletonRuntimeManager(environment);

       

              // getting RuntimeEngine out of manager

              RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());

       

              // get KieSession from runtimeEngine

              KieSession ksession = runtime.getKieSession();

           

              TaskService taskService = runtime.getTaskService();

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

              ProcessInstance processInstance = ksession.startProcess(

                      "com.sample.bpmn.bonDeCommande", params);

           

              String actorId = "admin";

            

               // this line returns no results!!! so i get an ArrayOutOfBoundException for the line after.

              List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner (actorId, "en-UK");

       

                  TaskSummary task = list.get(0);    //<---- here: ArrayOutOfBoundException index:0 size: 0

                  taskService.claim(task.getId(), actorId);

                  taskService.start(task.getId(), actorId);

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

                  // add results here

                  taskService.complete(task.getId(), actorId, results);

       

       

      Knowing i have the persistence unit "org.jbpm.persistence.jpa" defined  this way in my persistence.xml

       

       

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <persistence version="2.0"

       

          xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd

       

            http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"

       

          xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"

       

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

       

       

       

          <persistence-unit name="org.jbpm.persistence.jpa"   transaction-type="JTA">

       

              <provider>org.hibernate.ejb.HibernatePersistence</provider>

       

              <jta-data-source>jdbc/koosserydesk-jbpm-ds</jta-data-source>

       

              <mapping-file>META-INF/Taskorm.xml</mapping-file>

              <mapping-file>META-INF/JBPMorm.xml</mapping-file>

              <mapping-file>META-INF/TaskAuditorm.xml</mapping-file>

       

       

              <class>org.drools.persistence.info.SessionInfo</class>

              <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>

              <class>org.drools.persistence.info.WorkItemInfo</class>

              <class>org.jbpm.persistence.correlation.CorrelationKeyInfo</class>

              <class>org.jbpm.persistence.correlation.CorrelationPropertyInfo</class>

       

       

       

              <class>org.jbpm.process.audit.ProcessInstanceLog</class>

              <class>org.jbpm.process.audit.NodeInstanceLog</class>

              <class>org.jbpm.process.audit.VariableInstanceLog</class>

       

              <!-- manager -->

              <class>org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo</class>

       

              <class>org.jbpm.services.task.impl.model.AttachmentImpl</class>

              <class>org.jbpm.services.task.impl.model.ContentImpl</class>

              <class>org.jbpm.services.task.impl.model.BooleanExpressionImpl</class>

              <class>org.jbpm.services.task.impl.model.CommentImpl</class>

              <class>org.jbpm.services.task.impl.model.DeadlineImpl</class>

              <class>org.jbpm.services.task.impl.model.CommentImpl</class>

              <class>org.jbpm.services.task.impl.model.DeadlineImpl</class>

              <class>org.jbpm.services.task.impl.model.DelegationImpl</class>

              <class>org.jbpm.services.task.impl.model.EscalationImpl</class>

              <class>org.jbpm.services.task.impl.model.GroupImpl</class>

              <class>org.jbpm.services.task.impl.model.I18NTextImpl</class>

              <class>org.jbpm.services.task.impl.model.NotificationImpl</class>

              <class>org.jbpm.services.task.impl.model.EmailNotificationImpl</class>

              <class>org.jbpm.services.task.impl.model.EmailNotificationHeaderImpl</class>

              <class>org.jbpm.services.task.impl.model.PeopleAssignmentsImpl</class>

              <class>org.jbpm.services.task.impl.model.ReassignmentImpl</class>

       

              <class>org.jbpm.services.task.impl.model.TaskImpl</class>

              <class>org.jbpm.services.task.impl.model.TaskDataImpl</class>

              <class>org.jbpm.services.task.impl.model.UserImpl</class>

       

       

              <!-- Task Audit Classes -->

              <class>org.jbpm.services.task.audit.impl.model.AuditTaskImpl</class>

              <class>org.jbpm.services.task.audit.impl.model.TaskVariableImpl</class>

       

              <!--BAM for task service -->

              <class>org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl</class>

       

              <!-- Event Classes -->

              <class>org.jbpm.services.task.audit.impl.model.TaskEventImpl</class>

       

              <properties>

       

                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

       

                  <property name="hibernate.max_fetch_depth" value="5" />

       

                  <property name="hibernate.hbm2ddl.auto" value="update" />

       

                  <property name="hibernate.show_sql" value="true" />

       

                  <property name="hibernate.transaction.jta.platform"

                      value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform" />

       

              </properties>

       

          </persistence-unit>

       

      </persistence>

       

       

      When i launch the test, i have in my database these tables getting generated:

       

      Attachment                 |
      | AuditTaskImpl              |
      | BAMTaskSummary             |
      | BooleanExpression          |
      | Content                    |
      | ContextMappingInfo         |
      | CorrelationKeyInfo         |
      | CorrelationPropertyInfo    |
      | Deadline                   |
      | Delegation_delegates       |
      | Escalation                 |
      | EventTypes                 |
      | I18NText                   |
      | NodeInstanceLog            |
      | Notification               |
      | Notification_BAs           |
      | Notification_Recipients    |
      | Notification_email_header  |
      | OrganizationalEntity       |
      | PeopleAssignments_BAs      |

      | PeopleAssignments_ExclOwners   |

      | PeopleAssignments_PotOwners|

      | PeopleAssignments_Recipients   |

      | PeopleAssignments_Stakeholders |

      | ProcessInstanceInfo        |
      | ProcessInstanceLog         |
      | Reassignment               |

      | Reassignment_potentialOwners   |

      | SessionInfo                |
      | Task                       |
      | TaskEvent                  |
      | TaskVariableImpl           |
      | VariableInstanceLog        |
      | WorkItemInfo               |
      | email_header               |

      | task_comment 

       

       

       

      i know that the users should be stored in  OrganizationalEntity  table, so listing the content gave me this:

       

      +-------+----------------+

      | DTYPE | id             |

      +-------+----------------+

      | User  | Administrator  |

      | Group | Administrators |

      +-------+----------------+

       

      Should this table have more records than this ???

       

      I even put a file name userinfo.properties to my classpath containing users definitions.

       

      I dont know what i'm mssing but i really need help!

       

      An additionnal info: whille diving in my server logs, i see that this is the request returning no rresults:

       

      select distinct taskimpl0_.id as col_0_0_, taskimpl0_.name as col_1_0_, taskimpl0_.description as col_2_0_, taskimpl0_.status as col_3_0_, taskimpl0_.priority as col_4_0_, taskimpl0_.actualOwner_id as col_5_0_, taskimpl0_.createdBy_id as col_6_0_, taskimpl0_.createdOn as col_7_0_, taskimpl0_.activationTime as col_8_0_, taskimpl0_.expirationTime as col_9_0_, taskimpl0_.processId as col_10_0_, taskimpl0_.processInstanceId as col_11_0_, taskimpl0_.parentId as col_12_0_, taskimpl0_.deploymentId as col_13_0_, taskimpl0_.skipable as col_14_0_ from Task taskimpl0_ inner join PeopleAssignments_PotOwners potentialo1_ on taskimpl0_.id=potentialo1_.task_id inner join OrganizationalEntity organizati2_ on potentialo1_.entity_id=organizati2_.id left outer join PeopleAssignments_ExclOwners excludedow3_ on taskimpl0_.id=excludedow3_.task_id left outer join OrganizationalEntity organizati4_ on excludedow3_.entity_id=organizati4_.id where taskimpl0_.archived=0 and (taskimpl0_.actualOwner_id=? or taskimpl0_.actualOwner_id is null) and (taskimpl0_.status in (? , ? , ?)) and (organizati2_.id=? or organizati2_.id in (?)) and ( not (exists (select organizati6_.id from PeopleAssignments_ExclOwners excludedow5_, OrganizationalEntity organizati6_ where taskimpl0_.id=excludedow5_.task_id and excludedow5_.entity_id=organizati6_.id)) or organizati4_.id<>?) order by taskimpl0_.id DESC

       

      Really need help! thanks.