Subversion Repositories SmartDukaan

Rev

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