package org.ddouglascarr.models;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="member")
public class Member
{
    @Id
    @GeneratedValue
    private Long id;

    @Column(name="password_liquidcanon")
    @JsonIgnore
    private String password;
    private String login;

    private String name;
    private Boolean admin;
    private String notify_email;
    private Boolean active;
    private Date last_activity;

    public Member()
    {}

    public Member(Member member)
    {
        this.id = member.id;
        this.login = member.login;
        this.name = member.name;
        this.admin = member.admin;
        this.last_activity = member.last_activity;
        this.active = member.active;
        this.password = member.password;
    }


    // Getters and Setters
    public Long getId()
    {
        return id;
    }

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

    public String getLogin()
    {
        return login;
    }

    public void setLogin(String login)
    {
        this.login = login;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public Boolean getAdmin()
    {
        return admin;
    }

    public void setAdmin(Boolean admin)
    {
        this.admin = admin;
    }

    public String getNotify_email()
    {
        return notify_email;
    }

    public void setNotify_email(String notify_email)
    {
        this.notify_email = notify_email;
    }

    public Boolean getActive()
    {
        return active;
    }

    public void setActive(Boolean active)
    {
        this.active = active;
    }

    public Date getLast_activity()
    {
        return last_activity;
    }

    public void setLast_activity(Date last_activity)
    {
        this.last_activity = last_activity;
    }
}

@@ -102,16 +102,61 @@
 il.Date;
+%0Aimport java.util.List;%0Aimport java.util.Set;
 %0A%0Aimport
@@ -285,16 +285,126 @@
 nce.Id;%0A
+import javax.persistence.JoinColumn;%0Aimport javax.persistence.JoinTable;%0Aimport javax.persistence.ManyToMany;%0A
 import j
@@ -752,24 +752,24 @@
 ean active;%0A
-
     private 
@@ -789,16 +789,313 @@
 ivity;%0A%0A
+    @JsonIgnore%0A    @ManyToMany%0A    @JoinTable(%0A            name = %22privilege%22,%0A            joinColumns = @JoinColumn(name = %22member_id%22, referencedColumnName = %22id%22),%0A            inverseJoinColumns = @JoinColumn(name = %22unit_id%22, referencedColumnName = %22id%22)%0A    )%0A    private List%3CUnit%3E units;%0A%0A
     publ
@@ -2685,11 +2685,163 @@
 y;%0A    %7D
+%0A%0A    public List%3CUnit%3E getUnits()%0A    %7B%0A        return units;%0A    %7D%0A%0A    public void setUnits(List%3CUnit%3E units)%0A    %7B%0A        this.units = units;%0A    %7D
 %0A%7D%0A

Add Unit relationship to Member model