Subversion Repositories SmartDukaan

Rev

Rev 21720 | Rev 22009 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

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

import java.io.Serializable;
import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.spice.profitmandi.dao.enumuration.dtr.RetailerType;
import com.spice.profitmandi.dao.enumuration.dtr.SaleValue;

/**
 * This class basically contains api details
 * 
 * @author ashikali
 *
 */
@Entity
@Table(name="dtr.retailer", schema = "dtr", uniqueConstraints = {@UniqueConstraint(columnNames = {"number","type"})})
@NamedQueries({
        @NamedQuery(name = "Retailer.selectCount", query = "select count(r) from Retailer r"),
        @NamedQuery(name = "Retailer.selectAll",query="select r from Retailer r"),
        @NamedQuery(name = "Retailer.selectById",query="select r from Retailer r where r.id= :id"),
        @NamedQuery(name = "Retailer.selectByName",query="select r from Retailer r where r.name= :name"),
        @NamedQuery(name = "Retailer.selectCountByNumberAndType",query="select count(r) from Retailer r where r.number= :number and r.type= :type"),
        @NamedQuery(name = "Retailer.selectCountByDocumentId", query="select count(r) from Retailer r where r.documentId= :documentId"),
        @NamedQuery(name = "Retailer.selectCountByName", query = "select count(r) from Retailer r where r.name= :name"),
        @NamedQuery(name = "Retailer.selectCountById", query = "select count(r) from Retailer r where r.id= :id"),
        @NamedQuery(name = "Retailer.deleteById",query="delete from Retailer r where r.id= :id"),
        @NamedQuery(name = "Retailer.selectDocumentById", query = "select d from Retailer r join Document d on d.id = r.documentId where r.id = :id"),
        @NamedQuery(
                        name = "Retailer.selectFofoIdAndEmailIdByEmailId",
                        query = "select r.id, u.emailId from User u join UserAccounts ua on ua.user_id = u.id join Retailer r on r.id = ua.account_key where u.emailId = :emailId and ua.account_type = 'saholic' and r.fofo = true")
})
public class Retailer implements Serializable{
        
        private static final long serialVersionUID = 1L;
        
        public Retailer() {
        }
        
        @Id
        @Column(name = "id", unique=true, updatable=false)
        private int id;
        
        @Column(name = "name")
        private String name;
        
        @Column(name = "number", length = 128)
        private String number;
        
        @Column(name = "type")
        @Enumerated(EnumType.STRING)
        private RetailerType type;
        
        @Column(name = "monthly_sale_value")
        private SaleValue monthlySaleValue;
        
        @Column(name = "smartphone_sale_value")
        private SaleValue smartphoneSaleValue;
        
        @Column(name = "recharge", columnDefinition="tinyint(1) default 0")
        private boolean recharge;
        
        @Column(name = "mobile", columnDefinition="tinyint(1) default 0")
        private boolean mobile;
        
        @Column(name = "accessories", columnDefinition="tinyint(1) default 0")
        private boolean accessories;
        
        @Column(name = "other1", length = 128)
        private String other1;
        
        @Column(name = "other2", length = 128)
        private String other2;
        
        @Column(name = "self_pickup", columnDefinition="tinyint(1) default 0")
        private boolean selfPickup;
        
        @Column(name = "active", columnDefinition = "tinyint(1) default 0")
        private boolean active;
        
        @Column(name = "migrated", columnDefinition = "tinyint(1) default 0")
        private boolean migrated;
        
        @Column(name="create_timestamp", updatable = false)
        private LocalDateTime createTimestamp = LocalDateTime.now();
        
        @Column(name="update_timestamp")
        private LocalDateTime updateTimestamp = LocalDateTime.now();
                
        @Column(name = "document_id")
        private int documentId;
                
        @Column(name = "current_address_id")
        private int currentAddressId;
        
        @Column(name = "fofo", columnDefinition = "tinyint(1) default 0")
        private boolean fofo;
        
        public int getId() {
                return id;
        }
        public void setId(int id) {
                this.id = id;
        }
        public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    
    public String getNumber() {
                return number;
        }
    public void setNumber(String number) {
                this.number = number;
        }
    
    public SaleValue getMonthlySaleValue() {
                return monthlySaleValue;
        }
    public void setMonthlySaleValue(SaleValue monthlySaleValue) {
                this.monthlySaleValue = monthlySaleValue;
        }
    public SaleValue getSmartphoneSaleValue() {
                return smartphoneSaleValue;
        }
    public void setSmartphoneSaleValue(SaleValue smartphoneSaleValue) {
                this.smartphoneSaleValue = smartphoneSaleValue;
        }
    
    public boolean isRecharge() {
                return recharge;
        }
    public void setRecharge(boolean recharge) {
                this.recharge = recharge;
        }
    public boolean isMobile() {
                return mobile;
        }
    public void setMobile(boolean mobile) {
                this.mobile = mobile;
        }
    public boolean isAccessories() {
                return accessories;
        }
    public void setAccessories(boolean accessories) {
                this.accessories = accessories;
        }
    public String getOther1() {
                return other1;
        }
    public void setOther1(String other1) {
                this.other1 = other1;
        }
    public String getOther2() {
                return other2;
        }
    public void setOther2(String other2) {
                this.other2 = other2;
        }
    public void setType(RetailerType type) {
                this.type = type;
        }
    public RetailerType getType() {
                return type;
        }
    
    public int getDocumentId() {
                return documentId;
        }
    public void setDocumentId(int documentId) {
                this.documentId = documentId;
        }
    
    public void setCurrentAddressId(int currentAddressId) {
                this.currentAddressId = currentAddressId;
        }
    public int getCurrentAddressId() {
                return currentAddressId;
        }

    public boolean isSelfPickup() {
                return selfPickup;
        }
    public void setSelfPickup(boolean selfPickup) {
                this.selfPickup = selfPickup;
        }
    
    public boolean isActive() {
                return active;
        }
    public void setActive(boolean active) {
                this.active = active;
        }
    
    public boolean isMigrated() {
                return migrated;
        }
    public void setMigrated(boolean migrated) {
                this.migrated = migrated;
        }
    
    public void setCreateTimestamp(LocalDateTime createTimestamp) {
                this.createTimestamp = createTimestamp;
        }
    public LocalDateTime getCreateTimestamp() {
                return createTimestamp;
        }
    
    public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
                this.updateTimestamp = updateTimestamp;
        }
    public LocalDateTime getUpdateTimestamp() {
                return updateTimestamp;
        }
    
    public boolean isFofo() {
                return fofo;
        }
    public void setFofo(boolean fofo) {
                this.fofo = fofo;
        }
    
    
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + (accessories ? 1231 : 1237);
                result = prime * result + (active ? 1231 : 1237);
                result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
                result = prime * result + currentAddressId;
                result = prime * result + documentId;
                result = prime * result + (fofo ? 1231 : 1237);
                result = prime * result + id;
                result = prime * result + (migrated ? 1231 : 1237);
                result = prime * result + (mobile ? 1231 : 1237);
                result = prime * result + ((monthlySaleValue == null) ? 0 : monthlySaleValue.hashCode());
                result = prime * result + ((name == null) ? 0 : name.hashCode());
                result = prime * result + ((number == null) ? 0 : number.hashCode());
                result = prime * result + ((other1 == null) ? 0 : other1.hashCode());
                result = prime * result + ((other2 == null) ? 0 : other2.hashCode());
                result = prime * result + (recharge ? 1231 : 1237);
                result = prime * result + (selfPickup ? 1231 : 1237);
                result = prime * result + ((smartphoneSaleValue == null) ? 0 : smartphoneSaleValue.hashCode());
                result = prime * result + ((type == null) ? 0 : type.hashCode());
                result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.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;
                Retailer other = (Retailer) obj;
                if (accessories != other.accessories)
                        return false;
                if (active != other.active)
                        return false;
                if (createTimestamp == null) {
                        if (other.createTimestamp != null)
                                return false;
                } else if (!createTimestamp.equals(other.createTimestamp))
                        return false;
                if (currentAddressId != other.currentAddressId)
                        return false;
                if (documentId != other.documentId)
                        return false;
                if (fofo != other.fofo)
                        return false;
                if (id != other.id)
                        return false;
                if (migrated != other.migrated)
                        return false;
                if (mobile != other.mobile)
                        return false;
                if (monthlySaleValue != other.monthlySaleValue)
                        return false;
                if (name == null) {
                        if (other.name != null)
                                return false;
                } else if (!name.equals(other.name))
                        return false;
                if (number == null) {
                        if (other.number != null)
                                return false;
                } else if (!number.equals(other.number))
                        return false;
                if (other1 == null) {
                        if (other.other1 != null)
                                return false;
                } else if (!other1.equals(other.other1))
                        return false;
                if (other2 == null) {
                        if (other.other2 != null)
                                return false;
                } else if (!other2.equals(other.other2))
                        return false;
                if (recharge != other.recharge)
                        return false;
                if (selfPickup != other.selfPickup)
                        return false;
                if (smartphoneSaleValue != other.smartphoneSaleValue)
                        return false;
                if (type != other.type)
                        return false;
                if (updateTimestamp == null) {
                        if (other.updateTimestamp != null)
                                return false;
                } else if (!updateTimestamp.equals(other.updateTimestamp))
                        return false;
                return true;
        }
        @Override
        public String toString() {
                return "Retailer [id=" + id + ", name=" + name + ", number=" + number + ", type=" + type + ", monthlySaleValue="
                                + monthlySaleValue + ", smartphoneSaleValue=" + smartphoneSaleValue + ", recharge=" + recharge
                                + ", mobile=" + mobile + ", accessories=" + accessories + ", other1=" + other1 + ", other2=" + other2
                                + ", selfPickup=" + selfPickup + ", active=" + active + ", migrated=" + migrated + ", createTimestamp="
                                + createTimestamp + ", updateTimestamp=" + updateTimestamp + ", documentId="
                                + documentId + ", currentAddressId=" + currentAddressId + ", fofo=" + fofo + "]";
        }
           
    
        
}