package com.arrebol.taxiservicios.model.core;

import com.arrebol.taxiservicios.model.catalog.Location;
import com.arrebol.taxiservicios.model.enums.UserStatusType;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 *
 * @author Carlos Janitzio Zavala Lopez
 */
public class User implements Serializable {

    private static final long serialVersionUID = 5293919946950359645L;

    private String id;
    private Person person;
    private String userName;
    private String password;
    private boolean active;
    private boolean root;
    private boolean ajustador;
    private UserStatusType userStatusType;
    private Location location;
    private String createdBy;
    private Date createdOn;
    private String lastUpdatedBy;
    private Date lastUpdatedOn;
    private Set userHasPermissions = new HashSet(0);
    private boolean superAdmin;
    private boolean usuarioExterno;

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public User() {
    }

    public User(String userName) {
        this.userName = userName;
    }

    public User(String id, boolean active) {
        this.id = id;
        this.active = active;
    }

    public User(Person person) {
        this.person = person;
    }

    /**
     *
     * @param id Identify number
     * @param userName Username
     */
    public User(String id, String userName) {
        this.id = id;
        this.userName = userName;
    }

    /**
     *
     * @param person
     * @param userName
     */
    public User(Person person, String userName) {
        this.person = person;
        this.userName = userName;
    }

    /**
     *
     * @param userName
     * @param person
     */
    public User(String userName, Person person) {
        this.userName = userName;
        this.person = person;
    }

    /**
     *
     * @param id
     * @param userName
     * @param root
     */
    public User(String id, String userName, boolean root) {
        this.id = id;
        this.userName = userName;
        this.root = root;
    }

    /**
     *
     * @param id
     * @param userName
     * @param person
     */
    public User(String id, String userName, Person person) {
        this.id = id;
        this.userName = userName;
        this.person = person;
    }

    /**
     *
     * @param id
     * @param userName
     * @param person
     * @param root
     */
    public User(String id, String userName, Person person, boolean root) {
        this.id = id;
        this.userName = userName;
        this.person = person;
        this.root = root;
    }

    /**
     *
     * @param id
     * @param userName
     * @param person
     * @param root
     * @param active
     */
    public User(String id, String userName, Person person, boolean root, boolean active) {
        this.id = id;
        this.userName = userName;
        this.person = person;
        this.root = root;
        this.active = active;
    }

    public User(String id, String userName, String password, boolean active, Person person) {
        this.id = id;
        this.userName = userName;
        this.password = password;
        this.active = active;
        this.person = person;
    }

    public User(String id, String userName, String password, boolean active, Person person, Boolean root) {
        this.id = id;
        this.userName = userName;
        this.password = password;
        this.active = active;
        this.person = person;
        this.root = root;
    }

    public User(String id, Person person, String userName) {
        this.id = id;
        this.person = person;
        this.userName = userName;
    }

    /**
     * Use for user creation functionality.
     *
     * @param id
     * @param userName
     * @param password
     * @param active
     * @param createdBy
     */
    public User(String id, String userName, String password, boolean active, String createdBy) {
        this.id = id;
        this.userName = userName;
        this.password = password;
        this.active = active;
        this.createdBy = createdBy;
    }
    
    /**
     * Use for user creation functionality.
     *
     * @param id
     * @param root
     * @param userName
     * @param password
     * @param active
     * @param createdBy
     * 
     */
    public User(String id,Boolean root ,String userName, String password, boolean active, String createdBy) {
        this.id = id;
        this.root = root;
        this.userName = userName;
        this.password = password;
        this.active = active;
        this.createdBy = createdBy;
    }

    public User(String id, Person person, String userName, String password, boolean active, boolean root, UserStatusType userStatusType, Location location, String createdBy, Date createdOn, String lastUpdatedBy, Date lastUpdatedOn) {
        this.id = id;
        this.person = person;
        this.userName = userName;
        this.password = password;
        this.active = active;
        this.root = root;
        this.userStatusType = userStatusType;
        this.location = location;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.lastUpdatedBy = lastUpdatedBy;
        this.lastUpdatedOn = lastUpdatedOn;
    }

    public String getId() {
        return id;
    }

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

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

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

    public boolean isActive() {
        return active;
    }

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

    public boolean isRoot() {
        return root;
    }

    public void setRoot(boolean root) {
        this.root = root;
    }

    public UserStatusType getUserStatusType() {
        return userStatusType;
    }

    public void setUserStatusType(UserStatusType userStatusType) {
        this.userStatusType = userStatusType;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Date getLastUpdatedOn() {
        return lastUpdatedOn;
    }

    public void setLastUpdatedOn(Date lastUpdatedOn) {
        this.lastUpdatedOn = lastUpdatedOn;
    }

    public Set getUserHasPermissions() {
        return userHasPermissions;
    }

    public void setUserHasPermissions(Set userHasPermissions) {
        this.userHasPermissions = userHasPermissions;
    }

    public boolean isSuperAdmin() {
        return superAdmin;
    }

    public void setSuperAdmin(boolean superAdmin) {
        this.superAdmin = superAdmin;
    }
    
    

    @Override
    public String toString() {
        return "User{" + "person=" + person + ", userName=" + userName + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final User other = (User) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    public User(String id, String userName, Person person, boolean root, Location location) {
        this.id = id;
        this.person = person;
        this.userName = userName;
        this.root = root;
        this.location = location;
    }
    
    public User(String id, String userName, Person person, boolean root, Location location, boolean superAdmin, boolean usuarioExterno) {
        this.id = id;
        this.person = person;
        this.userName = userName;
        this.root = root;
        this.location = location;
        this.superAdmin = superAdmin;
        this.usuarioExterno = usuarioExterno;
    }

    public boolean isUsuarioExterno() {
        return usuarioExterno;
    }

    public void setUsuarioExterno(boolean usuarioExterno) {
        this.usuarioExterno = usuarioExterno;
    }        

    public boolean isAjustador() {
        return ajustador;
    }

    public void setAjustador(boolean ajustador) {
        this.ajustador = ajustador;
    }

}
