package com.libreecm.commonAPI.model.users;

//import org.springframework.security.core.GrantedAuthority;

/**
 * Class defines an user, its role and some information
 * @author Jordi Pérez Bayerri
 *
 */

public class LibreECMUser extends BaseObject{//extends org.springframework.security.core.userdetails.User {

	private Role role;

	private Integer id;
	
	private String username;
	
	private String password;
	
	private boolean enabled;
	
	private boolean accountNonExpired;
	
	private boolean accountNonLocked;
	
	//private List<GrantedAuthority> authorities;
	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}
	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return the enabled
	 */
	public boolean isEnabled() {
		return enabled;
	}
	/**
	 * @param enabled the enabled to set
	 */
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	/**
	 * @return the accountNonExpired
	 */
	public boolean isAccountNonExpired() {
		return accountNonExpired;
	}
	/**
	 * @param accountNonExpired the accountNonExpired to set
	 */
	public void setAccountNonExpired(boolean accountNonExpired) {
		this.accountNonExpired = accountNonExpired;
	}
	/**
	 * @return the accountNonLocked
	 */
	public boolean isAccountNonLocked() {
		return accountNonLocked;
	}
	/**
	 * @param accountNonLocked the accountNonLocked to set
	 */
	public void setAccountNonLocked(boolean accountNonLocked) {
		this.accountNonLocked = accountNonLocked;
	}
	
	public LibreECMUser(){
		//super("default", "default", true, true, true, true, new ArrayList<>()	);
		this.id=0;
		this.username="";
		this.password="";
		this.role=Role.USER;
	}
	/**
	 * Defines a new user for the system
	 * @param username
	 * @param role
	 * @param enabled
	 * @param accountNonExpired
	 * @param credentialsNonExpired
	 * @param accountNonLocked
	 * @param authorities
	 */
	public LibreECMUser(String username, Role role, boolean enabled, boolean accountNonExpired,
			boolean credentialsNonExpired, boolean accountNonLocked
			){//List<GrantedAuthority> authorities) {
		//super(username, "", enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
		this.username=username;
		this.role=role;
		this.enabled=enabled;
		this.accountNonExpired=accountNonExpired;
		this.accountNonLocked=accountNonLocked;
		//this.authorities=authorities;
		this.password="";
		this.id=0;
	}
	
	public String getId() {
		if (id==null){
			return null;
		}
		return this.id.toString();
	}
	
	public void setId(String id) {
		this.id=Integer.parseInt(id);
	}

	//public List<GrantedAuthority> getAuthorities() {
	//	return authorities;
	//}
	//public void setAuthorities(List<GrantedAuthority> authorities) {
	//	this.authorities = authorities;
	//}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}
	

	
	public String toString(){
    	return "User id:"+getId()
    			+" name "+getUsername()
    			+" role "+getRole();
    }

}
