View Javadoc

1   /**
2    * 
3    */
4   package de.tivsource.page.entity.event;
5   
6   import java.math.BigDecimal;
7   import java.text.DateFormat;
8   import java.text.SimpleDateFormat;
9   import java.util.Date;
10  import java.util.List;
11  import java.util.Locale;
12  
13  import javax.persistence.Basic;
14  import javax.persistence.CascadeType;
15  import javax.persistence.Entity;
16  import javax.persistence.FetchType;
17  import javax.persistence.JoinColumn;
18  import javax.persistence.ManyToOne;
19  import javax.persistence.OneToMany;
20  import javax.persistence.Temporal;
21  
22  import org.hibernate.envers.Audited;
23  
24  import de.tivsource.page.entity.location.Location;
25  import de.tivsource.page.entity.pictureitem.PictureItem;
26  import de.tivsource.page.entity.reservation.Reservation;
27  
28  /**
29   * @author Marc Michele
30   *
31   */
32  @Audited
33  @Entity
34  public class Event extends PictureItem {
35  
36      private BigDecimal price;
37  
38      @Temporal(javax.persistence.TemporalType.TIMESTAMP)
39      private Date beginning;
40  
41      @Temporal(javax.persistence.TemporalType.TIMESTAMP)
42      private Date ending;
43  
44      @Temporal(javax.persistence.TemporalType.TIMESTAMP)
45      private Date deadline;
46  
47      /**
48       * True wenn die Zeit auswählbar seien soll.
49       */
50      @Basic
51      @org.hibernate.annotations.Type(type = "yes_no")
52      private Boolean timeSelection = true;
53  
54      /**
55       * Location Objekt zu dem das Event Objekt gehört.
56       */
57      @ManyToOne(fetch = FetchType.EAGER)
58      @JoinColumn(name = "location_uuid")
59      private Location location;
60  
61      /**
62       * True wenn für diese Event Objekt noch eine Reservierung möglich ist.
63       */
64      @Basic
65      @org.hibernate.annotations.Type(type = "yes_no")
66      private Boolean reservation;
67  
68      @OneToMany(mappedBy = "event", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval=true)
69      private List<Reservation> reservations;
70  
71      /**
72       * Maximale Anzahl an Reservierungen die für diese Event Objekt möglich sind.
73       */
74      private Integer maxReservations;
75  
76      /**
77       * Maximal Anzahl an Personen für die Reserviert werden kann.
78       */
79      private Integer maxPersons;
80  
81      private Integer piwikGoal;
82  
83      public BigDecimal getPrice() {
84          return price;
85      }
86  
87      public void setPrice(BigDecimal price) {
88          this.price = price;
89      }
90  
91      public Date getBeginning() {
92          return beginning;
93      }
94  
95      public void setBeginning(Date beginning) {
96          this.beginning = beginning;
97      }
98  
99      public Date getEnding() {
100         return ending;
101     }
102 
103     public void setEnding(Date ending) {
104         this.ending = ending;
105     }
106 
107     public Date getDeadline() {
108         return deadline;
109     }
110 
111     public void setDeadline(Date deadline) {
112         this.deadline = deadline;
113     }
114 
115     public Boolean getTimeSelection() {
116         return timeSelection;
117     }
118 
119     public void setTimeSelection(Boolean timeSelection) {
120         this.timeSelection = timeSelection;
121     }
122 
123     public Location getLocation() {
124         return location;
125     }
126 
127     public void setLocation(Location location) {
128         this.location = location;
129     }
130 
131     public Boolean getReservation() {
132         return reservation;
133     }
134 
135     public void setReservation(Boolean reservation) {
136         this.reservation = reservation;
137     }
138 
139     public List<Reservation> getReservations() {
140         return reservations;
141     }
142 
143     public void setReservations(List<Reservation> reservations) {
144         this.reservations = reservations;
145     }
146 
147 	public Integer getPiwikGoal() {
148 		return piwikGoal;
149 	}
150 
151 	public void setPiwikGoal(Integer piwikGoal) {
152 		this.piwikGoal = piwikGoal;
153 	}
154 
155 	public Integer getMaxReservations() {
156 		return maxReservations;
157 	}
158 
159 	public void setMaxReservations(Integer maxReservations) {
160 		this.maxReservations = maxReservations;
161 	}
162 
163 	public Integer getMaxPersons() {
164 		return maxPersons;
165 	}
166 
167 	public void setMaxPersons(Integer maxPersons) {
168 		this.maxPersons = maxPersons;
169 	}
170 
171 	public String getFormatedDate() {
172 	    DateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy", Locale.ENGLISH);
173 	    return dateFormat.format(beginning);
174 	}
175 
176 }// Ende class