Subversion Repositories SmartDukaan

Rev

Rev 23362 | Rev 23426 | 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
 
21573 ashik.ali 14
import in.shop2020.model.v1.catalog.ItemType;
15
 
21552 ashik.ali 16
/**
17
 * This class basically contains item details
18
 * 
19
 * @author ashikali
20
 *
21
 */
22
@Entity
23
@Table(name="catalog.item", schema = "catalog")
24
public class Item implements Serializable{
25
 
26
	private static final long serialVersionUID = 1L;
27
 
28
	public Item() {
29
	}
30
 
31
	@Id
32
	@Column(name="id", columnDefinition = "int(11)")
33
	@GeneratedValue(strategy = GenerationType.IDENTITY)
34
	private int id;
35
 
21653 ashik.ali 36
	@Column(name="brand", length = 100)
21552 ashik.ali 37
	private String brand;
38
 
39
	@Column(name = "model_name", length = 100)
40
	private String modelName;
41
 
42
	@Column(name = "model_number", length = 100)
43
	private String modelNumber;
44
 
45
	@Column(name = "color", length = 20)
46
	private String color;
47
 
21898 kshitij.so 48
	@Column(name="catalog_item_id")
49
	private int catalogItemId;
50
 
21614 kshitij.so 51
	@Enumerated(EnumType.STRING)
21573 ashik.ali 52
	@Column(name = "type")
53
	private ItemType type;
54
 
21917 ashik.ali 55
	@Column(name = "hsnCode")
21895 ashik.ali 56
	private String hsnCode;
57
 
22216 ashik.ali 58
	@Column(name = "sellingPrice")
23398 amit.gupta 59
	private Float sellingPrice;
22216 ashik.ali 60
 
21552 ashik.ali 61
	public int getId() {
62
		return id;
63
	}
64
	public void setId(int id) {
65
		this.id = id;
66
	}
67
	public String getBrand() {
68
		return brand;
69
	}
70
	public void setBrand(String brand) {
71
		this.brand = brand;
72
	}
73
	public String getModelName() {
74
		return modelName;
75
	}
76
	public void setModelName(String modelName) {
77
		this.modelName = modelName;
78
	}
79
	public String getModelNumber() {
80
		return modelNumber;
81
	}
82
	public void setModelNumber(String modelNumber) {
83
		this.modelNumber = modelNumber;
84
	}
85
	public String getColor() {
23362 amit.gupta 86
		if(color != null && (color.startsWith("f_") || color.startsWith("F_"))){
23361 amit.gupta 87
			return color.substring(2);
88
		}
21552 ashik.ali 89
		return color;
90
	}
91
	public void setColor(String color) {
92
		this.color = color;
93
	}
94
 
21573 ashik.ali 95
	public ItemType getType() {
96
		return type;
97
	}
98
	public void setType(ItemType type) {
99
		this.type = type;
100
	}
21895 ashik.ali 101
 
102
	public String getHsnCode() {
103
		return hsnCode;
104
	}
105
	public void setHsnCode(String hsnCode) {
106
		this.hsnCode = hsnCode;
107
	}
21898 kshitij.so 108
 
109
	public int getCatalogItemId() {
110
		return catalogItemId;
111
	}
112
	public void setCatalogItemId(int catalogItemId) {
113
		this.catalogItemId = catalogItemId;
114
	}
21924 ashik.ali 115
 
23398 amit.gupta 116
	public Float getSellingPrice() {
22216 ashik.ali 117
		return sellingPrice;
118
	}
22009 ashik.ali 119
 
23398 amit.gupta 120
	public void setSellingPrice(Float sellingPrice) {
22216 ashik.ali 121
		this.sellingPrice = sellingPrice;
122
	}
123
 
23398 amit.gupta 124
	public String getItemDescription(){
125
		StringBuilder itemString = new StringBuilder();
126
		if(this.getBrand() != null && !this.getBrand().isEmpty()){
127
			itemString.append(this.getBrand().trim());
128
		}
129
		itemString.append(" ");
130
		if(this.getModelName() != null && !this.getModelName().isEmpty()){
131
			itemString.append(this.getModelName().trim());
132
		}
133
		itemString.append(" ");
134
		if(this.getModelNumber() != null && !this.getModelNumber().isEmpty()){
135
			itemString.append(this.getModelNumber().trim());
136
		}
137
		itemString.append(" ");
138
		if(this.getColor() != null && !this.getColor().isEmpty()){
139
			itemString.append(this.getColor().trim());
140
		}
141
		return itemString.toString();
142
	}
143
 
21602 ashik.ali 144
	@Override
21924 ashik.ali 145
	public int hashCode() {
146
		final int prime = 31;
147
		int result = 1;
148
		result = prime * result + id;
149
		return result;
150
	}
151
	@Override
152
	public boolean equals(Object obj) {
153
		if (this == obj)
154
			return true;
155
		if (obj == null)
156
			return false;
157
		if (getClass() != obj.getClass())
158
			return false;
159
		Item other = (Item) obj;
160
		if (id != other.id)
161
			return false;
162
		return true;
163
	}
164
	@Override
21602 ashik.ali 165
	public String toString() {
166
		return "Item [id=" + id + ", brand=" + brand + ", modelName=" + modelName + ", modelNumber=" + modelNumber
23172 ashik.ali 167
				+ ", color=" + color + ", catalogItemId=" + catalogItemId + ", type=" + type + ", hsnCode=" + hsnCode
168
				+ ", sellingPrice=" + sellingPrice + "]";
21602 ashik.ali 169
	}
21552 ashik.ali 170
 
171
}