Package it.hotel.model.user

Source Code of it.hotel.model.user.User

/*
Copyright (C) European Community 2008 - Licensed under the EUPL V.1.0 (http://ec.europa.eu/idabc/en/document/6523)
*/

package it.hotel.model.user;

import it.hotel.model.permission.Permission;
import it.hotel.model.role.Role;

/**
* Rappresentazione di un'utente.
* @version 1.0
* @author M.Diana - E.Santoboni
*/
public class User implements IUser {
   
  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getUserName()
   */
    public String getUserName() {
        return _userName;
    }
   
    /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setUserName(java.lang.String)
   */
    public void setUserName(String userName) {
        this._userName = userName;
    }
   
    /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getPassword()
   */
    public String getPassword() {
        return _password;
    }
   
    /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setPassword(java.lang.String)
   */
    public void setPassword(String password) {
        this._password = password;
    }
   
    /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#isGuest()
   */
    /**
     * @return
     */
    public boolean isGuest() {
      boolean isGuest = false;
      if (this.getRole() != null && this.getRole().getName().equals("guest")) {
        isGuest = true;
      }
        return isGuest;
    }
   
    /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#clone()
   */
    public Object clone() {
        IUser cl = new User();
        cl.setUserName(this._userName);
        cl.setName(this._name);
        cl.setSurname(this._surname);
        cl.setPassword(this._password);
        cl.setPasswordConfirm(this._passwordConfirm);
        cl.setEmail(this.email);
        cl.setLanguage(this.language);
        cl.setStructureId(this._structureId);
        Role roleClone = (Role) this.getRole().clone();
        cl.setRole(roleClone);
        return cl;
    }
   
    /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getRole()
   */
  public Role getRole() {
    return _role;
  }
 
  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setRole(it.hotel.system.services.role.Role)
   */
  public void setRole(Role role) {
    this._role = role;
  }
 
  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#hasPermission(java.lang.String)
   */
  public boolean hasPermission(String permissionName) {
    Role role = this.getRole();
    return (role != null && (role.hasPermission(Permission.SUPERUSER) || role.hasPermission(permissionName)));
  }
 
  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getName()
   */
  public String getName() {
    return _name;
  }
  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setName(java.lang.String)
   */
  public void setName(String name) {
    this._name = name;
  }
 
  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getSurname()
   */
  public String getSurname() {
    return _surname;
  }
  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setSurname(java.lang.String)
   */
  public void setSurname(String surname) {
    this._surname = surname;
 

  /**
   *
   */
  public String getFullName() {
    StringBuffer fullName = new StringBuffer();
    fullName.append(this.getName()).append(" ").append(this.getSurname());
    return fullName.toString();
  }
 
 
   
    private String _userName;
    private String _password;
    private String email;
    private String _passwordConfirm;
    private Role _role;
    private int _structureId;
   
    private String _name = "";
    private String _surname = "";
    private String language = "none";
   
    /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getPasswordConfirm()
   */
  public String getPasswordConfirm() {
    return _passwordConfirm;
  }

  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setPasswordConfirm(java.lang.String)
   */
  public void setPasswordConfirm(String confirm) {
    _passwordConfirm = confirm;
  }

  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getEmail()
   */
  public String getEmail() {
    return email;
  }

  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setEmail(java.lang.String)
   */
  public void setEmail(String email) {
    this.email = email;
  }

  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#getLanguage()
   */
  public String getLanguage() {
    return language;
  }

  /* (non-Javadoc)
   * @see it.hotel.system.services.user.IUser#setLanguage(java.lang.String)
   */
  public void setLanguage(String language) {
    this.language = language;
  }

  public int getStructureId() {
    return _structureId;
  }

  public void setStructureId(int id) {
    _structureId = id;
  }

 

 
}
TOP

Related Classes of it.hotel.model.user.User

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.