/**
   * Returns all values filled in in the writable fields on the form.
   *
   * @throws InvalidValueException when a validation error occurs.
   */
  public Map<String, String> getFormPropertyValues() throws InvalidValueException {
    // Commit the form to ensure validation is executed
    form.commit();

    Map<String, String> formPropertyValues = new HashMap<String, String>();

    // Get values from fields defined for each form property
    for (FormProperty formProperty : formProperties) {
      if (formProperty.isWritable()) {
        Field field = form.getField(formProperty.getId());
        FormPropertyRenderer renderer = getRenderer(formProperty);
        String fieldValue = renderer.getFieldValue(formProperty, field);

        formPropertyValues.put(formProperty.getId(), fieldValue);
      }
    }
    return formPropertyValues;
  }
 /**
  * 根据输入的参数生成提交数据,process和task通用
  *
  * @param hasFormKey
  * @param formProperties
  * @param request
  * @return
  */
 private Map<String, String> generateFormValueMap(
     boolean hasFormKey, List<FormProperty> formProperties, HttpServletRequest request) {
   Map<String, String> formValues = new HashMap<String, String>();
   if (hasFormKey) { // 外置表单
     Map<String, String[]> parameterMap = request.getParameterMap();
     Set<Entry<String, String[]>> entrySet = parameterMap.entrySet();
     for (Entry<String, String[]> entry : entrySet) {
       String key = entry.getKey();
       formValues.put(key, entry.getValue()[0]);
     }
   } else { // 动态表单
     for (FormProperty prop : formProperties) {
       if (prop.isWritable()) {
         String value = request.getParameter(prop.getId());
         formValues.put(prop.getId(), value);
       }
     }
   }
   return formValues;
 }
Example #3
0
 /**
  * @param oFormData form data of process
  * @return variable ids with custom property type QueueDataFormType
  */
 public static List<String> getListField_QueueDataFormType(FormData oFormData) {
   List<String> asFieldID = new ArrayList<String>();
   List<FormProperty> aFormProperty = oFormData.getFormProperties();
   if (!aFormProperty.isEmpty()) {
     for (FormProperty oFormProperty : aFormProperty) {
       if (oFormProperty.getType() instanceof QueueDataFormType) {
         asFieldID.add(oFormProperty.getId());
       }
     }
   }
   return asFieldID;
 }
  /**
   * 发起流程
   *
   * @return
   */
  public String startProcessInstance() {
    IdentityService identityService = processEngine.getIdentityService();
    identityService.setAuthenticatedUserId(SpringSecurityUtils.getCurrentUsername());

    FormService formService = processEngine.getFormService();
    StartFormData startFormData = formService.getStartFormData(processDefinitionId);
    HttpServletRequest request = ServletActionContext.getRequest();
    Map<String, String> map = new HashMap<String, String>();

    for (FormProperty formProperty : startFormData.getFormProperties()) {
      String name = formProperty.getId();
      map.put(name, request.getParameter(name));
    }

    formService.submitStartFormData(processDefinitionId, map);

    return RELOAD;
  }
  public void setFormProperties(List<FormProperty> formProperties) {
    this.formProperties = formProperties;

    form.removeAllProperties();

    // Clear current components in the grid
    if (formProperties != null) {
      for (FormProperty formProperty : formProperties) {
        FormPropertyRenderer renderer = getRenderer(formProperty);

        Field editorComponent = renderer.getPropertyField(formProperty);
        if (editorComponent != null) {
          // Get label for editor component.
          form.addField(formProperty.getId(), editorComponent);
        }
      }
    }
  }
  /**
   * 完成任务
   *
   * @return
   */
  public String completeTask() {
    HttpServletRequest request = ServletActionContext.getRequest();
    IdentityService identityService = processEngine.getIdentityService();
    identityService.setAuthenticatedUserId(SpringSecurityUtils.getCurrentUsername());

    FormService formService = processEngine.getFormService();
    TaskFormData taskFormData = formService.getTaskFormData(taskId);

    Map<String, String> map = new HashMap<String, String>();

    for (FormProperty formProperty : taskFormData.getFormProperties()) {
      if (formProperty.isWritable()) {
        String name = formProperty.getId();
        map.put(name, request.getParameter(name));
      }
    }

    formService.submitTaskFormData(taskId, map);

    return RELOAD;
  }