snaker-core/src/main/java/org/snaker/engine/core/TaskService.java
public void addTaskActor(String taskId, Integer performType, String... actors) {
		Task task = access().getTask(taskId);
		AssertHelper.notNull(task, "指定的任务[id=" + taskId + "]不存在");
		if(!task.isMajor()) return;
		if(performType == null) performType = task.getPerformType();
		if(performType == null) performType = 0;
		switch(performType) {
		case 0:
			assignTask(task.getId(), actors);
			Map<String, Object> data = task.getVariableMap();
			String oldActor = (String)data.get(Task.KEY_ACTOR);
			data.put(Task.KEY_ACTOR, oldActor + "," + StringHelper.getStringByArray(actors));
			task.setVariable(JsonHelper.toJson(data));
			access().updateTask(task);
			break;
		case 1:
			try {
				for(String actor : actors) {
					Task newTask = (Task)task.clone();
					newTask.setId(StringHelper.getPrimaryKey());
					newTask.setCreateTime(DateHelper.getTime());
					newTask.setOperator(actor);
					Map<String, Object> taskData = task.getVariableMap();
					taskData.put(Task.KEY_ACTOR, actor);
					task.setVariable(JsonHelper.toJson(taskData));
					access().saveTask(newTask);
					assignTask(newTask.getId(), actor);
				}
			} catch(CloneNotSupportedException ex) {
				throw new SnakerException("任务对象不支持复制", ex.getCause());
			}
			break;
		default :
			break;
		}
	}
public void addTaskActor(String taskId, Integer performType, String... actors) {
		Task task = access().getTask(taskId);
		AssertHelper.notNull(task, "指定的任务[id=" + taskId + "]不存在");
		if(!task.isMajor()) return;
		if(performType == null) performType = task.getPerformType();
		if(performType == null) performType = 0;
		switch(performType) {
		case 0:
			assignTask(task.getId(), actors);
			Map<String, Object> data = task.getVariableMap();
			String oldActor = (String)data.get(Task.KEY_ACTOR);
			data.put(Task.KEY_ACTOR, oldActor + "," + StringHelper.getStringByArray(actors));
			task.setVariable(JsonHelper.toJson(data));
			access().updateTask(task);
			break;
		case 1:
			try {
				for(String actor : actors) {
					Task newTask = (Task)task.clone();
					newTask.setId(StringHelper.getPrimaryKey());
					newTask.setCreateTime(DateHelper.getTime());
					newTask.setOperator(actor);
					Map<String, Object> taskData = task.getVariableMap();
					taskData.put(Task.KEY_ACTOR, actor);
					task.setVariable(JsonHelper.toJson(taskData));
					access().saveTask(newTask);
					assignTask(newTask.getId(), actor);
				}
			} catch(CloneNotSupportedException ex) {
				throw new SnakerException("任务对象不支持复制", ex.getCause());
			}
			break;
		default :
			break;
		}
	}
public void addTaskActor ( String taskId , Integer performType , String ... actors ) { Task task = access ( ) . getTask ( taskId ) ; AssertHelper . notNull ( task , "指定的任务[id=" + taskId  ]不存在") if ( ! task . isMajor ( ) ) return ; if ( performType == null ) performType = task . getPerformType ( ) ; if ( performType == null ) performType = 0 ; switch ( performType ) { case 0 : assignTask ( task . getId ( ) , actors ) ; Map < String , Object > data = task . getVariableMap ( ) ; String oldActor = ( String ) data . get ( Task . KEY_ACTOR ) ; data . put ( Task . KEY_ACTOR , oldActor + "," + StringHelper . getStringByArray ( actors ) ) ; task . setVariable ( JsonHelper . toJson ( data ) ) ; access ( ) . updateTask ( task ) ; break ; case 1 : try { for ( String actor : actors ) { Task newTask = ( Task ) task . clone ( ) ; newTask . setId ( StringHelper . getPrimaryKey ( ) ) ; newTask . setCreateTime ( DateHelper . getTime ( ) ) ; newTask . setOperator ( actor ) ; Map < String , Object > taskData = task . getVariableMap ( ) ; taskData . put ( Task . KEY_ACTOR , actor ) ; task . setVariable ( JsonHelper . toJson ( taskData ) ) ; access ( ) . saveTask ( newTask ) ; assignTask ( newTask . getId ( ) , actor ) ; } } catch ( CloneNotSupportedException ex ) { throw new SnakerException ( "任务对象不支持复制", ex.getCause()); } break ; default : break ; } }
向指定任务添加参与者
该方法根据performType类型判断是否需要创建新的活动任务
向指定任务添加参与者 该方法根据performType类型判断是否需要创建新的活动任务