return Collections.emptyMap();
}
}
public Void execute(CommandContext commandContext) {
ProcessEngine processEngine = getProcessEngine();
FormTemplateManager formTemplateManager = getFormTemplateManager();
KeyValue keyValue = getKeyValue();
String bpmProcessId = getParameter(OPERATION_BPM_PROCESS_ID);
BpmProcess bpmProcess = getBpmProcessManager().get(
Long.parseLong(bpmProcessId));
String processDefinitionId = bpmProcess.getBpmConfBase()
.getProcessDefinitionId();
// 先保存草稿
String businessKey = new ConfAssigneeOperation()
.execute(getParameters());
// 先设置登录用户
IdentityService identityService = processEngine.getIdentityService();
identityService.setAuthenticatedUserId(SpringSecurityUtils
.getCurrentUserId());
// 获得form的信息
FormInfo formInfo = new FindStartFormCmd(processDefinitionId)
.execute(commandContext);
// 尝试根据表单里字段的类型,进行转换
Map<String, String> formTypeMap = new HashMap<String, String>();
if (formInfo.isFormExists()) {
FormTemplate formTemplate = formTemplateManager.findUniqueBy(
"code", formInfo.getFormKey());
String content = formTemplate.getContent();
formTypeMap = this.fetchFormTypeMap(content);
}
Record record = keyValue.findByCode(businessKey);
Map<String, Object> processParameters = new HashMap<String, Object>();
// 如果有表单,就从数据库获取数据
for (Prop prop : record.getProps().values()) {
String key = prop.getCode();
String value = prop.getValue();
String formType = this.getFormType(formTypeMap, key);
if ("userpicker".equals(formType)) {
processParameters.put(key,
new ArrayList(Arrays.asList(value.split(","))));
} else if (formType != null) {
processParameters.put(key, value);
}
}
ProcessInstance processInstance = processEngine.getRuntimeService()
.startProcessInstanceById(processDefinitionId, businessKey,
processParameters);
record = new RecordBuilder().build(record, STATUS_RUNNING,
processInstance.getId());
keyValue.save(record);