Subversion Repositories SmartDukaan

Rev

Rev 31821 | Rev 32230 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31821 Rev 31846
Line 1... Line 1...
1
package com.spice.profitmandi.dao.entity.catalog;
1
package com.spice.profitmandi.dao.entity.catalog;
2
 
2
 
3
import java.io.Serializable;
3
import java.io.Serializable;
4
import java.util.ArrayList;
4
import java.time.LocalDateTime;
5
import java.util.Arrays;
5
import java.util.Arrays;
6
import java.util.List;
6
import java.util.List;
7
 
7
 
8
import javax.persistence.Column;
8
import javax.persistence.Column;
9
import javax.persistence.Entity;
9
import javax.persistence.Entity;
Line 24... Line 24...
24
 * This class basically contains item details
24
 * This class basically contains item details
25
 *
25
 *
26
 * @author ashikali
26
 * @author ashikali
27
 */
27
 */
28
 
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 "
-
 
33
				+ " where cis.fofoId = :fofoId and cis.availability > 0 and REPLACE(CONCAT(i.brand,' ', ifnull(i.modelName, ' '), ' ', ifnull(i.modelNumber, ' ')), '  ', ' ')  like CONCAT('%',:query,'%')"),
29
@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,'%')"),
34
 
30
 
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"),
31
        @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"),
38
 
32
 
39
		@NamedQuery(name = "Item.selectAllBrands", query = "select distinct"
-
 
40
				+ "  i.brand from Item i join TagListing tl on tl.itemId = i.id " + " where i.categoryId=:categoryId"),
-
 
41
		@NamedQuery(name = "Item.selectAllCategories", query = "select distinct"
-
 
42
				+ "  i.categoryId from Item i join TagListing tl on tl.itemId = i.id "),
-
 
43
		@NamedQuery(name = "Item.selectAllModels", query = "select "
-
 
44
				+ "  i from Item i join TagListing tl on tl.itemId = i.id where i.brand in :brands and i.categoryId = :categoryId") })
33
        @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")})
45
@Entity
34
@Entity
46
@Table(name = "catalog.item", schema = "catalog")
35
@Table(name = "catalog.item")
47
public class Item implements Serializable {
36
public class Item implements Serializable {
48
 
37
 
49
	public static final List<String> SMART_PG = Arrays.asList("85171300", "85171290");
38
    public static final List<String> SMART_PG = Arrays.asList("85171300", "85171290");
50
 
39
 
51
	private static final long serialVersionUID = 1L;
40
    private static final long serialVersionUID = 1L;
52
 
41
 
53
	public Item() {
42
    public Item() {
54
	}
43
    }
55
 
44
 
56
	@Id
45
    @Id
57
	@Column(name = "id", columnDefinition = "int(11)")
46
    @Column(name = "id", columnDefinition = "int(11)")
58
	@GeneratedValue(strategy = GenerationType.IDENTITY)
47
    @GeneratedValue(strategy = GenerationType.IDENTITY)
59
	private int id;
48
    private int id;
60
 
49
 
61
	@Column(name = "brand", length = 100)
50
    @Column(name = "brand", length = 100)
62
	private String brand;
51
    private String brand;
63
 
52
 
64
	@Column(name = "status")
53
    @Column(name = "status")
65
	@Enumerated(EnumType.ORDINAL)
54
    @Enumerated(EnumType.ORDINAL)
66
	private status status;
55
    private status status;
67
 
56
 
68
	@Column(name = "product_group", length = 100)
57
    @Column(name = "product_group", length = 100)
69
	private String productGroup;
58
    private String productGroup;
70
 
59
 
71
	@Column(name = "model_name", length = 100)
60
    @Column(name = "model_name", length = 100)
72
	private String modelName;
61
    private String modelName;
73
 
62
 
74
	@Column(name = "model_number", length = 100)
63
    @Column(name = "model_number", length = 100)
75
	private String modelNumber;
64
    private String modelNumber;
76
 
65
 
77
	@Column(name = "color", length = 20)
66
    @Column(name = "color", length = 20)
78
	private String color;
67
    private String color;
79
 
68
 
80
	@Column(name = "catalog_item_id")
69
    @Column(name = "catalog_item_id")
81
	private int catalogItemId;
70
    private int catalogItemId;
82
 
71
 
83
	@Column(name = "weight")
72
    @Column(name = "weight")
84
	private Double weight;
73
    private Double weight;
85
 
74
 
86
	@Column(name = "category")
75
    @Column(name = "category")
87
	private int categoryId;
76
    private int categoryId;
88
 
77
 
89
	public int getCategoryId() {
78
    @Column(name = "startDate")
90
		return categoryId;
79
    private LocalDateTime startDate;
91
	}
80
 
92
 
81
    public int getCategoryId() {
93
	public void setCategoryId(int categoryId) {
82
        return categoryId;
94
		this.categoryId = categoryId;
83
    }
95
	}
84
 
96
 
85
    public void setCategoryId(int categoryId) {
97
	@Enumerated(EnumType.STRING)
86
        this.categoryId = categoryId;
98
	@Column(name = "type")
87
    }
99
	private ItemType type;
88
 
100
 
89
    @Enumerated(EnumType.STRING)
101
	@Column(name = "hsnCode")
90
    @Column(name = "type")
102
	private String hsnCode;
91
    private ItemType type;
103
 
92
 
104
	@Column(name = "sellingPrice")
93
    @Column(name = "hsnCode")
105
	private Float sellingPrice;
94
    private String hsnCode;
106
 
95
 
107
	@Column
96
    @Column(name = "sellingPrice")
108
	private Float mrp;
97
    private Float sellingPrice;
109
 
98
 
110
	public String getProductGroup() {
99
    public String getProductGroup() {
111
		return productGroup;
100
        return productGroup;
112
	}
101
    }
113
 
102
 
114
	public void setProductGroup(String productGroup) {
103
    public void setProductGroup(String productGroup) {
115
		this.productGroup = productGroup;
104
        this.productGroup = productGroup;
116
	}
105
    }
117
 
106
 
118
	public int getId() {
107
    public int getId() {
119
		return id;
108
        return id;
120
	}
109
    }
121
 
110
 
122
	public void setId(int id) {
111
    @Column
123
		this.id = id;
112
    private Float mrp;
124
	}
113
 
125
 
114
    public void setId(int id) {
126
	public String getBrand() {
115
        this.id = id;
127
		return brand;
116
    }
128
	}
117
 
129
 
118
    public String getBrand() {
130
	public void setBrand(String brand) {
119
        return brand;
131
		this.brand = brand;
120
    }
132
	}
121
 
133
 
122
    public void setBrand(String brand) {
134
	public String getModelName() {
123
        this.brand = brand;
135
		return modelName;
124
    }
136
	}
125
 
137
 
126
    public String getModelName() {
138
	public void setModelName(String modelName) {
127
        return modelName;
139
		this.modelName = modelName;
128
    }
140
	}
129
 
141
 
130
    public void setModelName(String modelName) {
142
	public String getModelNumber() {
131
        this.modelName = modelName;
143
		return modelNumber;
132
    }
144
	}
133
 
145
 
134
    public String getModelNumber() {
146
	public void setModelNumber(String modelNumber) {
135
        return modelNumber;
147
		this.modelNumber = modelNumber;
136
    }
148
	}
137
 
149
 
138
    public void setModelNumber(String modelNumber) {
150
	public String getColor() {
139
        this.modelNumber = modelNumber;
151
		if (color != null && (color.startsWith("f_") || color.startsWith("F_"))) {
140
    }
152
			return color.substring(2);
141
 
153
		}
142
    public String getColor() {
154
		return color;
143
        if (color != null && (color.startsWith("f_") || color.startsWith("F_"))) {
155
	}
144
            return color.substring(2);
156
 
145
        }
157
	public String getColorNatural() {
146
        return color;
158
		return this.color;
147
    }
159
	}
148
 
160
 
149
    public String getColorNatural() {
161
	public void setColor(String color) {
150
        return this.color;
162
		this.color = color;
151
    }
163
	}
152
 
164
 
153
    public void setColor(String color) {
165
	public ItemType getType() {
154
        this.color = color;
166
		return type;
155
    }
167
	}
156
 
168
 
157
    public ItemType getType() {
169
	public void setType(ItemType type) {
158
        return type;
170
		this.type = type;
159
    }
171
	}
160
 
172
 
161
    public void setType(ItemType type) {
173
	public String getHsnCode() {
162
        this.type = type;
174
		return hsnCode;
163
    }
175
	}
164
 
176
 
165
    public String getHsnCode() {
177
	public void setHsnCode(String hsnCode) {
166
        return hsnCode;
178
		this.hsnCode = hsnCode;
167
    }
179
	}
168
 
180
 
169
    public void setHsnCode(String hsnCode) {
181
	public int getCatalogItemId() {
170
        this.hsnCode = hsnCode;
182
		return catalogItemId;
171
    }
183
	}
172
 
184
 
173
    public int getCatalogItemId() {
185
	public Double getWeight() {
174
        return catalogItemId;
186
		return weight;
175
    }
187
	}
176
 
188
 
177
    public Double getWeight() {
189
	public void setWeight(Double weight) {
178
        return weight;
190
		this.weight = weight;
179
    }
191
	}
180
 
192
 
181
    public void setWeight(Double weight) {
193
	public void setCatalogItemId(int catalogItemId) {
182
        this.weight = weight;
194
		this.catalogItemId = catalogItemId;
183
    }
195
	}
184
 
196
 
185
    public void setCatalogItemId(int catalogItemId) {
197
	public Float getSellingPrice() {
186
        this.catalogItemId = catalogItemId;
198
		return sellingPrice;
187
    }
199
	}
188
 
200
 
189
    public Float getSellingPrice() {
201
	public void setSellingPrice(Float sellingPrice) {
190
        return sellingPrice;
202
		this.sellingPrice = sellingPrice;
191
    }
203
	}
192
 
204
 
193
    public void setSellingPrice(Float sellingPrice) {
205
	public String getItemDescription() {
194
        this.sellingPrice = sellingPrice;
206
		StringBuilder itemString = new StringBuilder();
195
    }
207
		if (this.getBrand() != null && !this.getBrand().isEmpty()) {
196
 
208
			itemString.append(this.getBrand().trim());
197
 
209
		}
198
    public LocalDateTime getStartDate() {
210
		itemString.append(" ");
199
        return startDate;
211
		if (this.getModelName() != null && !this.getModelName().isEmpty()) {
200
    }
212
			itemString.append(this.getModelName().trim());
201
 
213
		}
202
    public void setStartDate(LocalDateTime startDate) {
214
		if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
203
        this.startDate = startDate;
215
			itemString.append(" ");
204
    }
216
			itemString.append(this.getModelNumber().trim());
205
 
217
		}
206
    public String getItemDescription() {
218
		if (this.getColor() != null && !this.getColor().isEmpty() && !this.getColor().trim().equals("f_")) {
207
        StringBuilder itemString = new StringBuilder();
219
			itemString.append(" ");
208
        if (this.getBrand() != null && !this.getBrand().isEmpty()) {
220
			itemString.append(this.getColor().trim());
209
            itemString.append(this.getBrand().trim());
221
		}
210
        }
222
		return itemString.toString().replaceAll("\\s+", " ").trim();
211
        itemString.append(" ");
223
	}
212
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
224
 
213
            itemString.append(this.getModelName().trim());
225
	public boolean isSmartPhone() {
214
        }
226
		return SMART_PG.contains(this.getHsnCode());
215
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
227
	}
216
            itemString.append(" ");
228
 
217
            itemString.append(this.getModelNumber().trim());
229
	public String getItemDescriptionNoColor() {
218
        }
230
		StringBuilder itemString = new StringBuilder();
219
        if (this.getColor() != null && !this.getColor().isEmpty() && !this.getColor().trim().equals("f_")) {
231
		if (this.getBrand() != null && !this.getBrand().isEmpty()) {
220
            itemString.append(" ");
232
			itemString.append(this.getBrand().trim());
221
            itemString.append(this.getColor().trim());
233
		}
222
        }
234
		itemString.append(" ");
223
        return itemString.toString().replaceAll("\\s+", " ").trim();
235
		if (this.getModelName() != null && !this.getModelName().isEmpty()) {
224
    }
236
			itemString.append(this.getModelName().trim());
225
 
237
		}
226
    public boolean isSmartPhone() {
238
		if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
227
        return SMART_PG.contains(this.getHsnCode());
239
			itemString.append(" ");
228
    }
240
			itemString.append(this.getModelNumber().trim());
229
 
241
		}
230
    public String getItemDescriptionNoColor() {
242
 
231
        StringBuilder itemString = new StringBuilder();
243
		return itemString.toString().replaceAll("\\s+", " ").trim();
232
        if (this.getBrand() != null && !this.getBrand().isEmpty()) {
244
	}
233
            itemString.append(this.getBrand().trim());
245
 
234
        }
246
	@Override
235
        itemString.append(" ");
247
	public int hashCode() {
236
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
248
		final int prime = 31;
237
            itemString.append(this.getModelName().trim());
249
		int result = 1;
238
        }
250
		result = prime * result + id;
239
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
251
		return result;
240
            itemString.append(" ");
252
	}
241
            itemString.append(this.getModelNumber().trim());
253
 
242
        }
254
	@Override
243
 
255
	public boolean equals(Object obj) {
244
        return itemString.toString().replaceAll("\\s+", " ").trim();
256
		if (this == obj)
245
    }
257
			return true;
246
 
258
		if (obj == null)
247
    @Override
259
			return false;
248
    public int hashCode() {
260
		if (getClass() != obj.getClass())
249
        final int prime = 31;
261
			return false;
250
        int result = 1;
262
		Item other = (Item) obj;
251
        result = prime * result + ((brand == null) ? 0 : brand.hashCode());
263
		if (id != other.id)
252
        result = prime * result + catalogItemId;
264
			return false;
253
        result = prime * result + categoryId;
265
		return true;
254
        result = prime * result + ((color == null) ? 0 : color.hashCode());
266
	}
255
        result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());
267
 
256
        result = prime * result + id;
268
	@Override
257
        result = prime * result + ((modelName == null) ? 0 : modelName.hashCode());
269
	public String toString() {
258
        result = prime * result + ((modelNumber == null) ? 0 : modelNumber.hashCode());
270
		return "Item [id=" + id + ", brand=" + brand + ", status=" + status + ", productGroup=" + productGroup
259
        result = prime * result + ((productGroup == null) ? 0 : productGroup.hashCode());
271
				+ ", modelName=" + modelName + ", modelNumber=" + modelNumber + ", color=" + color + ", catalogItemId="
260
        result = prime * result + ((sellingPrice == null) ? 0 : sellingPrice.hashCode());
272
				+ catalogItemId + ", weight=" + weight + ", categoryId=" + categoryId + ", type=" + type + ", hsnCode="
261
        result = prime * result + ((startDate == null) ? 0 : startDate.hashCode());
273
				+ hsnCode + ", sellingPrice=" + sellingPrice + "]";
262
        result = prime * result + ((status == null) ? 0 : status.hashCode());
274
	}
263
        result = prime * result + ((type == null) ? 0 : type.hashCode());
275
 
264
        result = prime * result + ((weight == null) ? 0 : weight.hashCode());
276
	public status getStatus() {
265
        return result;
277
		return status;
266
    }
278
	}
267
 
279
 
268
    @Override
280
	public void setStatus(status status) {
269
    public boolean equals(Object obj) {
281
		this.status = status;
270
        if (this == obj) return true;
282
	}
271
        if (obj == null) return false;
283
 
272
        if (getClass() != obj.getClass()) return false;
284
	public boolean isAnyColor() {
273
        Item other = (Item) obj;
285
		if(this.color != null) {
274
        if (brand == null) {
286
			String lowerCaseColor = this.color.toLowerCase();
275
            if (other.brand != null) return false;
287
			return lowerCaseColor.equals("any color") || lowerCaseColor.equals("f_any color") || lowerCaseColor.equals("any colour") || lowerCaseColor.equals("f_any colour");
276
        } else if (!brand.equals(other.brand)) return false;
288
		}
277
        if (catalogItemId != other.catalogItemId) return false;
289
		return false;
278
        if (categoryId != other.categoryId) return false;
290
	}
279
        if (color == null) {
291
 
280
            if (other.color != null) return false;
292
	public Float getMrp() {
281
        } else if (!color.equals(other.color)) return false;
293
		return mrp;
282
        if (hsnCode == null) {
294
	}
283
            if (other.hsnCode != null) return false;
295
 
284
        } else if (!hsnCode.equals(other.hsnCode)) return false;
296
	public void setMrp(Float mrp) {
285
        if (id != other.id) return false;
297
		this.mrp = mrp;
286
        if (modelName == null) {
298
	}
287
            if (other.modelName != null) return false;
-
 
288
        } else if (!modelName.equals(other.modelName)) return false;
-
 
289
        if (modelNumber == null) {
-
 
290
            if (other.modelNumber != null) return false;
-
 
291
        } else if (!modelNumber.equals(other.modelNumber)) return false;
-
 
292
        if (productGroup == null) {
-
 
293
            if (other.productGroup != null) return false;
-
 
294
        } else if (!productGroup.equals(other.productGroup)) return false;
-
 
295
        if (sellingPrice == null) {
-
 
296
            if (other.sellingPrice != null) return false;
-
 
297
        } else if (!sellingPrice.equals(other.sellingPrice)) return false;
-
 
298
        if (startDate == null) {
-
 
299
            if (other.startDate != null) return false;
-
 
300
        } else if (!startDate.equals(other.startDate)) return false;
-
 
301
        if (status != other.status) return false;
-
 
302
        if (type != other.type) return false;
-
 
303
        if (weight == null) {
-
 
304
            if (other.weight != null) return false;
-
 
305
        } else if (!weight.equals(other.weight)) return false;
-
 
306
        return true;
-
 
307
    }
-
 
308
 
-
 
309
    @Override
-
 
310
    public String toString() {
-
 
311
        return "Item [id=" + id + ", brand=" + brand + ", status=" + status + ", productGroup=" + productGroup + ", modelName=" + modelName + ", modelNumber=" + modelNumber + ", color=" + color + ", catalogItemId=" + catalogItemId + ", weight=" + weight + ", categoryId=" + categoryId + ", startDate=" + startDate + ", type=" + type + ", hsnCode=" + hsnCode + ", sellingPrice=" + sellingPrice + "]";
-
 
312
    }
-
 
313
 
-
 
314
    public status getStatus() {
-
 
315
        return status;
-
 
316
    }
-
 
317
 
-
 
318
    public void setStatus(status status) {
-
 
319
        this.status = status;
-
 
320
    }
-
 
321
 
-
 
322
    public boolean isAnyColor() {
-
 
323
        if (this.color != null) {
-
 
324
            String lowerCaseColor = this.color.toLowerCase();
-
 
325
            return lowerCaseColor.equals("any color") || lowerCaseColor.equals("f_any color") || lowerCaseColor.equals("any colour") || lowerCaseColor.equals("f_any colour");
-
 
326
        }
-
 
327
        return false;
-
 
328
    }
-
 
329
 
-
 
330
    public Float getMrp() {
-
 
331
        return mrp;
-
 
332
    }
-
 
333
 
-
 
334
    public void setMrp(Float mrp) {
-
 
335
        this.mrp = mrp;
-
 
336
    }
299
}
337
}
300
338