Subversion Repositories SmartDukaan

Rev

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

Rev 24402 Rev 25503
Line 18... Line 18...
18
import javax.persistence.Id;
18
import javax.persistence.Id;
19
import javax.persistence.Table;
19
import javax.persistence.Table;
20
import javax.persistence.Transient;
20
import javax.persistence.Transient;
21
 
21
 
22
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
22
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
-
 
23
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
23
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
24
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
24
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
25
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
25
 
26
 
26
/**
27
/**
27
 * This class basically contains scheme details
28
 * This class basically contains scheme details
28
 * 
29
 * 
29
 * @author ashikali
30
 * @author ashikali
30
 *
31
 *
31
 */
32
 */
32
@Entity
33
@Entity
33
@Table(name="catalog.scheme", schema = "catalog")
34
@Table(name = "catalog.scheme", schema = "catalog")
34
public class Scheme implements Serializable{
35
public class Scheme implements Serializable {
-
 
36
 
-
 
37
	public PartnerType getPartnerType() {
-
 
38
		return partnerType;
-
 
39
	}
-
 
40
 
-
 
41
	public void setPartnerType(PartnerType partnerType) {
-
 
42
		this.partnerType = partnerType;
35
	
43
	}
-
 
44
 
36
	private static final long serialVersionUID = 1L;
45
	private static final long serialVersionUID = 1L;
37
	
46
 
38
	public Scheme() {
47
	public Scheme() {
39
	}
48
	}
40
	
49
 
41
	@Id
50
	@Id
42
	@Column(name="id")
51
	@Column(name = "id")
43
	@GeneratedValue(strategy = GenerationType.IDENTITY)
52
	@GeneratedValue(strategy = GenerationType.IDENTITY)
44
	private int id;
53
	private int id;
45
	
54
 
46
	@Column(name = "name")
55
	@Column(name = "name")
47
	private String name;
56
	private String name;
48
	
57
 
49
	@Column(name = "description")
58
	@Column(name = "description")
50
	private String description;
59
	private String description;
51
	
60
 
52
	@Column(name = "type")
61
	@Column(name = "type")
53
	@Enumerated(EnumType.STRING)
62
	@Enumerated(EnumType.STRING)
54
	private SchemeType type;
63
	private SchemeType type;
55
	
64
 
56
	@Column(name = "amount_type")
65
	@Column(name = "amount_type")
57
	@Enumerated(EnumType.STRING)
66
	@Enumerated(EnumType.STRING)
58
	private AmountType amountType;
67
	private AmountType amountType;
59
	
68
 
60
	@Column(name = "amount")
69
	@Column(name = "amount")
61
	private float amount;
70
	private float amount;
62
	
71
 
63
	@Convert(converter = LocalDateTimeAttributeConverter.class)
72
	@Convert(converter = LocalDateTimeAttributeConverter.class)
64
	@Column(name = "start_date_time")
73
	@Column(name = "start_date_time")
65
	private LocalDateTime startDateTime = LocalDateTime.now();
74
	private LocalDateTime startDateTime = LocalDateTime.now();
66
	
75
 
67
	@Convert(converter = LocalDateTimeAttributeConverter.class)
76
	@Convert(converter = LocalDateTimeAttributeConverter.class)
68
	@Column(name = "end_date_time")
77
	@Column(name = "end_date_time")
69
	private LocalDateTime endDateTime = LocalDateTime.now();
78
	private LocalDateTime endDateTime = LocalDateTime.now();
70
	
79
 
71
	@Convert(converter = LocalDateTimeAttributeConverter.class)
80
	@Convert(converter = LocalDateTimeAttributeConverter.class)
72
	@Column(name = "create_timestamp")
81
	@Column(name = "create_timestamp")
73
	private LocalDateTime createTimestamp = LocalDateTime.now();
82
	private LocalDateTime createTimestamp = LocalDateTime.now();
74
	
83
 
75
	@Convert(converter = LocalDateTimeAttributeConverter.class)
84
	@Convert(converter = LocalDateTimeAttributeConverter.class)
76
	@Column(name = "active_timestamp")
85
	@Column(name = "active_timestamp")
77
	private LocalDateTime activeTimestamp = null;
86
	private LocalDateTime activeTimestamp = null;
78
	
87
 
79
	@Convert(converter = LocalDateTimeAttributeConverter.class)
88
	@Convert(converter = LocalDateTimeAttributeConverter.class)
80
	@Column(name = "expire_timestamp")
89
	@Column(name = "expire_timestamp")
81
	private LocalDateTime expireTimestamp = null;
90
	private LocalDateTime expireTimestamp = null;
82
	
91
 
83
	@Column(name = "created_by")
92
	@Column(name = "created_by")
84
	private int createdBy;
93
	private int createdBy;
85
	
-
 
86
	@Column(name = "retailer_all")
-
 
87
	private boolean retailerAll;
-
 
88
	
94
 
89
	@Transient
95
	@Transient
90
	private Set<Integer> retailerIds = new HashSet<>();
96
	private Set<Integer> retailerIds = new HashSet<>();
-
 
97
 
-
 
98
	@Column(name="partner_type")
-
 
99
	@Enumerated(EnumType.STRING)
-
 
100
	private PartnerType partnerType;
91
	
101
 
92
	@Transient
102
	@Transient
93
	private Map<Integer, String> itemStringMap = new HashMap<>();
103
	private Map<Integer, String> itemStringMap = new HashMap<>();
94
	
104
 
95
	public int getId() {
105
	public int getId() {
96
		return id;
106
		return id;
97
	}
107
	}
-
 
108
 
98
	public void setId(int id) {
109
	public void setId(int id) {
99
		this.id = id;
110
		this.id = id;
100
	}
111
	}
101
	
112
 
102
	public String getName() {
113
	public String getName() {
103
		return name;
114
		return name;
104
	}
115
	}
-
 
116
 
105
	public void setName(String name) {
117
	public void setName(String name) {
106
		this.name = name;
118
		this.name = name;
107
	}
119
	}
108
	
120
 
109
	public String getDescription() {
121
	public String getDescription() {
110
		return description;
122
		return description;
111
	}
123
	}
112
	
124
 
113
	public void setDescription(String description) {
125
	public void setDescription(String description) {
114
		this.description = description;
126
		this.description = description;
115
	}
127
	}
116
	
128
 
117
	public SchemeType getType() {
129
	public SchemeType getType() {
118
		return type;
130
		return type;
119
	}
131
	}
120
	
132
 
121
	public void setType(SchemeType type) {
133
	public void setType(SchemeType type) {
122
		this.type = type;
134
		this.type = type;
123
	}
135
	}
124
	
136
 
-
 
137
	@Override
-
 
138
	public String toString() {
-
 
139
		return "Scheme [id=" + id + ", name=" + name + ", description=" + description + ", type=" + type
-
 
140
				+ ", amountType=" + amountType + ", amount=" + amount + ", startDateTime=" + startDateTime
-
 
141
				+ ", endDateTime=" + endDateTime + ", createTimestamp=" + createTimestamp + ", activeTimestamp="
-
 
142
				+ activeTimestamp + ", expireTimestamp=" + expireTimestamp + ", createdBy=" + createdBy
-
 
143
				+ ", retailerIds=" + retailerIds + ", partnerType=" + partnerType + ", itemStringMap=" + itemStringMap
-
 
144
				+ "]";
125
	
145
	}
-
 
146
 
126
	public AmountType getAmountType() {
147
	public AmountType getAmountType() {
127
		return amountType;
148
		return amountType;
128
	}
149
	}
129
	
150
 
130
	public void setAmountType(AmountType amountType) {
151
	public void setAmountType(AmountType amountType) {
131
		this.amountType = amountType;
152
		this.amountType = amountType;
132
	}
153
	}
133
	
154
 
134
	public float getAmount() {
155
	public float getAmount() {
135
		return amount;
156
		return amount;
136
	}
157
	}
-
 
158
 
137
	public void setAmount(float amount) {
159
	public void setAmount(float amount) {
138
		this.amount = amount;
160
		this.amount = amount;
139
	}
161
	}
140
	
162
 
141
	public LocalDateTime getStartDateTime() {
163
	public LocalDateTime getStartDateTime() {
142
		return startDateTime;
164
		return startDateTime;
143
	}
165
	}
144
	
166
 
145
	public void setStartDateTime(LocalDateTime startDateTime) {
167
	public void setStartDateTime(LocalDateTime startDateTime) {
146
		this.startDateTime = startDateTime;
168
		this.startDateTime = startDateTime;
147
	}
169
	}
148
	
170
 
149
	public LocalDateTime getEndDateTime() {
171
	public LocalDateTime getEndDateTime() {
150
		return endDateTime;
172
		return endDateTime;
151
	}
173
	}
152
	
174
 
153
	public void setEndDateTime(LocalDateTime endDateTime) {
175
	public void setEndDateTime(LocalDateTime endDateTime) {
154
		this.endDateTime = endDateTime;
176
		this.endDateTime = endDateTime;
155
	}
177
	}
156
	
178
 
157
	public LocalDateTime getCreateTimestamp() {
179
	public LocalDateTime getCreateTimestamp() {
158
		return createTimestamp;
180
		return createTimestamp;
159
	}
181
	}
-
 
182
 
160
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
183
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
161
		this.createTimestamp = createTimestamp;
184
		this.createTimestamp = createTimestamp;
162
	}
185
	}
-
 
186
 
163
	public int getCreatedBy() {
187
	public int getCreatedBy() {
164
		return createdBy;
188
		return createdBy;
165
	}
189
	}
-
 
190
 
166
	public void setCreatedBy(int createdBy) {
191
	public void setCreatedBy(int createdBy) {
167
		this.createdBy = createdBy;
192
		this.createdBy = createdBy;
168
	}
193
	}
169
	
194
 
170
	public LocalDateTime getActiveTimestamp() {
195
	public LocalDateTime getActiveTimestamp() {
171
		return activeTimestamp;
196
		return activeTimestamp;
172
	}
197
	}
173
	
198
 
174
	public void setActiveTimestamp(LocalDateTime activeTimestamp) {
199
	public void setActiveTimestamp(LocalDateTime activeTimestamp) {
175
		this.activeTimestamp = activeTimestamp;
200
		this.activeTimestamp = activeTimestamp;
176
	}
201
	}
177
    
202
 
178
	public LocalDateTime getExpireTimestamp() {
203
	public LocalDateTime getExpireTimestamp() {
179
		return expireTimestamp;
204
		return expireTimestamp;
180
	}
205
	}
181
	
206
 
182
	public void setExpireTimestamp(LocalDateTime expireTimestamp) {
207
	public void setExpireTimestamp(LocalDateTime expireTimestamp) {
183
		this.expireTimestamp = expireTimestamp;
208
		this.expireTimestamp = expireTimestamp;
184
	}
209
	}
185
	
-
 
186
	public boolean isRetailerAll() {
-
 
187
		return retailerAll;
-
 
188
	}
-
 
189
	
210
 
190
	public void setRetailerAll(boolean retailerAll) {
-
 
191
		this.retailerAll = retailerAll;
-
 
192
	}
-
 
193
	
-
 
194
	public String getFormattedStartDateTime(){
211
	public String getFormattedStartDateTime() {
195
		if(startDateTime == null){
212
		if (startDateTime == null) {
196
			return null;
213
			return null;
197
		}
214
		}
198
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
215
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
199
		return startDateTime.format(formatter);
216
		return startDateTime.format(formatter);
200
    }
217
	}
201
	
218
 
202
	public String getFormattedEndDateTime(){
219
	public String getFormattedEndDateTime() {
203
		if(endDateTime == null){
220
		if (endDateTime == null) {
204
			return null;
221
			return null;
205
		}
222
		}
206
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
223
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
207
		return endDateTime.format(formatter);
224
		return endDateTime.format(formatter);
208
    }
225
	}
209
	
226
 
210
	public String getFormattedCreateTimestamp(){
227
	public String getFormattedCreateTimestamp() {
211
		if(createTimestamp == null){
228
		if (createTimestamp == null) {
212
			return null;
229
			return null;
213
		}
230
		}
214
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
231
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
215
		return createTimestamp.format(formatter);
232
		return createTimestamp.format(formatter);
216
    }
233
	}
217
	
234
 
218
	public String getFormattedActiveTimestamp(){
235
	public String getFormattedActiveTimestamp() {
219
		if(activeTimestamp == null){
236
		if (activeTimestamp == null) {
220
			return null;
237
			return null;
221
		}
238
		}
222
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
239
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
223
		return activeTimestamp.format(formatter);
240
		return activeTimestamp.format(formatter);
224
    }
241
	}
225
	
242
 
226
	public String getFormattedExpireTimestamp(){
243
	public String getFormattedExpireTimestamp() {
227
		if(expireTimestamp == null){
244
		if (expireTimestamp == null) {
228
			return null;
245
			return null;
229
		}
246
		}
230
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
247
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
231
		return expireTimestamp.format(formatter);
248
		return expireTimestamp.format(formatter);
232
    }
249
	}
233
	
250
 
234
	public Set<Integer> getRetailerIds() {
251
	public Set<Integer> getRetailerIds() {
235
		return retailerIds;
252
		return retailerIds;
236
	}
253
	}
237
	
254
 
238
	public void setRetailerIds(Set<Integer> retailerIds) {
255
	public void setRetailerIds(Set<Integer> retailerIds) {
239
		this.retailerIds = retailerIds;
256
		this.retailerIds = retailerIds;
240
	}
257
	}
241
	
258
 
242
	public String getRetailerIdsString(){
259
	public String getRetailerIdsString() {
243
		Set<String> stringRetailerIds = new HashSet<>();
260
		Set<String> stringRetailerIds = new HashSet<>();
244
		if(!retailerIds.isEmpty()){
261
		if (!retailerIds.isEmpty()) {
245
			for(int retailerId : retailerIds){
262
			for (int retailerId : retailerIds) {
246
				stringRetailerIds.add(String.valueOf(retailerId));
263
				stringRetailerIds.add(String.valueOf(retailerId));
247
			}
264
			}
248
		}
265
		}
249
		return String.join(", ", stringRetailerIds);
266
		return String.join(", ", stringRetailerIds);
250
	}
267
	}
251
	
268
 
252
	public Map<Integer, String> getItemStringMap() {
269
	public Map<Integer, String> getItemStringMap() {
253
		return itemStringMap;
270
		return itemStringMap;
254
	}
271
	}
255
	
272
 
256
	public void setItemStringMap(Map<Integer, String> itemStringMap) {
273
	public void setItemStringMap(Map<Integer, String> itemStringMap) {
257
		this.itemStringMap = itemStringMap;
274
		this.itemStringMap = itemStringMap;
258
	}
275
	}
259
	
276
 
-
 
277
	/*
260
	/*public String getItemIdsString(){
278
	 * public String getItemIdsString(){ Set<String> stringItemIds = new
261
		Set<String> stringItemIds = new HashSet<>();
-
 
262
		if(!itemIds.isEmpty()){
-
 
263
			for(int itemId : itemIds){
279
	 * HashSet<>(); if(!itemIds.isEmpty()){ for(int itemId : itemIds){
264
				stringItemIds.add(String.valueOf(itemId));
280
	 * stringItemIds.add(String.valueOf(itemId)); } } return String.join(", ",
265
			}
-
 
266
		}
-
 
267
		return String.join(", ", stringItemIds);
281
	 * stringItemIds); }
268
	}*/
282
	 */
269
	
-
 
270
	
283
 
271
	@Override
284
	@Override
272
	public int hashCode() {
285
	public int hashCode() {
273
		final int prime = 31;
286
		final int prime = 31;
274
		int result = 1;
287
		int result = 1;
275
		result = prime * result + id;
288
		result = prime * result + id;
276
		return result;
289
		return result;
277
	}
290
	}
-
 
291
 
278
	@Override
292
	@Override
279
	public boolean equals(Object obj) {
293
	public boolean equals(Object obj) {
280
		if (this == obj)
294
		if (this == obj)
281
			return true;
295
			return true;
282
		if (obj == null)
296
		if (obj == null)
Line 286... Line 300...
286
		Scheme other = (Scheme) obj;
300
		Scheme other = (Scheme) obj;
287
		if (id != other.id)
301
		if (id != other.id)
288
			return false;
302
			return false;
289
		return true;
303
		return true;
290
	}
304
	}
291
	
305
 
292
	@Override
-
 
293
	public String toString() {
-
 
294
		return "Scheme [id=" + id + ", name=" + name + ", description=" + description + ", type=" + type
-
 
295
				+ ", amountType=" + amountType + ", amount=" + amount + ", startDateTime=" + startDateTime
-
 
296
				+ ", endDateTime=" + endDateTime + ", createTimestamp=" + createTimestamp + ", activeTimestamp="
-
 
297
				+ activeTimestamp + ", expireTimestamp=" + expireTimestamp + ", createdBy=" + createdBy
-
 
298
				+ ", retailerAll=" + retailerAll + ", retailerIds=" + retailerIds + ", itemStringMap=" + itemStringMap + "]";
-
 
299
	}
-
 
300
	
-
 
301
	
-
 
302
}
306
}
303
307