Package com.thinkgem.jeesite.modules.prj.utils

Examples of com.thinkgem.jeesite.modules.prj.utils.SourceTable


    } catch (IOException e) {
      logger.error("模板设置失败");
    }
    Map<String,ERTable> map = findAllTable(project);
    for(ERTable erTable:map.values()) {
      SourceTable sourceTable = new SourceTable(project,erTable);
      if(sourceTable.getPhysicalNames().contains("id")) {
        //生成所有Controller
        Map<String, Object> model = Maps.newHashMap();
        TreeSet<String> importList = Sets.newTreeSet();
        String templateFile = "";
        if(sourceTable.isContainsParentIds()) {
          templateFile="tree/controller.ftl";
        } else  if(sourceTable.isContainsProcessInstanceId()) {
          templateFile="process/controller.ftl";
        } else {
          templateFile="normal/controller.ftl";
        }
        importList.addAll(SourceUtils.getImportList(SourceUtils.SOURCE_TYPE_CONTROLLER));
        model.put("sourceTable", sourceTable);
        model.put("importList", importList);
        model.put("f", SourceUtils.getFreemarkerMap());
        // 生成 Entity
        Template template=null;
        try {
          template = cfg.getTemplate(templateFile);
        } catch (IOException e) {
          logger.error("获取模板出错");
        }
        String content = FreeMarkers.renderTemplate(template, model);
        String filePath = generateRootPath+"\\src\\main\\java\\"+ project.getRootPackage().replace(".", "\\") + "\\modules\\" + sourceTable.getModuleName() + "\\controller\\"+ sourceTable.getControllerClassName() +".java";
        FileUtils.writeFile(content, filePath);
        //生成所有Service
       
        //生成所有form.jsp
       
View Full Code Here


      logger.error("模板设置失败");
    }
    Map<String,ERTable> map = findAllTable(project);
    //生成所有Entity
    for(ERTable erTable:map.values()) {
      SourceTable sourceTable = new SourceTable(project,erTable);
      if(sourceTable.getPhysicalNames().contains("id")) {
        // 定义模板变量
        Map<String, Object> model = Maps.newHashMap();
        TreeSet<String> importList = Sets.newTreeSet();
        for(SourceColumn sourceColumn:sourceTable.getSourceColumnList()) {
          //计算需要import的项目
          if(Collections3.isEmpty(sourceColumn.getNormalColumn().getRelationList())){
            String importName = sourceColumn.getImportName();
            if(StringUtils.isNotBlank(importName)) {
              importList.add(importName);
            }
          }
          if(!Collections3.isEmpty(sourceColumn.getSourceRelationList())) {
            for(SourceRelation sourceRelation:sourceColumn.getSourceRelationList()) {
              importList.addAll(sourceRelation.getImportList(project));
            }
          }
        }
        importList.addAll(SourceUtils.getImportList(SourceUtils.SOURCE_TYPE_ENTITY));
        model.put("sourceTable", sourceTable);
        model.put("importList", importList);
        // 生成 Entity
        Template template=null;
        try {
          template = cfg.getTemplate("entity.ftl");
        } catch (IOException e) {
          logger.error("获取模板出错");
        }
        String content = FreeMarkers.renderTemplate(template, model);
        String filePath = generateRootPath+"\\src\\main\\java\\"+ project.getRootPackage().replace(".", "\\") + "\\modules\\" + sourceTable.getModuleName() + "\\entity\\"+ sourceTable.getEntityClassName() +".java";
        FileUtils.writeFile(content, filePath);
      }
    }
    //生成所有Dao
    for(ERTable erTable:map.values()) {
      SourceTable sourceTable = new SourceTable(project,erTable);
      if(sourceTable.getPhysicalNames().contains("id")) {
        // 定义模板变量
        Map<String, Object> model = Maps.newHashMap();
        TreeSet<String> importList = Sets.newTreeSet();
        model.put("sourceTable", sourceTable);
        model.put("importList", importList);
        importList.add(sourceTable.getEntityPackage() + "." + sourceTable.getEntityClassName());
        importList.addAll(SourceUtils.getImportList(SourceUtils.SOURCE_TYPE_DAO));
        // 生成 Entity
        Template template=null;
        try {
          template = cfg.getTemplate("dao.ftl");
        } catch (IOException e) {
          logger.error("获取模板出错");
        }
        String content = FreeMarkers.renderTemplate(template, model);
        String filePath = generateRootPath+"\\src\\main\\java\\"+ project.getRootPackage().replace(".", "\\") + "\\modules\\" + sourceTable.getModuleName() + "\\dao\\"+ sourceTable.getDaoClassName() +".java";
        FileUtils.writeFile(content, filePath);
      }
    }
   
    FileUtils.zipFiles(generateRootPath, "", zipPath);
View Full Code Here

TOP

Related Classes of com.thinkgem.jeesite.modules.prj.utils.SourceTable

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.