Package org.jeecgframework.core.util

Examples of org.jeecgframework.core.util.ReflectHelper


    String fileid = request.getParameter("fileid");
    String subclassname = oConvertUtils.getString(request.getParameter("subclassname"), "org.jeecgframework.web.system.pojo.base.TSAttachment");
    String contentfield = oConvertUtils.getString(request.getParameter("contentfield"));
    Class fileClass = MyClassLoader.getClassByScn(subclassname);// 附件的实际类
    Object fileobj = systemService.getEntity(fileClass, fileid);
    ReflectHelper reflectHelper = new ReflectHelper(fileobj);
    String extend = oConvertUtils.getString(reflectHelper.getMethodValue("extend"));
    if ("dwg".equals(extend)) {
      String realpath = oConvertUtils.getString(reflectHelper.getMethodValue("realpath"));
      request.setAttribute("realpath", realpath);
      return new ModelAndView("common/upload/dwgView");
    } else if (FileUtils.isPicture(extend)) {
      String realpath = oConvertUtils.getString(reflectHelper.getMethodValue("realpath"));
      request.setAttribute("realpath", realpath);
      request.setAttribute("fileid", fileid);
      request.setAttribute("subclassname", subclassname);
      request.setAttribute("contentfield", contentfield);
      return new ModelAndView("common/upload/imageView");
    } else {
      String swfpath = oConvertUtils.getString(reflectHelper.getMethodValue("swfpath"));
      request.setAttribute("swfpath", swfpath);
      return new ModelAndView("common/upload/swfView");
    }

  }
View Full Code Here


  public void viewFile(HttpServletRequest request, HttpServletResponse response) {
    String fileid =oConvertUtils.getString(request.getParameter("fileid"));
    String subclassname = oConvertUtils.getString(request.getParameter("subclassname"), "com.jeecg.base.pojo.TSAttachment");
    Class fileClass = MyClassLoader.getClassByScn(subclassname);// 附件的实际类
    Object fileobj = systemService.getEntity(fileClass, fileid);
    ReflectHelper reflectHelper = new ReflectHelper(fileobj);
    UploadFile uploadFile = new UploadFile(request, response);
    String contentfield = oConvertUtils.getString(request.getParameter("contentfield"), uploadFile.getByteField());
    byte[] content = (byte[]) reflectHelper.getMethodValue(contentfield);
    String path = oConvertUtils.getString(reflectHelper.getMethodValue("realpath"));
    String extend = oConvertUtils.getString(reflectHelper.getMethodValue("extend"));
    String attachmenttitle = oConvertUtils.getString(reflectHelper.getMethodValue("attachmenttitle"));
    uploadFile.setExtend(extend);
    uploadFile.setTitleField(attachmenttitle);
    uploadFile.setRealPath(path);
    uploadFile.setContent(content);
    //uploadFile.setView(true);
View Full Code Here

    return updateSql.toString();
  }
 
  public static SqlParameterSource generateParameterMap(Object t, List<String> ignores){
    Map<String, Object> paramMap = new HashMap<String, Object>();
    ReflectHelper reflectHelper = new ReflectHelper(t);
    PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(t.getClass());
    for (PropertyDescriptor pd : pds) {
      if(null != ignores && ignores.contains(pd.getName())){
        continue;
      }
      paramMap.put(pd.getName(), reflectHelper.getMethodValue(pd.getName()));
    }
    MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(paramMap);
    return sqlParameterSource;
  }
View Full Code Here

   * updateDate,updateBy,updateName
   * @param obj
   * @param isUpdate
   */
  public static void setCommonForTable(Object obj, boolean isCreate){
    ReflectHelper reflectHelper=new ReflectHelper(obj);
    if(isCreate){
      reflectHelper.setMethodValue("createDate", new Date());
      reflectHelper.setMethodValue("createBy", ResourceUtil.getSessionUserName().getId());
      reflectHelper.setMethodValue("createName", ResourceUtil.getSessionUserName().getUserName());
    }
    reflectHelper.setMethodValue("updateDate", new Date());
    reflectHelper.setMethodValue("updateBy", ResourceUtil.getSessionUserName().getId());
    reflectHelper.setMethodValue("updateName", ResourceUtil.getSessionUserName().getUserName());
  }
View Full Code Here

   * 设置checkbox的值 -- Y/N
   * @param obj
   * @param params 以逗号隔开  "isNull,isShow,isQuery,isKey"
   */
  public static void judgeCheckboxValue(Object obj,String params){
    ReflectHelper reflectHelper=new ReflectHelper(obj);
    String [] paramsArr = params.split(",");
    for(int i = 0;i<paramsArr.length;i++){
        String checked = "N";
        if(reflectHelper.getMethodValue(paramsArr[i])!=null
            &&!"N".equalsIgnoreCase((String)reflectHelper.getMethodValue(paramsArr[i]))){
          checked = "Y";
        }
      reflectHelper.setMethodValue(paramsArr[i],checked);
    }
   
  }
View Full Code Here

      String id = "";
      String countSql = "";
      SqlParameterSource sqlParameterSource;
      List<Map<String, Object>> idList = new ArrayList<Map<String,Object>>();
      for (T t : dataList) {
        ReflectHelper reflectHelper = new ReflectHelper(t);
        List<String> ignores = new ArrayList<String>();
        ignores.add("class");
        PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(clazz);
        for (PropertyDescriptor pd : pds) {
          if(null == reflectHelper.getMethodValue(pd.getName())){
            ignores.add(pd.getName());
          }
        }
        if(t instanceof CgFormHeadPojo){
          reflectHelper.setMethodValue("isDbsynch", "N");
        }
        id = (String) reflectHelper.getMethodValue("id");
        countSql = "select id from "+ dbTable.getTableName() + " where id=?";
        if(t instanceof CgFormHeadPojo){
          countSql = "select id from "+ dbTable.getTableName() + " where table_name=?";
          id = oConvertUtils.getString(reflectHelper.getMethodValue("tableName"));
        }
        idList = jdbcTemplate.queryForList(countSql, id);
        sqlParameterSource = MigrateForm.generateParameterMap(t, ignores);
        if(idList.size() > 0 && t instanceof CgFormHeadPojo){
          idMap.put("id", oConvertUtils.getString(idList.get(0).get("id")));
View Full Code Here

   */
  public static Object fieldNametoValues(String FiledName, Object o){
    Object value = "";
    String fieldName = "";
    String childFieldName = null;
    ReflectHelper reflectHelper=new ReflectHelper(o);
    if (FiledName.indexOf("_") == -1) {
      if(FiledName.indexOf(".") == -1){
        fieldName = FiledName;
      }else{
        fieldName = FiledName.substring(0, FiledName.indexOf("."));//外键字段引用名
        childFieldName = FiledName.substring(FiledName.indexOf(".") + 1);//外键字段名
      }
    } else {
      fieldName = FiledName.substring(0, FiledName.indexOf("_"));//外键字段引用名
      childFieldName = FiledName.substring(FiledName.indexOf("_") + 1);//外键字段名
    }
    value = reflectHelper.getMethodValue(fieldName)==null?"":reflectHelper.getMethodValue(fieldName);
    if (value !=""&&value != null && (FiledName.indexOf("_") != -1||FiledName.indexOf(".") != -1)) {
      value = fieldNametoValues(childFieldName, value);
    }
    if(value != "" && value != null) {
      value = value.toString().replaceAll("\r\n", "");
View Full Code Here

    List<ComboBox> comboxBoxs = new ArrayList<ComboBox>();
    String[] fields = new String[] { comboBox.getId(), comboBox.getText() };
    Object[] values = new Object[fields.length];
    for (Object node : all) {
      ComboBox box = new ComboBox();
      ReflectHelper reflectHelper=new ReflectHelper(node);
      for (int i = 0; i < fields.length; i++) {
        String fieldName = fields[i].toString();
        values[i] = reflectHelper.getMethodValue(fieldName);
      }
      box.setId(values[0].toString());
      box.setText(values[1].toString());
      if (in != null) {
        for (Object node1 : in) {
          ReflectHelper reflectHelper2=new ReflectHelper(node);
          if (node1 != null) {
            String fieldName = fields[0].toString();
            String  test = reflectHelper2.getMethodValue(fieldName).toString();
            if (values[0].toString().equals(test)) {
              box.setSelected(true);
            }
          }
        }
View Full Code Here

    }
    else {
    try {
      uploadFile.getMultipartRequest().setCharacterEncoding("UTF-8");
      MultipartHttpServletRequest multipartRequest = uploadFile.getMultipartRequest();
      ReflectHelper reflectHelper = new ReflectHelper(uploadFile.getObject());
      String uploadbasepath = uploadFile.getBasePath();// 文件上传根目录
      if (uploadbasepath == null) {
        uploadbasepath = ResourceUtil.getConfigByName("uploadpath");
      }
      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
      // 文件数据库保存路径
      String path = uploadbasepath + "/";// 文件保存在硬盘的相对路径
      String realPath = uploadFile.getMultipartRequest().getSession().getServletContext().getRealPath("/") + "/" + path;// 文件的硬盘真实路径
      File file = new File(realPath);
      if (!file.exists()) {
        file.mkdirs();// 创建根目录
      }
      if (uploadFile.getCusPath() != null) {
        realPath += uploadFile.getCusPath() + "/";
        path += uploadFile.getCusPath() + "/";
        file = new File(realPath);
        if (!file.exists()) {
          file.mkdirs();// 创建文件自定义子目录
        }
      }
      else {
        realPath += DataUtils.getDataString(DataUtils.yyyyMMdd) + "/";
        path += DataUtils.getDataString(DataUtils.yyyyMMdd) + "/";
        file = new File(realPath);
        if (!file.exists()) {
          file.mkdir();// 创建文件时间子目录
        }
      }
      String entityName = uploadFile.getObject().getClass().getSimpleName();
      // 设置文件上传路径
      if (entityName.equals("TSTemplate")) {
        realPath = uploadFile.getMultipartRequest().getSession().getServletContext().getRealPath("/") + ResourceUtil.getConfigByName("templatepath") + "/";
        path = ResourceUtil.getConfigByName("templatepath") + "/";
      } else if (entityName.equals("TSIcon")) {
        realPath = uploadFile.getMultipartRequest().getSession().getServletContext().getRealPath("/") + uploadFile.getCusPath() + "/";
        path = uploadFile.getCusPath() + "/";
      }
      String fileName = "";
      String swfName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        swfName = PinyinUtil.getPinYinHeadChar(oConvertUtils.replaceBlank(FileUtils.getFilePrefix(fileName)));// 取文件名首字母作为SWF文件名
        String extend = FileUtils.getExtend(fileName);// 获取文件扩展名
        String myfilename="";
        String noextfilename="";//不带扩展名
        if(uploadFile.isRename())
        {
          
           noextfilename=DataUtils.getDataString(DataUtils.yyyymmddhhmmss)+StringUtil.random(8);//自定义文件名称
           myfilename=noextfilename+"."+extend;//自定义文件名称
        }
        else {
          myfilename=fileName;
        }
       
        String savePath = realPath + myfilename;// 文件保存全路径
        String fileprefixName = FileUtils.getFilePrefix(fileName);
        if (uploadFile.getTitleField() != null) {
          reflectHelper.setMethodValue(uploadFile.getTitleField(), fileprefixName);// 动态调用set方法给文件对象标题赋值
        }
        if (uploadFile.getExtend() != null) {
          // 动态调用 set方法给文件对象内容赋值
          reflectHelper.setMethodValue(uploadFile.getExtend(), extend);
        }
        if (uploadFile.getByteField() != null) {
          // 二进制文件保存在数据库中
          reflectHelper.setMethodValue(uploadFile.getByteField(), StreamUtils.InputStreamTOByte(mf.getInputStream()));
        }
        File savefile = new File(savePath);
        if (uploadFile.getRealPath() != null) {
          // 设置文件数据库的物理路径
          reflectHelper.setMethodValue(uploadFile.getRealPath(), path + myfilename);
        }
        saveOrUpdate(object);
        // 文件拷贝到指定硬盘目录
        FileCopyUtils.copy(mf.getBytes(), savefile);
//        if (uploadFile.getSwfpath() != null) {
//          // 转SWF
//          reflectHelper.setMethodValue(uploadFile.getSwfpath(), path + swfName + ".swf");
//          SwfToolsUtil.convert2SWF(savePath);
//        }
//        FileCopyUtils.copy(mf.getBytes(), savefile);
        if (uploadFile.getSwfpath() != null) {
          // 转SWF
          reflectHelper.setMethodValue(uploadFile.getSwfpath(), path + FileUtils.getFilePrefix(myfilename) + ".swf");
          SwfToolsUtil.convert2SWF(savePath);
        }

      }
    } catch (Exception e1) {
View Full Code Here

  // 构建ComboTree
  private ComboTree comboTree(Object obj, ComboTreeModel comboTreeModel, List in, boolean recursive) {
    ComboTree tree = new ComboTree();
    Map<String, Object> attributes = new HashMap<String, Object>();
    ReflectHelper reflectHelper = new ReflectHelper(obj);
    String id = oConvertUtils.getString(reflectHelper.getMethodValue(comboTreeModel.getIdField()));
    tree.setId(id);
    tree.setText(oConvertUtils.getString(reflectHelper.getMethodValue(comboTreeModel.getTextField())));
    if (comboTreeModel.getSrcField() != null) {
      attributes.put("href", oConvertUtils.getString(reflectHelper.getMethodValue(comboTreeModel.getSrcField())));
      tree.setAttributes(attributes);
    }
    if (in == null) {
    } else {
      if (in.size() > 0) {
        for (Object inobj : in) {
          ReflectHelper reflectHelper2 = new ReflectHelper(inobj);
          String inId = oConvertUtils.getString(reflectHelper2.getMethodValue(comboTreeModel.getIdField()));
          if (inId == id) {
            tree.setChecked(true);
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.jeecgframework.core.util.ReflectHelper

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.