普元EOS-自定义SDO代码生成模板

1 前言

普元EOS的数据实体生成SDO接口和实现类的代码,可以通过自定义代码生成模板,实现代码自定义。

2 模板存放位置

模板存放位置如下:安装目录/dropins/eostools/com.primeton.studio.entity.ui-x.x.x.x.jar里面,SDO模版都在/templates/sdo下。

找到这个jar文件,用winrar打开,注意:不要解压缩到文件夹,只要打开即可。

打开后,找到模板文件夹。

然后将这个文件夹拖拽到本地硬盘上,编辑其中的模板文件,然后再拖拽回去。

最后关闭winrar。这样就完成了jar文件中的模板文件的编辑。

3 删除实现类中大量的注释

在SDO实现类中有大量的注释,看起来很乱,可以修改模板文件 SdoCode.vm 文件,来删除无用的注释。

3.1 编辑覆盖SdoCode.vm 

编辑SdoCode.vm文件,编辑完毕后,拖拽进 winrar 窗口,覆盖jar中对应的文件。

编辑后的SdoCode 内容如下:

#parse("templates/JavaHeader.vm" )
package $javaInfo.getPackageName();

#set($tempImport="")
#foreach($importType in $javaInfo.getImportTypes())
#if( $importType && !$tempImport.contains($importType))
import $importType;
#set($tempImport="$tempImport,$importType")
#else

#end
#end

/**
 * A representation of the model object '<em><b>$javaInfo.getJavaName()</b></em>'.
 */

public class $javaInfo.getJavaName() #if(${javaInfo.getExtendClassInterfaceName()})extends ${javaInfo.getExtendClassInterfaceName()} #end#if(${javaInfo.getImplementInterfaceName()})implements ${javaInfo.getImplementInterfaceName()} #end{
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

#foreach($fieldInfo in $javaInfo.getFieldInfos())
#set ( $index = $velocityCount - 1 )
	public final static int INDEX_$fieldInfo.getFieldName().toUpperCase() = $index;
#end
	public static final int SDO_PROPERTY_COUNT = $javaInfo.getFieldInfos().size();

	public static final int EXTENDED_PROPERTY_COUNT = -1;
##

#parse( "templates/sdo/SdoConstructor.vm" )


	protected void validate() {
		validateType(TYPE);
	}

#parse( "templates/JavaGetSetMethod.vm" )

}

注意:拖拽覆盖前,一定要将EOS IDE关闭,否则该jar文件比占用,是无法被覆盖修改的。

3.2 编辑覆盖 JavaGetSetMethod.vm 

编辑后的文件内容如下:

## get, set ·½·¨
#foreach($fieldInfo in $javaInfo.getFieldInfos())

	public $fieldInfo.getShortTypeName() get${fieldInfo.getCapFieldName()}() {
		return $fieldInfo.getGetMethodString();
	}


	public void set${fieldInfo.getCapFieldName()}($fieldInfo.getShortTypeName() $fieldInfo.getFieldName()) {
		$fieldInfo.getSetMethodString();
	}

#end

3.3 最终效果

原SDO实现类文件如下:

/*******************************************************************************
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved.
 *
 * Created on Apr 11, 2008
 *******************************************************************************/
package com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl;

import com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.TProject;
import com.primeton.ext.data.sdo.DataUtil;
import com.primeton.ext.data.sdo.ExtendedDataObjectImpl;
import commonj.sdo.Type;
import java.util.Date;

/**
 * <!-- begin-user-doc2 -->
 * A representation of the model object '<em><b>TProjectImpl</b></em>'.
 * <!-- end-user-doc2 -->
 *
 * <p>
 * The following features are supported:
 * <ul>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getId <em>Id</em> <desc></desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectCode <em>ProjectCode</em> <desc>项目Code</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectName <em>ProjectName</em> <desc>项目名称</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectType <em>ProjectType</em> <desc>项目类型</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectTemplateId <em>ProjectTemplateId</em> <desc>项目模板Id</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getCreateTime <em>CreateTime</em> <desc>新增时间</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getCreateUser <em>CreateUser</em> <desc>新增用户</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getUpdateTime <em>UpdateTime</em> <desc>最后更新时间</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getUpdateUser <em>UpdateUser</em> <desc>最后更新人</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getSortNo <em>SortNo</em> <desc>排序号</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getVersion <em>Version</em> <desc>乐观锁</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getTenantId <em>TenantId</em> <desc>租户id</desc>}</li>
 * </ul>
 * </p>
 *
 * @extends ExtendedDataObjectImpl;
 *
 * @implements TProject;
 */

public class TProjectImpl extends ExtendedDataObjectImpl implements TProject {
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	public final static int INDEX_ID = 0;
	public final static int INDEX_PROJECTCODE = 1;
	public final static int INDEX_PROJECTNAME = 2;
	public final static int INDEX_PROJECTTYPE = 3;
	public final static int INDEX_PROJECTTEMPLATEID = 4;
	public final static int INDEX_CREATETIME = 5;
	public final static int INDEX_CREATEUSER = 6;
	public final static int INDEX_UPDATETIME = 7;
	public final static int INDEX_UPDATEUSER = 8;
	public final static int INDEX_SORTNO = 9;
	public final static int INDEX_VERSION = 10;
	public final static int INDEX_TENANTID = 11;
	public static final int SDO_PROPERTY_COUNT = 12;

	public static final int EXTENDED_PROPERTY_COUNT = -1;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public TProjectImpl() {
		this(TYPE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public TProjectImpl(Type type) {
		super(type);
	}

	protected void validate() {
		validateType(TYPE);
	}

	/**
	 * Returns the value of the '<em><b>Id</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>Id</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Id</em>' attribute.
	 * @see #setId(java.lang.String)
	 */
	public String getId() {
		return DataUtil.toString(super.getByIndex(INDEX_ID, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getId <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Id</em>' attribute.
	 * @see #getId()
	 */
	public void setId(String id) {
		super.setByIndex(INDEX_ID, id);
	}

	/**
	 * Returns the value of the '<em><b>ProjectCode</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectCode</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectCode</em>' attribute.
	 * @see #setProjectCode(java.lang.String)
	 */
	public String getProjectCode() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTCODE, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectCode <em>ProjectCode</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectCode</em>' attribute.
	 * @see #getProjectCode()
	 */
	public void setProjectCode(String projectCode) {
		super.setByIndex(INDEX_PROJECTCODE, projectCode);
	}

	/**
	 * Returns the value of the '<em><b>ProjectName</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectName</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectName</em>' attribute.
	 * @see #setProjectName(java.lang.String)
	 */
	public String getProjectName() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTNAME, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectName <em>ProjectName</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectName</em>' attribute.
	 * @see #getProjectName()
	 */
	public void setProjectName(String projectName) {
		super.setByIndex(INDEX_PROJECTNAME, projectName);
	}

	/**
	 * Returns the value of the '<em><b>ProjectType</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectType</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectType</em>' attribute.
	 * @see #setProjectType(java.lang.String)
	 */
	public String getProjectType() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTTYPE, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectType <em>ProjectType</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectType</em>' attribute.
	 * @see #getProjectType()
	 */
	public void setProjectType(String projectType) {
		super.setByIndex(INDEX_PROJECTTYPE, projectType);
	}

	/**
	 * Returns the value of the '<em><b>ProjectTemplateId</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectTemplateId</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectTemplateId</em>' attribute.
	 * @see #setProjectTemplateId(java.lang.String)
	 */
	public String getProjectTemplateId() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTTEMPLATEID, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectTemplateId <em>ProjectTemplateId</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectTemplateId</em>' attribute.
	 * @see #getProjectTemplateId()
	 */
	public void setProjectTemplateId(String projectTemplateId) {
		super.setByIndex(INDEX_PROJECTTEMPLATEID, projectTemplateId);
	}

	/**
	 * Returns the value of the '<em><b>CreateTime</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>CreateTime</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>CreateTime</em>' attribute.
	 * @see #setCreateTime(java.util.Date)
	 */
	public Date getCreateTime() {
		return DataUtil.toDate(super.getByIndex(INDEX_CREATETIME, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getCreateTime <em>CreateTime</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>CreateTime</em>' attribute.
	 * @see #getCreateTime()
	 */
	public void setCreateTime(Date createTime) {
		super.setByIndex(INDEX_CREATETIME, createTime);
	}

	/**
	 * Returns the value of the '<em><b>CreateUser</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>CreateUser</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>CreateUser</em>' attribute.
	 * @see #setCreateUser(java.lang.String)
	 */
	public String getCreateUser() {
		return DataUtil.toString(super.getByIndex(INDEX_CREATEUSER, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getCreateUser <em>CreateUser</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>CreateUser</em>' attribute.
	 * @see #getCreateUser()
	 */
	public void setCreateUser(String createUser) {
		super.setByIndex(INDEX_CREATEUSER, createUser);
	}

	/**
	 * Returns the value of the '<em><b>UpdateTime</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>UpdateTime</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>UpdateTime</em>' attribute.
	 * @see #setUpdateTime(java.util.Date)
	 */
	public Date getUpdateTime() {
		return DataUtil.toDate(super.getByIndex(INDEX_UPDATETIME, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getUpdateTime <em>UpdateTime</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>UpdateTime</em>' attribute.
	 * @see #getUpdateTime()
	 */
	public void setUpdateTime(Date updateTime) {
		super.setByIndex(INDEX_UPDATETIME, updateTime);
	}

	/**
	 * Returns the value of the '<em><b>UpdateUser</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>UpdateUser</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>UpdateUser</em>' attribute.
	 * @see #setUpdateUser(java.lang.String)
	 */
	public String getUpdateUser() {
		return DataUtil.toString(super.getByIndex(INDEX_UPDATEUSER, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getUpdateUser <em>UpdateUser</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>UpdateUser</em>' attribute.
	 * @see #getUpdateUser()
	 */
	public void setUpdateUser(String updateUser) {
		super.setByIndex(INDEX_UPDATEUSER, updateUser);
	}

	/**
	 * Returns the value of the '<em><b>SortNo</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>SortNo</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>SortNo</em>' attribute.
	 * @see #setSortNo(int)
	 */
	public int getSortNo() {
		return DataUtil.toInt(super.getByIndex(INDEX_SORTNO, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getSortNo <em>SortNo</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>SortNo</em>' attribute.
	 * @see #getSortNo()
	 */
	public void setSortNo(int sortNo) {
		super.setByIndex(INDEX_SORTNO, sortNo);
	}

	/**
	 * Returns the value of the '<em><b>Version</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>Version</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Version</em>' attribute.
	 * @see #setVersion(int)
	 */
	public int getVersion() {
		return DataUtil.toInt(super.getByIndex(INDEX_VERSION, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getVersion <em>Version</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Version</em>' attribute.
	 * @see #getVersion()
	 */
	public void setVersion(int version) {
		super.setByIndex(INDEX_VERSION, version);
	}

	/**
	 * Returns the value of the '<em><b>TenantId</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>TenantId</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>TenantId</em>' attribute.
	 * @see #setTenantId(java.lang.String)
	 */
	public String getTenantId() {
		return DataUtil.toString(super.getByIndex(INDEX_TENANTID, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getTenantId <em>TenantId</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>TenantId</em>' attribute.
	 * @see #getTenantId()
	 */
	public void setTenantId(String tenantId) {
		super.setByIndex(INDEX_TENANTID, tenantId);
	}


}

修改后,实现类文件如下:

/*******************************************************************************
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved.
 *
 * Created on Apr 11, 2008
 *******************************************************************************/
package com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl;

import com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.TProject;
import com.primeton.ext.data.sdo.DataUtil;
import com.primeton.ext.data.sdo.ExtendedDataObjectImpl;
import commonj.sdo.Type;
import java.util.Date;

/**
 * A representation of the model object '<em><b>TProjectImpl</b></em>'.
 */

public class TProjectImpl extends ExtendedDataObjectImpl implements TProject {
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	public final static int INDEX_ID = 0;
	public final static int INDEX_PROJECTCODE = 1;
	public final static int INDEX_PROJECTNAME = 2;
	public final static int INDEX_PROJECTTYPE = 3;
	public final static int INDEX_PROJECTTEMPLATEID = 4;
	public final static int INDEX_CREATETIME = 5;
	public final static int INDEX_CREATEUSER = 6;
	public final static int INDEX_UPDATETIME = 7;
	public final static int INDEX_UPDATEUSER = 8;
	public final static int INDEX_SORTNO = 9;
	public final static int INDEX_VERSION = 10;
	public final static int INDEX_TENANTID = 11;
	public static final int SDO_PROPERTY_COUNT = 12;

	public static final int EXTENDED_PROPERTY_COUNT = -1;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public TProjectImpl() {
		this(TYPE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public TProjectImpl(Type type) {
		super(type);
	}

	protected void validate() {
		validateType(TYPE);
	}


	public String getId() {
		return DataUtil.toString(super.getByIndex(INDEX_ID, true));
	}


	public void setId(String id) {
		super.setByIndex(INDEX_ID, id);
	}


	public String getProjectCode() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTCODE, true));
	}


	public void setProjectCode(String projectCode) {
		super.setByIndex(INDEX_PROJECTCODE, projectCode);
	}


	public String getProjectName() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTNAME, true));
	}


	public void setProjectName(String projectName) {
		super.setByIndex(INDEX_PROJECTNAME, projectName);
	}


	public String getProjectType() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTTYPE, true));
	}


	public void setProjectType(String projectType) {
		super.setByIndex(INDEX_PROJECTTYPE, projectType);
	}


	public String getProjectTemplateId() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTTEMPLATEID, true));
	}


	public void setProjectTemplateId(String projectTemplateId) {
		super.setByIndex(INDEX_PROJECTTEMPLATEID, projectTemplateId);
	}


	public Date getCreateTime() {
		return DataUtil.toDate(super.getByIndex(INDEX_CREATETIME, true));
	}


	public void setCreateTime(Date createTime) {
		super.setByIndex(INDEX_CREATETIME, createTime);
	}


	public String getCreateUser() {
		return DataUtil.toString(super.getByIndex(INDEX_CREATEUSER, true));
	}


	public void setCreateUser(String createUser) {
		super.setByIndex(INDEX_CREATEUSER, createUser);
	}


	public Date getUpdateTime() {
		return DataUtil.toDate(super.getByIndex(INDEX_UPDATETIME, true));
	}


	public void setUpdateTime(Date updateTime) {
		super.setByIndex(INDEX_UPDATETIME, updateTime);
	}


	public String getUpdateUser() {
		return DataUtil.toString(super.getByIndex(INDEX_UPDATEUSER, true));
	}


	public void setUpdateUser(String updateUser) {
		super.setByIndex(INDEX_UPDATEUSER, updateUser);
	}


	public int getSortNo() {
		return DataUtil.toInt(super.getByIndex(INDEX_SORTNO, true));
	}


	public void setSortNo(int sortNo) {
		super.setByIndex(INDEX_SORTNO, sortNo);
	}


	public int getVersion() {
		return DataUtil.toInt(super.getByIndex(INDEX_VERSION, true));
	}


	public void setVersion(int version) {
		super.setByIndex(INDEX_VERSION, version);
	}


	public String getTenantId() {
		return DataUtil.toString(super.getByIndex(INDEX_TENANTID, true));
	}


	public void setTenantId(String tenantId) {
		super.setByIndex(INDEX_TENANTID, tenantId);
	}


}

可以看到,新代码简洁多了。

4 在SDO接口中增加字段名常量

修改 SdoInterfaceCode.vm 文件,在文件中增加如下代码:

## FieldName Const
#foreach($fieldInfo in $javaInfo.getFieldInfos())
    public static final String FIELD_NAME_$fieldInfo.getFieldName().toUpperCase() = "$fieldInfo.getFieldName()";
#end

完整代码效果如下:

#parse("templates/JavaHeader.vm" )
package $javaInfo.getPackageName();

#set($tempImport="")
#foreach($importType in $javaInfo.getImportTypes())
#if( $importType && !$tempImport.contains($importType))
import $importType;
#set($tempImport="$tempImport,$importType")
#else


#end
#end

/**
#if($javaInfo.getExtendClassInterfaceName())
#foreach($extendInterface in $javaInfo.getExtendClassInterfaceName().split("[,]"))
#if( $extendInterface )
 * @extends $extendInterface;
#end
#end
 */
public interface $javaInfo.getJavaName() extends ${javaInfo.getExtendClassInterfaceName()} {
#else
 */
public interface $javaInfo.getJavaName() {
#end

	public String QNAME = "${javaInfo.getPackageName()}.${javaInfo.getJavaName()}";

	public Type TYPE = TypeHelper.INSTANCE.getType("$javaInfo.getPackageName()", "$javaInfo.getJavaName()");

	public static final IObjectFactory<$javaInfo.getJavaName()> FACTORY = new IObjectFactory<$javaInfo.getJavaName()>() {
		public $javaInfo.getJavaName() create() {
            Type type = TYPE;
			if(type == null) {
				type = TypeHelper.INSTANCE.getType("$javaInfo.getPackageName()", "$javaInfo.getJavaName()");
			}
			if(type == null) {
				throw new IllegalDataObjectTypeException("cannot find entity type: " + QNAME);	
			}
			return ($javaInfo.getJavaName()) DataFactory.INSTANCE.create(type);
		}
	};

## FieldName Const
#foreach($fieldInfo in $javaInfo.getFieldInfos())
    public static final String FIELD_NAME_$fieldInfo.getFieldName().toUpperCase() = "$fieldInfo.getFieldName()";
#end

## get, set
#foreach($fieldInfo in $javaInfo.getFieldInfos())

	public $fieldInfo.getShortTypeName() get${fieldInfo.getCapFieldName()}();

	public void set${fieldInfo.getCapFieldName()}($fieldInfo.getShortTypeName() $fieldInfo.getFieldName());

#end

}

最终我们看到 SDO接口中增加了字段名常量

    public static final String FIELD_NAME_ID = "id";
    public static final String FIELD_NAME_PROJECTCODE = "projectCode";
    public static final String FIELD_NAME_PROJECTNAME = "projectName";
    public static final String FIELD_NAME_PROJECTTYPE = "projectType";
    public static final String FIELD_NAME_PROJECTTEMPLATEID = "projectTemplateId";
    public static final String FIELD_NAME_CREATETIME = "createTime";
    public static final String FIELD_NAME_CREATEUSER = "createUser";
    public static final String FIELD_NAME_UPDATETIME = "updateTime";
    public static final String FIELD_NAME_UPDATEUSER = "updateUser";
    public static final String FIELD_NAME_SORTNO = "sortNo";
    public static final String FIELD_NAME_VERSION = "version";
    public static final String FIELD_NAME_TENANTID = "tenantId";

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小崔爱读书

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值