Subversion Repositories SmartDukaan

Rev

Rev 30499 | Rev 31767 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21713 ashik.ali 1
package com.spice.profitmandi.dao.entity.catalog;
21552 ashik.ali 2
 
31065 tejbeer 3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Arrays;
6
import java.util.List;
7
 
8
import javax.persistence.Column;
9
import javax.persistence.Entity;
10
import javax.persistence.EnumType;
11
import javax.persistence.Enumerated;
12
import javax.persistence.GeneratedValue;
13
import javax.persistence.GenerationType;
14
import javax.persistence.Id;
15
import javax.persistence.NamedQueries;
16
import javax.persistence.NamedQuery;
17
import javax.persistence.Table;
18
 
24264 amit.gupta 19
import com.spice.profitmandi.common.enumuration.ItemType;
31065 tejbeer 20
 
24072 amit.gupta 21
import in.shop2020.model.v1.catalog.status;
21573 ashik.ali 22
 
21552 ashik.ali 23
/**
24
 * This class basically contains item details
30121 amit.gupta 25
 *
21552 ashik.ali 26
 * @author ashikali
27
 */
29707 tejbeer 28
 
29
@NamedQueries({
30
		@NamedQuery(name = "Item.selectItemByLikes", query = "select new com.spice.profitmandi.common.model.CustomItemModel("
31
				+ "	i.id, i.brand, i.modelName, i.modelNumber, i.color"
32
				+ "	) from Item  i join CurrentInventorySnapshot cis on i.id = cis.itemId "
30121 amit.gupta 33
				+ " where cis.fofoId = :fofoId and cis.availability > 0 and REPLACE(CONCAT(i.brand,' ', ifnull(i.modelName, ' '), ' ', ifnull(i.modelNumber, ' ')), '  ', ' ')  like CONCAT('%',:query,'%')"),
34
 
35
		@NamedQuery(name = "Item.selectCatalogIdByMopRange", query = "select i.catalogItemId"
36
				+ " from Item i join TagListing tl on tl.itemId = i.id "
37
				+ " where tl.mop between :startPrice and :endPrice and  i.categoryId=10006 group by i.catalogItemId"),
30492 amit.gupta 38
 
39
		@NamedQuery(name = "Item.selectAllBrands", query = "select distinct"
31065 tejbeer 40
				+ "  i.brand from Item i join TagListing tl on tl.itemId = i.id " + " where i.categoryId=:categoryId"),
30492 amit.gupta 41
		@NamedQuery(name = "Item.selectAllCategories", query = "select distinct"
30499 amit.gupta 42
				+ "  i.categoryId from Item i join TagListing tl on tl.itemId = i.id "),
43
		@NamedQuery(name = "Item.selectAllModels", query = "select "
31065 tejbeer 44
				+ "  i from Item i join TagListing tl on tl.itemId = i.id where i.brand in :brands and i.categoryId = :categoryId") })
21552 ashik.ali 45
@Entity
29707 tejbeer 46
@Table(name = "catalog.item", schema = "catalog")
47
public class Item implements Serializable {
48
 
31065 tejbeer 49
	public static final List<String> SMART_PG = Arrays.asList("85171300", "85171290");
50
 
21552 ashik.ali 51
	private static final long serialVersionUID = 1L;
29707 tejbeer 52
 
21552 ashik.ali 53
	public Item() {
54
	}
29707 tejbeer 55
 
21552 ashik.ali 56
	@Id
29707 tejbeer 57
	@Column(name = "id", columnDefinition = "int(11)")
21552 ashik.ali 58
	@GeneratedValue(strategy = GenerationType.IDENTITY)
59
	private int id;
29707 tejbeer 60
 
61
	@Column(name = "brand", length = 100)
21552 ashik.ali 62
	private String brand;
29707 tejbeer 63
 
64
	@Column(name = "status")
24072 amit.gupta 65
	@Enumerated(EnumType.ORDINAL)
66
	private status status;
29707 tejbeer 67
 
28653 amit.gupta 68
	@Column(name = "product_group", length = 100)
69
	private String productGroup;
29707 tejbeer 70
 
21552 ashik.ali 71
	@Column(name = "model_name", length = 100)
72
	private String modelName;
29707 tejbeer 73
 
21552 ashik.ali 74
	@Column(name = "model_number", length = 100)
75
	private String modelNumber;
29707 tejbeer 76
 
21552 ashik.ali 77
	@Column(name = "color", length = 20)
78
	private String color;
29707 tejbeer 79
 
80
	@Column(name = "catalog_item_id")
21898 kshitij.so 81
	private int catalogItemId;
29707 tejbeer 82
 
83
	@Column(name = "weight")
28656 amit.gupta 84
	private Double weight;
29707 tejbeer 85
 
86
	@Column(name = "category")
23426 amit.gupta 87
	private int categoryId;
29707 tejbeer 88
 
23426 amit.gupta 89
	public int getCategoryId() {
90
		return categoryId;
91
	}
29707 tejbeer 92
 
23426 amit.gupta 93
	public void setCategoryId(int categoryId) {
94
		this.categoryId = categoryId;
95
	}
96
 
21614 kshitij.so 97
	@Enumerated(EnumType.STRING)
21573 ashik.ali 98
	@Column(name = "type")
99
	private ItemType type;
29707 tejbeer 100
 
21917 ashik.ali 101
	@Column(name = "hsnCode")
21895 ashik.ali 102
	private String hsnCode;
29707 tejbeer 103
 
22216 ashik.ali 104
	@Column(name = "sellingPrice")
23398 amit.gupta 105
	private Float sellingPrice;
29707 tejbeer 106
 
28653 amit.gupta 107
	public String getProductGroup() {
108
		return productGroup;
109
	}
29707 tejbeer 110
 
28653 amit.gupta 111
	public void setProductGroup(String productGroup) {
112
		this.productGroup = productGroup;
113
	}
29707 tejbeer 114
 
21552 ashik.ali 115
	public int getId() {
116
		return id;
117
	}
29707 tejbeer 118
 
21552 ashik.ali 119
	public void setId(int id) {
120
		this.id = id;
121
	}
29707 tejbeer 122
 
21552 ashik.ali 123
	public String getBrand() {
124
		return brand;
125
	}
29707 tejbeer 126
 
21552 ashik.ali 127
	public void setBrand(String brand) {
128
		this.brand = brand;
129
	}
29707 tejbeer 130
 
21552 ashik.ali 131
	public String getModelName() {
132
		return modelName;
133
	}
29707 tejbeer 134
 
21552 ashik.ali 135
	public void setModelName(String modelName) {
136
		this.modelName = modelName;
137
	}
29707 tejbeer 138
 
21552 ashik.ali 139
	public String getModelNumber() {
140
		return modelNumber;
141
	}
29707 tejbeer 142
 
21552 ashik.ali 143
	public void setModelNumber(String modelNumber) {
144
		this.modelNumber = modelNumber;
145
	}
29707 tejbeer 146
 
21552 ashik.ali 147
	public String getColor() {
29707 tejbeer 148
		if (color != null && (color.startsWith("f_") || color.startsWith("F_"))) {
23361 amit.gupta 149
			return color.substring(2);
150
		}
21552 ashik.ali 151
		return color;
152
	}
29707 tejbeer 153
 
24414 amit.gupta 154
	public String getColorNatural() {
155
		return this.color;
156
	}
29707 tejbeer 157
 
21552 ashik.ali 158
	public void setColor(String color) {
159
		this.color = color;
160
	}
29707 tejbeer 161
 
21573 ashik.ali 162
	public ItemType getType() {
163
		return type;
164
	}
29707 tejbeer 165
 
21573 ashik.ali 166
	public void setType(ItemType type) {
167
		this.type = type;
168
	}
29707 tejbeer 169
 
21895 ashik.ali 170
	public String getHsnCode() {
171
		return hsnCode;
172
	}
29707 tejbeer 173
 
21895 ashik.ali 174
	public void setHsnCode(String hsnCode) {
175
		this.hsnCode = hsnCode;
176
	}
29707 tejbeer 177
 
21898 kshitij.so 178
	public int getCatalogItemId() {
179
		return catalogItemId;
180
	}
29707 tejbeer 181
 
28656 amit.gupta 182
	public Double getWeight() {
28653 amit.gupta 183
		return weight;
184
	}
29707 tejbeer 185
 
28656 amit.gupta 186
	public void setWeight(Double weight) {
28653 amit.gupta 187
		this.weight = weight;
188
	}
29707 tejbeer 189
 
21898 kshitij.so 190
	public void setCatalogItemId(int catalogItemId) {
191
		this.catalogItemId = catalogItemId;
192
	}
29707 tejbeer 193
 
23398 amit.gupta 194
	public Float getSellingPrice() {
22216 ashik.ali 195
		return sellingPrice;
196
	}
29707 tejbeer 197
 
23398 amit.gupta 198
	public void setSellingPrice(Float sellingPrice) {
22216 ashik.ali 199
		this.sellingPrice = sellingPrice;
200
	}
29707 tejbeer 201
 
202
	public String getItemDescription() {
23398 amit.gupta 203
		StringBuilder itemString = new StringBuilder();
29707 tejbeer 204
		if (this.getBrand() != null && !this.getBrand().isEmpty()) {
23398 amit.gupta 205
			itemString.append(this.getBrand().trim());
206
		}
207
		itemString.append(" ");
29707 tejbeer 208
		if (this.getModelName() != null && !this.getModelName().isEmpty()) {
23398 amit.gupta 209
			itemString.append(this.getModelName().trim());
210
		}
29707 tejbeer 211
		if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
24072 amit.gupta 212
			itemString.append(" ");
23398 amit.gupta 213
			itemString.append(this.getModelNumber().trim());
214
		}
29707 tejbeer 215
		if (this.getColor() != null && !this.getColor().isEmpty() && !this.getColor().trim().equals("f_")) {
24072 amit.gupta 216
			itemString.append(" ");
23398 amit.gupta 217
			itemString.append(this.getColor().trim());
218
		}
24087 amit.gupta 219
		return itemString.toString().replaceAll("\\s+", " ").trim();
23398 amit.gupta 220
	}
29707 tejbeer 221
 
31065 tejbeer 222
	public boolean isSmartPhone() {
223
		return SMART_PG.contains(this.getHsnCode());
224
	}
225
 
29707 tejbeer 226
	public String getItemDescriptionNoColor() {
23569 govind 227
		StringBuilder itemString = new StringBuilder();
29707 tejbeer 228
		if (this.getBrand() != null && !this.getBrand().isEmpty()) {
23569 govind 229
			itemString.append(this.getBrand().trim());
230
		}
231
		itemString.append(" ");
29707 tejbeer 232
		if (this.getModelName() != null && !this.getModelName().isEmpty()) {
23569 govind 233
			itemString.append(this.getModelName().trim());
234
		}
29707 tejbeer 235
		if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
24072 amit.gupta 236
			itemString.append(" ");
23569 govind 237
			itemString.append(this.getModelNumber().trim());
238
		}
29707 tejbeer 239
 
24087 amit.gupta 240
		return itemString.toString().replaceAll("\\s+", " ").trim();
23569 govind 241
	}
29707 tejbeer 242
 
21602 ashik.ali 243
	@Override
21924 ashik.ali 244
	public int hashCode() {
245
		final int prime = 31;
246
		int result = 1;
247
		result = prime * result + id;
248
		return result;
249
	}
29707 tejbeer 250
 
21924 ashik.ali 251
	@Override
252
	public boolean equals(Object obj) {
253
		if (this == obj)
254
			return true;
255
		if (obj == null)
256
			return false;
257
		if (getClass() != obj.getClass())
258
			return false;
259
		Item other = (Item) obj;
260
		if (id != other.id)
261
			return false;
262
		return true;
263
	}
29707 tejbeer 264
 
21924 ashik.ali 265
	@Override
21602 ashik.ali 266
	public String toString() {
28653 amit.gupta 267
		return "Item [id=" + id + ", brand=" + brand + ", status=" + status + ", productGroup=" + productGroup
268
				+ ", modelName=" + modelName + ", modelNumber=" + modelNumber + ", color=" + color + ", catalogItemId="
269
				+ catalogItemId + ", weight=" + weight + ", categoryId=" + categoryId + ", type=" + type + ", hsnCode="
270
				+ hsnCode + ", sellingPrice=" + sellingPrice + "]";
21602 ashik.ali 271
	}
29707 tejbeer 272
 
24072 amit.gupta 273
	public status getStatus() {
274
		return status;
275
	}
29707 tejbeer 276
 
24072 amit.gupta 277
	public void setStatus(status status) {
278
		this.status = status;
279
	}
29707 tejbeer 280
 
21552 ashik.ali 281
}