package com.armundia.app.login;

import java.io.Serializable;

import javax.enterprise.context.SessionScoped;

import com.armundia.core.users.entity.SeUsers;
import com.armundia.v2.shared.interfaces.ISessionUser;
import com.armundia.v2.shared.pojo.UtenteBasePojo;

@SessionScoped
public class DatiUtentePojo extends UtenteBasePojo implements ISessionUser, Serializable {
	private static final long serialVersionUID = -407431522773890390L;

	protected String token;

	public DatiUtentePojo() {}

	public DatiUtentePojo(SeUsers utente) {
		this.userId = utente.getUserid();
		this.name = utente.getFirstname();
		this.lastName = utente.getLastname();
		this.email = utente.getEmail();
		this.codLang = utente.getCodLang();
		this.phone = utente.getPhone();
		this.dateLastLogin = utente.getDataPrecedenteLogin();
		this.datePasswordModified = utente.getDtpassword();
	}

	public String getFirstname() {
		return name;
	}

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

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}
	
	public void setValuesFrom(DatiUtentePojo other) {
		if (other != null) {
			this.userId = other.getUserId();
			this.codLang = other.getCodLang();
			this.dateLastLogin = other.getDateLastLogin();
			this.name = other.getName();
			this.lastName = other.getLastName();
			this.email = other.getEmail();
			this.phone = other.getPhone();
			this.jsessionId = other.getJsessionId();
			this.datePasswordModified = other.getDatePasswordModified();
			this.roles = other.getRoles();
			this.authorizations = other.getAuthorizations();
			this.usrFlUnMusked = other.getUsrFlUnMusked();
			this.profile = other.getProfile();
			this.userCookie = other.getUserCookie();
			this.environment = other.getEnvironment();
			// Nuovi campi aggiunti
			this.token = other.getToken();
		}
	}
}