View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package org.directdemocracyportal.democracy.model.application;
6   
7   import java.util.Date;
8   
9   import javax.persistence.DiscriminatorColumn;
10  import javax.persistence.DiscriminatorType;
11  import javax.persistence.Entity;
12  import javax.persistence.GeneratedValue;
13  import javax.persistence.GenerationType;
14  import javax.persistence.Id;
15  import javax.persistence.Inheritance;
16  import javax.persistence.InheritanceType;
17  import javax.persistence.JoinColumn;
18  import javax.persistence.ManyToOne;
19  import javax.persistence.Temporal;
20  import javax.persistence.TemporalType;
21  
22  import org.directdemocracyportal.democracy.model.core.BaseEntity;
23  import org.hibernate.annotations.Cache;
24  import org.hibernate.annotations.CacheConcurrencyStrategy;
25  
26  /***
27   * The Class Event.
28   */
29  @Entity
30  @Inheritance(strategy = InheritanceType.JOINED)
31  @DiscriminatorColumn(name = "event_type", discriminatorType = DiscriminatorType.STRING)
32  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
33  public class Event extends BaseEntity
34  {
35  
36      /*** The Constant serialVersionUID. */
37      private static final long serialVersionUID = 2771108428103239806L;
38  
39      /*** The id. */
40      private Long id;
41  
42      /*** The user. */
43      private User user;
44  
45      /*** The action. */
46      private Action action;
47  
48      /*** The time. */
49      private Date time;
50  
51      /***
52       * Instantiates a new event.
53       */
54      public Event() {
55      }
56  
57      /***
58       * Instantiates a new event.
59       *
60       * @param user the user
61       * @param action the action
62       * @param time the time
63       */
64      public Event(User user, Action action, Date time) {
65          this.user = user;
66          this.action = action;
67          this.time = time;
68      }
69  
70      /*
71       * (non-Javadoc)
72       *
73       * @see org.directdemocracyportal.democracy.model.core.BaseEntity#getId()
74       */
75      @Override
76      @Id
77      @GeneratedValue(strategy = GenerationType.AUTO)
78      public Long getId() {
79          return this.id;
80      }
81  
82      /***
83       * Sets the id.
84       *
85       * @param id the new id
86       */
87      public void setId(Long id) {
88          this.id = id;
89      }
90  
91      /***
92       * Gets the user.
93       *
94       * @return the user
95       */
96      @ManyToOne
97      @JoinColumn
98      public User getUser() {
99          return user;
100     }
101 
102     /***
103      * Sets the user.
104      *
105      * @param user the new user
106      */
107     public void setUser(User user) {
108         this.user = user;
109     }
110 
111     /***
112      * Gets the action.
113      *
114      * @return the action
115      */
116     public Action getAction() {
117         return action;
118     }
119 
120     /***
121      * Sets the action.
122      *
123      * @param action the new action
124      */
125     public void setAction(Action action) {
126         this.action = action;
127     }
128 
129     /***
130      * Gets the time.
131      *
132      * @return the time
133      */
134     @Temporal(TemporalType.DATE)
135     public Date getTime() {
136         return time;
137     }
138 
139     /***
140      * Sets the time.
141      *
142      * @param time the new time
143      */
144     public void setTime(Date time) {
145         this.time = time;
146     }
147 }