Initial commit related to Issue 64. Last login should point to the user's last login.
[pithos] / src / gr / ebs / gss / server / domain / UserLogin.java
1 /*
2  * Copyright 2010 Electronic Business Systems Ltd.
3  *
4  * This file is part of GSS.
5  *
6  * GSS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 package gr.ebs.gss.server.domain;
20
21 import java.util.Date;
22
23 import javax.persistence.CascadeType;
24 import javax.persistence.Entity;
25 import javax.persistence.FetchType;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.Id;
28 import javax.persistence.ManyToOne;
29 import javax.persistence.Table;
30 import javax.persistence.UniqueConstraint;
31 /**
32  * 
33  * The class that holds information about the login dates that user logins to the system.
34  * 
35  */
36 @Entity
37 @Table(name="userlogin", uniqueConstraints=@UniqueConstraint(columnNames={"user_id", "logindate"}))
38 public class UserLogin {
39
40         /**
41          * The persistence ID of the object.
42          */
43         @Id
44         @GeneratedValue
45         private Long id;
46         
47         private Date loginDate;
48         
49         /**
50          * The user to whom the login date belongs to
51          * 
52          */     
53         @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
54
55         //@JoinColumn(name="user_id") not necessary since the persistence provider supports auto schema generation
56         private User user;
57         
58         /**
59          * Modify the id.
60          *
61          * @param _id the id to set
62          */
63         public void setId(Long _id) {
64                 this.id = _id;
65         }
66
67         /**
68          * Retrieve the id.
69          *
70          * @return the id
71          */
72         public Long getId() {
73                 return id;
74         }
75
76         /**
77          * Modify the user.
78          *
79          * @param aUser the user to set
80          */
81         public void setUser(User aUser) {
82                 this.user = aUser;
83         }
84
85         /**
86          * Retrieve the user.
87          *
88          * @return the user
89          */
90         public User getUser() {
91                 return user;
92         }
93
94         /**
95          * Modify the lastLoginDate.
96          *
97          * @param _lastLogin the lastLoginDate to set
98          */
99         public void setLoginDate(Date _lastLogin) {
100                 this.loginDate = _lastLogin;
101         }
102
103         /**
104          * Retrieve the lastLoginDate.
105          *
106          * @return the lastLoginDate
107          */
108         public Date getLoginDate() {
109                 return loginDate;
110         }
111
112         
113 //      /**
114 //       * Modify the loginDate for a specific user.
115 //       *
116 //       * @param _loginDate the loginDate to set
117 //       */
118 //      public void setLoginDateForUser(Date _loginDate, User _user) {
119 //              this.loginDate = _loginDate;
120 //              this.user = _user;
121 //      }
122         
123
124 }