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

package hu.nir.nmail.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author attila
 */
@Entity
@Table(name = "nmail_user")
@NamedQueries({})
public class NmailUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "user_id", nullable = false)
    private Long userId;
    @Column(name = "last_name")
    private String lastName;
    @Column(name = "first_name")
    private String firstName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private Collection<UserProces> userProcesCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "nmailUser")
    private MailFolder mailFolder;
    //@OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false, nullable= false)
    @OneToOne
    private UserSetting userSetting;
    //@OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false, nullable= false)
    @OneToOne
    private UserRestriction userRestriction;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private Collection<EmailAddress> emailAddressCollection;
    @JoinColumn(name = "user_id", referencedColumnName = "id", insertable = false, updatable = false)
    @OneToOne
    private NmailUserLogin nmailUserLogin;

    public NmailUser() {
    }

    public NmailUser(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public Collection<UserProces> getUserProcesCollection() {
        return userProcesCollection;
    }

    public void setUserProcesCollection(Collection<UserProces> userProcesCollection) {
        this.userProcesCollection = userProcesCollection;
    }

    public MailFolder getMailFolder() {
        return mailFolder;
    }

    public void setMailFolder(MailFolder mailFolder) {
        this.mailFolder = mailFolder;
    }

    public UserSetting getUserSetting() {
        return userSetting;
    }

    public void setUserSetting(UserSetting userSetting) {
        this.userSetting = userSetting;
    }

    public UserRestriction getUserRestriction() {
        return userRestriction;
    }

    public void setUserRestriction(UserRestriction userRestriction) {
        this.userRestriction = userRestriction;
    }

    public Collection<EmailAddress> getEmailAddressCollection() {
        return emailAddressCollection;
    }

    public void setEmailAddressCollection(Collection<EmailAddress> emailAddressCollection) {
        this.emailAddressCollection = emailAddressCollection;
    }

    public NmailUserLogin getNmailUserLogin() {
        return nmailUserLogin;
    }

    public void setNmailUserLogin(NmailUserLogin nmailUserLogin) {
        this.nmailUserLogin = nmailUserLogin;
    }

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

    @Override
    public String toString() {
        return "hu.nir.nmail.ejb.entity.NmailUser[userId=" + userId + "]";
    }

}
