Subversion Repositories SmartDukaan

Rev

Rev 27388 | Rev 30121 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
22600 ashik.ali 1
package com.spice.profitmandi.dao.entity.catalog;
2
 
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
22859 ashik.ali 5
import java.time.format.DateTimeFormatter;
23339 ashik.ali 6
import java.util.HashMap;
22859 ashik.ali 7
import java.util.HashSet;
23339 ashik.ali 8
import java.util.Map;
22859 ashik.ali 9
import java.util.Set;
22600 ashik.ali 10
 
11
import javax.persistence.Column;
12
import javax.persistence.Convert;
13
import javax.persistence.Entity;
23297 ashik.ali 14
import javax.persistence.EnumType;
15
import javax.persistence.Enumerated;
22600 ashik.ali 16
import javax.persistence.GeneratedValue;
17
import javax.persistence.GenerationType;
18
import javax.persistence.Id;
19
import javax.persistence.Table;
22859 ashik.ali 20
import javax.persistence.Transient;
22600 ashik.ali 21
 
22
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
25503 amit.gupta 23
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
23527 ashik.ali 24
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
22653 ashik.ali 25
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
22600 ashik.ali 26
 
27
/**
28
 * This class basically contains scheme details
29
 * 
30
 * @author ashikali
31
 *
32
 */
33
@Entity
25503 amit.gupta 34
@Table(name = "catalog.scheme", schema = "catalog")
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;
43
	}
44
 
22600 ashik.ali 45
	private static final long serialVersionUID = 1L;
25503 amit.gupta 46
 
22600 ashik.ali 47
	public Scheme() {
48
	}
25503 amit.gupta 49
 
22600 ashik.ali 50
	@Id
25503 amit.gupta 51
	@Column(name = "id")
22600 ashik.ali 52
	@GeneratedValue(strategy = GenerationType.IDENTITY)
53
	private int id;
25503 amit.gupta 54
 
22653 ashik.ali 55
	@Column(name = "name")
56
	private String name;
25503 amit.gupta 57
 
22653 ashik.ali 58
	@Column(name = "description")
59
	private String description;
25503 amit.gupta 60
 
22653 ashik.ali 61
	@Column(name = "type")
23297 ashik.ali 62
	@Enumerated(EnumType.STRING)
22653 ashik.ali 63
	private SchemeType type;
25503 amit.gupta 64
 
22600 ashik.ali 65
	@Column(name = "amount_type")
23297 ashik.ali 66
	@Enumerated(EnumType.STRING)
23527 ashik.ali 67
	private AmountType amountType;
25503 amit.gupta 68
 
22600 ashik.ali 69
	@Column(name = "amount")
70
	private float amount;
25503 amit.gupta 71
 
22600 ashik.ali 72
	@Convert(converter = LocalDateTimeAttributeConverter.class)
23019 ashik.ali 73
	@Column(name = "start_date_time")
74
	private LocalDateTime startDateTime = LocalDateTime.now();
25503 amit.gupta 75
 
22600 ashik.ali 76
	@Convert(converter = LocalDateTimeAttributeConverter.class)
23019 ashik.ali 77
	@Column(name = "end_date_time")
78
	private LocalDateTime endDateTime = LocalDateTime.now();
25503 amit.gupta 79
 
22608 ashik.ali 80
	@Convert(converter = LocalDateTimeAttributeConverter.class)
22600 ashik.ali 81
	@Column(name = "create_timestamp")
22859 ashik.ali 82
	private LocalDateTime createTimestamp = LocalDateTime.now();
25503 amit.gupta 83
 
22653 ashik.ali 84
	@Convert(converter = LocalDateTimeAttributeConverter.class)
85
	@Column(name = "active_timestamp")
86
	private LocalDateTime activeTimestamp = null;
25503 amit.gupta 87
 
22653 ashik.ali 88
	@Convert(converter = LocalDateTimeAttributeConverter.class)
22702 ashik.ali 89
	@Column(name = "expire_timestamp")
22653 ashik.ali 90
	private LocalDateTime expireTimestamp = null;
25503 amit.gupta 91
 
22600 ashik.ali 92
	@Column(name = "created_by")
93
	private int createdBy;
25503 amit.gupta 94
 
26679 amit.gupta 95
	@Column
26685 amit.gupta 96
	private boolean cashback;
26679 amit.gupta 97
 
22859 ashik.ali 98
	@Transient
99
	private Set<Integer> retailerIds = new HashSet<>();
27388 amit.gupta 100
 
101
	@Transient
102
	private String amountModel;
28653 amit.gupta 103
 
104
	@Transient
105
	private float schemeValue;
106
 
107
 
25503 amit.gupta 108
 
28653 amit.gupta 109
	public float getSchemeValue() {
110
		return schemeValue;
111
	}
112
 
113
	public void setSchemeValue(float schemeValue) {
114
		this.schemeValue = schemeValue;
115
	}
116
 
25503 amit.gupta 117
	@Column(name="partner_type")
118
	@Enumerated(EnumType.STRING)
119
	private PartnerType partnerType;
120
 
22859 ashik.ali 121
	@Transient
23339 ashik.ali 122
	private Map<Integer, String> itemStringMap = new HashMap<>();
25503 amit.gupta 123
 
22600 ashik.ali 124
	public int getId() {
125
		return id;
126
	}
25503 amit.gupta 127
 
22600 ashik.ali 128
	public void setId(int id) {
129
		this.id = id;
130
	}
27388 amit.gupta 131
 
132
 
25503 amit.gupta 133
 
27388 amit.gupta 134
	public String getAmountModel() {
135
		return amountModel;
136
	}
137
 
138
	public void setAmountModel(String amountModel) {
139
		this.amountModel = amountModel;
140
	}
141
 
22653 ashik.ali 142
	public String getName() {
143
		return name;
22600 ashik.ali 144
	}
25503 amit.gupta 145
 
22653 ashik.ali 146
	public void setName(String name) {
147
		this.name = name;
22600 ashik.ali 148
	}
25503 amit.gupta 149
 
22653 ashik.ali 150
	public String getDescription() {
151
		return description;
22600 ashik.ali 152
	}
25503 amit.gupta 153
 
22653 ashik.ali 154
	public void setDescription(String description) {
155
		this.description = description;
22600 ashik.ali 156
	}
25503 amit.gupta 157
 
26685 amit.gupta 158
	public boolean isCashback() {
159
		return cashback;
26679 amit.gupta 160
	}
161
 
26685 amit.gupta 162
	public void setCashback(boolean cashback) {
163
		this.cashback = cashback;
26679 amit.gupta 164
	}
165
 
22653 ashik.ali 166
	public SchemeType getType() {
167
		return type;
168
	}
25503 amit.gupta 169
 
22653 ashik.ali 170
	public void setType(SchemeType type) {
171
		this.type = type;
172
	}
25503 amit.gupta 173
 
174
	@Override
175
	public String toString() {
176
		return "Scheme [id=" + id + ", name=" + name + ", description=" + description + ", type=" + type
177
				+ ", amountType=" + amountType + ", amount=" + amount + ", startDateTime=" + startDateTime
178
				+ ", endDateTime=" + endDateTime + ", createTimestamp=" + createTimestamp + ", activeTimestamp="
28653 amit.gupta 179
				+ activeTimestamp + ", expireTimestamp=" + expireTimestamp + ", createdBy=" + createdBy + ", cashback="
180
				+ cashback + ", retailerIds=" + retailerIds + ", amountModel=" + amountModel + ", schemeValue="
181
				+ schemeValue + ", partnerType=" + partnerType + ", itemStringMap=" + itemStringMap + "]";
25503 amit.gupta 182
	}
183
 
23527 ashik.ali 184
	public AmountType getAmountType() {
22600 ashik.ali 185
		return amountType;
186
	}
25503 amit.gupta 187
 
23527 ashik.ali 188
	public void setAmountType(AmountType amountType) {
22600 ashik.ali 189
		this.amountType = amountType;
190
	}
25503 amit.gupta 191
 
22600 ashik.ali 192
	public float getAmount() {
193
		return amount;
194
	}
25503 amit.gupta 195
 
22600 ashik.ali 196
	public void setAmount(float amount) {
197
		this.amount = amount;
198
	}
25503 amit.gupta 199
 
23019 ashik.ali 200
	public LocalDateTime getStartDateTime() {
201
		return startDateTime;
22600 ashik.ali 202
	}
25503 amit.gupta 203
 
23019 ashik.ali 204
	public void setStartDateTime(LocalDateTime startDateTime) {
205
		this.startDateTime = startDateTime;
22600 ashik.ali 206
	}
25503 amit.gupta 207
 
23019 ashik.ali 208
	public LocalDateTime getEndDateTime() {
209
		return endDateTime;
22653 ashik.ali 210
	}
25503 amit.gupta 211
 
23019 ashik.ali 212
	public void setEndDateTime(LocalDateTime endDateTime) {
213
		this.endDateTime = endDateTime;
22653 ashik.ali 214
	}
25503 amit.gupta 215
 
22859 ashik.ali 216
	public LocalDateTime getCreateTimestamp() {
217
		return createTimestamp;
22600 ashik.ali 218
	}
25503 amit.gupta 219
 
22859 ashik.ali 220
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
221
		this.createTimestamp = createTimestamp;
22600 ashik.ali 222
	}
25503 amit.gupta 223
 
22600 ashik.ali 224
	public int getCreatedBy() {
225
		return createdBy;
226
	}
25503 amit.gupta 227
 
22600 ashik.ali 228
	public void setCreatedBy(int createdBy) {
229
		this.createdBy = createdBy;
230
	}
25503 amit.gupta 231
 
22653 ashik.ali 232
	public LocalDateTime getActiveTimestamp() {
233
		return activeTimestamp;
22600 ashik.ali 234
	}
25503 amit.gupta 235
 
22653 ashik.ali 236
	public void setActiveTimestamp(LocalDateTime activeTimestamp) {
237
		this.activeTimestamp = activeTimestamp;
22600 ashik.ali 238
	}
25503 amit.gupta 239
 
22653 ashik.ali 240
	public LocalDateTime getExpireTimestamp() {
241
		return expireTimestamp;
242
	}
25503 amit.gupta 243
 
22653 ashik.ali 244
	public void setExpireTimestamp(LocalDateTime expireTimestamp) {
245
		this.expireTimestamp = expireTimestamp;
246
	}
25503 amit.gupta 247
 
248
	public String getFormattedStartDateTime() {
249
		if (startDateTime == null) {
22859 ashik.ali 250
			return null;
251
		}
24402 amit.gupta 252
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
23019 ashik.ali 253
		return startDateTime.format(formatter);
25503 amit.gupta 254
	}
255
 
256
	public String getFormattedEndDateTime() {
257
		if (endDateTime == null) {
22859 ashik.ali 258
			return null;
259
		}
24402 amit.gupta 260
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
23019 ashik.ali 261
		return endDateTime.format(formatter);
25503 amit.gupta 262
	}
263
 
264
	public String getFormattedCreateTimestamp() {
265
		if (createTimestamp == null) {
22859 ashik.ali 266
			return null;
267
		}
24402 amit.gupta 268
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22859 ashik.ali 269
		return createTimestamp.format(formatter);
25503 amit.gupta 270
	}
271
 
272
	public String getFormattedActiveTimestamp() {
273
		if (activeTimestamp == null) {
22859 ashik.ali 274
			return null;
275
		}
24402 amit.gupta 276
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22859 ashik.ali 277
		return activeTimestamp.format(formatter);
25503 amit.gupta 278
	}
279
 
280
	public String getFormattedExpireTimestamp() {
281
		if (expireTimestamp == null) {
22859 ashik.ali 282
			return null;
283
		}
24402 amit.gupta 284
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22859 ashik.ali 285
		return expireTimestamp.format(formatter);
25503 amit.gupta 286
	}
287
 
22859 ashik.ali 288
	public Set<Integer> getRetailerIds() {
289
		return retailerIds;
290
	}
25503 amit.gupta 291
 
22859 ashik.ali 292
	public void setRetailerIds(Set<Integer> retailerIds) {
293
		this.retailerIds = retailerIds;
294
	}
25503 amit.gupta 295
 
296
	public String getRetailerIdsString() {
22859 ashik.ali 297
		Set<String> stringRetailerIds = new HashSet<>();
25503 amit.gupta 298
		if (!retailerIds.isEmpty()) {
299
			for (int retailerId : retailerIds) {
22859 ashik.ali 300
				stringRetailerIds.add(String.valueOf(retailerId));
301
			}
302
		}
303
		return String.join(", ", stringRetailerIds);
304
	}
25503 amit.gupta 305
 
23339 ashik.ali 306
	public Map<Integer, String> getItemStringMap() {
307
		return itemStringMap;
22859 ashik.ali 308
	}
25503 amit.gupta 309
 
23339 ashik.ali 310
	public void setItemStringMap(Map<Integer, String> itemStringMap) {
311
		this.itemStringMap = itemStringMap;
22859 ashik.ali 312
	}
25503 amit.gupta 313
 
314
	/*
315
	 * public String getItemIdsString(){ Set<String> stringItemIds = new
316
	 * HashSet<>(); if(!itemIds.isEmpty()){ for(int itemId : itemIds){
317
	 * stringItemIds.add(String.valueOf(itemId)); } } return String.join(", ",
318
	 * stringItemIds); }
319
	 */
320
 
22600 ashik.ali 321
	@Override
322
	public int hashCode() {
323
		final int prime = 31;
324
		int result = 1;
26679 amit.gupta 325
		result = prime * result + ((activeTimestamp == null) ? 0 : activeTimestamp.hashCode());
326
		result = prime * result + Float.floatToIntBits(amount);
327
		result = prime * result + ((amountType == null) ? 0 : amountType.hashCode());
26685 amit.gupta 328
		result = prime * result + (cashback ? 1231 : 1237);
26679 amit.gupta 329
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
330
		result = prime * result + createdBy;
331
		result = prime * result + ((description == null) ? 0 : description.hashCode());
332
		result = prime * result + ((endDateTime == null) ? 0 : endDateTime.hashCode());
333
		result = prime * result + ((expireTimestamp == null) ? 0 : expireTimestamp.hashCode());
22600 ashik.ali 334
		result = prime * result + id;
26679 amit.gupta 335
		result = prime * result + ((itemStringMap == null) ? 0 : itemStringMap.hashCode());
336
		result = prime * result + ((name == null) ? 0 : name.hashCode());
337
		result = prime * result + ((partnerType == null) ? 0 : partnerType.hashCode());
338
		result = prime * result + ((retailerIds == null) ? 0 : retailerIds.hashCode());
339
		result = prime * result + ((startDateTime == null) ? 0 : startDateTime.hashCode());
340
		result = prime * result + ((type == null) ? 0 : type.hashCode());
22600 ashik.ali 341
		return result;
342
	}
25503 amit.gupta 343
 
22600 ashik.ali 344
	@Override
345
	public boolean equals(Object obj) {
346
		if (this == obj)
347
			return true;
348
		if (obj == null)
349
			return false;
350
		if (getClass() != obj.getClass())
351
			return false;
352
		Scheme other = (Scheme) obj;
26679 amit.gupta 353
		if (activeTimestamp == null) {
354
			if (other.activeTimestamp != null)
355
				return false;
356
		} else if (!activeTimestamp.equals(other.activeTimestamp))
357
			return false;
358
		if (Float.floatToIntBits(amount) != Float.floatToIntBits(other.amount))
359
			return false;
360
		if (amountType != other.amountType)
361
			return false;
26685 amit.gupta 362
		if (cashback != other.cashback)
26679 amit.gupta 363
			return false;
364
		if (createTimestamp == null) {
365
			if (other.createTimestamp != null)
366
				return false;
367
		} else if (!createTimestamp.equals(other.createTimestamp))
368
			return false;
369
		if (createdBy != other.createdBy)
370
			return false;
371
		if (description == null) {
372
			if (other.description != null)
373
				return false;
374
		} else if (!description.equals(other.description))
375
			return false;
376
		if (endDateTime == null) {
377
			if (other.endDateTime != null)
378
				return false;
379
		} else if (!endDateTime.equals(other.endDateTime))
380
			return false;
381
		if (expireTimestamp == null) {
382
			if (other.expireTimestamp != null)
383
				return false;
384
		} else if (!expireTimestamp.equals(other.expireTimestamp))
385
			return false;
22600 ashik.ali 386
		if (id != other.id)
387
			return false;
26679 amit.gupta 388
		if (itemStringMap == null) {
389
			if (other.itemStringMap != null)
390
				return false;
391
		} else if (!itemStringMap.equals(other.itemStringMap))
392
			return false;
393
		if (name == null) {
394
			if (other.name != null)
395
				return false;
396
		} else if (!name.equals(other.name))
397
			return false;
398
		if (partnerType != other.partnerType)
399
			return false;
400
		if (retailerIds == null) {
401
			if (other.retailerIds != null)
402
				return false;
403
		} else if (!retailerIds.equals(other.retailerIds))
404
			return false;
405
		if (startDateTime == null) {
406
			if (other.startDateTime != null)
407
				return false;
408
		} else if (!startDateTime.equals(other.startDateTime))
409
			return false;
410
		if (type != other.type)
411
			return false;
22600 ashik.ali 412
		return true;
413
	}
25503 amit.gupta 414
 
22600 ashik.ali 415
}