[jboss-user] [JBoss jBPM] - Re: required variables

dleerob do-not-reply at jboss.com
Fri Sep 14 09:00:42 EDT 2007


I'm sure that would work fine. I actually created a quick fix method which does just that (as you can see below), and it did validate correctly. The method returns true if validation passes, and I then only call taskInstance.end(); Doing it this way for now, I am then able to get around the "end" bug aswell. I've pasted the method below which may help people with a workaround for now.
/**
  |      * A bug workaround method to validate that all required 
  |      * variables in a task instance have been set.
  |      * @see Bug[2] at the bottom of this class.
  |      * @param taskInstance
  |      * @return boolean true if validation passes.
  |      */
  |     private boolean validateTaskInstanceVariables (TaskInstance taskInstance) {
  |     	boolean pass = true;
  |     	TaskController taskController = taskInstance.getTask().getTaskController();
  |     	if (taskController != null) {
  |     		List variableAccesses = taskController.getVariableAccesses();
  |     		if (variableAccesses != null) {
  | 	    		String missingTaskVariables = null;
  | 	        Iterator it = variableAccesses.iterator();
  | 	        while (it.hasNext()) {
  | 	          VariableAccess variableAccess = (VariableAccess) it.next();
  | 	          String mappedName = variableAccess.getMappedName();
  | 	          //first check if the required variableInstances are present
  | 	          if ((variableAccess.isRequired()) 
  | 	          	  && (!taskInstance.hasVariableLocally(mappedName) 
  | 	          	  		|| taskInstance.getVariable(mappedName) == null) 
  | 	          	  ) {
  | 	            if (missingTaskVariables==null) {
  | 	              missingTaskVariables = mappedName;
  | 	            } 
  | 	            else {
  | 	              missingTaskVariables += ", "+mappedName;
  | 	            }
  | 	          }
  | 	        }
  | 	        // if there are missing, required parameters, set pass to false.
  | 	        if (missingTaskVariables != null) {
  | 	        	log.debug("Missing task variables: "+missingTaskVariables);
  | 	        	pass = false;
  | 	        }
  |     		}
  |     	}
  |     	return pass;
  |     }

I can try and apply the patch on my system to test if validation works, but I am not building from source so would take me some time to setup my environment and get to it.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4084434#4084434

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4084434



More information about the jboss-user mailing list