4 Replies Latest reply on Oct 20, 2005 11:18 AM by Ronald van Kuijk

    SwimlaneInstance / PooledActor data integrity issue

    brittm Novice

      To programatically set pooled actors for a swimlane instance, one would expect the following to work:

       Set pooledActors = new HashSet();
       pooledActors.add(new PooledActor("Bill"));
       swimlaneInstance.setPooledActors(pooledActors);

      However, neither the SwimlaneInstance nor PooledActor classes currently automatically associate the PooledActor with the SwimlaneInstance before persisting, thus leaving a PooledActor hanging without reference in the database.
      In order to maintain data integrity, we have to do the following:
       Set pooledActors = new HashSet();
       PooledActor pooledActor = new PooledActor("Bill");
       pooledActor.setSwimlaneInstance(swimlaneInstance);
       pooledActors.add(pooledActor);
       swimlaneInstance.setPooledActors(pooledActors);

      Neither swimlaneInstance.setPooledActors(Set pooledActors) nor swimlaneInsance.setPooledActors(String[] pooledActors) handle this association. I'm thinking that data integrity issues shouldn't be left in the hands of the API user.
      Should SwimlaneInstance's setPooledActors() methods perhaps look something more like this?
       public void setPooledActors(Set pooledActors) {
       if(pooledActors == null) {
       this.pooledActors = null;
       }else{
       Iterator itr = pooledActors.iterator();
       while(itr.hasNext()) {
       PooledActor p = (PooledActor)itr.next();
       p.setSwimlaneInstance(this);
       this.pooledActors.add(p);
       }
       }
      
       }
      

      Thanks,
      Britt

        • 1. Re: SwimlaneInstance / PooledActor data integrity issue
          brittm Novice

          I think I've identified a broader issue than that listed above. I don't think the current code is built to support reassignment of SwimlaneInstance pooledActors (though reassigning the actor seems to work fine).

          In support of that statement--if a TaskInstance does not have any pooledActors itself, it will try to return it's SwimlaneInstance's pooledActors; however, if assignments to the SwimlaneInstance's pooledActors are made after the TaskInstance has been created, the TaskInstance will (as mentioned) return the pooledActors assigned to the SwimlaneInstance while taskMgmtSession.findPooledTaskInstances(theSamePooledActor) returns nothing (from the jbpm_taskactorpool table).

          Another related issue is that calling swimlaneInstance.setPooledActors(pooledActors) doesn't replace the pooledActors already in the database, it adds to them.

          Unless someone steps up to make the argument that we shouldn't be reassigning a SwimlaneInstance's PooledActors anyway, I'll create a JIRA issue on this and label it as a bug (since the method calls are already there, and actor reassignment is functional).

          Personally, this functionallity is fairly important to my own applications.

          Thanks,
          Britt

          • 3. Re: SwimlaneInstance / PooledActor data integrity issue
            Tom Baeyens Master

            1) swimlaneInstance.setPooledActors should set the backpointer. in all of the jbpm code, 1-n bidirectional relations are maintained at the 'many' side.

            2) for the assignment i will try to work out some test cases. it would be great if you could help in creating those test cases. if you sign the contributors agreement, you can get cvs access. send me an email if you want to know more: tom dot baeyens at jboss dot com.

            regards, tom.

            • 4. Re: SwimlaneInstance / PooledActor data integrity issue
              Ronald van Kuijk Master

              this email adres is normally visible as your username..... :-))))