protected FormPropertyRenderer getRenderer(FormProperty formProperty) {
   FormType formPropertyType = formProperty.getType();
   if (formPropertyType == null) {
     return formPropertyRendererManager.getTypeLessFormPropertyRenderer();
   } else {
     return formPropertyRendererManager.getPropertyRendererForType(formProperty.getType());
   }
 }
Ejemplo n.º 2
0
 public static String getCastomFieldValue(FormData formData, String fieldName) {
   List<FormProperty> formDataList = formData.getFormProperties();
   if (!formDataList.isEmpty()) {
     for (FormProperty prop : formDataList) {
       if (prop.getType() instanceof FormFileType && prop.getName().equalsIgnoreCase(fieldName)) {
         return prop.getValue() != null ? prop.getValue() : "";
       }
     }
   }
   return "";
 }
Ejemplo n.º 3
0
 /**
  * Получить имя поля
  *
  * @param formData
  * @return
  */
 public static List<String> getListCastomFieldName(FormData formData) {
   List<String> filedName = new ArrayList<String>();
   List<FormProperty> formDataList = formData.getFormProperties();
   if (!formDataList.isEmpty()) {
     for (FormProperty prop : formDataList) {
       if (prop.getType() instanceof FormFileType) {
         filedName.add(prop.getName());
       }
     }
   }
   return filedName;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
  @Override
  public Field getPropertyField(FormProperty formProperty) {
    SelectUserField selectUserField = new SelectUserField(getPropertyLabel(formProperty));
    selectUserField.setRequired(formProperty.isRequired());
    selectUserField.setRequiredError(
        getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
    selectUserField.setEnabled(formProperty.isWritable());

    if (formProperty.getValue() != null) {
      selectUserField.setValue(formProperty.getValue());
    }

    return selectUserField;
  }
Ejemplo n.º 6
0
  /**
   * 发起流程
   *
   * @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;
  }
  /**
   * 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;
  }
  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);
        }
      }
    }
  }
  @SuppressWarnings("unchecked")
  @Override
  protected void doConvert(FormProperty formProperty, FormPropertyTransfer formPropertyTransfer) {

    formPropertyTransfer.setType(Enumeration.class);
    Map<String, String> information =
        (Map<String, String>) formProperty.getType().getInformation("values");
    // ArrayList, because it's serializable
    formPropertyTransfer.setExtraFormTypeInformation(new ArrayList<String>(information.keySet()));
  }
 /**
  * 根据输入的参数生成提交数据,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;
 }
Ejemplo n.º 11
0
  /**
   * 完成任务
   *
   * @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;
  }