コード例 #1
0
 public static Map getShareVars() {
   Map templateModel = new HashMap();
   templateModel.putAll(System.getProperties());
   templateModel.putAll(GeneratorProperties.getProperties());
   templateModel.put("env", System.getenv());
   templateModel.put("now", new Date());
   templateModel.put(
       GeneratorConstants.DATABASE_TYPE.code,
       GeneratorProperties.getDatabaseType(GeneratorConstants.DATABASE_TYPE.code));
   templateModel.putAll(GeneratorContext.getContext());
   templateModel.putAll(getToolsMap());
   return templateModel;
 }
コード例 #2
0
 public Connection getConnection() {
   try {
     if (connection == null || connection.isClosed()) {
       loadJdbcDriver();
       connection =
           DriverManager.getConnection(
               GeneratorProperties.getRequiredProperty("jdbc.url"),
               GeneratorProperties.getRequiredProperty("jdbc.username"),
               GeneratorProperties.getProperty("jdbc.password"));
     }
     return connection;
   } catch (SQLException e) {
     throw new RuntimeException(e);
   }
 }
コード例 #3
0
 private void loadJdbcDriver() {
   String driver = GeneratorProperties.getRequiredProperty("jdbc.driver");
   try {
     Class.forName(driver);
   } catch (ClassNotFoundException e) {
     throw new RuntimeException("not found jdbc driver class:[" + driver + "]", e);
   }
 }
コード例 #4
0
  public void test() {
    //		GeneratorProperties.("badqiu_birth", new Date());
    GeneratorProperties.setProperty("badqiu_name", "com.badqiu");
    GeneratorModel gm = GeneratorModelUtils.newGeneratorModel("clazz", javaClass);
    assertEquals(gm.templateModel.get("badqiu_name_dir"), null);
    assertEquals(gm.templateModel.get("badqiu_name"), "com.badqiu");
    assertEquals(gm.templateModel.get("clazz"), javaClass);

    assertEquals(gm.filePathModel.get("badqiu_name_dir"), null);
    assertEquals(gm.filePathModel.get("badqiu_name"), "com.badqiu");

    assertEquals(gm.filePathModel.get("className"), javaClass.getClassName());
    assertEquals(GeneratorFacadeTest.class, gm.filePathModel.get("clazz"));
  }
コード例 #5
0
ファイル: GLogger.java プロジェクト: Gyoung/rapid_framework
 public static void debug(String string, Map templateModel) {
   if (logLevel <= DEBUG) {
     GLogger.println(string);
     if (templateModel == null) return;
     for (Object key : templateModel.keySet()) {
       if (System.getProperties().containsKey(key)
           || GeneratorProperties.getProperties().containsKey(key)) {
         continue;
       }
       if (key.toString().endsWith("_dir")) {
         continue;
       }
       GLogger.println(key + " = " + templateModel.get(key));
     }
   }
 }
コード例 #6
0
 /** 得到模板可以引用的工具类 */
 private static Map getToolsMap() {
   Map toolsMap = new HashMap();
   String[] tools = GeneratorProperties.getStringArray(GENERATOR_TOOLS_CLASS);
   for (String className : tools) {
     try {
       Object instance = ClassHelper.newInstance(className);
       toolsMap.put(Class.forName(className).getSimpleName(), instance);
       GLogger.debug(
           "put tools class:"
               + className
               + " with key:"
               + Class.forName(className).getSimpleName());
     } catch (Exception e) {
       GLogger.error("cannot load tools by className:" + className + " cause:" + e);
     }
   }
   return toolsMap;
 }
コード例 #7
0
 public GeneratorFacade() {
   if (StringHelper.isNotBlank(GeneratorProperties.getProperty("outRoot"))) {
     generator.setOutRootDir(GeneratorProperties.getProperty("outRoot"));
   }
 }
コード例 #8
0
 public String getSchema() {
   return GeneratorProperties.getNullIfBlank("jdbc.schema");
 }
コード例 #9
0
 public String getCatalog() {
   return GeneratorProperties.getNullIfBlank("jdbc.catalog");
 }