Subversion Repositories SmartDukaan

Rev

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

Rev 22702 Rev 22859
Line 1... Line 1...
1
package com.spice.profitmandi.dao.entity.catalog;
1
package com.spice.profitmandi.dao.entity.catalog;
2
 
2
 
3
import java.io.Serializable;
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
4
import java.time.LocalDateTime;
-
 
5
import java.time.format.DateTimeFormatter;
-
 
6
import java.util.HashSet;
-
 
7
import java.util.Set;
5
 
8
 
6
import javax.persistence.Column;
9
import javax.persistence.Column;
7
import javax.persistence.Convert;
10
import javax.persistence.Convert;
8
import javax.persistence.Entity;
11
import javax.persistence.Entity;
9
import javax.persistence.GeneratedValue;
12
import javax.persistence.GeneratedValue;
10
import javax.persistence.GenerationType;
13
import javax.persistence.GenerationType;
11
import javax.persistence.Id;
14
import javax.persistence.Id;
12
import javax.persistence.NamedQueries;
-
 
13
import javax.persistence.NamedQuery;
-
 
14
import javax.persistence.Table;
15
import javax.persistence.Table;
15
import javax.persistence.UniqueConstraint;
16
import javax.persistence.Transient;
16
 
17
 
17
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
18
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
18
import com.spice.profitmandi.dao.enumuration.catalog.SchemeAmountType;
19
import com.spice.profitmandi.dao.enumuration.catalog.SchemeAmountType;
19
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
20
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
20
 
21
 
Line 24... Line 25...
24
 * @author ashikali
25
 * @author ashikali
25
 *
26
 *
26
 */
27
 */
27
@Entity
28
@Entity
28
@Table(name="catalog.scheme", schema = "catalog")
29
@Table(name="catalog.scheme", schema = "catalog")
29
 
-
 
30
@NamedQueries({
-
 
31
	@NamedQuery(name = "Scheme.updateActiveTimestampById", query = "update Scheme s set s.activeTimestamp = :activeTimestamp where s.id= :id"),
-
 
32
	@NamedQuery(name = "Scheme.updateExpireTimestampById", query = "update Scheme s set s.expireTimestamp = :expireTimestamp where s.id= :id")
-
 
33
})
-
 
34
public class Scheme implements Serializable{
30
public class Scheme implements Serializable{
35
	
31
	
36
	private static final long serialVersionUID = 1L;
32
	private static final long serialVersionUID = 1L;
37
	
33
	
38
	public Scheme() {
34
	public Scheme() {
Line 66... Line 62...
66
	@Column(name = "end_date")
62
	@Column(name = "end_date")
67
	private LocalDateTime endDate = LocalDateTime.now();
63
	private LocalDateTime endDate = LocalDateTime.now();
68
	
64
	
69
	@Convert(converter = LocalDateTimeAttributeConverter.class)
65
	@Convert(converter = LocalDateTimeAttributeConverter.class)
70
	@Column(name = "create_timestamp")
66
	@Column(name = "create_timestamp")
71
	private LocalDateTime createdTimestamp = LocalDateTime.now();
67
	private LocalDateTime createTimestamp = LocalDateTime.now();
72
	
68
	
73
	@Convert(converter = LocalDateTimeAttributeConverter.class)
69
	@Convert(converter = LocalDateTimeAttributeConverter.class)
74
	@Column(name = "active_timestamp")
70
	@Column(name = "active_timestamp")
75
	private LocalDateTime activeTimestamp = null;
71
	private LocalDateTime activeTimestamp = null;
76
	
72
	
Line 79... Line 75...
79
	private LocalDateTime expireTimestamp = null;
75
	private LocalDateTime expireTimestamp = null;
80
	
76
	
81
	@Column(name = "created_by")
77
	@Column(name = "created_by")
82
	private int createdBy;
78
	private int createdBy;
83
	
79
	
84
	@Column(name = "all")
80
	@Column(name = "retailer_all")
85
	private boolean all;
81
	private boolean retailerAll;
-
 
82
	
-
 
83
	@Transient
-
 
84
	private Set<Integer> retailerIds = new HashSet<>();
-
 
85
	
-
 
86
	@Transient
-
 
87
	private Set<Integer> itemIds = new HashSet<>();
86
	
88
	
87
	public int getId() {
89
	public int getId() {
88
		return id;
90
		return id;
89
	}
91
	}
90
	public void setId(int id) {
92
	public void setId(int id) {
Line 142... Line 144...
142
	}
144
	}
143
	public void setEndDate(LocalDateTime endDate) {
145
	public void setEndDate(LocalDateTime endDate) {
144
		this.endDate = endDate;
146
		this.endDate = endDate;
145
	}
147
	}
146
	
148
	
147
	public LocalDateTime getCreatedTimestamp() {
149
	public LocalDateTime getCreateTimestamp() {
148
		return createdTimestamp;
150
		return createTimestamp;
149
	}
151
	}
150
	public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
152
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
151
		this.createdTimestamp = createdTimestamp;
153
		this.createTimestamp = createTimestamp;
152
	}
154
	}
153
	public int getCreatedBy() {
155
	public int getCreatedBy() {
154
		return createdBy;
156
		return createdBy;
155
	}
157
	}
156
	public void setCreatedBy(int createdBy) {
158
	public void setCreatedBy(int createdBy) {
Line 171... Line 173...
171
	
173
	
172
	public void setExpireTimestamp(LocalDateTime expireTimestamp) {
174
	public void setExpireTimestamp(LocalDateTime expireTimestamp) {
173
		this.expireTimestamp = expireTimestamp;
175
		this.expireTimestamp = expireTimestamp;
174
	}
176
	}
175
	
177
	
176
	public boolean isAll() {
178
	public boolean isRetailerAll() {
177
		return all;
179
		return retailerAll;
178
	}
180
	}
179
	
181
	
180
	public void setAll(boolean all) {
182
	public void setRetailerAll(boolean retailerAll) {
181
		this.all = all;
183
		this.retailerAll = retailerAll;
182
	}
184
	}
-
 
185
	
-
 
186
	public String getFormattedStartDate(){
-
 
187
		if(startDate == null){
-
 
188
			return null;
-
 
189
		}
-
 
190
    	DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
-
 
191
		return startDate.format(formatter);
-
 
192
    }
-
 
193
	
-
 
194
	public String getFormattedEndDate(){
-
 
195
		if(endDate == null){
-
 
196
			return null;
-
 
197
		}
-
 
198
    	DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
-
 
199
		return endDate.format(formatter);
-
 
200
    }
-
 
201
	
-
 
202
	public String getFormattedCreateTimestamp(){
-
 
203
		if(createTimestamp == null){
-
 
204
			return null;
-
 
205
		}
-
 
206
    	DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
-
 
207
		return createTimestamp.format(formatter);
-
 
208
    }
-
 
209
	
-
 
210
	public String getFormattedActiveTimestamp(){
-
 
211
		if(activeTimestamp == null){
-
 
212
			return null;
-
 
213
		}
-
 
214
    	DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
-
 
215
		return activeTimestamp.format(formatter);
-
 
216
    }
-
 
217
	
-
 
218
	public String getFormattedExpireTimestamp(){
-
 
219
		if(expireTimestamp == null){
-
 
220
			return null;
-
 
221
		}
-
 
222
    	DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
-
 
223
		return expireTimestamp.format(formatter);
-
 
224
    }
-
 
225
	
-
 
226
	public Set<Integer> getRetailerIds() {
-
 
227
		return retailerIds;
-
 
228
	}
-
 
229
	
-
 
230
	public void setRetailerIds(Set<Integer> retailerIds) {
-
 
231
		this.retailerIds = retailerIds;
-
 
232
	}
-
 
233
	
-
 
234
	public String getRetailerIdsString(){
-
 
235
		Set<String> stringRetailerIds = new HashSet<>();
-
 
236
		if(!retailerIds.isEmpty()){
-
 
237
			for(int retailerId : retailerIds){
-
 
238
				stringRetailerIds.add(String.valueOf(retailerId));
-
 
239
			}
-
 
240
		}
-
 
241
		return String.join(", ", stringRetailerIds);
-
 
242
	}
-
 
243
	
-
 
244
	public Set<Integer> getItemIds() {
-
 
245
		return itemIds;
-
 
246
	}
-
 
247
	
-
 
248
	public void setItemIds(Set<Integer> itemIds) {
-
 
249
		this.itemIds = itemIds;
-
 
250
	}
-
 
251
	
-
 
252
	public String getItemIdsString(){
-
 
253
		Set<String> stringItemIds = new HashSet<>();
-
 
254
		if(!itemIds.isEmpty()){
-
 
255
			for(int itemId : itemIds){
-
 
256
				stringItemIds.add(String.valueOf(itemId));
-
 
257
			}
-
 
258
		}
-
 
259
		return String.join(", ", stringItemIds);
-
 
260
	}
-
 
261
	
183
	@Override
262
	@Override
184
	public int hashCode() {
263
	public int hashCode() {
185
		final int prime = 31;
264
		final int prime = 31;
186
		int result = 1;
265
		int result = 1;
187
		result = prime * result + id;
266
		result = prime * result + id;
Line 202... Line 281...
202
	}
281
	}
203
	@Override
282
	@Override
204
	public String toString() {
283
	public String toString() {
205
		return "Scheme [id=" + id + ", name=" + name + ", description=" + description + ", type=" + type
284
		return "Scheme [id=" + id + ", name=" + name + ", description=" + description + ", type=" + type
206
				+ ", amountType=" + amountType + ", amount=" + amount + ", startDate=" + startDate + ", endDate="
285
				+ ", amountType=" + amountType + ", amount=" + amount + ", startDate=" + startDate + ", endDate="
207
				+ endDate + ", createdTimestamp=" + createdTimestamp + ", activeTimestamp=" + activeTimestamp
286
				+ endDate + ", createTimestamp=" + createTimestamp + ", activeTimestamp=" + activeTimestamp
208
				+ ", expireTimestamp=" + expireTimestamp + ", createdBy=" + createdBy + ", all=" + all + "]";
287
				+ ", expireTimestamp=" + expireTimestamp + ", createdBy=" + createdBy + ", retailerAll=" + retailerAll + ", retailerIds=" + retailerIds + "]";
209
	}
288
	}
210
	
289
	
211
}
290
}
212
291