}
}
private void startProcess() {
ApplicationContext ac = AppUtil.getApplicationContext();
AppService appService = (AppService) ac.getBean("appService");
FormService formService = (FormService) ac.getBean("formService");
WorkflowProcess process = appService.getWorkflowProcessForApp(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"));
setProperty("process", process);
if (isUnauthorized(process.getId())) {
// extract form values from request
FormData formData = new FormData();
String recordId = getRequestParameterString("recordId");
if (recordId != null && recordId.trim().length() == 0) {
recordId = null;
}
formData = formService.retrieveFormDataFromRequestMap(formData, getRequestParameters());
if (getPropertyString("keyName") != null && getPropertyString("keyName").trim().length() > 0 && getKey() != null) {
formData.addRequestParameterValues(getPropertyString("keyName"), new String[]{getKey()});
}
// get workflow variables
Map<String, String> variableMap = AppUtil.retrieveVariableDataFromMap(getRequestParameters());
String formUrl = getUrl() + "?_action=start";
WorkflowProcessResult result = appService.submitFormToStartProcess(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"), formData, variableMap, recordId, formUrl);
PackageActivityForm startFormDef = appService.viewStartProcessForm(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"), formData, formUrl);
if (startFormDef != null && (startFormDef.getForm() != null || PackageActivityForm.ACTIVITY_FORM_TYPE_EXTERNAL.equals(startFormDef.getType()))) {
if (result == null) {
// validation error, get form
Form startForm = startFormDef.getForm();
// generate form HTML
String formHtml = formService.retrieveFormErrorHtml(startForm, formData);
AppDefinition appDef = appService.getAppDefinition(getRequestParameterString("appId"), getRequestParameterString("appVersion"));
// show form
setProperty("headerTitle", process.getName());
setProperty("view", "formView");
setProperty("formHtml", formHtml);