package com.nisum.model.impl;

import com.nisum.model.Employee;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

@Table
@Entity(name="employee")
public class EmployeeImp implements Employee {

  @Id
  @GeneratedValue
  private Integer id;

  private String firstName;
  private String lastName;

  @Transient
  private JobRoleImp jobRole;

  public EmployeeImp() {
  }

  public String getFirstName() {
    return firstName;
  }

  public String getLastName() {
    return lastName;
  }

  public String getDisplayName() {
    return String.format("%s%s",
        this.firstName.toUpperCase().charAt(0),
        this.lastName.toUpperCase());
  }

  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }

  public void setLastName(String lastName) {
    this.lastName = lastName;
  }

  public JobRoleImp getJobRole() {
    return jobRole;
  }

  public void setJobRole(JobRoleImp jobRole) {
    this.jobRole = jobRole;
  }

  public Integer getId() {
    return id;
  }

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

  public void set(String[] settings){
    setFirstName(settings[0]);
    setLastName(settings[1]);
    setJobRole(new JobRoleImp(settings[2]));
  }
}
