/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.qsoft.rs.sincoar.model;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TGENEOFFICE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tgeneoffice.findAll", query = "SELECT t FROM Tgeneoffice t"),
    @NamedQuery(name = "Tgeneoffice.findByOfficecode", query = "SELECT t FROM Tgeneoffice t WHERE t.tgeneofficePK.officecode = :officecode"),
    @NamedQuery(name = "Tgeneoffice.findByBranchcode", query = "SELECT t FROM Tgeneoffice t WHERE t.tgeneofficePK.branchcode = :branchcode"),
    @NamedQuery(name = "Tgeneoffice.findByCompanycode", query = "SELECT t FROM Tgeneoffice t WHERE t.tgeneofficePK.companycode = :companycode"),
    @NamedQuery(name = "Tgeneoffice.findByRecordversion", query = "SELECT t FROM Tgeneoffice t WHERE t.recordversion = :recordversion"),
    @NamedQuery(name = "Tgeneoffice.findByDescription", query = "SELECT t FROM Tgeneoffice t WHERE t.description = :description"),
    @NamedQuery(name = "Tgeneoffice.findByAddress", query = "SELECT t FROM Tgeneoffice t WHERE t.address = :address"),
    @NamedQuery(name = "Tgeneoffice.findByPhone", query = "SELECT t FROM Tgeneoffice t WHERE t.phone = :phone")})
public class Tgeneoffice implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TgeneofficePK tgeneofficePK;
    @Column(name = "RECORDVERSION")
    private BigInteger recordversion;
    @Column(name = "DESCRIPTION")
    private String description;
    @Column(name = "ADDRESS")
    private String address;
    @Column(name = "PHONE")
    private String phone;
    @OneToMany(mappedBy = "tgeneoffice")
    private Collection<Tsafeuserdetail> tsafeuserdetailCollection;
    @OneToMany(mappedBy = "tgeneoffice")
    private Collection<Tcustpersondetail> tcustpersondetailCollection;
    @JoinColumns({
        @JoinColumn(name = "BRANCHCODE", referencedColumnName = "BRANCHCODE", insertable = false, updatable = false),
        @JoinColumn(name = "COMPANYCODE", referencedColumnName = "COMPANYCODE", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Tgenebranch tgenebranch;
    @JoinColumns({
        @JoinColumn(name = "COUNTRYCODE", referencedColumnName = "COUNTRYCODE"),
        @JoinColumn(name = "PROVINCECODE", referencedColumnName = "PROVINCECODE"),
        @JoinColumn(name = "CANTONCODE", referencedColumnName = "CANTONCODE"),
        @JoinColumn(name = "CITYCODE", referencedColumnName = "CITYCODE")})
    @ManyToOne
    private Tgenecity tgenecity;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgeneoffice")
    private Collection<Tsafeusercompany> tsafeusercompanyCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgeneoffice")
    private Collection<Tsafeterminal> tsafeterminalCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgeneoffice")
    private Collection<Tgenscheduleparameters> tgenscheduleparametersCollection;

    public Tgeneoffice() {
    }

    public Tgeneoffice(TgeneofficePK tgeneofficePK) {
        this.tgeneofficePK = tgeneofficePK;
    }

    public Tgeneoffice(short officecode, short branchcode, long companycode) {
        this.tgeneofficePK = new TgeneofficePK(officecode, branchcode, companycode);
    }

    public TgeneofficePK getTgeneofficePK() {
        return tgeneofficePK;
    }

    public void setTgeneofficePK(TgeneofficePK tgeneofficePK) {
        this.tgeneofficePK = tgeneofficePK;
    }

    public BigInteger getRecordversion() {
        return recordversion;
    }

    public void setRecordversion(BigInteger recordversion) {
        this.recordversion = recordversion;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getAddress() {
        return address;
    }

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

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @XmlTransient
    public Collection<Tsafeuserdetail> getTsafeuserdetailCollection() {
        return tsafeuserdetailCollection;
    }

    public void setTsafeuserdetailCollection(Collection<Tsafeuserdetail> tsafeuserdetailCollection) {
        this.tsafeuserdetailCollection = tsafeuserdetailCollection;
    }

    @XmlTransient
    public Collection<Tcustpersondetail> getTcustpersondetailCollection() {
        return tcustpersondetailCollection;
    }

    public void setTcustpersondetailCollection(Collection<Tcustpersondetail> tcustpersondetailCollection) {
        this.tcustpersondetailCollection = tcustpersondetailCollection;
    }

    public Tgenebranch getTgenebranch() {
        return tgenebranch;
    }

    public void setTgenebranch(Tgenebranch tgenebranch) {
        this.tgenebranch = tgenebranch;
    }

    public Tgenecity getTgenecity() {
        return tgenecity;
    }

    public void setTgenecity(Tgenecity tgenecity) {
        this.tgenecity = tgenecity;
    }

    @XmlTransient
    public Collection<Tsafeusercompany> getTsafeusercompanyCollection() {
        return tsafeusercompanyCollection;
    }

    public void setTsafeusercompanyCollection(Collection<Tsafeusercompany> tsafeusercompanyCollection) {
        this.tsafeusercompanyCollection = tsafeusercompanyCollection;
    }

    @XmlTransient
    public Collection<Tsafeterminal> getTsafeterminalCollection() {
        return tsafeterminalCollection;
    }

    public void setTsafeterminalCollection(Collection<Tsafeterminal> tsafeterminalCollection) {
        this.tsafeterminalCollection = tsafeterminalCollection;
    }

    @XmlTransient
    public Collection<Tgenscheduleparameters> getTgenscheduleparametersCollection() {
        return tgenscheduleparametersCollection;
    }

    public void setTgenscheduleparametersCollection(Collection<Tgenscheduleparameters> tgenscheduleparametersCollection) {
        this.tgenscheduleparametersCollection = tgenscheduleparametersCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tgeneofficePK != null ? tgeneofficePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tgeneoffice)) {
            return false;
        }
        Tgeneoffice other = (Tgeneoffice) object;
        if ((this.tgeneofficePK == null && other.tgeneofficePK != null) || (this.tgeneofficePK != null && !this.tgeneofficePK.equals(other.tgeneofficePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsoft.rs.sincoar.model.Tgeneoffice[ tgeneofficePK=" + tgeneofficePK + " ]";
    }
    
}
