AccessRight.java 3.2 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fi.insomnia.bortal.model;


import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * An access privilege such as a privilege to login or to work with compos.
 */
@Entity
@Table(name = "access_rights")
@NamedQueries({
	@NamedQuery(name = "AccessRight.findAll", query = "SELECT a FROM AccessRight a"),
	@NamedQuery(name = "AccessRight.findByAccessRightsId", query = "SELECT a FROM AccessRight a WHERE a.accessRightsId = :accessRightsId"),
	@NamedQuery(name = "AccessRight.findByAccessRight", query = "SELECT a FROM AccessRight a WHERE a.accessRight = :accessRight") })
public class AccessRight implements ModelInterface {
    private static final long serialVersionUID = 1L;
    @Id
    
    @Column(name = "access_rights_id", nullable = false)
    private Integer id;
    
    @Column(name = "access_right", nullable = false)
    private String accessRight;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accessRightsId")
    private List<NewsGroup> newsGroupList;
    @OneToMany(mappedBy = "accessRightsId")
    private List<RoleRight> roleRightList;

    public Integer getId() {
	return id;
    }

    public void setId(Integer id) {
	this.id = id;
    }

    @Version
    @Column(nullable = false)
    private int jpaVersionField;

    public AccessRight() {
    }

    public AccessRight(Integer accessRightsId) {
	this.id = accessRightsId;
    }

    public AccessRight(Integer accessRightsId, String accessRight) {
	this.id = accessRightsId;
	this.accessRight = accessRight;
    }

    public String getAccessRight() {
	return accessRight;
    }

    public void setAccessRight(String accessRight) {
	this.accessRight = accessRight;
    }

    public List<NewsGroup> getNewsGroupList() {
	return newsGroupList;
    }

    public void setNewsGroupList(List<NewsGroup> newsGroupList) {
	this.newsGroupList = newsGroupList;
    }

    public List<RoleRight> getRoleRightList() {
	return roleRightList;
    }

    public void setRoleRightList(List<RoleRight> roleRightList) {
	this.roleRightList = roleRightList;
    }

    @Override
    public int hashCode() {
	int hash = 0;
	hash += (id != null ? id.hashCode() : 0);
	return hash;
    }

    @Override
    public boolean equals(Object object) {
	// TODO: Warning - this method won't work in the case the id fields are
	// not set
	if (!(object instanceof AccessRight)) {
	    return false;
	}
	AccessRight other = (AccessRight) object;
	if ((this.id == null && other.id != null)
		|| (this.id != null && !this.id.equals(other.id))) {
	    return false;
	}
	return true;
    }

    @Override
    public String toString() {
	return "fi.insomnia.bortal.model.AccessRight[accessRightsId=" + id
		+ "]";
    }

    public void setJpaVersionField(int jpaVersionField) {
	this.jpaVersionField = jpaVersionField;
    }

    public int getJpaVersionField() {
	return jpaVersionField;
    }

}