Rev 28653 | Rev 29575 | 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 java.io.Serializable;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.EnumType;import javax.persistence.Enumerated;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.Table;import com.spice.profitmandi.common.enumuration.ItemType;import in.shop2020.model.v1.catalog.status;/*** This class basically contains item details** @author ashikali**/@Entity@Table(name="catalog.item", schema = "catalog")public class Item implements Serializable{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;public int getCategoryId() {return categoryId;}public void setCategoryId(int categoryId) {this.categoryId = categoryId;}@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;}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 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 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 + ((status == null) ? 0 : status.hashCode());result = prime * result + ((type == null) ? 0 : type.hashCode());long temp;temp = Double.doubleToLongBits(weight);result = prime * result + (int) (temp ^ (temp >>> 32));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 (status != other.status)return false;if (type != other.type)return false;if (Double.doubleToLongBits(weight) != Double.doubleToLongBits(other.weight))return false;return true;}@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 + ", type=" + type + ", hsnCode="+ hsnCode + ", sellingPrice=" + sellingPrice + "]";}public status getStatus() {return status;}public void setStatus(status status) {this.status = status;}}