/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.apc.model.catalog;

import com.arrebol.apc.model.core.Office;
import com.arrebol.apc.model.enums.ActiveStatus;
import com.arrebol.apc.model.gasoline.Gasoline;
import com.arrebol.apc.model.loan.Loan;
import java.io.Serializable;
import java.util.Date;
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.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.GenericGenerator;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
@Entity
@Table(name = "APC_ROUTE",
        uniqueConstraints = {
            @UniqueConstraint(columnNames = {"id_office", "route_name"}, name = "apc_route_uk")
        }
)
public class RouteCtlg implements Serializable {

    private static final long serialVersionUID = -903631618997045859L;

    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid2")
    @Column(name = "id", length = 36)
    private String id;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(
            name = "id_office",
            referencedColumnName = "id",
            nullable = false
    )
    private Office office;

    @Column(name = "route_name", length = 25, nullable = false)
    private String route;

    @Enumerated(EnumType.STRING)
    @Column(name = "active_status", nullable = false)
    private ActiveStatus activeStatus;

    @Column(name = "created_by", nullable = false, length = 36)
    private String createdBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_on", length = 19)
    private Date createdOn;

    @Column(name = "last_updated_by", length = 36)
    private String lastUpdatedBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_updated_on", length = 19)
    private Date lastUpdatedOn;

    @OneToMany(
            fetch = FetchType.LAZY,
            mappedBy = "routeCtlg",
            orphanRemoval = true,
            cascade = CascadeType.ALL
    )
    private List<HumanResourceHasRoute> humanResourceHasRoutes;

    @OneToMany(
            mappedBy = "office",
            cascade = CascadeType.ALL,
            fetch = FetchType.LAZY,
            orphanRemoval = true
    )
    private List<People> peoples;

    @OneToMany(
            mappedBy = "routeCtlg",
            cascade = CascadeType.ALL,
            fetch = FetchType.LAZY,
            orphanRemoval = true
    )
    private List<Loan> loans;

    @OneToMany(
            fetch = FetchType.LAZY,
            mappedBy = "routeCtlg",
            orphanRemoval = true,
            cascade = CascadeType.ALL
    )
    private List<Gasoline> gasolines;

    public RouteCtlg() {
    }

    /**
     *
     * @param id
     */
    public RouteCtlg(String id) {
        this.id = id;
    }

    /**
     *
     * @param id
     * @param route
     */
    public RouteCtlg(String id, String route) {
        this.id = id;
        this.route = route;
    }

    /**
     * Complete constructor.
     *
     * @param id
     * @param office
     * @param route
     * @param activeStatus
     * @param createdBy
     * @param createdOn
     * @param lastUpdatedBy
     * @param lastUpdatedOn
     * @param humanResourceHasRoutes
     */
    public RouteCtlg(String id, Office office, String route, ActiveStatus activeStatus, String createdBy, Date createdOn, String lastUpdatedBy, Date lastUpdatedOn, List<HumanResourceHasRoute> humanResourceHasRoutes) {
        this.id = id;
        this.office = office;
        this.route = route;
        this.activeStatus = activeStatus;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.lastUpdatedBy = lastUpdatedBy;
        this.lastUpdatedOn = lastUpdatedOn;
        this.humanResourceHasRoutes = humanResourceHasRoutes;
    }

    public String getId() {
        return id;
    }

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

    public Office getOffice() {
        return office;
    }

    public void setOffice(Office office) {
        this.office = office;
    }

    public String getRoute() {
        return route;
    }

    public void setRoute(String route) {
        this.route = route;
    }

    public ActiveStatus getActiveStatus() {
        return activeStatus;
    }

    public void setActiveStatus(ActiveStatus activeStatus) {
        this.activeStatus = activeStatus;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Date getLastUpdatedOn() {
        return lastUpdatedOn;
    }

    public void setLastUpdatedOn(Date lastUpdatedOn) {
        this.lastUpdatedOn = lastUpdatedOn;
    }

    public List<HumanResourceHasRoute> getHumanResourceHasRoutes() {
        return humanResourceHasRoutes;
    }

    public void setHumanResourceHasRoutes(List<HumanResourceHasRoute> humanResourceHasRoutes) {
        this.humanResourceHasRoutes = humanResourceHasRoutes;
    }

    public List<People> getPeoples() {
        return peoples;
    }

    public void setPeoples(List<People> peoples) {
        this.peoples = peoples;
    }

    public List<Loan> getLoans() {
        return loans;
    }

    public void setLoans(List<Loan> loans) {
        this.loans = loans;
    }

    public List<Gasoline> getGasolines() {
        return gasolines;
    }

    public void setGasolines(List<Gasoline> gasolines) {
        this.gasolines = gasolines;
    }

    @Override
    public String toString() {
        return "RouteCtlg{" + "route=" + route + '}';
    }

}
