Subversion Repositories SmartDukaan

Rev

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