package org.osforce.connect.entity.blog;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.osforce.connect.entity.system.Project;
import org.osforce.platform.entity.support.IdEntity;

/**
 * Uses  commons category
 * @author gavin
 * @since 1.0.0
 * @create Nov 10, 2010 - 4:33:55 PM
 * <a href="http://www.opensourceforce.org">开源力量</a>
 */
@Entity
@Table(name="blog_categories")
@Cacheable
public class BlogCategory extends IdEntity {

	private static final long serialVersionUID = -1856521070359459275L;
	
	private String label;
	private String code;
	private Integer level = 0;
	private Boolean enabled = true;
	// helper 
	private Long projectId;
	// refer
	private Project project;
	private List<BlogPost> blogPosts = new ArrayList<BlogPost>();
	
	public BlogCategory() {
	}

	@Column(nullable=false)
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}
	
	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}
	
	public Boolean getEnabled() {
		return enabled;
	}
	
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}
	
	@Transient
	public Long getProjectId() {
		if(projectId==null && project!=null) {
			projectId = project.getId(); 
		}
		return projectId;
	}
	
	public void setProjectId(Long projectId) {
		this.projectId = projectId;
	}
	
	@ManyToOne(fetch=FetchType.LAZY, optional=false)
	@JoinColumn(name="project_id")
	public Project getProject() {
		return project;
	}
	
	public void setProject(Project project) {
		this.project = project;
	}
	
	@OneToMany(fetch=FetchType.LAZY, mappedBy="category")
	public List<BlogPost> getBlogPosts() {
		return blogPosts;
	}
	
	public void setBlogPosts(List<BlogPost> blogPosts) {
		this.blogPosts = blogPosts;
	}
}

@@ -515,34 +515,8 @@
 /**%0A
- * Uses  commons category%0A
  * @
@@ -528,16 +528,16 @@
 r gavin%0A
+
  * @sinc
@@ -803,18 +803,17 @@
 59275L;%0A
-%09
 %0A
+
 %09private
@@ -920,17 +920,16 @@
 / helper
- 
 %0A%09privat
@@ -1045,18 +1045,17 @@
 ost%3E();%0A
-%09
 %0A
+
 %09public 
@@ -1207,26 +1207,25 @@
 = label;%0A%09%7D%0A
-%09
 %0A
+
 %09public Stri
@@ -1249,34 +1249,33 @@
 return code;%0A%09%7D%0A
-%09
 %0A
+
 %09public void set
@@ -1313,26 +1313,25 @@
  = code;%0A%09%7D%0A
-%09
 %0A
+
 %09public Inte
@@ -1427,26 +1427,25 @@
 = level;%0A%09%7D%0A
-%09
 %0A
+
 %09public Bool
@@ -1480,26 +1480,25 @@
 enabled;%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -1557,18 +1557,17 @@
 led;%0A%09%7D%0A
-%09
 %0A
+
 %09@Transi
@@ -1672,17 +1672,16 @@
 getId();
- 
 %0A%09%09%7D%0A%09%09r
@@ -1696,26 +1696,25 @@
 ojectId;%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -1778,18 +1778,17 @@
 tId;%0A%09%7D%0A
-%09
 %0A
+
 %09@ManyTo
@@ -1909,26 +1909,25 @@
 project;%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -1986,18 +1986,17 @@
 ect;%0A%09%7D%0A
-%09
 %0A
+
 %09@OneToM
@@ -2105,17 +2105,16 @@
 sts;%0A%09%7D%0A
-%09
 %0A%09public

prepare release 1.0.3