AnsweredAssumed Answered

Adding an aspect that is both optional and mandatory

Question asked by evolmark on May 10, 2007
I have a task that need to send content either to a group of reviewers or to the editors for final processing.

Editors are associated using a <pooledactors> tag,  reviewers are part of a heterogenous group selected using something similar to bpm_assignees, my version is called swwf_assignees wich has been declared as optional

THE PROBLEM I need to solve
I need to validate that if the SendToReviewers transition is called that at least one reviewer was selected


MY CURRENT APPROACH

<task-node name="produce">
      <task name="swwf:produceTask" swimlane="producers"></task>
      <transition name="reject" to="returnToInitiator" />
      <transition name="sendToReviewers" to="validateIfThereAreReviewers" />
      <transition name="sendToProofing" to="proof" />
   </task-node>

   <task-node name="returnToInitiator">
      <task name="swwf:returnToInitiator" swimlane="initiator"></task>
   </task-node>

   <swimlane name="reviewers" />


   <decision name="validateIfThereAreReviewers">
      <event type="node-enter">
         <script>
            <variable name="swwf_reviewerCnt" access="write" />
            <expression>
               swwf_reviewerCnt = swwf_assignees.size();
            </expression>
         </script>
      </event>

      <transition name="reviewersNotProvided" to="produce">
      <script></script>
      </transition>
      <transition name="reviewersProvided" to="startReview">
         <condition>#{swwf_reviewerCnt > 0 }</condition>
      </transition>
   </decision>


   <node name="startReview">
      <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
         <foreach>#{swwf_assignees}</foreach>
         <var>reviewer</var>
      </action>
      <transition name="" to="review" />
   </node>

   <task-node name="review">
      <task name="swwf:reviewTask">
         <assignment
            class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{reviewer}</actor>
         </assignment>
      </task>
      <transition name="finished" to="produce" />
   </task-node>

This throws an error when nobody is selected in reviewers, swwf_assignees seems to be undefined.

    exception during evaluation of script expression
    Sourced file: inline evaluation of: ``swwf_reviewerCnt = swwf_assignees.size();'' : Attempt to resolve method: size() on undefined variable or….
QUESTIONS
Any recomended approach to solve the problem
Can I ask if a variable is un/defined
how to handle exceptions

Outcomes