Package org.jeecgframework.web.cgform.entity.config

Examples of org.jeecgframework.web.cgform.entity.config.CgFormHeadEntity


          no += ids[i];
          continue;
        }
        List<Columnt> list = new JeecgReadTable()
            .readOriginalTableColumn(ids[i]);
        CgFormHeadEntity cgFormHead = new CgFormHeadEntity();
        cgFormHead.setJformType(1);
        cgFormHead.setIsCheckbox("Y");
        cgFormHead.setIsDbSynch("Y");
        cgFormHead.setIsTree("N");
        cgFormHead.setQuerymode("group");
        cgFormHead.setTableName(ids[i].toLowerCase());
        cgFormHead.setIsPagination("Y");
        cgFormHead.setContent(ids[i]);
        cgFormHead.setJformVersion("1");
        List<CgFormFieldEntity> columnsList = new ArrayList<CgFormFieldEntity>();
        for (int k = 0; k < list.size(); k++) {
          Columnt columnt = list.get(k);
          String fieldName = columnt.getFieldDbName();
          CgFormFieldEntity cgFormField = new CgFormFieldEntity();
          cgFormField.setFieldName(columnt.getFieldDbName()
              .toLowerCase());
          if (StringUtil.isNotEmpty(columnt.getFiledComment()))
            cgFormField.setContent(columnt.getFiledComment());
          else
            cgFormField.setContent(columnt.getFieldName());
          cgFormField.setIsKey("N");
          cgFormField.setIsShow("Y");
          cgFormField.setIsShowList("Y");
          cgFormField.setOrderNum(k + 2);
          cgFormField.setQueryMode("group");
          cgFormField.setLength(0);
          cgFormField.setFieldLength(120);
          cgFormField.setPointLength(0);
          cgFormField.setShowType("text");
          cgFormField.setIsNull(columnt.getNullable());
          if("id".equalsIgnoreCase(fieldName)){
            String[] pkTypeArr = {"java.lang.Integer","java.lang.Long"};
            String idFiledType = columnt.getFieldType();
            if(Arrays.asList(pkTypeArr).contains(idFiledType)){
              //如果主键是数字类型,则设置为自增长
              cgFormHead.setJformPkType("NATIVE");
            }else{
              //否则设置为UUID
              cgFormHead.setJformPkType("UUID");
            }
            cgFormField.setIsKey("Y");
            cgFormField.setIsShow("N");
            cgFormField.setIsShowList("N");
          }
          if ("java.lang.Integer".equalsIgnoreCase(columnt.getFieldType())){
            cgFormField.setType(DataBaseConst.INT);
          }else if ("java.lang.Long".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.INT);
          } else if ("java.util.Date".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.DATE);
            cgFormField.setShowType("date");
          } else if ("java.lang.Double".equalsIgnoreCase(columnt.getFieldType())
              ||"java.lang.Float".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.DOUBLE);
          } else if ("java.math.BigDecimal".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.BIGDECIMAL);
          } else if (columnt.getFieldType().contains("blob")) {
            cgFormField.setType(DataBaseConst.BLOB);
            columnt.setCharmaxLength(null);
          } else {
            cgFormField.setType(DataBaseConst.STRING);
          }
          if (StringUtil.isNotEmpty(columnt.getCharmaxLength())) {
            if (Long.valueOf(columnt.getCharmaxLength()) >= 3000) {
              cgFormField.setType(DataBaseConst.TEXT);
              cgFormField.setShowType(DataBaseConst.TEXTAREA);
              try{//有可能长度超出int的长度
                cgFormField.setLength(Integer.valueOf(columnt.getCharmaxLength()));
              }catch(Exception e){}
            } else {
              cgFormField.setLength(Integer.valueOf(columnt
                  .getCharmaxLength()));
            }
          } else {
            if (StringUtil.isNotEmpty(columnt.getPrecision())) {
              cgFormField.setLength(Integer.valueOf(columnt
                  .getPrecision()));
            }
            //update-begin--Author:zhangdaihao  Date:20140212 for:[001]oracle下number类型,数据库表导出表单,默认长度为0同步失败
            else{
              if(cgFormField.getType().equals(DataBaseConst.INT)){
                cgFormField.setLength(10);
              }
            }
            //update-end--Author:zhangdaihao  Date:20140212 for:[001]oracle下number类型,数据库表导出表单,默认长度为0同步失败
            if (StringUtil.isNotEmpty(columnt.getScale()))
              cgFormField.setPointLength(Integer.valueOf(columnt
                  .getScale()));

          }
          columnsList.add(cgFormField);
        }
        cgFormHead.setColumns(columnsList);
        cgFormFieldService.saveTable(cgFormHead, "");
        if (yes != "")
          yes += ",";
        yes += ids[i];
      }
View Full Code Here


  @RequestMapping(params = "save")
  @ResponseBody
  public AjaxJson save(CgFormHeadEntity cgFormHead,
      HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    CgFormHeadEntity oldTable =cgFormFieldService.getEntity(CgFormHeadEntity.class, cgFormHead.getId());
    cgFormFieldService.removeSubTableStr4Main(oldTable);
    //step.1 如果数据表已经创建,则不能更改主键策略(后续通过强制同步解决此问题)
    /*if(cgFormHead.getId()!=null){
      boolean tableexist = cgFormFieldService.checkTableExist(cgFormHead.getTableName());
      if(tableexist){
        if(!cgFormHead.getJformPkType().equalsIgnoreCase(oldTable.getJformPkType())){
          if((cgFormHead.getJformPkType().equalsIgnoreCase("NATIVE")||cgFormHead.getJformPkType().equalsIgnoreCase("SEQUENCE"))
              &&(oldTable.getJformPkType().equalsIgnoreCase("NATIVE")||oldTable.getJformPkType().equalsIgnoreCase("SEQUENCE"))){
            //native和sequence可以互转
          }else{
            throw new org.jeecgframework.core.common.exception.BusinessException("数据表已经创建,不能更换主键策略");
          }
        }
      }
    }
    */
    //step.2 判定表格是否存在
    CgFormHeadEntity table = judgeTableIsNotExit(cgFormHead,oldTable);
    //step.3 刷新orderNum并且去重复
    refreshFormFieldOrderNum(cgFormHead);
   
   
    if (StringUtil.isNotEmpty(cgFormHead.getId())&&table!=null) {
      List<CgFormFieldEntity>  formFieldEntities = table.getColumns();
      for (CgFormFieldEntity cgFormFieldEntity : formFieldEntities) {
        if (StringUtil.isEmpty(cgFormFieldEntity.getOldFieldName())
            && StringUtil.isNotEmpty(cgFormFieldEntity.getFieldName())) {
          cgFormFieldEntity.setFieldName(cgFormFieldEntity.getFieldName().toLowerCase());
          cgFormFieldEntity.setOldFieldName(cgFormFieldEntity.getFieldName());
View Full Code Here

   * @param cgFormHead
   * @param oldTable
   * @return
   */
  private CgFormHeadEntity judgeTableIsNotExit(CgFormHeadEntity cgFormHead, CgFormHeadEntity oldTable) {
    CgFormHeadEntity table = cgFormFieldService.findUniqueByProperty(
        CgFormHeadEntity.class, "tableName",
        cgFormHead.getTableName());
    if (StringUtil.isNotEmpty(cgFormHead.getId())) {
      if(table != null&&!oldTable.getTableName().equals(cgFormHead.getTableName())){
        message = "重命名的表已经存在";
View Full Code Here

   * sql插件 页面跳转
   * @return
   */
  @RequestMapping(params = "sqlPlugin")
  public ModelAndView sqlPlugin(String id,HttpServletRequest request) {
    CgFormHeadEntity bean = cgFormFieldService.getEntity(
        CgFormHeadEntity.class, id);
    request.setAttribute("bean", bean);
    return new ModelAndView("jeecg/cgform/config/cgFormSqlPlugin");
  }
View Full Code Here

   */
  @RequestMapping(params = "sqlPluginSave")
  @ResponseBody
  public AjaxJson sqlPluginSave(String id,String sql_plug_in,
      HttpServletRequest request) {
    CgFormHeadEntity bean = cgFormFieldService.getEntity(
        CgFormHeadEntity.class, id);
    //bean.setSqlPlugIn(sql_plug_in);
    cgFormFieldService.updateTable(bean,null);
    message = "保存成功";
    systemService.addLog(message, Globals.Log_Type_INSERT,
View Full Code Here

   * js插件 页面跳转
   * @return
   */
  @RequestMapping(params = "jsPlugin")
  public ModelAndView jsPlugin(String id,HttpServletRequest request) {
    CgFormHeadEntity bean = cgFormFieldService.getEntity(
        CgFormHeadEntity.class, id);
    request.setAttribute("bean", bean);
    return new ModelAndView("jeecg/cgform/config/cgFormJsPlugin");
  }
View Full Code Here

   */
  @RequestMapping(params = "jsPluginSave")
  @ResponseBody
  public AjaxJson jsPluginSave(String id,String js_plug_in,
      HttpServletRequest request) {
    CgFormHeadEntity bean = cgFormFieldService.getEntity(
        CgFormHeadEntity.class, id);
    //bean.setJsPlugIn(js_plug_in);停用jsPlugIn这个字段
    cgFormFieldService.updateTable(bean,null);
    message = "保存成功";
    systemService.addLog(message, Globals.Log_Type_INSERT,
View Full Code Here

          String version = cgFormFieldService.getCgFormVersionByTableName(tableName);
          //装载表单配置
        Map configData = cgFormFieldService.getFtlFormConfig(tableName,version);
        data = new HashMap(configData);
        //如果该表是主表查出关联的附表
        CgFormHeadEntity head = (CgFormHeadEntity)data.get("head");
          Map<String, Object> dataForm = new HashMap<String, Object>();
          if(StringUtils.isNotEmpty(id)){
            dataForm = dataBaseService.findOneForJdbc(tableName, id);
          }
          Iterator it=dataForm.entrySet().iterator();
        while(it.hasNext()){
          Map.Entry entry=(Map.Entry)it.next();
            String ok=(String)entry.getKey();
            Object ov=entry.getValue();
            data.put(ok, ov);
        }
          Map<String, Object> tableData  = new HashMap<String, Object>();
          //获取主表或单表表单数据
          tableData.put(tableName, dataForm);
          //获取附表表表单数据
        if(StringUtils.isNotEmpty(id)){
          if(head.getJformType()==CgAutoListConstant.JFORM_TYPE_MAIN_TALBE){
            String subTableStr = head.getSubTableStr();
            if(StringUtils.isNotEmpty(subTableStr)){
               String [] subTables = subTableStr.split(",");
               List<Map<String,Object>> subTableData = new ArrayList<Map<String,Object>>();
               for(String subTable:subTables){
                  subTableData = cgFormFieldService.getSubTableData(tableName,subTable,id);
View Full Code Here

    // step.2 扫描字段配置,循环处理填有主表以及主表字段的条目
    for (CgFormFieldEntity fieldE : columns) {
      String mainT = fieldE.getMainTable();
      String mainF = fieldE.getMainField();
      if (!StringUtil.isEmpty(mainT) && !StringUtil.isEmpty(mainF)) {
        CgFormHeadEntity mainE = this.getCgFormHeadByTableName(mainT);
        if (mainE == null) {
          continue;
        }
        // step.4 追加处理主表的附表串
        String subTableStr = String
            .valueOf(mainE.getSubTableStr() == null ? "" : mainE
                .getSubTableStr());
        // step.5 判断是否已经存在于附表串
        if (!subTableStr.contains(thisSubTable)) {
          // step.6 追加到附表串
          if (!StringUtil.isEmpty(subTableStr)) {
            subTableStr += "," + thisSubTable;
          } else {
            subTableStr += thisSubTable;
          }
          mainE.setSubTableStr(subTableStr);
          logger.info("--主表" + mainE.getTableName() + "的附表串:"
              + mainE.getSubTableStr());
        }
        // step.7 更新主表的表配置
        this.updateTable(mainE, "sign");
      }
    }
View Full Code Here

    // step.2 扫描字段配置,循环处理填有主表以及主表字段的条目
    for (CgFormFieldEntity fieldE : columns) {
      String mainT = fieldE.getMainTable();
      String mainF = fieldE.getMainField();
      if (!StringUtil.isEmpty(mainT) && !StringUtil.isEmpty(mainF)) {
        CgFormHeadEntity mainE = this.getCgFormHeadByTableName(mainT);
        if (mainE == null) {
          continue;
        }
        // step.4 追加处理主表的附表串
        String subTableStr = String
            .valueOf(mainE.getSubTableStr() == null ? "" : mainE
                .getSubTableStr());
        // step.5 判断是否已经存在于附表串
        if (subTableStr.contains(thisSubTable)) {
          // step.6 剔除主表的附表串
          if (subTableStr.contains(thisSubTable + ",")) {
            subTableStr = subTableStr.replace(thisSubTable + ",",
                "");
          } else if(subTableStr.contains(","+thisSubTable)){
            subTableStr = subTableStr.replace("," + thisSubTable,
                "");
          } else{
            subTableStr = subTableStr.replace(thisSubTable,"");
          }
          mainE.setSubTableStr(subTableStr);
          logger.info("--主表" + mainE.getTableName() + "的附表串:"
              + mainE.getSubTableStr());
          // step.7 更新主表的表配置,不用更新,因为hibernate是读取的缓存,所以和那边操作的对象是一个的
          //this.updateTable(mainE, null);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.jeecgframework.web.cgform.entity.config.CgFormHeadEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.