提交 224da2a8 编写于 作者: sq3536's avatar sq3536

拉平model属性

上级 c6c2fbb9
package cn.ibizlab.codegen.model;
public class BaseModel {
protected Object opt;
public <T> T setOpt(Object opt)
{
this.opt=opt;
return (T)this;
}
protected DataObj extParams=new DataObj();
public <T> T set(String key,Object val)
{
extParams.set(key,val);
return (T)this;
}
public Object get(String key)
{
return extParams.get(key);
}
public Object getOpt() {
return opt;
}
public DataObj getExtParams() {
return extParams;
}
public <T> T setExtParams(DataObj extParams) {
this.extParams = extParams;
return (T)this;
}
}
......@@ -9,6 +9,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.ds.IPSDEDataSet;
/**
* 实体[数据集]
......@@ -17,60 +18,42 @@ import lombok.experimental.Accessors;
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@ApiModel("数据集")
public class DataSetModel {
public class DataSetModel extends BaseModel{
/**
* 标识
*/
@JSONField(name = "dataset_id")
@JsonProperty("dataset_id")
@ApiModelProperty("标识")
private String datasetId;
/**
* 名称
*/
@JSONField(name = "dataset_name")
@JsonProperty("dataset_name")
@ApiModelProperty("名称")
private String datasetName;
/**
* 实体标识
*/
@JSONField(name = "entity_id")
@JsonProperty("entity_id")
@ApiModelProperty("实体标识")
private String entityId;
/**
* 实体
*/
@JSONField(name = "entity_name")
@JsonProperty("entity_name")
@ApiModelProperty("实体")
private String entityName;
/**
* 代码名称
*/
@JSONField(name = "code_name")
@JsonProperty("code_name")
@ApiModelProperty("代码名称")
private String codeName;
/**
* 代码
*/
@JSONField(name = "ds_code")
@JsonProperty("ds_code")
@ApiModelProperty("代码")
private String dsCode;
/**
* 模型
*/
@JSONField(name = "ds_model")
@JsonProperty("ds_model")
@ApiModelProperty("模型")
private String dsModel;
public IPSDEDataSet getDataSets()
{
return (IPSDEDataSet)opt;
}
}
......@@ -89,9 +89,8 @@ public class DynamicModelStorage {
IPSSystem iPSSystem=getPSSystem();
IPSDataEntity dataEntity = iPSSystem.getPSDataEntity(entity,true);
Assert.notNull(dataEntity,"未找到对应的实体模型:"+entity);
EntityModel entityModel=new EntityModel();
EntityModel entityModel=new EntityModel().setOpt(dataEntity);
entityModel.setStorageMode(dataEntity.getStorageMode());
entityModel.setEntity(dataEntity);
List<String> dsTypes=new ArrayList<>();
if(dataEntity.getAllPSDEDBConfigs()!=null)
......@@ -111,8 +110,7 @@ public class DynamicModelStorage {
{
for(IPSDERBase der : dataEntity.getMinorPSDERs())
{
RelationshipModel rel=new RelationshipModel();
rel.setRelation(der);
RelationshipModel rel=new RelationshipModel().setOpt(der);
rel.setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getCodeName()).setEntityId(der.getMajorPSDataEntity().getId())
.setEntityCodeName(der.getMajorPSDataEntity().getCodeName()).setEntityName(der.getMajorPSDataEntity().getName())
.setEntityLogicName(der.getMajorPSDataEntity().getLogicName()).setTableName(der.getMajorPSDataEntity().getTableName());
......@@ -141,8 +139,7 @@ public class DynamicModelStorage {
{
if(StringUtils.isEmpty(der.getMinorCodeName()))
continue;
RelationshipModel rel=new RelationshipModel();
rel.setRelation(der);
RelationshipModel rel=new RelationshipModel().setOpt(der);
rel.setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getMinorCodeName()).setEntityId(der.getMinorPSDataEntity().getId())
.setEntityCodeName(der.getMinorPSDataEntity().getCodeName()).setEntityName(der.getMinorPSDataEntity().getName())
.setEntityLogicName(der.getMinorPSDataEntity().getLogicName()).setTableName(der.getMinorPSDataEntity().getTableName());
......@@ -169,8 +166,7 @@ public class DynamicModelStorage {
String dict=null;
try { dict=defield.getPSCodeList()!=null?defield.getPSCodeList().getCodeName():null; } catch (Exception ex){}
FieldModel fieldModel=new FieldModel();
fieldModel.setField(defield);
FieldModel fieldModel=new FieldModel().setOpt(defield);
if(defield.getAllPSDEFDTColumns()!=null)
{
......@@ -347,7 +343,8 @@ public class DynamicModelStorage {
}
}
}
DataSetModel dsModel=new DataSetModel().setDatasetId(entityModel.getEntityName().toLowerCase()+"-ds-"+dataSet.getCodeName()+"-"+entry.getKey().toLowerCase().replace("mysql5","mysql"))
DataSetModel dsModel=new DataSetModel().setOpt(dataSet);
dsModel.setDatasetId(entityModel.getEntityName().toLowerCase()+"-ds-"+dataSet.getCodeName()+"-"+entry.getKey().toLowerCase().replace("mysql5","mysql"))
.setDatasetName(dataSet.getLogicName()).setCodeName(dataSet.getCodeName())
.setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(entry.getValue().toLowerCase().replace("mysql5","mysql")).setDsModel(sql);
entityModel.addDataSet(dsModel);
......
......@@ -19,7 +19,7 @@ import java.util.Map;
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class EntityModel {
public class EntityModel extends BaseModel {
......@@ -53,11 +53,14 @@ public class EntityModel {
public String getModule() {
if(getEntity().getPSSystemModule()!=null)
return getEntity().getPSSystemModule().getCodeName();
return "Ungroup";
return getEntity().getPSSystemModule().getCodeName().toLowerCase();
return "ungroup";
}
private IPSDataEntity entity;
public IPSDataEntity getEntity(){
return (IPSDataEntity)opt;
}
private List<DataSetModel> dataSets;
......@@ -103,7 +106,7 @@ public class EntityModel {
references.forEach(ship->{
if(!StringUtils.isEmpty(ship.getCodeName()))
refMaps.put(ship.getCodeName(),ship);
if(!StringUtils.isEmpty(ship.getRelation())) {
if(!StringUtils.isEmpty(ship.getName())) {
String fkname= DataObject.getStringValue(ship.getRelation().getName(),"");
if(!StringUtils.isEmpty(fkname))
refMaps.put(fkname, ship);
......@@ -135,7 +138,7 @@ public class EntityModel {
{
fieldMap=new LinkedHashMap<>();
fields.forEach(field->{
fieldMap.put(field.getColumnName(),field);
fieldMap.put(field.getFieldName(),field);
fieldMap.put(field.getCodeName(),field);
});
}
......@@ -158,26 +161,11 @@ public class EntityModel {
return lastModifyField;
}
private boolean isLogicValid=true;
public boolean isLogicValid()
{
if(isLogicValid&&logicValidField==null) {
if (fields != null) {
for (FieldModel fieldModel : fields) {
if (fieldModel.isLogicValidField()) {
logicValidField = fieldModel;
return isLogicValid;
}
}
}
isLogicValid = false;
}
return isLogicValid;
return getEntity().isLogicValid();
}
......@@ -185,7 +173,7 @@ public class EntityModel {
public FieldModel getLogicValidField() {
if(isLogicValid&&logicValidField==null) {
if(isLogicValid()&&logicValidField==null) {
if (fields != null) {
for (FieldModel fieldModel : fields) {
if (fieldModel.isLogicValidField()) {
......@@ -194,33 +182,24 @@ public class EntityModel {
}
}
}
isLogicValid = false;
}
return logicValidField;
}
private String validLogicValue;
public String getValidLogicValue()
{
if(StringUtils.isEmpty(validLogicValue))
validLogicValue=this.getEntity().getValidLogicValue();
String validLogicValue=this.getEntity().getValidLogicValue();
if(StringUtils.isEmpty(validLogicValue))
validLogicValue="1";
return validLogicValue;
}
private String invalidLogicValue;
public String getInvalidLogicValue()
{
if(StringUtils.isEmpty(invalidLogicValue))
invalidLogicValue=this.getEntity().getInvalidLogicValue();
String invalidLogicValue=this.getEntity().getInvalidLogicValue();
if(StringUtils.isEmpty(invalidLogicValue))
invalidLogicValue="0";
return invalidLogicValue;
......@@ -233,7 +212,7 @@ public class EntityModel {
public FieldModel getKeyField() {
if(fields!=null&&keyField==null)
for(FieldModel fieldModel:fields)
if(fieldModel.isKeyField()) {
if(fieldModel.isKeyDEField()) {
keyField=fieldModel;
return keyField;
}
......@@ -258,7 +237,7 @@ public class EntityModel {
public List<FieldModel> getKeyFields() {
if(this.getKeyField()!=null&&this.getKeyField().isPhysicalField()) {
if(this.getKeyField()!=null&&this.getKeyField().isPhisicalDEField()) {
List<FieldModel> keyFields = new ArrayList<>();
keyFields.add(getKeyField());
return keyFields;
......@@ -329,12 +308,8 @@ public class EntityModel {
@JSONField(serialize = false)
@JsonIgnore
private Map<String, POSchema> poSchemas;
@JSONField(serialize = false)
@JsonIgnore
public POSchema getDefaultPOSchema()
{
return getPOSchema("default");
......@@ -374,18 +349,7 @@ public class EntityModel {
return null;
}
private DataObj extParams=new DataObj();
public EntityModel set(String key,Object val)
{
extParams.set(key,val);
return this;
}
public Object get(String key)
{
return key;
}
public String getStringValue(String key,String defaultVal)
{
......
......@@ -18,35 +18,32 @@ import java.util.Set;
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
public class FieldModel {
public class FieldModel extends BaseModel {
public String getCodeName() {
return getField().getCodeName();
}
public String getFieldName() {
return getField().getName();
}
public String getColumnName(){
return getField().getName();
}
public String getLogicName() {
return getField().getLogicName();
}
public DataType getType()
public PropType getType()
{
return DataType.findTypeName(this.getField().getStdDataType());
return PropType.findType(this.getField().getStdDataType());
}
private String expression;
private IPSDEField field;
public IPSDEField getField()
{
return (IPSDEField)opt;
}
private RelationshipModel reference;
......@@ -54,45 +51,31 @@ public class FieldModel {
private String refFieldCodeName;
@JsonIgnore
@JSONField(serialize = false)
public boolean isPhysicalField()
public boolean isPhisicalDEField()
{
return this.getField().isPhisicalDEField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isKeyField()
public boolean isKeyDEField()
{
return this.getField().isKeyDEField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLogicValidField()
{
return "LOGICVALID".equals(this.getField().getPredefinedType());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isLastModifyField()
{
return "UPDATEDATE".equals(this.getField().getPredefinedType());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isCreateTimeField()
{
return "CREATEDATE".equals(this.getField().getPredefinedType());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isUnionKeyField()
{
return !StringUtils.isEmpty(this.getField().getUnionKeyValue());
......@@ -133,13 +116,6 @@ public class FieldModel {
}
private DataObj extParams=new DataObj();
public FieldModel set(String key,Object val)
{
extParams.set(key,val);
return this;
}
public String getStringValue(String key,String defaultVal)
{
......@@ -148,78 +124,9 @@ public class FieldModel {
public String getColumnName(String dsType)
{
return this.getStringValue("column-"+dsType.toLowerCase(),getColumnName());
return this.getStringValue("column-"+dsType.toLowerCase(),getFieldName());
}
public static enum DataType {
UNKNOWN(0,"UNKNOWN","string","String"),
BIGINT(1,"BIGINT","number","Long"),
BINARY(2,"BINARY","string","String"),
BIT(3,"BIT","boolean","Boolean"),
CHAR(4,"CHAR","string","String"),
DATETIME(5,"DATETIME","string", "Timestamp"),
DECIMAL(6,"DECIMAL","number", "BigDecimal"),
FLOAT(7,"FLOAT","number", "BigDecimal"),
IMAGE(8,"IMAGE","string","String"),
INT(9,"INT","number","Integer"),
MONEY(10,"MONEY","number", "BigDecimal"),
NCHAR(11,"NCHAR","string","String"),
NTEXT(12,"NTEXT","string","String"),
NVARCHAR(13,"NVARCHAR","string","String"),
NUMERIC(14,"NUMERIC","number", "BigDecimal"),
REAL(15,"REAL","number","Float"),
SMALLDATETIME(16,"SMALLDATETIME","string", "Timestamp"),
SMALLINT(17,"SMALLINT","number","Integer"),
SMALLMONEY(18,"SMALLMONEY","number", "BigDecimal"),
SQL_VARIANT(19,"SQL_VARIANT","string","String"),
SYSNAME(20,"SYSNAME","string","String"),
TEXT(21,"TEXT","string","String"),
TIMESTAMP(22,"TIMESTAMP","string","Timestamp"),
TINYINT(23,"TINYINT","number","Integer"),
VARBINARY(24,"VARBINARY","string","String"),
VARCHAR(25,"VARCHAR","string","String"),
UNIQUEIDENTIFIER(26,"UNIQUEIDENTIFIER","string","String"),
DATE(27,"DATE","string", "Timestamp"),
TIME(28,"TIME","string", "Timestamp");
public final int code;
public final String name;
public final String prop;
public final String java;
private DataType(int code, String name, String prop, String java) {
this.code = code;
this.name = name;
this.prop = prop;
this.java = java;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
public String getProp() {
return prop;
}
public String getJava() {
return java;
}
public static DataType findTypeName(Integer type) {
for (DataType userTypeEnum : DataType.values()) {
if (userTypeEnum.getCode()==type) {
return userTypeEnum;
}
}
return VARCHAR;
}
}
......
......@@ -19,39 +19,22 @@ import java.io.Serializable;
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("lookup")
public class LookupModel implements Serializable {
/**
* 标识
*/
@JSONField(name = "id")
@JsonProperty("id")
@ApiModelProperty("标识")
private String id;
/**
* 关系标识
*/
@JSONField(name = "relationId")
@JsonProperty("relationId")
@ApiModelProperty("关系标识")
private String relationid;
/**
* 属性名称
*/
@JSONField(name = "fieldName")
@JsonProperty("fieldName")
@ApiModelProperty("属性名称")
private String fieldname;
/**
* 引用属性名称
*/
@JSONField(name = "refFieldName")
@JsonProperty("refFieldName")
@ApiModelProperty("引用属性名称")
private String reffieldname;
......
......@@ -10,6 +10,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.IPSDataEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
......@@ -57,7 +58,7 @@ public class POSchema {
@JSONField(serialize = false)
@JsonIgnore
private Object node;
private IPSDataEntity node;
@JSONField(ordinal = 7)
private List<Column> columns;
......@@ -502,22 +503,20 @@ public class POSchema {
@JSONField(serialize = false)
public boolean isText()
{
String type=this.getType().toUpperCase();
return type.indexOf("TEXT")>=0||type.indexOf("CHAR")>=0||type.indexOf("LOB")>=0;
return "String".equalsIgnoreCase(PropType.findByDBType(type).java);
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isNumber()
{
String type=this.getType().toUpperCase();
return type.indexOf("NUM")>=0||type.indexOf("FLOAT")>=0||type.indexOf("DOUBLE")>=0||type.indexOf("DECIMAL")>=0;
return "BigDecimal".equalsIgnoreCase(PropType.findByDBType(type).java);
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isInt()
{
String type=this.getType().toUpperCase();
return type.indexOf("INT")==0;
PropType propType=PropType.findByDBType(type);
return "Long".equalsIgnoreCase(propType.java)||"Integer".equalsIgnoreCase(propType.java);
}
@JsonIgnore
......@@ -525,7 +524,7 @@ public class POSchema {
public boolean isDateTime()
{
String type=this.getType().toUpperCase();
return type.indexOf("DATE")>=0||type.indexOf("TIME")>=0;
return "Timestamp".equalsIgnoreCase(PropType.findByDBType(type).java);
}
@JSONField(ordinal = 12)
......
package cn.ibizlab.codegen.model;
public enum PropType {
UNKNOWN(0,"UNKNOWN","string","String"),
BIGINT(1,"BIGINT","number","Long"),
BINARY(2,"BINARY","string","String"),
BIT(3,"BIT","boolean","Boolean"),
CHAR(4,"CHAR","string","String"),
DATETIME(5,"DATETIME","string", "Timestamp"),
DECIMAL(6,"DECIMAL","number", "BigDecimal"),
FLOAT(7,"FLOAT","number", "BigDecimal"),
IMAGE(8,"IMAGE","string","String"),
INT(9,"INT","number","Integer"),
MONEY(10,"MONEY","number", "BigDecimal"),
NCHAR(11,"NCHAR","string","String"),
NTEXT(12,"NTEXT","string","String"),
NVARCHAR(13,"NVARCHAR","string","String"),
NUMERIC(14,"NUMERIC","number", "BigDecimal"),
REAL(15,"REAL","number","Float"),
SMALLDATETIME(16,"SMALLDATETIME","string", "Timestamp"),
SMALLINT(17,"SMALLINT","number","Integer"),
SMALLMONEY(18,"SMALLMONEY","number", "BigDecimal"),
SQL_VARIANT(19,"SQL_VARIANT","string","String"),
SYSNAME(20,"SYSNAME","string","String"),
TEXT(21,"TEXT","string","String"),
TIMESTAMP(22,"TIMESTAMP","string","Timestamp"),
TINYINT(23,"TINYINT","number","Integer"),
VARBINARY(24,"VARBINARY","string","String"),
VARCHAR(25,"VARCHAR","string","String"),
UNIQUEIDENTIFIER(26,"UNIQUEIDENTIFIER","string","String"),
DATE(27,"DATE","string", "Timestamp"),
TIME(28,"TIME","string", "Timestamp");
public final int code;
public final String name;
public final String json;
public final String java;
private PropType(int code, String name, String json, String java) {
this.code = code;
this.name = name;
this.json = json;
this.java = java;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
public String getJson() {
return json;
}
public String getJava() {
return java;
}
public static PropType findType(Integer type) {
for (PropType userTypeEnum : values()) {
if (userTypeEnum.getCode()==type) {
return userTypeEnum;
}
}
return PropType.VARCHAR;
}
public static PropType findByDBType(String type) {
for (PropType userTypeEnum : values()) {
if (userTypeEnum.getName()==type) {
return userTypeEnum;
}
}
return VARCHAR;
}
}
......@@ -14,8 +14,7 @@ import java.util.List;
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
public class RelationshipModel {
public class RelationshipModel extends BaseModel{
private String name;
......@@ -33,7 +32,11 @@ public class RelationshipModel {
private String relationType;
private IPSDERBase relation;
public IPSDERBase getRelation()
{
return (IPSDERBase)opt;
}
private List<FieldModel> fields;
......
package cn.ibizlab.codegen.model;
public class SystemModel {
}
......@@ -124,7 +124,7 @@ public class TransUtils {
Map<String,FieldModel> keyMap=new LinkedHashMap<>();
Map<String,RelationshipModel> relationshipModelMap = new LinkedHashMap<>();
if(entityModel.getKeyFields()!=null)entityModel.getKeyFields().forEach(model->keyMap.put(model.getColumnName(),model));
if(entityModel.getKeyFields()!=null)entityModel.getKeyFields().forEach(model->keyMap.put(model.getFieldName(),model));
int order = 1;
for (FieldModel fieldModel : entityModel.getFields()) {
......@@ -188,7 +188,7 @@ public class TransUtils {
}
}
if(!fieldModel.isPhysicalField())
if(!fieldModel.isPhisicalDEField())
poSchema.addTransient(column.setComputed(true));
else
poSchema.addColumn(column);
......
//
// JMustache - A Java implementation of the Mustache templating language
// http://github.com/samskivert/jmustache/blob/master/LICENSE
package cn.ibizlab.codegen.templating;
import cn.ibizlab.codegen.model.BaseModel;
import com.samskivert.mustache.BasicCollector;
import com.samskivert.mustache.Mustache;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.AbstractList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* The default collector used by JMustache.
*/
public class MustacheCollector extends BasicCollector
{
@Override
public Mustache.VariableFetcher createFetcher (Object ctx, String name) {
Mustache.VariableFetcher fetcher = super.createFetcher(ctx, name);
if (fetcher != null) return fetcher;
// first check for a getter which provides the value
Class<?> cclass = ctx.getClass();
final Method m = getMethod(cclass, name);
if (m != null) {
return new Mustache.VariableFetcher() {
public Object get (Object ctx, String name) throws Exception {
return m.invoke(ctx);
}
};
}
// next check for a getter which provides the value
final Field f = getField(cclass, name);
if (f != null) {
return new Mustache.VariableFetcher() {
public Object get (Object ctx, String name) throws Exception {
return f.get(ctx);
}
};
}
// finally check for a default interface method which provides the value (this is left to
// last because it's much more expensive and hopefully something already matched above)
final Method im = getIfaceMethod(cclass, name);
if (im != null) {
return new Mustache.VariableFetcher() {
public Object get (Object ctx, String name) throws Exception {
return im.invoke(ctx);
}
};
}
if(ctx instanceof BaseModel)
{
if(((BaseModel) ctx).getOpt()!=null)
{
Class<?> cclass2 = ((BaseModel) ctx).getOpt().getClass();
final Method opt = getMethod(cclass2, name);
if (opt != null) {
return new Mustache.VariableFetcher() {
public Object get (Object ctx, String name) throws Exception {
return opt.invoke(((BaseModel) ctx).getOpt());
}
};
}
}
Object val=((BaseModel) ctx).get(name);
if(val!=null)
{
return new Mustache.VariableFetcher() {
public Object get (Object ctx, String name) throws Exception {
return val;
}
};
}
}
return null;
}
@Override
public <K,V> Map<K,V> createFetcherCache () {
return new ConcurrentHashMap<K,V>();
}
protected Method getMethod (Class<?> clazz, String name) {
// first check up the superclass chain
for (Class<?> cc = clazz; cc != null && cc != Object.class; cc = cc.getSuperclass()) {
Method m = getMethodOn(cc, name);
if (m != null) return m;
}
return null;
}
protected Method getIfaceMethod (Class<?> clazz, String name) {
// enumerate the transitive closure of all interfaces implemented by clazz
Set<Class<?>> ifaces = new LinkedHashSet<Class<?>>();
for (Class<?> cc = clazz; cc != null && cc != Object.class; cc = cc.getSuperclass()) {
addIfaces(ifaces, cc, false);
}
// now search those in the order that we found them
for (Class<?> iface : ifaces) {
Method m = getMethodOn(iface, name);
if (m != null) return m;
}
return null;
}
private void addIfaces (Set<Class<?>> ifaces, Class<?> clazz, boolean isIface) {
if (isIface) ifaces.add(clazz);
for (Class<?> iface : clazz.getInterfaces()) addIfaces(ifaces, iface, true);
}
protected Method getMethodOn (Class<?> clazz, String name) {
Method m;
try {
m = clazz.getDeclaredMethod(name);
if (!m.getReturnType().equals(void.class)) return makeAccessible(m);
} catch (Exception e) {
// fall through
}
String upperName = Character.toUpperCase(name.charAt(0)) + name.substring(1);
try {
m = clazz.getDeclaredMethod("get" + upperName);
if (!m.getReturnType().equals(void.class)) return makeAccessible(m);
} catch (Exception e) {
// fall through
}
try {
m = clazz.getDeclaredMethod("is" + upperName);
if (m.getReturnType().equals(boolean.class) ||
m.getReturnType().equals(Boolean.class)) return makeAccessible(m);
} catch (Exception e) {
// fall through
}
return null;
}
private Method makeAccessible (Method m) {
if (!m.isAccessible()) m.setAccessible(true);
return m;
}
protected Field getField (Class<?> clazz, String name) {
Field f;
try {
f = clazz.getDeclaredField(name);
if (!f.isAccessible()) {
f.setAccessible(true);
}
return f;
} catch (Exception e) {
// fall through
}
Class<?> sclass = clazz.getSuperclass();
if (sclass != Object.class && sclass != null) {
return getField(clazz.getSuperclass(), name);
}
return null;
}
}
......@@ -41,7 +41,7 @@ public class MustacheEngineAdapter implements TemplatingEngineAdapter {
return "mustache";
}
Mustache.Compiler compiler = Mustache.compiler();
Mustache.Compiler compiler = Mustache.compiler().withCollector(new MustacheCollector());
/**
* Compiles a template into a string
......
......@@ -10,6 +10,7 @@
<description></description>
<packaging>pom</packaging>
{{>../{{projectName}}-util/pom.xml}}
<parent>
<groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-dependencies</artifactId>
......
package {{packageName}}.{{module}}.domain;
//{{entity.dsTypes}} {{entity.ds_types}} {{entity.dataAccCtrlArch}}
public class {{entity.codeName}}
{
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册