package net.techreadiness.persistence.domain;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import net.techreadiness.persistence.AuditedBaseEntity;
import net.techreadiness.persistence.BaseEntity;
import net.techreadiness.persistence.ServiceObjectMapped;
import net.techreadiness.service.object.BaseObject;
import net.techreadiness.service.object.Role;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
/**
* The persistent class for the role database table.
*
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "role")
public class RoleDO extends AuditedBaseEntity implements Serializable, ServiceObjectMapped {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "role_id", unique = true, nullable = false)
private Long roleId;
@Column(nullable = false, length = 50)
private String code;
@Column(length = 1000)
private String description;
@Column(name = "display_order")
private Integer displayOrder;
@Column(nullable = false, length = 100)
private String name;
@Column(length = 100)
private String category;
@Column(name = "short_name", length = 100)
private String shortName;
// bi-directional many-to-one association to ScopeDO
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "scope_id", nullable = false)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private ScopeDO scope;
// bi-directional many-to-one association to RolePermissionDO
@OneToMany(mappedBy = "role")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private List<RolePermissionDO> rolePermissions;
// bi-directional many-to-one association to UserRoleDO
@OneToMany(mappedBy = "role")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private List<UserRoleDO> userRoles;
public RoleDO() {
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getDisplayOrder() {
return displayOrder;
}
public void setDisplayOrder(Integer displayOrder) {
this.displayOrder = displayOrder;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ScopeDO getScope() {
return scope;
}
public void setScope(ScopeDO scope) {
this.scope = scope;
}
public List<RolePermissionDO> getRolePermissions() {
return rolePermissions;
}
public void setRolePermissions(List<RolePermissionDO> rolePermissions) {
this.rolePermissions = rolePermissions;
}
public List<UserRoleDO> getUserRoles() {
return userRoles;
}
public void setUserRoles(List<UserRoleDO> userRoles) {
this.userRoles = userRoles;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getShortName() {
return shortName;
}
public void setCategory(String category) {
this.category = category;
}
public String getCategory() {
return category;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (roleId == null ? 0 : roleId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof RoleDO)) {
return false;
}
RoleDO other = (RoleDO) obj;
if (roleId == null) {
if (other.roleId != null) {
return false;
}
} else if (!roleId.equals(other.roleId)) {
return false;
}
return true;
}
@Override
public Class<? extends BaseObject<? extends BaseEntity>> getServiceObjectType() {
return Role.class;
}
}