Subversion Repositories SmartDukaan

Rev

Rev 23830 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23830 ashik.ali 1
package com.spice.profitmandi.dao.entity.dtr;
2
 
3
import java.io.Serializable;
4
import java.time.LocalDate;
5
import java.time.LocalDateTime;
6
import java.time.format.DateTimeFormatter;
7
 
8
import javax.persistence.Column;
9
import javax.persistence.Convert;
10
import javax.persistence.Entity;
11
import javax.persistence.Id;
12
import javax.persistence.Table;
13
 
14
import com.spice.profitmandi.dao.convertor.LocalDateAttributeConverter;
15
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
16
 
17
/**
18
 * This class basically contains punch in/out details
19
 * 
20
 * @author ashikali
21
 *
22
 */
23
 
24
@Entity
25
@Table(name="dtr.punch_in_out", schema = "dtr")
26
public class PunchInOut implements Serializable{
27
 
28
	private static final long serialVersionUID = 1L;
29
 
30
	public PunchInOut() {
31
	}
32
 
33
	@Id
34
	@Column(name = "fofo_id")
35
	private int fofoId;
36
 
37
	@Id
38
	@Convert(converter = LocalDateAttributeConverter.class)
39
	@Column(name="create_date", updatable = false, unique = true)
40
	private LocalDate createDate = LocalDate.now();
41
 
42
	@Convert(converter = LocalDateTimeAttributeConverter.class)
43
	@Column(name="punch_in_timestamp", updatable = false)
44
	private LocalDateTime punchInTimestamp = null;
45
 
46
	@Convert(converter = LocalDateTimeAttributeConverter.class)
47
	@Column(name="punch_out_timestamp")
48
	private LocalDateTime punchOutTimestamp = null;
49
 
50
	public int getFofoId() {
51
		return fofoId;
52
	}
53
 
54
	public void setFofoId(int fofoId) {
55
		this.fofoId = fofoId;
56
	}
57
 
58
	public LocalDateTime getPunchInTimestamp() {
59
		return punchInTimestamp;
60
	}
61
 
62
	public void setPunchInTimestamp(LocalDateTime punchInTimestamp) {
63
		this.punchInTimestamp = punchInTimestamp;
64
	}
65
 
66
	public LocalDateTime getPunchOutTimestamp() {
67
		return punchOutTimestamp;
68
	}
69
 
70
	public void setPunchOutTimestamp(LocalDateTime punchOutTimestamp) {
71
		this.punchOutTimestamp = punchOutTimestamp;
72
	}
73
 
74
	public String getFormattedCreateDate(){
75
		if(createDate == null){
76
			return null;
77
		}
24402 amit.gupta 78
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
23830 ashik.ali 79
		return createDate.format(formatter);
80
    }
81
 
82
	public String getFormattedPunchInTimestamp(){
83
		if(punchInTimestamp == null){
84
			return null;
85
		}
24402 amit.gupta 86
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
23830 ashik.ali 87
		return punchInTimestamp.format(formatter);
88
    }
89
 
90
	public String getFormattedPunchOutTimestamp(){
91
		if(punchOutTimestamp == null){
92
			return null;
93
		}
24402 amit.gupta 94
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
23830 ashik.ali 95
		return punchOutTimestamp.format(formatter);
96
    }
97
 
98
	@Override
99
	public int hashCode() {
100
		final int prime = 31;
101
		int result = 1;
102
		result = prime * result + ((createDate == null) ? 0 : createDate.hashCode());
103
		result = prime * result + fofoId;
104
		return result;
105
	}
106
 
107
	@Override
108
	public boolean equals(Object obj) {
109
		if (this == obj)
110
			return true;
111
		if (obj == null)
112
			return false;
113
		if (getClass() != obj.getClass())
114
			return false;
115
		PunchInOut other = (PunchInOut) obj;
116
		if (createDate == null) {
117
			if (other.createDate != null)
118
				return false;
119
		} else if (!createDate.equals(other.createDate))
120
			return false;
121
		if (fofoId != other.fofoId)
122
			return false;
123
		return true;
124
	}
125
 
126
	@Override
127
	public String toString() {
128
		return "PunchInOut [fofoId=" + fofoId + ", createDate=" + createDate + ", punchInTimestamp=" + punchInTimestamp
129
				+ ", punchOutTimestamp=" + punchOutTimestamp + "]";
130
	}
131
 
132
 
133
}