/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.ticket;

import java.time.LocalDateTime;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import model.AbstractEntity;
import model.adresses.CompanyBillingAddress;
import model.company.Company;
import model.company.Location;
import model.files.Invoice;
import model.files.Report;
import model.person.Person;
import model.person.Token;

/**
 *
 * @author patri
 */
@Entity
public class Ticket extends AbstractEntity{
    
    @Column(nullable = false)
    @OneToOne
    private Company company;
    
    @OneToOne
    private CompanyBillingAddress billingAddress;
    
    @OneToMany
    private List<Location> locations;
    
    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private Status status;
    
    @Column(nullable = false)
    @OneToOne
    private Person creator;
    
    @Column(nullable = true)
    @OneToOne
    private Person owner;
    
    private LocalDateTime startDate;
    
    private LocalDateTime endDate;
    
    @OneToMany(mappedBy = "ticket", cascade = CascadeType.ALL)
    private List<Comment> comments;
    
    private boolean payed;
    
    @OneToMany(mappedBy = "ticket", orphanRemoval = true, cascade = CascadeType.ALL)
    private List<Token> tokens;
    
    @OneToMany(mappedBy = "ticket", cascade = {CascadeType.PERSIST, CascadeType.PERSIST})
    private List<Report> reports;
    
    @OneToMany(mappedBy = "ticket", cascade = {CascadeType.PERSIST, CascadeType.PERSIST})
    private List<Invoice> invoices;
    
    @Column(nullable = false, length = 200)
    private String filenameGeneration;

    public Ticket() {
    }

    public CompanyBillingAddress getBillingAddress() {
        return billingAddress;
    }

    public void setBillingAddress(CompanyBillingAddress billingAddress) {
        this.billingAddress = billingAddress;
    }

    public LocalDateTime getStartDate() {
        return startDate;
    }

    public void setStartDate(LocalDateTime startDate) {
        this.startDate = startDate;
    }

    public LocalDateTime getEndDate() {
        return endDate;
    }

    public void setEndDate(LocalDateTime endDate) {
        this.endDate = endDate;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    public List<Location> getLocations() {
        return locations;
    }

    public void setLocations(List<Location> locations) {
        this.locations = locations;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Person getCreator() {
        return creator;
    }

    public void setCreator(Person creator) {
        this.creator = creator;
    }

    public Person getOwner() {
        return owner;
    }

    public void setOwner(Person owner) {
        this.owner = owner;
    }

    public List<Comment> getComments() {
        return comments;
    }

    public void setComments(List<Comment> comments) {
        this.comments = comments;
    }

    public boolean isPayed() {
        return payed;
    }

    public void setPayed(boolean payed) {
        this.payed = payed;
    }

    public List<Token> getTokens() {
        return tokens;
    }

    public void setTokens(List<Token> tokens) {
        this.tokens = tokens;
    }

    public List<Report> getReports() {
        return reports;
    }

    public void setReports(List<Report> reports) {
        this.reports = reports;
    }

    public List<Invoice> getInvoices() {
        return invoices;
    }

    public void setInvoices(List<Invoice> invoices) {
        this.invoices = invoices;
    }

    public String getFilenameGeneration() {
        return filenameGeneration;
    }

    public void setFilenameGeneration(String filenameGeneration) {
        this.filenameGeneration = filenameGeneration;
    }
    
    
}
