package com.eksad.masterdata.domain; import com.eksad.ddms.common.util.object.EntityObject; import com.eksad.ddms.common.util.status.DataStatus; import com.eksad.masterdata.common.listEnum.*; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.persistence.*; import org.hibernate.validator.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.sql.Time; import java.util.Date; import java.util.HashSet; import java.util.Objects; import java.util.Set; @Entity @Table(name = "MST_PROMO") public class Promo implements EntityObject { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "mst_promo_gen") @SequenceGenerator(name = "mst_promo_gen", sequenceName = "mst_promo_seq", allocationSize = 1) Integer id; @NotNull(message = "joinable cannot be null") private Boolean isJoinable; @Column(unique = true) @NotEmpty(message = "promo id cannot be null") private String promoID; @NotNull(message = "promo code cannot be null") private String promoCode; @Temporal(TemporalType.DATE) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd hh:mm:ss") private Date promoStartDate; @Temporal(TemporalType.DATE) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd hh:mm:ss") private Date promoEndDate; @NotNull(message = "promo name cannot be null") private String promoName; @NotNull(message = "promo source cannot be null") private String promoSource; // @NotNull(message = "customer type cannot be null") private String categoryID; // @Enumerated(EnumType.STRING) // @NotNull(message = "customer type cannot be null") // private CustomerType customerType; // // @Enumerated(EnumType.STRING) // private PromoBookingType promoBookingType; // // @Enumerated(EnumType.STRING) // private PromoCustomerOccupationType customerOccupation; // // @Enumerated(EnumType.STRING) // private PromoGenderCustomerType customerGender; @Enumerated(EnumType.STRING) private PromoAhassType ahassType; @Enumerated(EnumType.STRING) private PromoAreaType areaType; @Enumerated(EnumType.STRING) private PromoLokasiType lokasiType; @Enumerated(EnumType.STRING) private PromoProgramType programType; // @Enumerated(EnumType.STRING) // private PromoJasaBengkelType promoJasaBengkelType; @Enumerated(EnumType.STRING) private PromoSparepartType promoSparepartType; @Enumerated(EnumType.STRING) private PromoPackageServiceType promoPackageServiceType; private String promoCustomer; private Integer jumlahService; private Integer jumlahBerlaku; private Integer jumlahPengulangan; @Enumerated(EnumType.STRING) private PromoBerlakuAhassType promoBerlakuAhassType; private String ketentuanSettings; @Enumerated(EnumType.STRING) private PromoKetentuanType promoKetentuanType; private String kelipatanKM; private Time jamMulai; private Time jamAkhir; private String hariBerlaku; @Enumerated(value = EnumType.STRING) private DataStatus promoStatus; @Embedded private CreationalSpecification promoCreational; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "promoID", referencedColumnName = "promoID") private Set listPromoUnitBerlaku = new HashSet<>(); // @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) // @JoinColumn(name = "promoID", referencedColumnName = "promoID") // private Set listPromoJasa = new HashSet<>(); @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "promoID", referencedColumnName = "promoID") private Set listDiscountPart = new HashSet<>(); @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "promoID", referencedColumnName = "promoID") private Set listPackageService = new HashSet<>(); @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "promoID", referencedColumnName = "promoID") private Set listPromoArea; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "promoID", referencedColumnName = "promoID") private Set listPromoPos; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "promoID", referencedColumnName = "promoID") private Set listPromoAhass; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "promoID", referencedColumnName = "promoID") private Set listPromoCustomerJob; public Promo() { } public Promo(Boolean isJoinable, String promoID, String promoCode, Date promoStartDate, Date promoEndDate, String promoName, String promoSource, String categoryID, PromoAhassType ahassType, PromoAreaType areaType, PromoLokasiType lokasiType, PromoProgramType programType, String kelipatanKM, Time jamMulai, Time jamAkhir, String hariBerlaku, DataStatus promoStatus, CreationalSpecification promoCreational, Set listPromoUnitBerlaku, Set listDiscountPart, Set listPackageService, Set listPromoArea, Set listPromoPos, Set listPromoAhass, Set listPromoCustomerJob, PromoSparepartType promoSparepartType, PromoPackageServiceType promoPackageServiceType, String promoCustomer, Integer jumlahService, Integer jumlahBerlaku, Integer jumlahPengulangan, PromoBerlakuAhassType promoBerlakuAhassType, String ketentuanSettings, PromoKetentuanType promoKetentuanType) { this.isJoinable = isJoinable; this.promoID = promoID; this.promoCode = promoCode; this.promoStartDate = promoStartDate; this.promoEndDate = promoEndDate; this.promoName = promoName; this.promoSource = promoSource; this.categoryID = categoryID; // this.customerType = customerType; // this.promoBookingType = promoBookingType; // this.customerOccupation = customerOccupation; // this.customerGender = customerGender; this.ahassType = ahassType; this.areaType = areaType; this.lokasiType = lokasiType; this.programType = programType; this.kelipatanKM = kelipatanKM; this.jamMulai = jamMulai; this.jamAkhir = jamAkhir; this.hariBerlaku = hariBerlaku; this.promoStatus = promoStatus; this.promoCreational = promoCreational; this.listPromoUnitBerlaku = listPromoUnitBerlaku; // this.listPromoJasa = listPromoJasa; this.listDiscountPart = listDiscountPart; this.listPackageService = listPackageService; this.listPromoArea = listPromoArea; this.listPromoPos = listPromoPos; this.listPromoAhass = listPromoAhass; this.listPromoCustomerJob = listPromoCustomerJob; // this.promoJasaBengkelType = promoJasaBengkelType; this.promoSparepartType = promoSparepartType; this.promoPackageServiceType = promoPackageServiceType; this.promoCustomer = promoCustomer; this.jumlahService = jumlahService; this.jumlahBerlaku = jumlahBerlaku; this.jumlahPengulangan = jumlahPengulangan; this.promoBerlakuAhassType = promoBerlakuAhassType; this.ketentuanSettings = ketentuanSettings; this.promoKetentuanType = promoKetentuanType; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Boolean getIsJoinable() { return isJoinable; } public void setIsJoinable(Boolean isJoinable) { this.isJoinable = isJoinable; } public String getPromoID() { return promoID; } public void setPromoID(String promoID) { this.promoID = promoID; } public String getPromoCode() { return promoCode; } public void setPromoCode(String promoCode) { this.promoCode = promoCode; } public Date getPromoStartDate() { return promoStartDate; } public void setPromoStartDate(Date promoStartDate) { this.promoStartDate = promoStartDate; } public Date getPromoEndDate() { return promoEndDate; } public void setPromoEndDate(Date promoEndDate) { this.promoEndDate = promoEndDate; } public String getPromoName() { return promoName; } public void setPromoName(String promoName) { this.promoName = promoName; } public String getPromoSource() { return promoSource; } public void setPromoSource(String promoSource) { this.promoSource = promoSource; } // public CustomerType getCustomerType() { // return customerType; // } // // public void setCustomerType(CustomerType customerType) { // this.customerType = customerType; // } // // public PromoBookingType getPromoBookingType() { // return promoBookingType; // } // // public void setPromoBookingType(PromoBookingType promoBookingType) { // this.promoBookingType = promoBookingType; // } // // public PromoCustomerOccupationType getCustomerOccupation() { // return customerOccupation; // } // // public void setCustomerOccupation(PromoCustomerOccupationType customerOccupation) { // this.customerOccupation = customerOccupation; // } // // public PromoGenderCustomerType getCustomerGender() { // return customerGender; // } // // public void setCustomerGender(PromoGenderCustomerType customerGender) { // this.customerGender = customerGender; // } public String getCategoryID() { return categoryID; } public void setCategoryID(String categoryID) { this.categoryID = categoryID; } public PromoAhassType getAhassType() { return ahassType; } public void setAhassType(PromoAhassType ahassType) { this.ahassType = ahassType; } public PromoAreaType getAreaType() { return areaType; } public void setAreaType(PromoAreaType areaType) { this.areaType = areaType; } public PromoLokasiType getLokasiType() { return lokasiType; } public void setLokasiType(PromoLokasiType lokasiType) { this.lokasiType = lokasiType; } public PromoProgramType getProgramType() { return programType; } public void setProgramType(PromoProgramType programType) { this.programType = programType; } public String getKelipatanKM() { return kelipatanKM; } public void setKelipatanKM(String kelipatanKM) { this.kelipatanKM = kelipatanKM; } public Time getJamMulai() { return jamMulai; } public void setJamMulai(Time jamMulai) { this.jamMulai = jamMulai; } public Time getJamAkhir() { return jamAkhir; } public void setJamAkhir(Time jamAkhir) { this.jamAkhir = jamAkhir; } public String getHariBerlaku() { return hariBerlaku; } public void setHariBerlaku(String hariBerlaku) { this.hariBerlaku = hariBerlaku; } public DataStatus getPromoStatus() { return promoStatus; } public void setPromoStatus(DataStatus promoStatus) { this.promoStatus = promoStatus; } public CreationalSpecification getPromoCreational() { return promoCreational; } public void setPromoCreational(CreationalSpecification promoCreational) { this.promoCreational = promoCreational; } public Set getListPromoUnitBerlaku() { return listPromoUnitBerlaku; } public void setListPromoUnitBerlaku(Set listPromoUnitBerlaku) { this.listPromoUnitBerlaku = listPromoUnitBerlaku; } // public Set getListPromoJasa() { // return listPromoJasa; // } // // public void setListPromoJasa(Set listPromoJasa) { // this.listPromoJasa = listPromoJasa; // } public Set getListDiscountPart() { return listDiscountPart; } public void setListDiscountPart(Set listDiscountPart) { this.listDiscountPart = listDiscountPart; } public Set getListPackageService() { return listPackageService; } public void setListPackageService(Set listPackageService) { this.listPackageService = listPackageService; } public Set getListPromoArea() { return listPromoArea; } public void setListPromoArea(Set listPromoArea) { this.listPromoArea = listPromoArea; } public Set getListPromoPos() { return listPromoPos; } public void setListPromoPos(Set listPromoPos) { this.listPromoPos = listPromoPos; } public Set getListPromoAhass() { return listPromoAhass; } public void setListPromoAhass(Set listPromoAhass) { this.listPromoAhass = listPromoAhass; } public Set getListPromoCustomerJob() { return listPromoCustomerJob; } public void setListPromoCustomerJob(Set listPromoCustomerJob) { this.listPromoCustomerJob = listPromoCustomerJob; } // public PromoJasaBengkelType getPromoJasaBengkelType() { // return promoJasaBengkelType; // } // // public void setPromoJasaBengkelType(PromoJasaBengkelType promoJasaBengkelType) { // this.promoJasaBengkelType = promoJasaBengkelType; // } public PromoSparepartType getPromoSparepartType() { return promoSparepartType; } public void setPromoSparepartType(PromoSparepartType promoSparepartType) { this.promoSparepartType = promoSparepartType; } public PromoPackageServiceType getPromoPackageServiceType() { return promoPackageServiceType; } public void setPromoPackageServiceType(PromoPackageServiceType promoPackageServiceType) { this.promoPackageServiceType = promoPackageServiceType; } public String getPromoCustomer() { return promoCustomer; } public void setPromoCustomer(String promoCustomer) { this.promoCustomer = promoCustomer; } public Integer getJumlahService() { return jumlahService; } public void setJumlahService(Integer jumlahService) { this.jumlahService = jumlahService; } public Integer getJumlahBerlaku() { return jumlahBerlaku; } public void setJumlahBerlaku(Integer jumlahBerlaku) { this.jumlahBerlaku = jumlahBerlaku; } public Integer getJumlahPengulangan() { return jumlahPengulangan; } public void setJumlahPengulangan(Integer jumlahPengulangan) { this.jumlahPengulangan = jumlahPengulangan; } public PromoBerlakuAhassType getPromoBerlakuAhassType() { return promoBerlakuAhassType; } public void setPromoBerlakuAhassType(PromoBerlakuAhassType promoBerlakuAhassType) { this.promoBerlakuAhassType = promoBerlakuAhassType; } public String getKetentuanSettings() { return ketentuanSettings; } public void setKetentuanSettings(String ketentuanSettings) { this.ketentuanSettings = ketentuanSettings; } public PromoKetentuanType getPromoKetentuanType() { return promoKetentuanType; } public void setPromoKetentuanType(PromoKetentuanType promoKetentuanType) { this.promoKetentuanType = promoKetentuanType; } @Override public int hashCode() { int hash = 7; hash = 79 * hash + Objects.hashCode(this.id); hash = 79 * hash + Objects.hashCode(this.isJoinable); hash = 79 * hash + Objects.hashCode(this.promoID); hash = 79 * hash + Objects.hashCode(this.promoCode); hash = 79 * hash + Objects.hashCode(this.promoStartDate); hash = 79 * hash + Objects.hashCode(this.promoEndDate); hash = 79 * hash + Objects.hashCode(this.promoName); hash = 79 * hash + Objects.hashCode(this.promoSource); hash = 79 * hash + Objects.hashCode(this.categoryID); // hash = 79 * hash + Objects.hashCode(this.customerType); // hash = 79 * hash + Objects.hashCode(this.promoBookingType); // hash = 79 * hash + Objects.hashCode(this.customerOccupation); // hash = 79 * hash + Objects.hashCode(this.customerGender); hash = 79 * hash + Objects.hashCode(this.ahassType); hash = 79 * hash + Objects.hashCode(this.areaType); hash = 79 * hash + Objects.hashCode(this.lokasiType); hash = 79 * hash + Objects.hashCode(this.programType); // hash = 79 * hash + Objects.hashCode(this.promoJasaBengkelType); hash = 79 * hash + Objects.hashCode(this.promoSparepartType); hash = 79 * hash + Objects.hashCode(this.promoPackageServiceType); hash = 79 * hash + Objects.hashCode(this.promoCustomer); hash = 79 * hash + Objects.hashCode(this.jumlahService); hash = 79 * hash + Objects.hashCode(this.jumlahBerlaku); hash = 79 * hash + Objects.hashCode(this.jumlahPengulangan); hash = 79 * hash + Objects.hashCode(this.promoBerlakuAhassType); hash = 79 * hash + Objects.hashCode(this.ketentuanSettings); hash = 79 * hash + Objects.hashCode(this.promoKetentuanType); hash = 79 * hash + Objects.hashCode(this.kelipatanKM); hash = 79 * hash + Objects.hashCode(this.jamMulai); hash = 79 * hash + Objects.hashCode(this.jamAkhir); hash = 79 * hash + Objects.hashCode(this.hariBerlaku); hash = 79 * hash + Objects.hashCode(this.promoStatus); hash = 79 * hash + Objects.hashCode(this.promoCreational); hash = 79 * hash + Objects.hashCode(this.listPromoUnitBerlaku); // hash = 79 * hash + Objects.hashCode(this.listPromoJasa); hash = 79 * hash + Objects.hashCode(this.listDiscountPart); hash = 79 * hash + Objects.hashCode(this.listPackageService); hash = 79 * hash + Objects.hashCode(this.listPromoArea); hash = 79 * hash + Objects.hashCode(this.listPromoPos); hash = 79 * hash + Objects.hashCode(this.listPromoAhass); hash = 79 * hash + Objects.hashCode(this.listPromoCustomerJob); 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 Promo other = (Promo) obj; if (!Objects.equals(this.promoID, other.promoID)) { return false; } if (!Objects.equals(this.promoCode, other.promoCode)) { return false; } if (!Objects.equals(this.promoName, other.promoName)) { return false; } if (!Objects.equals(this.promoSource, other.promoSource)) { return false; } if (!Objects.equals(this.promoCustomer, other.promoCustomer)) { return false; } if (!Objects.equals(this.ketentuanSettings, other.ketentuanSettings)) { return false; } if (!Objects.equals(this.kelipatanKM, other.kelipatanKM)) { return false; } if (!Objects.equals(this.hariBerlaku, other.hariBerlaku)) { return false; } if (!Objects.equals(this.id, other.id)) { return false; } if (!Objects.equals(this.isJoinable, other.isJoinable)) { return false; } if (!Objects.equals(this.promoStartDate, other.promoStartDate)) { return false; } if (!Objects.equals(this.promoEndDate, other.promoEndDate)) { return false; } if (this.categoryID != other.categoryID) { return false; } // if (this.customerType != other.customerType) { // return false; // } // if (this.promoBookingType != other.promoBookingType) { // return false; // } // if (this.customerOccupation != other.customerOccupation) { // return false; // } // if (this.customerGender != other.customerGender) { // return false; // } if (this.ahassType != other.ahassType) { return false; } if (this.areaType != other.areaType) { return false; } if (this.lokasiType != other.lokasiType) { return false; } if (this.programType != other.programType) { return false; } // if (this.promoJasaBengkelType != other.promoJasaBengkelType) { // return false; // } if (this.promoSparepartType != other.promoSparepartType) { return false; } if (this.promoPackageServiceType != other.promoPackageServiceType) { return false; } if (!Objects.equals(this.jumlahService, other.jumlahService)) { return false; } if (!Objects.equals(this.jumlahBerlaku, other.jumlahBerlaku)) { return false; } if (!Objects.equals(this.jumlahPengulangan, other.jumlahPengulangan)) { return false; } if (this.promoBerlakuAhassType != other.promoBerlakuAhassType) { return false; } if (this.promoKetentuanType != other.promoKetentuanType) { return false; } if (!Objects.equals(this.jamMulai, other.jamMulai)) { return false; } if (!Objects.equals(this.jamAkhir, other.jamAkhir)) { return false; } if (this.promoStatus != other.promoStatus) { return false; } if (!Objects.equals(this.promoCreational, other.promoCreational)) { return false; } if (!Objects.equals(this.listPromoUnitBerlaku, other.listPromoUnitBerlaku)) { return false; } // if (!Objects.equals(this.listPromoJasa, other.listPromoJasa)) { // return false; // } if (!Objects.equals(this.listDiscountPart, other.listDiscountPart)) { return false; } if (!Objects.equals(this.listPackageService, other.listPackageService)) { return false; } if (!Objects.equals(this.listPromoArea, other.listPromoArea)) { return false; } if (!Objects.equals(this.listPromoPos, other.listPromoPos)) { return false; } if (!Objects.equals(this.listPromoAhass, other.listPromoAhass)) { return false; } if (!Objects.equals(this.listPromoCustomerJob, other.listPromoCustomerJob)) { return false; } return true; } @Override public boolean sameIdentityAs(Promo t) { return this.equals(t); } }