Subversion Repositories SmartDukaan

Rev

Rev 33680 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.dtr;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

@Entity
@Table(name = "dtr.scratch_offer")
@NamedQueries({@NamedQuery(name = "ScratchOffer.selectAllCountOfOffer",
                query = "SELECT so.offerName, COUNT(so) FROM ScratchOffer so " +
                                "WHERE so.scratched=true AND so.createdTimestamp BETWEEN :startDate AND :endDate " +
                                "GROUP BY so.offerName")
})
public class ScratchOffer implements Serializable {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Id
        @Column(name = "id", unique = true, updatable = false)
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;

        @Column(name = "invoice_number")
        private String invoiceNumber;

        @Column(name = "customer_id")
        private int customerId;

        @Column(name = "offer_name")
        private String offerName;

        @Column(name = "scratched")
        private boolean scratched;

        @Column(name = "created_timestamp")
        private LocalDateTime createdTimestamp;

        @Column(name = "unlocked_at")
        private LocalDateTime unlockedAt;

        @Column(name = "scracthed_at")
        private LocalDateTime scracthedAt;

        @Column(name = "offer_id")
        private int offerId;

        @Column(name = "gift_id")
        private int giftId;

        public LocalDateTime getScracthedAt() {
                return scracthedAt;
        }

        public void setScracthedAt(LocalDateTime scracthedAt) {
                this.scracthedAt = scracthedAt;
        }

        @Transient
        private boolean unlocked;

        @Transient
        private LocalDateTime expiredTimestamp;

        @Transient
        private boolean expired;

        public boolean isExpired() {
                return expired;
        }

        public void setExpired(boolean expired) {
                this.expired = expired;
        }

        public LocalDateTime getExpiredTimestamp() {
                return expiredTimestamp;
        }

        public void setExpiredTimestamp(LocalDateTime expiredTimestamp) {
                this.expiredTimestamp = expiredTimestamp;
        }

        public boolean isUnlocked() {
                return unlocked;
        }

        public void setUnlocked(boolean unlocked) {
                this.unlocked = unlocked;
        }

        public LocalDateTime getUnlockedAt() {
                return unlockedAt;
        }

        public void setUnlockedAt(LocalDateTime unlockedAt) {
                this.unlockedAt = unlockedAt;
        }

        public int getId() {
                return id;
        }

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

        public int getCustomerId() {
                return customerId;
        }

        public void setCustomerId(int customerId) {
                this.customerId = customerId;
        }

        public String getInvoiceNumber() {
                return invoiceNumber;
        }

        public void setInvoiceNumber(String invoiceNumber) {
                this.invoiceNumber = invoiceNumber;
        }

        public String getOfferName() {
                return offerName;
        }

        public void setOfferName(String offerName) {
                this.offerName = offerName;
        }

        public boolean isScratched() {
                return scratched;
        }

        public void setScratched(boolean scratched) {
                this.scratched = scratched;
        }

        public LocalDateTime getCreatedTimestamp() {
                return createdTimestamp;
        }

        public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
                this.createdTimestamp = createdTimestamp;
        }

        public int getOfferId() {
                return offerId;
        }

        public void setOfferId(int offerId) {
                this.offerId = offerId;
        }

        public int getGiftId() {
                return giftId;
        }

        public void setGiftId(int giftId) {
                this.giftId = giftId;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + ((createdTimestamp == null) ? 0 : createdTimestamp.hashCode());
                result = prime * result + customerId;
                result = prime * result + ((expiredTimestamp == null) ? 0 : expiredTimestamp.hashCode());
                result = prime * result + id;
                result = prime * result + ((invoiceNumber == null) ? 0 : invoiceNumber.hashCode());
                result = prime * result + ((offerName == null) ? 0 : offerName.hashCode());
                result = prime * result + ((scracthedAt == null) ? 0 : scracthedAt.hashCode());
                result = prime * result + (scratched ? 1231 : 1237);
                result = prime * result + (unlocked ? 1231 : 1237);
                result = prime * result + ((unlockedAt == null) ? 0 : unlockedAt.hashCode());
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                ScratchOffer other = (ScratchOffer) obj;
                if (createdTimestamp == null) {
                        if (other.createdTimestamp != null)
                                return false;
                } else if (!createdTimestamp.equals(other.createdTimestamp))
                        return false;
                if (customerId != other.customerId)
                        return false;
                if (expiredTimestamp == null) {
                        if (other.expiredTimestamp != null)
                                return false;
                } else if (!expiredTimestamp.equals(other.expiredTimestamp))
                        return false;
                if (id != other.id)
                        return false;
                if (invoiceNumber == null) {
                        if (other.invoiceNumber != null)
                                return false;
                } else if (!invoiceNumber.equals(other.invoiceNumber))
                        return false;
                if (!Objects.equals(offerName, other.offerName))
                        return false;
                if (scracthedAt == null) {
                        if (other.scracthedAt != null)
                                return false;
                } else if (!scracthedAt.equals(other.scracthedAt))
                        return false;
                if (scratched != other.scratched)
                        return false;
                if (unlocked != other.unlocked)
                        return false;
                if (unlockedAt == null) {
                        if (other.unlockedAt != null)
                                return false;
                } else if (!unlockedAt.equals(other.unlockedAt))
                        return false;
                return true;
        }

        @Override
        public String toString() {
                return "ScratchOffer [id=" + id + ", invoiceNumber=" + invoiceNumber + ", customerId=" + customerId
                                + ", offerName=" + offerName + ", scratched=" + scratched + ", createdTimestamp=" + createdTimestamp
                                + ", unlockedAt=" + unlockedAt + ", scracthedAt=" + scracthedAt + ", unlocked=" + unlocked
                                + ", offerId=" + offerId + ", giftId=" + giftId
                                + ", expiredTimestamp=" + expiredTimestamp + "]";
        }

}