/**
   * 设置默认值
   *
   * @param dv
   * @param formName
   * @param actionType
   * @return
   */
  private S_FrameWork_Query_OperationValueObject setDefault(
      S_FrameWork_Query_OperationValueObject valueObject, String formName, String actionType) {

    String entityName = "S_FrameWork_Query_Operation"; // 代码自动生成
    Document doc = DomService.getXMLDocFromEntity(entityName, formName);
    // 1.遍历所有节点,判断是否有默认设置
    // 2.比较actionType,看是否当前默认设置的操作
    // 3.反射设置当前属性的默认值
    try {

      if (doc == null) {
        return valueObject;
      }
      String methordName = "";

      Element root = doc.getRootElement();
      java.util.List elements = root.getChildren("item");
      Element tempElm = null;
      String s = null;
      String sType = "string";
      String sDBType = "String";
      DefaultValue dv = new DefaultValue();
      String whendefault = "";
      String defaultValue = "";

      for (int i = 0; i < elements.size(); i++) {
        tempElm = (Element) elements.get(i);
        s = tempElm.getAttribute("name").getValue();
        methordName = "set" + s.substring(0, 1).toUpperCase() + s.substring(1, s.length());
        if ((tempElm.getAttribute("datatype") != null
            && tempElm.getAttribute("datatype").getValue() != null)) {
          if (tempElm.getAttribute("dbtype") == null) {
            sType = tempElm.getAttribute("datatype").getValue();
          } else {
            sType = tempElm.getAttribute("dbtype").getValue();
          }
        }

        // 设置缺省值;当新增加的时候,设置缺省值,此处只在初始化和load的时候设置;修改的时候不设置
        // updated by wzp 20050323
        if (tempElm.getAttribute("datatype") != null
            && tempElm.getAttribute("default") != null
            && tempElm.getAttribute("whendefault") != null) {
          whendefault = tempElm.getAttribute("whendefault").getValue();
          defaultValue = tempElm.getAttribute("default").getValue();
          // 如何判断是新增?
          if (actionType.toLowerCase().indexOf("init_") == 0
              && whendefault.toLowerCase().indexOf("init") > -1) {
            // 初始化
            valueObject = this.invokeMethord(valueObject, methordName, sType, defaultValue);
          } else if (actionType.toLowerCase().indexOf("create_") == 0
              && whendefault.toLowerCase().indexOf("create") > -1) {
            // 创建
            valueObject = this.invokeMethord(valueObject, methordName, sType, defaultValue);
          } else if (actionType.toLowerCase().indexOf("save_") == 0
              && whendefault.toLowerCase().indexOf("save") > -1) {
            // 修改
            valueObject = this.invokeMethord(valueObject, methordName, sType, defaultValue);
          }
        }
      }

    } catch (Exception exe) {
      exe.printStackTrace();
    }

    return valueObject;
  }
  /**
   * 执行反射
   *
   * @param valueObject
   * @param methordName
   * @param type
   * @param defaultValue
   * @return
   */
  private S_FrameWork_Query_OperationValueObject invokeMethord(
      S_FrameWork_Query_OperationValueObject valueObject,
      String methordName,
      String type,
      String defaultValue) {

    // 映射
    String[] paramStr;
    Integer[] paramI;
    Timestamp[] paramDate;
    Float[] paramfl;
    Date[] paramSqlDate;
    java.lang.reflect.Method m;
    Object b;
    DefaultValue dv = new DefaultValue();
    HttpServletRequest request = super.getHttpServletRequest();
    dv.setRequest(request);
    dv.setObjectManager((ApplicationUSOM) getUSOM());

    try {

      // 1.判断数据类型
      // 2.设置默认值
      // 3.默认值有三种:系统信息,用户信息,request信息,session信息
      if (type.equalsIgnoreCase("String")) {

        paramStr = new String[] {dv.setDefault(defaultValue)}; // 字符串
        m =
            (S_FrameWork_Query_OperationValueObject.class)
                .getMethod(methordName, new Class[] {String.class});
        b = m.invoke(valueObject, paramStr);
        return valueObject;

      } else if (type.equalsIgnoreCase("float")) {

        paramfl = new Float[] {Float.valueOf(dv.setDefault(defaultValue))}; // 字符串
        m =
            (S_FrameWork_Query_OperationValueObject.class)
                .getMethod(methordName, new Class[] {Float.class});
        b = m.invoke(valueObject, paramfl);
        return valueObject;

      } else if (type.equalsIgnoreCase("integer")) {

        paramI = new Integer[] {new Integer(dv.setDefault(defaultValue))}; // 整型
        m =
            (S_FrameWork_Query_OperationValueObject.class)
                .getMethod(methordName, new Class[] {int.class});
        b = m.invoke(valueObject, paramI);
        return valueObject;

      } else if (type.equalsIgnoreCase("datetime") || type.equalsIgnoreCase("date")) {

        try {
          paramDate = new Timestamp[] {formatToTimestamp(dv.setDefault(defaultValue))}; // 日期
          m =
              (S_FrameWork_Query_OperationValueObject.class)
                  .getMethod(methordName, new Class[] {Timestamp.class});
          b = m.invoke(valueObject, paramDate);
          return valueObject;
        } catch (Exception e) {
          try {
            paramSqlDate = new Date[] {formatToSQLDATE(dv.setDefault(defaultValue))}; // 日期
            m =
                (S_FrameWork_Query_OperationValueObject.class)
                    .getMethod(methordName, new Class[] {java.sql.Date.class});
            b = m.invoke(valueObject, paramSqlDate);
            return valueObject;
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return valueObject;
  }
  /**
   * Validates whether the the form values are valid.
   *
   * @param String sAction
   * @return boolean
   */
  private boolean isFormValid(String sAction) {
    boolean bReturn = true;
    ApplicationUSOM objectManager = (ApplicationUSOM) getUSOM();
    if (sAction.equalsIgnoreCase(Save_S_FrameWork_Query_Operation)
        || sAction.equalsIgnoreCase(Create_S_FrameWork_Query_Operation)) {
      /////////////////////////////////////////////////////
      // To Do:  Post Submit Form Validation
      /////////////////////////////////////////////////////

      try {
        // if creating, create an empty one first
        if (sAction.equalsIgnoreCase(Create_S_FrameWork_Query_Operation)) {
          m_S_FrameWork_Query_OperationValueObject = new S_FrameWork_Query_OperationValueObject();
        } else // must be saving an existing one, so get it from the cache
        {

          m_S_FrameWork_Query_OperationValueObject =
              objectManager.getCurrentS_FrameWork_Query_Operation();

          // for update the cache usom
          beforeSaveValueObject = m_S_FrameWork_Query_OperationValueObject;

          if (m_S_FrameWork_Query_OperationValueObject == null) {
            logMessage(
                FrameworkLogEventType.DEBUG_LOG_EVENT_TYPE,
                "S_FrameWork_Query_OperationWorkerBean:isFormValid() - failed to acquire the Current S_FrameWork_Query_Operation from the Application USOM. ");
            return (false);
          }
        }

        // AIB Generated Section - Do Not Modify Within

        m_S_FrameWork_Query_OperationValueObject.setOPERATION_CODE(
            StringService.strToStr(getServletRequestParameter("oPERATION_CODE")));

        m_S_FrameWork_Query_OperationValueObject.setFORMSN(
            StringService.strToStr(getServletRequestParameter("fORMSN")));

        m_S_FrameWork_Query_OperationValueObject.setOPERATION_NAME(
            StringService.strToStr(getServletRequestParameter("oPERATION_NAME")));

        m_S_FrameWork_Query_OperationValueObject.setOPERATION_VALUE(
            StringService.strToStr(getServletRequestParameter("oPERATION_VALUE")));

        m_S_FrameWork_Query_OperationValueObject.setOPERATION_ORDER(
            StringService.strToStr(getServletRequestParameter("oPERATION_ORDER")));

        m_S_FrameWork_Query_OperationValueObject.setEXT1(
            StringService.strToStr(getServletRequestParameter("eXT1")));

        m_S_FrameWork_Query_OperationValueObject.setEXT2(
            StringService.strToStr(getServletRequestParameter("eXT2")));

        m_S_FrameWork_Query_OperationValueObject.setEXT3(
            StringService.strToStr(getServletRequestParameter("eXT3")));

        m_S_FrameWork_Query_OperationValueObject.setEXT4(
            StringService.strToStr(getServletRequestParameter("eXT4")));

        m_S_FrameWork_Query_OperationValueObject.setEXT5(
            StringService.strToStr(getServletRequestParameter("eXT5")));

        m_S_FrameWork_Query_OperationValueObject.setDepartmentCode(
            StringService.strToStr(getServletRequestParameter("departmentCode")));

        m_S_FrameWork_Query_OperationValueObject.setCreator(
            StringService.strToStr(getServletRequestParameter("creator")));

        m_S_FrameWork_Query_OperationValueObject.setSecurityGrade(
            StringService.strToStr(getServletRequestParameter("securityGrade")));

        m_S_FrameWork_Query_OperationValueObject.setCreatedTime(
            formatToTimestamp(getServletRequestParameter("createdTime")));

        m_S_FrameWork_Query_OperationValueObject.setLastUpdatedBy(
            StringService.strToStr(getServletRequestParameter("lastUpdatedBy")));

        m_S_FrameWork_Query_OperationValueObject.setLastUpdatedTime(
            formatToTimestamp(getServletRequestParameter("lastUpdatedTime")));

        m_S_FrameWork_Query_OperationValueObject.setRefreshTime(
            formatToTimestamp(getServletRequestParameter("refreshTime")));

        m_S_FrameWork_Query_OperationValueObject.setUploadFlag(
            StringService.strToStr(getServletRequestParameter("uploadFlag")));

        m_S_FrameWork_Query_OperationValueObject.setDownloadFlag(
            StringService.strToStr(getServletRequestParameter("downloadFlag")));

        m_S_FrameWork_Query_OperationValueObject.setDeleteFlag(
            StringService.strToStr(getServletRequestParameter("deleteFlag")));

        // ~AIB Generated

      } catch (Exception exc) {
        logMessage(
            FrameworkLogEventType.DEBUG_LOG_EVENT_TYPE,
            "S_FrameWork_Query_OperationWorkerBean:isFormValid() - Exception caught - " + exc);
        exc.printStackTrace();
        bReturn = false;
      }
    }

    return bReturn;
  }