Subversion Repositories SmartDukaan

Rev

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

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