Java Code Examples for com.jfinal.plugin.activerecord.generator.MetaBuilder#build()
The following examples show how to use
com.jfinal.plugin.activerecord.generator.MetaBuilder#build() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: _JFCodeGenerator.java From sdb-mall with Apache License 2.0 | 6 votes |
public TableMeta getTableMeta(String tableName) { if (tablemetaMap == null) { DataSource dataSource = _JFinalGenerator.getDataSource(); MetaBuilder metaBuilder = new MetaBuilder(dataSource); metaBuilder.setDialect(new MysqlDialect()); metaBuilder.addExcludedTable(_JFinalGenerator.excludedTable); List<TableMeta> tableMetas = metaBuilder.build(); new DataGenerator(dataSource, null).rebuildColumnMetas(tableMetas); if (tableMetas.size() == 0) { System.out.println("TableMeta 数量为 0,不生成任何文件"); return null; } Kv kv = Kv.create(); for (TableMeta tableMeta : tableMetas) { kv.set(tableMeta.name, tableMeta); } tablemetaMap = kv; } return (TableMeta) tablemetaMap.get(tableName); }
Example 2
Source File: SystemGenerator.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
public static void main(String[] args) { String dbTables = "user,attachment,menu,option,payment_record,permission,role,utm," + "wechat_menu,wechat_reply," + "member,member_group,member_dist_amount,member_joined_record,member_price," + "user_address,user_amount,user_amount_statement,user_amount_payout," + "coupon,coupon_code,coupon_used_record," + "user_cart,user_order,user_order_item,user_order_delivery,user_order_invoice," + "user_openid,user_favorite,user_tag," + "payment_record"; String optionsTables = "coupon,member,member_group,product,product_category,user_address," + "user_amount_statement,user_amount_payout,user_cart,user_order,user_order_item,user_order_delivery,user_order_invoice," + "payment_record,user_openid,member_joined_record,user_favorite,user_tag"; JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jpress3"); JbootApplication.setBootArg("jboot.datasource.user", "root"); JbootApplication.setBootArg("jboot.datasource.password", "123456"); String modelPackage = "io.jpress.model"; String baseModelPackage = modelPackage + ".base"; String modelDir = PathKit.getWebRootPath() + "/../jpress-model/src/main/java/" + modelPackage.replace(".", "/"); String baseModelDir = PathKit.getWebRootPath() + "/../jpress-model/src/main/java/" + baseModelPackage.replace(".", "/"); System.out.println("start generate...dir:" + modelDir); Set<String> genTableNames = StrUtil.splitToSet(dbTables, ","); MetaBuilder metaBuilder = CodeGenHelpler.createMetaBuilder(); metaBuilder.setGenerateRemarks(true); List<TableMeta> tableMetas = metaBuilder.build(); tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase())); new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas); new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas); String servicePackage = "io.jpress.service"; String apiPath = PathKit.getWebRootPath() + "/../jpress-service-api/src/main/java/" + servicePackage.replace(".", "/"); String providerPath = PathKit.getWebRootPath() + "/../jpress-service-provider/src/main/java/" + servicePackage.replace(".", "/") + "/provider"; new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas); new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas); Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ","); if (optionsTableNames != null && optionsTableNames.size() > 0) { tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase())); new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas); } }
Example 3
Source File: AddonGenerator.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
private void genCode() { JbootApplication.setBootArg("jboot.datasource.url", dbUrl); JbootApplication.setBootArg("jboot.datasource.user", dbUser); JbootApplication.setBootArg("jboot.datasource.password", dbPassword); String baseModelPackage = modelPackage + ".base"; String modelDir = basePath + "/src/main/java/" + modelPackage.replace(".", "/"); String baseModelDir = basePath + "/src/main/java/" + baseModelPackage.replace(".", "/"); System.out.println("start generate... dir:" + modelDir); MetaBuilder metaBuilder = CodeGenHelpler.createMetaBuilder(); metaBuilder.setGenerateRemarks(true); List<TableMeta> tableMetas = metaBuilder.build(); Set<String> genTableNames = StrUtil.splitToSet(dbTables, ","); tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase())); new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas); new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas); String apiPath = basePath + "/src/main/java/" + servicePackage.replace(".", "/"); String providerPath = basePath + "/src/main/java/" + servicePackage.replace(".", "/") + "/provider"; new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas); new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas); if (genUI) { new AddonUIGenerator(basePath, addonName, modelPackage, tableMetas) .genControllers() .genEdit() .genList(); } Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ","); if (optionsTableNames != null && optionsTableNames.size() > 0) { tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase())); new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas); } }
Example 4
Source File: ModuleGenerator.java From jpress with GNU Lesser General Public License v3.0 | 2 votes |
private void genCode() { String modelModuleName = "/module-" + moduleName + "-model"; String serviceApiModuleName = "/module-" + moduleName + "-service-api"; String serviceProviderModuleName = "/module-" + moduleName + "-service-provider"; JbootApplication.setBootArg("jboot.datasource.url", dbUrl); JbootApplication.setBootArg("jboot.datasource.user", dbUser); JbootApplication.setBootArg("jboot.datasource.password", dbPassword); String baseModelPackage = modelPackage + ".base"; String modelDir = basePath + modelModuleName + "/src/main/java/" + modelPackage.replace(".", "/"); String baseModelDir = basePath + modelModuleName + "/src/main/java/" + baseModelPackage.replace(".", "/"); System.out.println("start generate... dir:" + modelDir); Set<String> genTableNames = StrUtil.splitToSet(dbTables, ","); MetaBuilder mb = CodeGenHelpler.createMetaBuilder(); mb.setGenerateRemarks(true); List<TableMeta> tableMetas = mb.build(); tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase())); new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas); new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas); String apiPath = basePath + serviceApiModuleName + "/src/main/java/" + servicePackage.replace(".", "/"); String providerPath = basePath + serviceProviderModuleName + "/src/main/java/" + servicePackage.replace(".", "/") + "/provider"; new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas); new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas); if (genUI) { new ModuleUIGenerator(moduleName, modelPackage, tableMetas).genListener().genControllers().genEdit().genList(); } Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ","); if (optionsTableNames != null && optionsTableNames.size() > 0) { tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase())); new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas); } }