package edu.baylor.icpc.formbuilder.example;

// Generated Jan 31, 2008 10:45:34 PM by Hibernate Tools 3.2.0.CR1

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.Email;
import org.hibernate.validator.Future;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Past;
import org.hibernate.validator.Pattern;
import org.hibernate.validator.Range;

import edu.baylor.icpc.formbuilder.annotation.FormHtml;
import edu.baylor.icpc.formbuilder.annotation.FormLink;
import edu.baylor.icpc.formbuilder.annotation.FormOrder;
import edu.baylor.icpc.formbuilder.annotation.FormPassword;
import edu.baylor.icpc.formbuilder.annotation.FormPattern;

/**
 * Person generated by hbm2java
 */
@Entity
@Table(name = "Person", catalog = "FormBuilder")
public class Person implements java.io.Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;


    private Long id;


    private String firstName;

    private Country country;

    private String lastName;

    private String email;

    private int salary;

    private String username;

    private String password;

    private boolean married;

    private Gender gender;

    private String notes;
    
    private String html;

    private String link;

    private Date employedFrom;

    private Date employedTo;

    private Date wasBorn;

    private Date lastDealUpdate;
    
    private Color favoriteColor = new Color();

    
    public Person() {
    }

    public Person(Country country, String firstName, String lastName,
            String email, int salary, String username,
            String password, boolean married, Gender gender) {
        this.country = country;
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
        this.salary = salary;
        this.username = username;
        this.password = password;
        this.married = married;
        this.gender = gender;
    }

    public Person(Country country, String firstName, String lastName,
            String email, int salary, String username,
            String password, boolean married, Gender gender, String notes,
            Date employedFrom, Date employedTo) {
        this.country = country;
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
        this.salary = salary;
        this.username = username;
        this.password = password;
        this.married = married;
        this.gender = gender;
        this.notes = notes;
        this.employedFrom = employedFrom;
        this.employedTo = employedTo;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return this.id;
    }

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

    @Column(name = "firstName", nullable = false, length = 100)
    @NotNull
    @Length(max = 100)
    @FormOrder(1)
    public String getFirstName() {
        return this.firstName;
    }

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

    @Column(name = "lastName", nullable = false, length = 100)
    @NotNull
    @Length(max = 100)
    @FormOrder(2)
    public String getLastName() {
        return this.lastName;
    }

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

    @Column(name = "email", nullable = false, length = 100, unique = true)
    @NotNull
    @Email
    @Length(max = 100)
    @FormOrder(3)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "username", nullable = false, length = 50, unique = true)
    @NotNull
    @Pattern(regex = "^[a-z._-]+")
    @FormPattern("^[a-z._-]+$")
    @Length(max = 50)
    @FormOrder(4)
    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Column(name = "password", nullable = false, length = 50)
    @NotNull
    @Length(min = 6, max = 50)
    @FormOrder(5)
    @FormPassword
    public String getPassword() {
        return this.password;
    }

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

    @Column(name = "gender", nullable = false)
    @NotNull
    @Enumerated(EnumType.STRING)
    @FormOrder(6)
    public Gender getGender() {
        return this.gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "wasBorn", nullable = false)
    @NotNull
    @Past
    @FormOrder(7)
    public Date getWasBorn() {
        return this.wasBorn;
    }

    public void setWasBorn(Date wasBorn) {
        this.wasBorn = wasBorn;
    }

    @Column(name = "salary", nullable = false)
    @Range(min = 1000, max = 100000)
    @NotNull
    @FormOrder(8)
    public int getSalary() {
        return this.salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @Column(name = "married", nullable = false)
    @NotNull
    @FormOrder(9)
    public boolean isMarried() {
        return this.married;
    }

    public void setMarried(boolean married) {
        this.married = married;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "countryId", nullable = false)
    @NotNull
    @FormOrder(10)
    public Country getCountry() {
        return this.country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    @Column(name = "notes", length = 512)
    @Length(max = 512)
    @FormOrder(11)
    public String getNotes() {
        return this.notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "employedFrom")
    @Past
    @FormOrder(12)
    public Date getEmployedFrom() {
        return this.employedFrom;
    }

    public void setEmployedFrom(Date employedFrom) {
        this.employedFrom = employedFrom;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "employedTo")
    @Future
    @FormOrder(13)
    public Date getEmployedTo() {
        return this.employedTo;
    }

    public void setEmployedTo(Date employedTo) {
        this.employedTo = employedTo;
    }

    public enum Gender {
        FEMALE("Female"), MALE("Male");

        private final String label;

        Gender(String label) {
            this.label = label;
        }

        public String getLabel() {
            return label;
        }

    }

    public static List<Enum<Gender>> getGenderList() {
        List<Enum<Gender>> types = new ArrayList<Enum<Gender>>();
        for (Gender value : Gender.values()) {
            types.add(value);
        }
        return types;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "lastDealUpdate", nullable = true, length = 0)
    @Past
    @FormOrder(14)
    public Date getLastDealUpdate() {
        return this.lastDealUpdate;
    }

    public void setLastDealUpdate(Date lastDealUpdate) {
        this.lastDealUpdate = lastDealUpdate;
    }
    @Column(name = "html", length = 512)
    @Length(max = 512)
    @FormOrder(15)
    @FormHtml
    public String getHtml() {
        return this.html;
    }

    public void setHtml(String html) {
        this.html = html;
    }

    @Column(name = "link", length = 100)
    @Length(max = 100)
    @FormOrder(16)
    @FormLink
    @Pattern(regex = "(^[^\\s]*)|()")
    @FormPattern("^[^\\s]*$")
    public String getLink() {
        // "^www[^\\s]*" = starts www and does not have spaces
        return this.link;
    }

    public void setLink(String link) {
            this.link = link;
    }

    @Embedded
    @FormOrder(17)
    @AttributeOverride(name = "rgb", column = @Column(name = "favoriteColor"))
    public Color getFavoriteColor() {
        return favoriteColor;
    }

    public void setFavoriteColor(Color favoriteColor) {
        this.favoriteColor = favoriteColor;
    }

}