Subversion Repositories SmartDukaan

Rev

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