com.unilever.audit.entities.Items.java Source code

Java tutorial

Introduction

Here is the source code for com.unilever.audit.entities.Items.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.unilever.audit.entities;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Masheq
 */
@Entity
@Table(name = "ITEMS")
@XmlRootElement
@NamedQueries({ @NamedQuery(name = "Items.findAll", query = "SELECT i FROM Items i"),
        @NamedQuery(name = "Items.findById", query = "SELECT i FROM Items i WHERE i.id = :id"),
        @NamedQuery(name = "Items.findByItemno", query = "SELECT i FROM Items i WHERE i.itemno = :itemno"),
        @NamedQuery(name = "Items.findByNamee", query = "SELECT i FROM Items i WHERE i.namee = :namee"),
        @NamedQuery(name = "Items.findByNamea", query = "SELECT i FROM Items i WHERE i.namea = :namea"),
        @NamedQuery(name = "Items.getSyncDownList", query = "SELECT i FROM Items i WHERE i.lastModifiedDate >i.creationDate AND i.lastModifiedDate >"
                + "SELECT l.lastSyncDate FROM LastSync l WHERE l.user.id= :id") })
@NamedNativeQueries({
        @NamedNativeQuery(name = "Items.getFullSyncDownList", query = " select i.* from ITEMS i where i.id in \n"
                + "             (select n.ITEMID from npdkpis n where n.id in \n"
                + "                (select nc.npdid from npdkpichannel nc where nc.SALESECTORID in (select \n"
                + "                c.salesectorno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.MERCHANDISERID=? )AND nc.CATEGORYID IN \n"
                + "                       (SELECT c.categoryno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.merchandiserid=?)) ) \n"
                + "              UNION      \n" + "              select i.* from ITEMS i where i.id in\n"
                + "            (select pro.ITEMID from PROMOTIONKPIS  pro where pro.id in \n"
                + "               (select proc.PROMOTIONID from PROMOTIONCHANNEL proc where proc.SALESECTORID in (select  \n"
                + "                c.salesectorno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.MERCHANDISERID=? )AND proc.CATEGORYID IN \n"
                + "                        (SELECT c.categoryno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.merchandiserid=?)) )\n"
                + "                    UNION      \n" + "              select i.* from ITEMS i where i.id in\n"
                + "            (select prod.ITEMID from PRODUCTKPIS  prod where prod.id in \n"
                + "               (select prodch.PRODUCTID from PRODUCTKPICHANNEL prodch where prodch.SALESECTORID in (select  \n"
                + "                c.salesectorno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.MERCHANDISERID=? )AND prodch.CATEGORYID IN \n"
                + "                        (SELECT c.categoryno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.merchandiserid=?)) )\n"
                + "                          UNION      \n"
                + "              select i.* from ITEMS i where i.id in\n"
                + "            (select st.ITEMID from STOCKKPIS  st where st.id in \n"
                + "               (select stch.STOCKID from STOCKKPICHANNEL stch where stch.SALESECTORID in (select  \n"
                + "                c.salesectorno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.MERCHANDISERID=? )AND stch.CATEGORYID IN \n"
                + "                        (SELECT c.categoryno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.merchandiserid=?)) ) \n"
                + "                             UNION      \n"
                + "              select i.* from ITEMS i where i.id in\n"
                + "            (select pri.ITEMID from PRICEKPIS  pri where pri.id in \n"
                + "               (select prich.PRICEID from PRICEKPICHANNEL prich where prich.SALESECTORID in (select  \n"
                + "                c.salesectorno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.MERCHANDISERID=? )AND prich.CATEGORYID IN \n"
                + "                        (SELECT c.categoryno from Merchidisers_Customers mc INNER JOIN  customers c ON c.id = mc.customerid WHERE mc.merchandiserid=?)) ) ", resultClass = Items.class) })
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class Items implements Serializable {
    /*  @OneToMany(mappedBy = "item", fetch = FetchType.LAZY)
      private List<Npdkpis> npdkpisList;
      */
    @Id
    @Column(name = "ID")
    @GeneratedValue(generator = "last_sync_generator", strategy = GenerationType.SEQUENCE)
    @SequenceGenerator(name = "last_sync_generator", sequenceName = "LAST_SYNC_SEQ", allocationSize = 1)
    private Integer id;

    @Basic(optional = false)
    @NotNull
    @Column(name = "IS_DELETED")
    private char isDeleted;
    /*
    @OneToMany(mappedBy = "item", fetch = FetchType.LAZY)
    private List<Pricekpis> pricekpisList;
    @OneToMany(mappedBy = "item", fetch = FetchType.LAZY)
    private List<Stockkpis> stockkpisList;
    @OneToMany(mappedBy = "item", fetch = FetchType.LAZY)
    private List<Promotionkpis> promotionkpisList;
        
    @OneToMany(mappedBy = "item", fetch = FetchType.LAZY)
    private List<Productkpis> productkpisList;
    */
    @Column(name = "LAST_MODIFIED_DATE")
    @Temporal(TemporalType.DATE)
    private Date lastModifiedDate;
    @Column(name = "CREATION_DATE")
    @Temporal(TemporalType.DATE)
    private Date creationDate;
    private static final long serialVersionUID = 1L;

    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation

    @Size(max = 15)
    @Column(name = "ITEMNO")
    private String itemno;
    @Size(max = 100)
    @Column(name = "NAMEE")
    private String namee;
    @Size(max = 100)
    @Column(name = "NAMEA")
    private String namea;

    @Transient
    private String status;

    public Items() {
    }

    public Items(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

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

    public String getItemno() {
        return itemno;
    }

    public void setItemno(String itemno) {
        this.itemno = itemno;
    }

    public String getNamee() {
        return namee;
    }

    public void setNamee(String namee) {
        this.namee = namee;
    }

    public String getNamea() {
        return namea;
    }

    public void setNamea(String namea) {
        this.namea = namea;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        // hash += (id != null ? id.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 Items)) {
            return false;
        }
        Items other = (Items) object;
        /* if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
        return false;
         }*/
        return true;
    }

    @Override
    public String toString() {
        return "com.unilever.audit.entities.Items[ id=" + id + " ]";
    }

    public Date getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Date lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public boolean getIsDeleted() {
        return isDeleted == 'Y';
    }

    public void setIsDeleted(boolean isDeleted) {
        this.isDeleted = isDeleted ? 'Y' : 'N';
    }

    @XmlAttribute
    public String getStatus() {
        return getStatus(lastModifiedDate, creationDate, getIsDeleted());
    }

    @XmlTransient
    private String getStatus(Date modifieddate, Date creationDate, boolean isDeleted) {
        if (isDeleted)
            status = "D";
        else if (modifieddate.equals(creationDate))
            status = "I";
        else
            status = "U";
        return status;
    }

    /*
        @XmlTransient
        public List<Pricekpis> getPricekpisList() {
    return pricekpisList;
        }
        
        public void setPricekpisList(List<Pricekpis> pricekpisList) {
    this.pricekpisList = pricekpisList;
        }
        
        @XmlTransient
        public List<Stockkpis> getStockkpisList() {
    return stockkpisList;
        }
        
        public void setStockkpisList(List<Stockkpis> stockkpisList) {
    this.stockkpisList = stockkpisList;
        }
        
        @XmlTransient
        public List<Promotionkpis> getPromotionkpisList() {
    return promotionkpisList;
        }
        
        public void setPromotionkpisList(List<Promotionkpis> promotionkpisList) {
    this.promotionkpisList = promotionkpisList;
        }
        
        @XmlTransient
        public List<Productkpis> getProductkpisList() {
    return productkpisList;
        }
        
        public void setProductkpisList(List<Productkpis> productkpisList) {
    this.productkpisList = productkpisList;
        }
        
        @XmlTransient
        public List<Npdkpis> getNpdkpisList() {
    return npdkpisList;
        }
        
        public void setNpdkpisList(List<Npdkpis> npdkpisList) {
    this.npdkpisList = npdkpisList;
        }
    */

}