Subversion Repositories SmartDukaan

Rev

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