package cz.utb.tadis.auth.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.Id;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

public class UserProfile {

    @Id
    private Long id;

    @Email
    @NotBlank
    private String email;

    @NotNull
    private Boolean active;

    @NotBlank
    private String firstName;

    @NotBlank
    private String lastName;

    private String company;

    private String position;

    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    private Role role;

    public UserProfile(Long id, String email, Boolean active, String firstName, String lastName, String company, String position, Role role) {
        this.id = id;
        this.email = email;
        this.active = active;
        this.firstName = firstName;
        this.lastName = lastName;
        this.company = company;
        this.position = position;
        this.role = role;
    }

    public static UserProfile convertUser(User user){
        return new UserProfile(
                user.getId(),
                user.getEmail(),
                user.getActive(),
                user.getFirstName(),
                user.getLastName(),
                user.getCompany(),
                user.getPosition(),
                user.getRole()
        );
    }

    public Long getId() {
        return id;
    }

    public String getEmail() {
        return email;
    }

    public Boolean getActive() {
        return active;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public String getCompany() {
        return company;
    }

    public String getPosition() {
        return position;
    }

    public Role getRole() {
        return role;
    }
}
