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

package fi.insomnia.bortal.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author jkj
 */
@Entity
@Table(name = "role_rights")
@NamedQueries({
    @NamedQuery(name = "RoleRight.findAll", query = "SELECT r FROM RoleRight r"),
    @NamedQuery(name = "RoleRight.findByRoleRights", query = "SELECT r FROM RoleRight r WHERE r.roleRights = :roleRights"),
    @NamedQuery(name = "RoleRight.findByRead", query = "SELECT r FROM RoleRight r WHERE r.read = :read"),
    @NamedQuery(name = "RoleRight.findByWrite", query = "SELECT r FROM RoleRight r WHERE r.write = :write")})
public class RoleRight implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "role_rights", nullable = false)
    private Integer roleRights;
    @Basic(optional = false)
    @Column(name = "read", nullable = false)
    private boolean read;
    @Basic(optional = false)
    @Column(name = "write", nullable = false)
    private boolean write;
    @JoinColumn(name = "access_rights_id", referencedColumnName = "access_rights_id")
    @ManyToOne
    private AccessRight accessRightsId;
    @JoinColumn(name = "roles_id", referencedColumnName = "roles_id", nullable = false)
    @ManyToOne(optional = false)
    private Role rolesId;

    public RoleRight() {
    }

    public RoleRight(Integer roleRights) {
        this.roleRights = roleRights;
    }

    public RoleRight(Integer roleRights, boolean read, boolean write) {
        this.roleRights = roleRights;
        this.read = read;
        this.write = write;
    }

    public Integer getRoleRights() {
        return roleRights;
    }

    public void setRoleRights(Integer roleRights) {
        this.roleRights = roleRights;
    }

    public boolean getRead() {
        return read;
    }

    public void setRead(boolean read) {
        this.read = read;
    }

    public boolean getWrite() {
        return write;
    }

    public void setWrite(boolean write) {
        this.write = write;
    }

    public AccessRight getAccessRightsId() {
        return accessRightsId;
    }

    public void setAccessRightsId(AccessRight accessRightsId) {
        this.accessRightsId = accessRightsId;
    }

    public Role getRolesId() {
        return rolesId;
    }

    public void setRolesId(Role rolesId) {
        this.rolesId = rolesId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roleRights != null ? roleRights.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 RoleRight)) {
            return false;
        }
        RoleRight other = (RoleRight) object;
        if ((this.roleRights == null && other.roleRights != null) || (this.roleRights != null && !this.roleRights.equals(other.roleRights))) {
            return false;
        }
        return true;
    }

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

}