本文整理汇总了Java中ch.rasc.extclassgenerator.Model类的典型用法代码示例。如果您正苦于以下问题:Java Model类的具体用法?Java Model怎么用?Java Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Model类属于ch.rasc.extclassgenerator包,在下文中一共展示了Model类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getModelName
import ch.rasc.extclassgenerator.Model; //导入依赖的package包/类
protected static String getModelName(Class<?> model) {
Model modelAnnotation = model.getAnnotation(Model.class);
if (modelAnnotation != null && StringUtils.hasText(modelAnnotation.value())) {
return modelAnnotation.value();
}
return model.getName();
}
开发者ID:ralscha,项目名称:extclassgenerator,代码行数:9,代码来源:AbstractAssociation.java
示例2: generateModel
import ch.rasc.extclassgenerator.Model; //导入依赖的package包/类
public void generateModel() throws IOException{
String packagePath = Util.join(File.separatorChar, ProjectConfig.getProperty("package.pojo").split("\\."));
Map<TableDef, List<FieldEntry>> metaMap = mapper.fetchDatabaseMeta(ProjectConfig.getProperty("db.url")
, ProjectConfig.getProperty("db.username")
, ProjectConfig.getProperty("db.password"));
Resource template = new ClassPathResource(TEMPLATE_FILE_PATH);
BufferedReader templateReader = new BufferedReader(new InputStreamReader(template.getInputStream()));
List<String> mustache = new ArrayList<String>();
String line;
while((line=templateReader.readLine())!=null){
mustache.add(line);
}
templateReader.close();
for(Map.Entry<TableDef, List<FieldEntry>> entry : metaMap.entrySet()){
// System.err.println(entry.getKey().toJSON());
// System.err.println(Util.getJsonObject(entry.getValue()));
// System.err.println();
TableDef tableDef = entry.getKey();
List<FieldEntry> entries = entry.getValue();
Resource resource = new FileSystemResource(CWD_RELATIVE_PATH+packagePath+File.separatorChar+Util.qualifyModelName(tableDef.getTableName())+SOURCE_FILE_AFFIX);
//Writer is ready, now start to write something to the opened file
PrintWriter writer = new PrintWriter(resource.getFile());
ModelConfig modelConfig = new ModelConfig();
modelConfig.setFieldEntries(entries);
modelConfig.setModelDescription(Util.conditionedGet(tableDef.getTableDescription(), "No Description Available"));
modelConfig.setModelName(Util.qualifyModelName(tableDef.getTableName()));
modelConfig.setPackageName(ProjectConfig.getProperty("package.pojo"));
modelConfig.setSchema(Util.conditionedGet(tableDef.getTableCatalog(), tableDef.getTableSchema()));
modelConfig.setSuperClsPath(EntityObject.class.getName());
modelConfig.setTable(tableDef.getTableName());
modelConfig.setExtPackageName(ProjectConfig.getProperty("extjs.model.package"));
Set<String> importInfos = new HashSet<String>();
importInfos.add(modelConfig.getSuperClsPath());
importInfos.add(Table.class.getName());
importInfos.add(Column.class.getName());
importInfos.add(Model.class.getName());
for(FieldEntry fieldEntry : entries){
@SuppressWarnings("rawtypes")
Class cls = mapper.mapFieldType(fieldEntry);
if(fieldEntry.isDateType()){
importInfos.add(ModelField.class.getName());
fieldEntry.setExtDateFormat(ProjectConfig.getProperty("extjs.format.date"));
}
String clsName = cls.getName();
if(clsName.split("\\.").length>1){
if(!clsName.contains("java.lang."))
importInfos.add(cls.getName());
}
if(tableDef.getPkColumnNames().contains(fieldEntry.getMappedFieldName())){
importInfos.add(Id.class.getName());
fieldEntry.setPrimaryKey(true);
}
fieldEntry.setFieldName(Util.qualifyFieldName(fieldEntry.getMappedFieldName()));
fieldEntry.setQualifiedFieldName(Util.repairName(fieldEntry.getFieldName()));
fieldEntry.setTypeName(cls.getSimpleName());
}
modelConfig.setImportInfos(importInfos);
Util.render(mustache, writer, modelConfig.toJSON());
writer.flush();
writer.close();
}
}
开发者ID:doomdagger,项目名称:s_framework,代码行数:82,代码来源:EntityGenerator.java
注:本文中的ch.rasc.extclassgenerator.Model类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论