/*
 * 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.core;

import com.arrebol.apc.model.admin.Advance;
import com.arrebol.apc.model.admin.Bonus;
import com.arrebol.apc.model.admin.ExpenseCompany;
import com.arrebol.apc.model.admin.Goal;
import com.arrebol.apc.model.admin.MoneyDaily;
import com.arrebol.apc.model.admin.OtherExpense;
import com.arrebol.apc.model.admin.StableGeneralBox;
import com.arrebol.apc.model.admin.Transfer;
import com.arrebol.apc.model.catalog.People;
import com.arrebol.apc.model.catalog.RouteCtlg;
import com.arrebol.apc.model.enums.OfficeStatus;
import com.arrebol.apc.model.gasoline.Gasoline;
import com.arrebol.apc.model.loan.LoanType;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;
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.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_OFFICE",
        uniqueConstraints = {
            @UniqueConstraint(columnNames = {"office_name"})}
)
public class Office implements Serializable {

    private static final long serialVersionUID = -141661123746446879L;

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

    @Column(name = "office_name", length = 100, nullable = false)
    private String officeName;

    @Column(name = "address", length = 250)
    private String address;

    @Enumerated(EnumType.STRING)
    @Column(name = "office_status", nullable = false)
    private OfficeStatus officeStatus;

    @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(
            mappedBy = "office",
            cascade = CascadeType.ALL,
            fetch = FetchType.LAZY,
            orphanRemoval = true
    )
    private List<UserByOffice> userByOffices;

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

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

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

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

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

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

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

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

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

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

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

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

    public Office() {
    }

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

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

    public Office(String id, String officeName, String address) {
        this.id = id;
        this.officeName = officeName;
        this.address = address;
    }

    public String getId() {
        return id;
    }

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

    public String getOfficeName() {
        return officeName;
    }

    public void setOfficeName(String officeName) {
        this.officeName = officeName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public OfficeStatus getOfficeStatus() {
        return officeStatus;
    }

    public void setOfficeStatus(OfficeStatus officeStatus) {
        this.officeStatus = officeStatus;
    }

    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<UserByOffice> getUserByOffices() {
        return userByOffices;
    }

    public void setUserByOffices(List<UserByOffice> userByOffices) {
        this.userByOffices = userByOffices;
    }

    public List<HumanResourceByOffice> getHumanResourceByOffices() {
        return humanResourceByOffices;
    }

    public void setHumanResourceByOffices(List<HumanResourceByOffice> humanResourceByOffices) {
        this.humanResourceByOffices = humanResourceByOffices;
    }

    public List<RouteCtlg> getRouteCtlgs() {
        return routeCtlgs;
    }

    public void setRouteCtlgs(List<RouteCtlg> routeCtlgs) {
        this.routeCtlgs = routeCtlgs;
    }

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

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

    public List<LoanType> getLoanTypes() {
        return loanTypes;
    }

    public void setLoanTypes(List<LoanType> loanTypes) {
        this.loanTypes = loanTypes;
    }

    public List<Transfer> getTransfers() {
        return transfers;
    }

    public void setTransfers(List<Transfer> transfers) {
        this.transfers = transfers;
    }

    public List<MoneyDaily> getMoneyDailys() {
        return moneyDailys;
    }

    public void setMoneyDailys(List<MoneyDaily> moneyDailys) {
        this.moneyDailys = moneyDailys;
    }

    public List<OtherExpense> getOtherExpenses() {
        return otherExpenses;
    }

    public void setOtherExpenses(List<OtherExpense> otherExpenses) {
        this.otherExpenses = otherExpenses;
    }

    public List<Goal> getGoals() {
        return goals;
    }

    public void setGoals(List<Goal> goals) {
        this.goals = goals;
    }

    public List<Advance> getAdvances() {
        return advances;
    }

    public void setAdvances(List<Advance> advances) {
        this.advances = advances;
    }

    public List<Bonus> getBonuses() {
        return bonuses;
    }

    public void setBonuses(List<Bonus> bonuses) {
        this.bonuses = bonuses;
    }

    public List<ExpenseCompany> getExpenseCompanies() {
        return expenseCompanies;
    }

    public void setExpenseCompanies(List<ExpenseCompany> expenseCompanies) {
        this.expenseCompanies = expenseCompanies;
    }

    public List<StableGeneralBox> getStableGeneralBoxes() {
        return stableGeneralBoxes;
    }

    public void setStableGeneralBoxes(List<StableGeneralBox> stableGeneralBoxes) {
        this.stableGeneralBoxes = stableGeneralBoxes;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 97 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Office other = (Office) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Office{" + "officeName=" + officeName + ", address=" + address + '}';
    }

}
