snaker-core/src/main/java/org/snaker/engine/core/TaskService.java
public List<Task> createTask(TaskModel taskModel, Execution execution) {
		List<Task> tasks = new ArrayList<Task>();
		
		Map<String, Object> args = execution.getArgs();
		if(args == null) args = new HashMap<String, Object>();
		Date expireDate = DateHelper.processTime(args, taskModel.getExpireTime());
		Date remindDate = DateHelper.processTime(args, taskModel.getReminderTime());
		String form = (String)args.get(taskModel.getForm());
		String actionUrl = StringHelper.isEmpty(form) ? taskModel.getForm() : form;
		
		String[] actors = getTaskActors(taskModel, execution);
		args.put(Task.KEY_ACTOR, StringHelper.getStringByArray(actors));
		Task task = createTaskBase(taskModel, execution);
		task.setActionUrl(actionUrl);
		task.setExpireDate(expireDate);
		task.setExpireTime(DateHelper.parseTime(expireDate));
        task.setVariable(JsonHelper.toJson(args));
		
		if(taskModel.isPerformAny()) {
			//任务执行方式为参与者中任何一个执行即可驱动流程继续流转，该方法只产生一个task
			task = saveTask(task, actors);
			task.setRemindDate(remindDate);
			tasks.add(task);
		} else if(taskModel.isPerformAll()){
			//任务执行方式为参与者中每个都要执行完才可驱动流程继续流转，该方法根据参与者个数产生对应的task数量
			for(String actor : actors) {
                Task singleTask;
                try {
                    singleTask = (Task) task.clone();
                } catch (CloneNotSupportedException e) {
                    singleTask = task;
                }
                singleTask = saveTask(singleTask, actor);
                singleTask.setRemindDate(remindDate);
                tasks.add(singleTask);
			}
		}
		return tasks;
	}
public List<Task> createTask(TaskModel taskModel, Execution execution) {
		List<Task> tasks = new ArrayList<Task>();
		
		Map<String, Object> args = execution.getArgs();
		if(args == null) args = new HashMap<String, Object>();
		Date expireDate = DateHelper.processTime(args, taskModel.getExpireTime());
		Date remindDate = DateHelper.processTime(args, taskModel.getReminderTime());
		String form = (String)args.get(taskModel.getForm());
		String actionUrl = StringHelper.isEmpty(form) ? taskModel.getForm() : form;
		
		String[] actors = getTaskActors(taskModel, execution);
		args.put(Task.KEY_ACTOR, StringHelper.getStringByArray(actors));
		Task task = createTaskBase(taskModel, execution);
		task.setActionUrl(actionUrl);
		task.setExpireDate(expireDate);
		task.setExpireTime(DateHelper.parseTime(expireDate));
        task.setVariable(JsonHelper.toJson(args));
		
		if(taskModel.isPerformAny()) {
			//任务执行方式为参与者中任何一个执行即可驱动流程继续流转，该方法只产生一个task
			task = saveTask(task, actors);
			task.setRemindDate(remindDate);
			tasks.add(task);
		} else if(taskModel.isPerformAll()){
			//任务执行方式为参与者中每个都要执行完才可驱动流程继续流转，该方法根据参与者个数产生对应的task数量
			for(String actor : actors) {
                Task singleTask;
                try {
                    singleTask = (Task) task.clone();
                } catch (CloneNotSupportedException e) {
                    singleTask = task;
                }
                singleTask = saveTask(singleTask, actor);
                singleTask.setRemindDate(remindDate);
                tasks.add(singleTask);
			}
		}
		return tasks;
	}
public List < Task > createTask ( TaskModel taskModel , Execution execution ) { List < Task > tasks = new ArrayList < Task > ( ) ; Map < String , Object > args = execution . getArgs ( ) ; if ( args == null ) args = new HashMap < String , Object > ( ) ; Date expireDate = DateHelper . processTime ( args , taskModel . getExpireTime ( ) ) ; Date remindDate = DateHelper . processTime ( args , taskModel . getReminderTime ( ) ) ; String form = ( String ) args . get ( taskModel . getForm ( ) ) ; String actionUrl = StringHelper . isEmpty ( form ) ? taskModel . getForm ( ) : form ; String [ ] actors = getTaskActors ( taskModel , execution ) ; args . put ( Task . KEY_ACTOR , StringHelper . getStringByArray ( actors ) ) ; Task task = createTaskBase ( taskModel , execution ) ; task . setActionUrl ( actionUrl ) ; task . setExpireDate ( expireDate ) ; task . setExpireTime ( DateHelper . parseTime ( expireDate ) ) ; task . setVariable ( JsonHelper . toJson ( args ) ) ; if ( taskModel . isPerformAny ( ) ) { //任务执行方式为参与者中任何一个执行即可驱动流程继续流转，该方法只产生一个task task = saveTask ( task , actors ) ; task . setRemindDate ( remindDate ) ; tasks . add ( task ) ; } else if ( taskModel . isPerformAll ( ) ) { //任务执行方式为参与者中每个都要执行完才可驱动流程继续流转，该方法根据参与者个数产生对应的task数量 for ( String actor : actors ) { Task singleTask ; try { singleTask = ( Task ) task . clone ( ) ; } catch ( CloneNotSupportedException e ) { singleTask = task ; } singleTask = saveTask ( singleTask , actor ) ; singleTask . setRemindDate ( remindDate ) ; tasks . add ( singleTask ) ; } } return tasks ; }
由DBAccess实现类创建task，并根据model类型决定是否分配参与者
@param taskModel 模型
@param execution 执行对象
@return List<Task> 任务列表
由DBAccess实现类创建task，并根据model类型决定是否分配参与者