/* ==================================================================
* Created [2009-4-27 下午11:32:55] by Jon.King
* ==================================================================
* TSS
* ==================================================================
* mailTo:jinpujun@hotmail.com
* Copyright (c) Jon.King, 2009-2012
* ==================================================================
*/
package com.jinhe.tss.portal.entity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.dom4j.Document;
import com.jinhe.tss.core.cachepool.AbstractCacheableKey;
import com.jinhe.tss.core.cachepool.CacheableKey;
import com.jinhe.tss.core.persistence.IEntity;
import com.jinhe.tss.core.sso.Environment;
/**
* 门户实体:包括基本信息及主题信息等
*/
@Entity
@Table(name = "pms_portal")
@SequenceGenerator(name = "portal_sequence", sequenceName = "portal_sequence", initialValue = 1, allocationSize = 1)
public class Portal implements IEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "portal_sequence")
private Long id;
private Long themeId; // 默认主题编号
private String themeName; // 默认主题名称(默认为:XXXX(门户名称)的主题)
private Long currentThemeId; // 当前主题编号
private String currentThemeName; // 当前主题名称(默认为:XXXX(门户名称)的主题)
@Transient private String name;
@Transient private Long personalThemeId; // 用户个性化定制的主题
@Transient private List<Document> personalPageXMLs; // 用户个性化定制的门户各个页面的配置XML列表
public List<Document> getPersonalPageXMLs() {
if(personalPageXMLs == null) {
personalPageXMLs = new ArrayList<Document>();
}
return personalPageXMLs;
}
/**
* 获取用户自定义的主题ID,如果为空则返回默认主题ID
* @return
*/
public Long getPersonalThemeId() {
return personalThemeId != null ? personalThemeId : themeId;
}
public void setPersonalThemeId(Long personalThemeId) {
this.personalThemeId = personalThemeId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* 门户缓存池Key值实体。
* 包含了门户的名称,Id以及主题名称和ID信息。
* @return
*/
public CacheableKey getDefaultKey(){
return new AbstractCacheableKey(){
private static final long serialVersionUID = -2568028025542451100L;
public String getKey() {
return Portal.this.id + "_" + Portal.this.getPersonalThemeId();
}
public String getName() {
return Portal.this.getName();
}
public String getRemark() {
return "主题:" + Portal.this.themeName;
}
};
}
/**
* 获取个性化定制门户缓存池Key值实体。
* 包含了门户的名称和Id、主题名称和ID信息、执行该个性化定制的用户信息。
* @return
*/
public CacheableKey getPersonalKey(){
return new AbstractCacheableKey(){
private static final long serialVersionUID = 1650983464853324828L;
public String getKey() {
return Portal.this.id + "_" + Portal.this.getPersonalThemeId() + "_" + Environment.getOperatorId();
}
public String getName() {
return Portal.this.getName();
}
public String getRemark() {
return "主题:" + Portal.this.themeName + ",用户:" + Environment.getOperatorName();
}
};
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getThemeId() {
return themeId;
}
public void setThemeId(Long themeId) {
this.themeId = themeId;
}
public String getThemeName() {
return themeName;
}
public void setThemeName(String themeName) {
this.themeName = themeName;
}
public Long getCurrentThemeId() {
return currentThemeId;
}
public String getCurrentThemeName() {
return currentThemeName;
}
public void setCurrentThemeId(Long currentThemeId) {
this.currentThemeId = currentThemeId;
}
public void setCurrentThemeName(String currentThemeName) {
this.currentThemeName = currentThemeName;
}
}