Subversion Repositories SmartDukaan

Rev

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

Rev 30121 Rev 30454
Line 7... Line 7...
7
 
7
 
8
import javax.persistence.*;
8
import javax.persistence.*;
9
import java.io.Serializable;
9
import java.io.Serializable;
10
import java.time.LocalDateTime;
10
import java.time.LocalDateTime;
11
import java.time.format.DateTimeFormatter;
11
import java.time.format.DateTimeFormatter;
12
import java.util.HashMap;
-
 
13
import java.util.HashSet;
-
 
14
import java.util.Map;
-
 
15
import java.util.Set;
12
import java.util.*;
16
 
13
 
17
/**
14
/**
18
 * This class basically contains scheme details
15
 * This class basically contains scheme details
19
 * 
16
 * 
20
 * @author ashikali
17
 * @author ashikali
Line 54... Line 51...
54
 
51
 
55
	@Column(name = "amount_type")
52
	@Column(name = "amount_type")
56
	@Enumerated(EnumType.STRING)
53
	@Enumerated(EnumType.STRING)
57
	private AmountType amountType;
54
	private AmountType amountType;
58
 
55
 
-
 
56
	@Column(name = "base_plus_gst_calc")
-
 
57
	private boolean basePlusGstCalc;
-
 
58
 
59
	@Column(name = "amount")
59
	@Column(name = "amount")
60
	private float amount;
60
	private float amount;
61
 
61
 
62
	@Convert(converter = LocalDateTimeAttributeConverter.class)
62
	@Convert(converter = LocalDateTimeAttributeConverter.class)
63
	@Column(name = "start_date_time")
63
	@Column(name = "start_date_time")
Line 102... Line 102...
102
 
102
 
103
	public void setSchemeValue(float schemeValue) {
103
	public void setSchemeValue(float schemeValue) {
104
		this.schemeValue = schemeValue;
104
		this.schemeValue = schemeValue;
105
	}
105
	}
106
 
106
 
107
	@Column(name="partner_type")
107
	@Column(name = "partner_type")
108
	@Enumerated(EnumType.STRING)
108
	@Enumerated(EnumType.STRING)
109
	private PartnerType partnerType;
109
	private PartnerType partnerType;
110
 
110
 
-
 
111
 
-
 
112
	@Override
-
 
113
	public String toString() {
-
 
114
		return "Scheme{" +
-
 
115
				"id=" + id +
-
 
116
				", name='" + name + '\'' +
-
 
117
				", description='" + description + '\'' +
-
 
118
				", type=" + type +
-
 
119
				", amountType=" + amountType +
-
 
120
				", gstReversal=" + basePlusGstCalc +
-
 
121
				", amount=" + amount +
-
 
122
				", startDateTime=" + startDateTime +
-
 
123
				", endDateTime=" + endDateTime +
-
 
124
				", createTimestamp=" + createTimestamp +
-
 
125
				", activeTimestamp=" + activeTimestamp +
-
 
126
				", expireTimestamp=" + expireTimestamp +
-
 
127
				", createdBy=" + createdBy +
-
 
128
				", cashback=" + cashback +
-
 
129
				", retailerIds=" + retailerIds +
-
 
130
				", amountModel='" + amountModel + '\'' +
-
 
131
				", schemeValue=" + schemeValue +
-
 
132
				", partnerType=" + partnerType +
-
 
133
				", catalogStringMap=" + catalogStringMap +
-
 
134
				'}';
-
 
135
	}
-
 
136
 
-
 
137
	@Override
-
 
138
	public boolean equals(Object o) {
-
 
139
		if (this == o) return true;
-
 
140
		if (o == null || getClass() != o.getClass()) return false;
-
 
141
		Scheme scheme = (Scheme) o;
-
 
142
		return id == scheme.id && basePlusGstCalc == scheme.basePlusGstCalc && Float.compare(scheme.amount, amount) == 0 && createdBy == scheme.createdBy && cashback == scheme.cashback && Float.compare(scheme.schemeValue, schemeValue) == 0 && Objects.equals(name, scheme.name) && Objects.equals(description, scheme.description) && type == scheme.type && amountType == scheme.amountType && Objects.equals(startDateTime, scheme.startDateTime) && Objects.equals(endDateTime, scheme.endDateTime) && Objects.equals(createTimestamp, scheme.createTimestamp) && Objects.equals(activeTimestamp, scheme.activeTimestamp) && Objects.equals(expireTimestamp, scheme.expireTimestamp) && Objects.equals(retailerIds, scheme.retailerIds) && Objects.equals(amountModel, scheme.amountModel) && partnerType == scheme.partnerType && Objects.equals(catalogStringMap, scheme.catalogStringMap);
-
 
143
	}
-
 
144
 
-
 
145
	@Override
-
 
146
	public int hashCode() {
-
 
147
		return Objects.hash(id, name, description, type, amountType, basePlusGstCalc, amount, startDateTime, endDateTime, createTimestamp, activeTimestamp, expireTimestamp, createdBy, cashback, retailerIds, amountModel, schemeValue, partnerType, catalogStringMap);
-
 
148
	}
-
 
149
 
111
	@Transient
150
	@Transient
112
	private Map<Integer, String> catalogStringMap = new HashMap<>();
151
	private Map<Integer, String> catalogStringMap = new HashMap<>();
113
 
152
 
114
	public int getId() {
153
	public int getId() {
115
		return id;
154
		return id;
Line 159... Line 198...
159
 
198
 
160
	public void setType(SchemeType type) {
199
	public void setType(SchemeType type) {
161
		this.type = type;
200
		this.type = type;
162
	}
201
	}
163
 
202
 
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="
-
 
169
				+ activeTimestamp + ", expireTimestamp=" + expireTimestamp + ", createdBy=" + createdBy + ", cashback="
-
 
170
				+ cashback + ", retailerIds=" + retailerIds + ", amountModel=" + amountModel + ", schemeValue="
-
 
171
				+ schemeValue + ", partnerType=" + partnerType + ", itemStringMap=" + catalogStringMap + "]";
-
 
172
	}
-
 
173
 
-
 
174
	public AmountType getAmountType() {
203
	public AmountType getAmountType() {
175
		return amountType;
204
		return amountType;
176
	}
205
	}
177
 
206
 
178
	public void setAmountType(AmountType amountType) {
207
	public void setAmountType(AmountType amountType) {
Line 291... Line 320...
291
			}
320
			}
292
		}
321
		}
293
		return String.join(", ", stringRetailerIds);
322
		return String.join(", ", stringRetailerIds);
294
	}
323
	}
295
 
324
 
-
 
325
 
296
	public Map<Integer, String> getCatalogStringMap() {
326
	public boolean isBasePlusGstCalc() {
297
		return catalogStringMap;
327
		return basePlusGstCalc;
298
	}
328
	}
299
 
329
 
300
	public void setCatalogStringMap(Map<Integer, String> catalogStringMap) {
330
	public void setBasePlusGstCalc(boolean gstReversal) {
301
		this.catalogStringMap = catalogStringMap;
331
		this.basePlusGstCalc = gstReversal;
302
	}
332
	}
303
 
333
 
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
 
334
 
311
	@Override
-
 
312
	public int hashCode() {
-
 
313
		final int prime = 31;
-
 
314
		int result = 1;
-
 
315
		result = prime * result + ((activeTimestamp == null) ? 0 : activeTimestamp.hashCode());
-
 
316
		result = prime * result + Float.floatToIntBits(amount);
335
	public Map<Integer, String> getCatalogStringMap() {
317
		result = prime * result + ((amountType == null) ? 0 : amountType.hashCode());
-
 
318
		result = prime * result + (cashback ? 1231 : 1237);
-
 
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());
-
 
324
		result = prime * result + id;
-
 
325
		result = prime * result + ((catalogStringMap == null) ? 0 : catalogStringMap.hashCode());
-
 
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());
-
 
331
		return result;
336
		return catalogStringMap;
332
	}
337
	}
333
 
338
 
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;
-
 
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;
-
 
352
		if (cashback != other.cashback)
-
 
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;
-
 
376
		if (id != other.id)
-
 
377
			return false;
-
 
378
		if (catalogStringMap == null) {
-
 
379
			if (other.catalogStringMap != null)
-
 
380
				return false;
-
 
381
		} else if (!catalogStringMap.equals(other.catalogStringMap))
339
	public void setCatalogStringMap(Map<Integer, String> catalogStringMap) {
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)
340
		this.catalogStringMap = catalogStringMap;
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;
-
 
402
		return true;
-
 
403
	}
341
	}
404
 
342
 
-
 
343
 
405
}
344
}
406
345