Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
21720 ashik.ali 1
package com.spice.profitmandi.dao.entity.dtr;
21545 ashik.ali 2
 
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
5
 
6
import javax.persistence.Column;
7
import javax.persistence.Entity;
8
import javax.persistence.GeneratedValue;
9
import javax.persistence.GenerationType;
10
import javax.persistence.Id;
11
import javax.persistence.NamedQueries;
12
import javax.persistence.NamedQuery;
13
import javax.persistence.Table;
14
import javax.persistence.UniqueConstraint;
15
 
21720 ashik.ali 16
import com.spice.profitmandi.dao.enumuration.dtr.Method;
21545 ashik.ali 17
 
18
/**
19
 * This class basically contains api details
20
 * 
21
 * @author ashikali
22
 *
23
 */
24
@Entity
21596 ashik.ali 25
@Table(name="dtr.api", schema = "dtr", uniqueConstraints = {@UniqueConstraint(columnNames = {"uri","method"})})
21545 ashik.ali 26
@NamedQueries({
27
	@NamedQuery(name = "Api.selectCount", query = "select count(a) from Api a"),
28
	@NamedQuery(name="Api.selectAll",query="select a from Api a"),
29
	@NamedQuery(name="Api.selectById",query="select a from Api a where a.id= :id"),
30
	@NamedQuery(name="Api.selectByName",query="select a from Api a where a.name= :name"),
31
	@NamedQuery(name="Api.selectByUri",query="select a from Api a where a.uri= :uri"),
32
	@NamedQuery(name="Api.selectUniqueCount",query="select count(a) from Api a where a.uri = :uri and a.method = :method"),
33
	@NamedQuery(name="Api.selectNameCount",query="select count(a) from Api a where a.name = :name"),
34
	@NamedQuery(name="Api.deleteById",query="delete from Api a where a.id= :id"),
35
	@NamedQuery(name = "Api.updateById", query = "update Api a set a.name = :name, a.uri = :uri, a.method = :method, a.updateTimestamp = :updateTimestamp where a.id = :id"),
36
})
37
public class Api implements Serializable{
38
 
39
	private static final long serialVersionUID = 1L;
40
 
41
	public Api() {
42
	}
43
 
44
	@Id
45
	@Column(name="id", unique=true, updatable=false)
46
	@GeneratedValue(strategy = GenerationType.IDENTITY)
47
	private int id;
48
 
49
	@Column(name="name", unique = true)
50
	private String name;
51
 
52
	@Column(name = "uri")
53
	private String uri;
54
 
55
	@Column(name = "method")
56
	private Method method;
57
 
58
	@Column(name="create_timestamp", updatable = false)
59
	private LocalDateTime createTimestamp = LocalDateTime.now();
60
 
61
	@Column(name="update_timestamp")
62
	private LocalDateTime updateTimestamp = LocalDateTime.now();
63
 
64
 
65
	public int getId() {
66
		return id;
67
	}
68
	public void setId(int id) {
69
		this.id = id;
70
	}
71
	public void setName(String name) {
72
        this.name = name;
73
    }
74
    public String getName() {
75
        return name;
76
    }
77
    public void setMethod(Method method) {
78
		this.method = method;
79
	}
80
    public Method getMethod() {
81
		return method;
82
	}
83
    public String getUri() {
84
		return uri;
85
	}
86
    public void setUri(String uri) {
87
		this.uri = uri;
88
	}
89
 
90
    public void setCreateTimestamp(LocalDateTime createTimestamp) {
91
		this.createTimestamp = createTimestamp;
92
	}
93
    public LocalDateTime getCreateTimestamp() {
94
		return createTimestamp;
95
	}
96
 
97
    public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
98
		this.updateTimestamp = updateTimestamp;
99
	}
100
    public LocalDateTime getUpdateTimestamp() {
101
		return updateTimestamp;
102
	}
21924 ashik.ali 103
 
21545 ashik.ali 104
	@Override
21924 ashik.ali 105
	public int hashCode() {
106
		final int prime = 31;
107
		int result = 1;
108
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
109
		result = prime * result + id;
110
		result = prime * result + ((method == null) ? 0 : method.hashCode());
111
		result = prime * result + ((name == null) ? 0 : name.hashCode());
112
		result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
113
		result = prime * result + ((uri == null) ? 0 : uri.hashCode());
114
		return result;
115
	}
116
	@Override
117
	public boolean equals(Object obj) {
118
		if (this == obj)
119
			return true;
120
		if (obj == null)
121
			return false;
122
		if (getClass() != obj.getClass())
123
			return false;
124
		Api other = (Api) obj;
125
		if (createTimestamp == null) {
126
			if (other.createTimestamp != null)
127
				return false;
128
		} else if (!createTimestamp.equals(other.createTimestamp))
129
			return false;
130
		if (id != other.id)
131
			return false;
132
		if (method != other.method)
133
			return false;
134
		if (name == null) {
135
			if (other.name != null)
136
				return false;
137
		} else if (!name.equals(other.name))
138
			return false;
139
		if (updateTimestamp == null) {
140
			if (other.updateTimestamp != null)
141
				return false;
142
		} else if (!updateTimestamp.equals(other.updateTimestamp))
143
			return false;
144
		if (uri == null) {
145
			if (other.uri != null)
146
				return false;
147
		} else if (!uri.equals(other.uri))
148
			return false;
149
		return true;
150
	}
151
	@Override
21545 ashik.ali 152
	public String toString() {
153
		return "Api [id=" + id + ", name=" + name + ", uri=" + uri + ", method=" + method + ", createTimestamp="
21695 amit.gupta 154
				+ createTimestamp + ", updateTimestamp=" + updateTimestamp + "]";
21924 ashik.ali 155
	}    
21545 ashik.ali 156
 
157
}