[技术讨论] 动态分支的解决方案

founder 2013-12-17
  • step增加type属性:0-竞争型(先到先得), 1-动态分支型(详见:http://eworkflow.iteye.com/blog/650576)。同步修改流程设计器,调整DTD
  • 修改AbstractWorkflow.doAction, transitionWorkflow等方法,引擎增加对动态分支的处理
  • 吐槽:读AbstractWorkflow的代码,一点优雅、美感都感觉不到,长达300行的transitionWorkflow方法啊!!!

/**
 * Perform an action on the specified workflow instance.
 * 
 * @param id
 *            The workflow instance id.
 * @param stepInstanceId
 * 			  step instance id, see os_current_step.id           
 * @param actionId
 *            The action id to perform (action id's are listed in the
 *            workflow descriptor).
 * @param inputs
 *            The inputs to the workflow instance.
 * @throws InvalidInputException
 *             if a validator is specified and an input is invalid.
 * @throws InvalidActionException
 *             if the action is invalid for the specified workflow
 *             instance's current state.
 */
public void doAction(long id, long stepInstanceId, int actionId, Map inputs) throws InvalidInputException, WorkflowException;

// create new step and store
if (nextStepDescriptor.isDynamicSplit()) {
	String[] ownerList = owner.split(",");
	for (String o : ownerList) {
		if (o == null || o.trim().length() == 0) {
			continue;
		}
		String stepOwnerDesc = StepUserHelper.getStepUsersDesc(o);
		String stepOwner = "," + o + ",";
		Step newStep = Step.buildBaseCurrentStep(-1, entry.getId(), nextStep, stepOwner, 
				startDate, dueDate, status,	previousIds);
		store.saveCurrentStep(newStep);
	}
}
else {
	Step newStep = Step.buildBaseCurrentStep(-1, entry.getId(), nextStep, owner, 
			startDate, dueDate, status,	previousIds);
	store.saveCurrentStep(newStep);
}
Global site tag (gtag.js) - Google Analytics