レポート開発方法の概要

6142 ワード

最も簡単な方法は、POJOのニーズに合わせて、Annotationで実現することです.
 
具体的には、次のコード例を参照してください.
@ReportClass(
		title = "Users",
		reportSheets = {
				@ReportSheet(
						freezed = 1,
						index = false,
						sheetName = "User",
						reportPrimitiveFields = {@ReportPrimitiveField(fieldName="email",width=20),
												 @ReportPrimitiveField(fieldName="name",width=15,
														 url="http://localhost:8080/vaalhaai/framework/identityUserAction!open.do?id=${id}"),
												 @ReportPrimitiveField(fieldName="loginId",width=20),
												 @ReportPrimitiveField(fieldName="nickName")
												 }
				),
		
				@ReportSheet(
						freezed = 2,
						index = true,
						sheetName = "All",
						reportPrimitiveFields = {@ReportPrimitiveField(fieldName="email",width=20),
												 @ReportPrimitiveField(fieldName="name",width=15),
												 @ReportPrimitiveField(fieldName="loginId",width=20),
												 @ReportPrimitiveField(fieldName="nickName",width = 20),
												 @ReportPrimitiveField(fieldName="password",width = 10)
												 },
						reportEntityCollectionFields = {
							@ReportEntityCollectionField(
									className="com.vaalhaai.framework.identity.entity.Group",
									sheetName="Group",
									fieldName="groups")	
						}
				)
			}
		)
public class User extends BaseEntity {

	private static final long serialVersionUID = 83202417663407938L;

	/** password */
	@Column(name = "PASSWORD")
	@Size(min = 6, max = 128)
	private String password;

	/** login id */
	@Column(name = "LOGIN_ID", unique = true)
	@Index(name = "FRAMEWORK_IDENTITY_USER_LOGINID", columnNames = "LOGIN_ID")
	@Size(min = 5, max = 50)
	private String loginId;

	/** email */
	@Column(name = "EMAIL")
	@Email
	@Size(max = 50)
	private String email;

	/** birthday */
	@Column(name = "BIRTHDAY")
	@Temporal(TemporalType.DATE)
	private Date birthday;

	/** gender */
	@Column(name = "GENDER")
	@Size(max = 10)
	private String gender;

	@Column(name = "NICK_NAME")
	@Size(max = 50)
	private String nickName;

	@Column(name = "CELLPHONE")
	@Size(max = 50)
	private String cellphone;

	@Column(name = "TELEPHONE")
	@Size(max = 50)
	private String telephone;

	@ManyToMany(cascade = { CascadeType.ALL })
	@JoinTable(name = "VAALHAAI_IDENTITY_USER_REF_GROUP", joinColumns = { @JoinColumn(name = "GROUP_ID") }, inverseJoinColumns = { @JoinColumn(name = "USER_ID") })
	private Set<Group> groups = new HashSet<Group>();

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	/*
	 * public void setBirthday(String birthday) throws ParseException {
	 * this.birthday = DateUtil.parseDate(birthday); }
	 */
	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	/**
	 * @return the cellphone
	 */
	public String getCellphone() {
		return cellphone;
	}

	/**
	 * @param cellphone
	 *            the cellphone to set
	 */
	public void setCellphone(String cellphone) {
		this.cellphone = cellphone;
	}

	/**
	 * @return the groups
	 */
	public Set<Group> getGroups() {
		return groups;
	}

	/**
	 * @param groups
	 *            the groups to set
	 */
	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((loginId == null) ? 0 : loginId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (loginId == null) {
			if (other.loginId != null)
				return false;
		} else if (!loginId.equals(other.loginId))
			return false;
		return true;
	}

}

定義はAnnotationで行うことができます.
タイトルに対する中国語サポートは、国際化された方法で実現できます.
User		=  

name 		=  
loginId 	=  
password 	=  
email		=  
birthday	=  
gender		=  
nickName	=  
cellphone	=  
telephone	=  
groups		=  

# 
Users		=  
All			=  

 
もしあなたがAnnotationの方式を使うのが好きでないならば、次のバージョンを期待して、データベースのカスタマイズの方式を使用することを支持することができます!