Subversion Repositories SmartDukaan

Rev

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