Subversion Repositories SmartDukaan

Rev

Rev 26685 | Rev 28653 | 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;
25503 amit.gupta 103
 
104
	@Column(name="partner_type")
105
	@Enumerated(EnumType.STRING)
106
	private PartnerType partnerType;
107
 
22859 ashik.ali 108
	@Transient
23339 ashik.ali 109
	private Map<Integer, String> itemStringMap = new HashMap<>();
25503 amit.gupta 110
 
22600 ashik.ali 111
	public int getId() {
112
		return id;
113
	}
25503 amit.gupta 114
 
22600 ashik.ali 115
	public void setId(int id) {
116
		this.id = id;
117
	}
27388 amit.gupta 118
 
119
 
25503 amit.gupta 120
 
27388 amit.gupta 121
	public String getAmountModel() {
122
		return amountModel;
123
	}
124
 
125
	public void setAmountModel(String amountModel) {
126
		this.amountModel = amountModel;
127
	}
128
 
22653 ashik.ali 129
	public String getName() {
130
		return name;
22600 ashik.ali 131
	}
25503 amit.gupta 132
 
22653 ashik.ali 133
	public void setName(String name) {
134
		this.name = name;
22600 ashik.ali 135
	}
25503 amit.gupta 136
 
22653 ashik.ali 137
	public String getDescription() {
138
		return description;
22600 ashik.ali 139
	}
25503 amit.gupta 140
 
22653 ashik.ali 141
	public void setDescription(String description) {
142
		this.description = description;
22600 ashik.ali 143
	}
25503 amit.gupta 144
 
26685 amit.gupta 145
	public boolean isCashback() {
146
		return cashback;
26679 amit.gupta 147
	}
148
 
26685 amit.gupta 149
	public void setCashback(boolean cashback) {
150
		this.cashback = cashback;
26679 amit.gupta 151
	}
152
 
22653 ashik.ali 153
	public SchemeType getType() {
154
		return type;
155
	}
25503 amit.gupta 156
 
22653 ashik.ali 157
	public void setType(SchemeType type) {
158
		this.type = type;
159
	}
25503 amit.gupta 160
 
161
	@Override
162
	public String toString() {
163
		return "Scheme [id=" + id + ", name=" + name + ", description=" + description + ", type=" + type
164
				+ ", amountType=" + amountType + ", amount=" + amount + ", startDateTime=" + startDateTime
165
				+ ", endDateTime=" + endDateTime + ", createTimestamp=" + createTimestamp + ", activeTimestamp="
26679 amit.gupta 166
				+ activeTimestamp + ", expireTimestamp=" + expireTimestamp + ", createdBy=" + createdBy + ", cashBack="
26685 amit.gupta 167
				+ cashback + ", retailerIds=" + retailerIds + ", partnerType=" + partnerType + ", itemStringMap="
26679 amit.gupta 168
				+ itemStringMap + "]";
25503 amit.gupta 169
	}
170
 
23527 ashik.ali 171
	public AmountType getAmountType() {
22600 ashik.ali 172
		return amountType;
173
	}
25503 amit.gupta 174
 
23527 ashik.ali 175
	public void setAmountType(AmountType amountType) {
22600 ashik.ali 176
		this.amountType = amountType;
177
	}
25503 amit.gupta 178
 
22600 ashik.ali 179
	public float getAmount() {
180
		return amount;
181
	}
25503 amit.gupta 182
 
22600 ashik.ali 183
	public void setAmount(float amount) {
184
		this.amount = amount;
185
	}
25503 amit.gupta 186
 
23019 ashik.ali 187
	public LocalDateTime getStartDateTime() {
188
		return startDateTime;
22600 ashik.ali 189
	}
25503 amit.gupta 190
 
23019 ashik.ali 191
	public void setStartDateTime(LocalDateTime startDateTime) {
192
		this.startDateTime = startDateTime;
22600 ashik.ali 193
	}
25503 amit.gupta 194
 
23019 ashik.ali 195
	public LocalDateTime getEndDateTime() {
196
		return endDateTime;
22653 ashik.ali 197
	}
25503 amit.gupta 198
 
23019 ashik.ali 199
	public void setEndDateTime(LocalDateTime endDateTime) {
200
		this.endDateTime = endDateTime;
22653 ashik.ali 201
	}
25503 amit.gupta 202
 
22859 ashik.ali 203
	public LocalDateTime getCreateTimestamp() {
204
		return createTimestamp;
22600 ashik.ali 205
	}
25503 amit.gupta 206
 
22859 ashik.ali 207
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
208
		this.createTimestamp = createTimestamp;
22600 ashik.ali 209
	}
25503 amit.gupta 210
 
22600 ashik.ali 211
	public int getCreatedBy() {
212
		return createdBy;
213
	}
25503 amit.gupta 214
 
22600 ashik.ali 215
	public void setCreatedBy(int createdBy) {
216
		this.createdBy = createdBy;
217
	}
25503 amit.gupta 218
 
22653 ashik.ali 219
	public LocalDateTime getActiveTimestamp() {
220
		return activeTimestamp;
22600 ashik.ali 221
	}
25503 amit.gupta 222
 
22653 ashik.ali 223
	public void setActiveTimestamp(LocalDateTime activeTimestamp) {
224
		this.activeTimestamp = activeTimestamp;
22600 ashik.ali 225
	}
25503 amit.gupta 226
 
22653 ashik.ali 227
	public LocalDateTime getExpireTimestamp() {
228
		return expireTimestamp;
229
	}
25503 amit.gupta 230
 
22653 ashik.ali 231
	public void setExpireTimestamp(LocalDateTime expireTimestamp) {
232
		this.expireTimestamp = expireTimestamp;
233
	}
25503 amit.gupta 234
 
235
	public String getFormattedStartDateTime() {
236
		if (startDateTime == null) {
22859 ashik.ali 237
			return null;
238
		}
24402 amit.gupta 239
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
23019 ashik.ali 240
		return startDateTime.format(formatter);
25503 amit.gupta 241
	}
242
 
243
	public String getFormattedEndDateTime() {
244
		if (endDateTime == null) {
22859 ashik.ali 245
			return null;
246
		}
24402 amit.gupta 247
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
23019 ashik.ali 248
		return endDateTime.format(formatter);
25503 amit.gupta 249
	}
250
 
251
	public String getFormattedCreateTimestamp() {
252
		if (createTimestamp == null) {
22859 ashik.ali 253
			return null;
254
		}
24402 amit.gupta 255
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22859 ashik.ali 256
		return createTimestamp.format(formatter);
25503 amit.gupta 257
	}
258
 
259
	public String getFormattedActiveTimestamp() {
260
		if (activeTimestamp == null) {
22859 ashik.ali 261
			return null;
262
		}
24402 amit.gupta 263
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22859 ashik.ali 264
		return activeTimestamp.format(formatter);
25503 amit.gupta 265
	}
266
 
267
	public String getFormattedExpireTimestamp() {
268
		if (expireTimestamp == null) {
22859 ashik.ali 269
			return null;
270
		}
24402 amit.gupta 271
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22859 ashik.ali 272
		return expireTimestamp.format(formatter);
25503 amit.gupta 273
	}
274
 
22859 ashik.ali 275
	public Set<Integer> getRetailerIds() {
276
		return retailerIds;
277
	}
25503 amit.gupta 278
 
22859 ashik.ali 279
	public void setRetailerIds(Set<Integer> retailerIds) {
280
		this.retailerIds = retailerIds;
281
	}
25503 amit.gupta 282
 
283
	public String getRetailerIdsString() {
22859 ashik.ali 284
		Set<String> stringRetailerIds = new HashSet<>();
25503 amit.gupta 285
		if (!retailerIds.isEmpty()) {
286
			for (int retailerId : retailerIds) {
22859 ashik.ali 287
				stringRetailerIds.add(String.valueOf(retailerId));
288
			}
289
		}
290
		return String.join(", ", stringRetailerIds);
291
	}
25503 amit.gupta 292
 
23339 ashik.ali 293
	public Map<Integer, String> getItemStringMap() {
294
		return itemStringMap;
22859 ashik.ali 295
	}
25503 amit.gupta 296
 
23339 ashik.ali 297
	public void setItemStringMap(Map<Integer, String> itemStringMap) {
298
		this.itemStringMap = itemStringMap;
22859 ashik.ali 299
	}
25503 amit.gupta 300
 
301
	/*
302
	 * public String getItemIdsString(){ Set<String> stringItemIds = new
303
	 * HashSet<>(); if(!itemIds.isEmpty()){ for(int itemId : itemIds){
304
	 * stringItemIds.add(String.valueOf(itemId)); } } return String.join(", ",
305
	 * stringItemIds); }
306
	 */
307
 
22600 ashik.ali 308
	@Override
309
	public int hashCode() {
310
		final int prime = 31;
311
		int result = 1;
26679 amit.gupta 312
		result = prime * result + ((activeTimestamp == null) ? 0 : activeTimestamp.hashCode());
313
		result = prime * result + Float.floatToIntBits(amount);
314
		result = prime * result + ((amountType == null) ? 0 : amountType.hashCode());
26685 amit.gupta 315
		result = prime * result + (cashback ? 1231 : 1237);
26679 amit.gupta 316
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
317
		result = prime * result + createdBy;
318
		result = prime * result + ((description == null) ? 0 : description.hashCode());
319
		result = prime * result + ((endDateTime == null) ? 0 : endDateTime.hashCode());
320
		result = prime * result + ((expireTimestamp == null) ? 0 : expireTimestamp.hashCode());
22600 ashik.ali 321
		result = prime * result + id;
26679 amit.gupta 322
		result = prime * result + ((itemStringMap == null) ? 0 : itemStringMap.hashCode());
323
		result = prime * result + ((name == null) ? 0 : name.hashCode());
324
		result = prime * result + ((partnerType == null) ? 0 : partnerType.hashCode());
325
		result = prime * result + ((retailerIds == null) ? 0 : retailerIds.hashCode());
326
		result = prime * result + ((startDateTime == null) ? 0 : startDateTime.hashCode());
327
		result = prime * result + ((type == null) ? 0 : type.hashCode());
22600 ashik.ali 328
		return result;
329
	}
25503 amit.gupta 330
 
22600 ashik.ali 331
	@Override
332
	public boolean equals(Object obj) {
333
		if (this == obj)
334
			return true;
335
		if (obj == null)
336
			return false;
337
		if (getClass() != obj.getClass())
338
			return false;
339
		Scheme other = (Scheme) obj;
26679 amit.gupta 340
		if (activeTimestamp == null) {
341
			if (other.activeTimestamp != null)
342
				return false;
343
		} else if (!activeTimestamp.equals(other.activeTimestamp))
344
			return false;
345
		if (Float.floatToIntBits(amount) != Float.floatToIntBits(other.amount))
346
			return false;
347
		if (amountType != other.amountType)
348
			return false;
26685 amit.gupta 349
		if (cashback != other.cashback)
26679 amit.gupta 350
			return false;
351
		if (createTimestamp == null) {
352
			if (other.createTimestamp != null)
353
				return false;
354
		} else if (!createTimestamp.equals(other.createTimestamp))
355
			return false;
356
		if (createdBy != other.createdBy)
357
			return false;
358
		if (description == null) {
359
			if (other.description != null)
360
				return false;
361
		} else if (!description.equals(other.description))
362
			return false;
363
		if (endDateTime == null) {
364
			if (other.endDateTime != null)
365
				return false;
366
		} else if (!endDateTime.equals(other.endDateTime))
367
			return false;
368
		if (expireTimestamp == null) {
369
			if (other.expireTimestamp != null)
370
				return false;
371
		} else if (!expireTimestamp.equals(other.expireTimestamp))
372
			return false;
22600 ashik.ali 373
		if (id != other.id)
374
			return false;
26679 amit.gupta 375
		if (itemStringMap == null) {
376
			if (other.itemStringMap != null)
377
				return false;
378
		} else if (!itemStringMap.equals(other.itemStringMap))
379
			return false;
380
		if (name == null) {
381
			if (other.name != null)
382
				return false;
383
		} else if (!name.equals(other.name))
384
			return false;
385
		if (partnerType != other.partnerType)
386
			return false;
387
		if (retailerIds == null) {
388
			if (other.retailerIds != null)
389
				return false;
390
		} else if (!retailerIds.equals(other.retailerIds))
391
			return false;
392
		if (startDateTime == null) {
393
			if (other.startDateTime != null)
394
				return false;
395
		} else if (!startDateTime.equals(other.startDateTime))
396
			return false;
397
		if (type != other.type)
398
			return false;
22600 ashik.ali 399
		return true;
400
	}
25503 amit.gupta 401
 
22600 ashik.ali 402
}