package org.datavaultplatform.common.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
import javax.persistence.*;

@JsonIgnoreProperties(ignoreUnknown = true)
@Entity
@Table(name="Users")
public class User {
    // User Identifier (not a UUID)
    @Id
    @Column(name = "id", unique = true)
    private String id;
    
    // Name of the user
    @Column(name = "name", nullable = false)
    private String name;

    // Password
    @Column(name = "password")
    private String password;

    // Is this user an administrator?
    @Column(name = "admin", nullable = false)
    private Boolean admin;

    // A user is related to a number of vaults
    @JsonIgnore
    @OneToMany(targetEntity=Vault.class, mappedBy="user", fetch=FetchType.LAZY)
    @OrderBy("creationTime")
    private List<Vault> vaults;

    // A user is related to a number of file storage systems
    @JsonIgnore
    @OneToMany(targetEntity=FileStore.class, mappedBy="user", fetch=FetchType.LAZY)
    private List<FileStore> fileStores;
    
    public User() {}
    public User(String name) {
        this.name = name;
    }

    public void setID(String id) {
        this.id = id;
    }

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

    public String getName() { return name; }

    public String getPassword() {
        return password;
    }

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

    public Boolean isAdmin() {
        return admin;
    }

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


    public List<Vault> getVaults() {
        return vaults;
    }

    public List<FileStore> getFileStores() {
        return fileStores;
    }
    
    @Override
    public boolean equals(Object other) {
        
        if (this == other) return true;
        
        if (!(other instanceof User)) {
            return false;
        }
        
        final User user = (User)other;
        
        if (!user.getID().equals(getID())) {
            return false;
        }
        
        return true;
    }
    
    @Override
    public int hashCode() {
        return getID().hashCode();
    }
}

@@ -581,16 +581,87 @@
 sword;%0A%0A
+    // Password%0A    @Column(name = %22email%22)%0A    private String email;%0A%0A
     // I
@@ -1634,32 +1634,168 @@
 assword;%0A    %7D%0A%0A
+    public String getEmail() %7B%0A        return email;%0A    %7D%0A%0A    public void setEmail(String email) %7B%0A        this.email = email;%0A    %7D%0A%0A
     public Boole

Add email property to User object