Rev 32417 | Rev 35169 | 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.catalog;import com.spice.profitmandi.common.enumuration.ItemType;import in.shop2020.model.v1.catalog.status;import javax.persistence.*;import java.io.Serializable;import java.time.LocalDateTime;import java.util.Arrays;import java.util.List;/*** This class basically contains item details** @author ashikali*/@NamedQueries({@NamedQuery(name = "Item.selectItemByLikes", query = "select new com.spice.profitmandi.common.model.CustomItemModel(" + " i.id, i.brand, i.modelName, i.modelNumber, i.color" + " ) from Item i join CurrentInventorySnapshot cis on i.id = cis.itemId " + " where cis.fofoId = :fofoId and cis.availability > 0 and REPLACE(CONCAT(i.brand,' ', ifnull(i.modelName, ' '), ' ', ifnull(i.modelNumber, ' ')), ' ', ' ') like CONCAT('%',:query,'%')"),@NamedQuery(name = "Item.selectCatalogIdByMopRange", query = "select i.catalogItemId" + " from Item i join TagListing tl on tl.itemId = i.id " + " where tl.mop between :startPrice and :endPrice and i.categoryId=10006 group by i.catalogItemId"),@NamedQuery(name = "Item.selectAllBrands", query = "select distinct" + " i.brand from Item i join TagListing tl on tl.itemId = i.id " + " where i.categoryId=:categoryId"), @NamedQuery(name = "Item.selectAllCategories", query = "select distinct" + " i.categoryId from Item i join TagListing tl on tl.itemId = i.id "), @NamedQuery(name = "Item.selectAllModels", query = "select " + " i from Item i join TagListing tl on tl.itemId = i.id where i.brand in :brands and i.categoryId = :categoryId")})@Entity@Table(name = "catalog.item")public class Item implements Serializable {public static final List<String> SMART_PG = Arrays.asList("85171300", "85171290");private static final long serialVersionUID = 1L;public Item() {}@Id@Column(name = "id", columnDefinition = "int(11)")@GeneratedValue(strategy = GenerationType.IDENTITY)private int id;@Column(name = "brand", length = 100)private String brand;@Column(name = "status")@Enumerated(EnumType.ORDINAL)private status status;@Column(name = "product_group", length = 100)private String productGroup;@Column(name = "model_name", length = 100)private String modelName;@Column(name = "model_number", length = 100)private String modelNumber;@Column(name = "color", length = 20)private String color;@Column(name = "catalog_item_id")private int catalogItemId;@Column(name = "weight")private Double weight;@Column(name = "category")private int categoryId;@Column(name = "startDate")private LocalDateTime startDate;@Column(name = "addedOn")private LocalDateTime addedOn;@Column(name = "updatedOn")private LocalDateTime updatedOn;private Boolean risky;private Integer expectedDelay;@Column(name = "warranty_period")private Integer warrantyPeriod;private Integer preferredVendor;public int getCategoryId() {return categoryId;}public void setCategoryId(int categoryId) {this.categoryId = categoryId;}public LocalDateTime getAddedOn() {return addedOn;}public void setAddedOn(LocalDateTime addedOn) {this.addedOn = addedOn;}public LocalDateTime getUpdatedOn() {return updatedOn;}public void setUpdatedOn(LocalDateTime updatedOn) {this.updatedOn = updatedOn;}public boolean isRisky() {return risky;}public void setRisky(boolean risky) {this.risky = risky;}public int getExpectedDelay() {return expectedDelay;}public void setExpectedDelay(int expectedDelay) {this.expectedDelay = expectedDelay;}public Integer getWarrantyPeriod() {return warrantyPeriod;}public void setWarrantyPeriod(Integer warrantyPeriod) {this.warrantyPeriod = warrantyPeriod;}public Integer getPreferredVendor() {return preferredVendor;}public void setPreferredVendor(Integer preferredVendor) {this.preferredVendor = preferredVendor;}@Enumerated(EnumType.STRING)@Column(name = "type")private ItemType type;@Column(name = "hsnCode")private String hsnCode;@Column(name = "sellingPrice")private Float sellingPrice;public String getProductGroup() {return productGroup;}public void setProductGroup(String productGroup) {this.productGroup = productGroup;}public int getId() {return id;}@Columnprivate Float mrp;public void setId(int id) {this.id = id;}public String getBrand() {return brand;}public void setBrand(String brand) {this.brand = brand;}public String getModelName() {return modelName;}public void setModelName(String modelName) {this.modelName = modelName;}public String getModelNumber() {return modelNumber;}public void setModelNumber(String modelNumber) {this.modelNumber = modelNumber;}public String getColor() {if (color != null && (color.startsWith("f_") || color.startsWith("F_"))) {return color.substring(2);}return color;}public String getColorNatural() {return this.color;}public void setColor(String color) {this.color = color;}public ItemType getType() {return type;}public void setType(ItemType type) {this.type = type;}public String getHsnCode() {return hsnCode;}public void setHsnCode(String hsnCode) {this.hsnCode = hsnCode;}public int getCatalogItemId() {return catalogItemId;}public Double getWeight() {return weight;}public void setWeight(Double weight) {this.weight = weight;}public void setCatalogItemId(int catalogItemId) {this.catalogItemId = catalogItemId;}public Float getSellingPrice() {return sellingPrice;}public void setSellingPrice(Float sellingPrice) {this.sellingPrice = sellingPrice;}public LocalDateTime getStartDate() {return startDate;}public void setStartDate(LocalDateTime startDate) {this.startDate = startDate;}public String getItemDescription() {StringBuilder itemString = new StringBuilder();if (this.getBrand() != null && !this.getBrand().isEmpty()) {itemString.append(this.getBrand().trim());}itemString.append(" ");if (this.getModelName() != null && !this.getModelName().isEmpty()) {itemString.append(this.getModelName().trim());}if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {itemString.append(" ");itemString.append(this.getModelNumber().trim());}if (this.getColor() != null && !this.getColor().isEmpty() && !this.getColor().trim().equals("f_")) {itemString.append(" ");itemString.append(this.getColor().trim());}return itemString.toString().replaceAll("\\s+", " ").trim();}public boolean isSmartPhone() {return SMART_PG.contains(this.getHsnCode());}public String getModel() {StringBuilder itemString = new StringBuilder();if (this.getModelName() != null && !this.getModelName().isEmpty()) {itemString.append(this.getModelName().trim());}if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {itemString.append(" ");itemString.append(this.getModelNumber().trim());}return itemString.toString().replaceAll("\\s+", " ").trim();}public String getItemDescriptionNoColor() {StringBuilder itemString = new StringBuilder();if (this.getBrand() != null && !this.getBrand().isEmpty()) {itemString.append(this.getBrand().trim());}itemString.append(" ");if (this.getModelName() != null && !this.getModelName().isEmpty()) {itemString.append(this.getModelName().trim());}if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {itemString.append(" ");itemString.append(this.getModelNumber().trim());}return itemString.toString().replaceAll("\\s+", " ").trim();}@Overridepublic int hashCode() {final int prime = 31;int result = 1;result = prime * result + ((brand == null) ? 0 : brand.hashCode());result = prime * result + catalogItemId;result = prime * result + categoryId;result = prime * result + ((color == null) ? 0 : color.hashCode());result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());result = prime * result + id;result = prime * result + ((modelName == null) ? 0 : modelName.hashCode());result = prime * result + ((modelNumber == null) ? 0 : modelNumber.hashCode());result = prime * result + ((productGroup == null) ? 0 : productGroup.hashCode());result = prime * result + ((sellingPrice == null) ? 0 : sellingPrice.hashCode());result = prime * result + ((startDate == null) ? 0 : startDate.hashCode());result = prime * result + ((status == null) ? 0 : status.hashCode());result = prime * result + ((type == null) ? 0 : type.hashCode());result = prime * result + ((weight == null) ? 0 : weight.hashCode());return result;}@Overridepublic boolean equals(Object obj) {if (this == obj) return true;if (obj == null) return false;if (getClass() != obj.getClass()) return false;Item other = (Item) obj;if (brand == null) {if (other.brand != null) return false;} else if (!brand.equals(other.brand)) return false;if (catalogItemId != other.catalogItemId) return false;if (categoryId != other.categoryId) return false;if (color == null) {if (other.color != null) return false;} else if (!color.equals(other.color)) return false;if (hsnCode == null) {if (other.hsnCode != null) return false;} else if (!hsnCode.equals(other.hsnCode)) return false;if (id != other.id) return false;if (modelName == null) {if (other.modelName != null) return false;} else if (!modelName.equals(other.modelName)) return false;if (modelNumber == null) {if (other.modelNumber != null) return false;} else if (!modelNumber.equals(other.modelNumber)) return false;if (productGroup == null) {if (other.productGroup != null) return false;} else if (!productGroup.equals(other.productGroup)) return false;if (sellingPrice == null) {if (other.sellingPrice != null) return false;} else if (!sellingPrice.equals(other.sellingPrice)) return false;if (startDate == null) {if (other.startDate != null) return false;} else if (!startDate.equals(other.startDate)) return false;if (status != other.status) return false;if (type != other.type) return false;if (weight == null) {if (other.weight != null) return false;} else if (!weight.equals(other.weight)) return false;return true;}public status getStatus() {return status;}public void setStatus(status status) {this.status = status;}public boolean isAnyColor() {if (this.color != null) {String lowerCaseColor = this.color.toLowerCase();return lowerCaseColor.equals("any color") || lowerCaseColor.equals("f_any color") || lowerCaseColor.equals("any colour") || lowerCaseColor.equals("f_any colour");}return false;}public Item clone() {Item item = new Item();item.setBrand(this.getBrand());item.setModelName(this.getModelName());item.setModelNumber(this.getModelNumber());item.setColor(this.getColor());item.setCatalogItemId(this.catalogItemId);item.setHsnCode(this.getHsnCode());item.setCategoryId(this.getCategoryId());item.setMrp(this.getMrp());item.setProductGroup(this.getProductGroup());item.setSellingPrice(this.getSellingPrice());item.setStartDate(LocalDateTime.now());item.setStatus(this.getStatus());item.setType(this.getType());item.setWeight(this.getWeight());item.setAddedOn(LocalDateTime.now());item.setUpdatedOn(LocalDateTime.now());item.setExpectedDelay(0);item.setPreferredVendor(null);item.setRisky(true);item.setWarrantyPeriod(0);return item;}public Float getMrp() {return mrp;}public void setMrp(Float mrp) {this.mrp = mrp;}@Overridepublic String toString() {return "Item{" +"id=" + id +", brand='" + brand + '\'' +", status=" + status +", productGroup='" + productGroup + '\'' +", modelName='" + modelName + '\'' +", modelNumber='" + modelNumber + '\'' +", color='" + color + '\'' +", catalogItemId=" + catalogItemId +", weight=" + weight +", categoryId=" + categoryId +", startDate=" + startDate +", addedOn=" + addedOn +", updatedOn=" + updatedOn +", risky=" + risky +", expectedDelay=" + expectedDelay +", warrantyPeriod=" + warrantyPeriod +", preferredVendor=" + preferredVendor +", type=" + type +", hsnCode='" + hsnCode + '\'' +", sellingPrice=" + sellingPrice +", mrp=" + mrp +'}';}}