3 import java.io.Serializable;
5 import java.util.Vector;
7 import javax.persistence.*;
8 import javax.xml.bind.annotation.XmlAccessType;
9 import javax.xml.bind.annotation.XmlAccessorType;
10 import javax.xml.bind.annotation.XmlID;
11 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
13 @XmlAccessorType(XmlAccessType.FIELD)
15 public class Event implements Serializable {
20 private static final long serialVersionUID = 1L;
22 @XmlJavaTypeAdapter(IntegerAdapter.class)
23 private Integer eventNumber;
24 private String description;
25 private Date eventDate;
26 @OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
27 private Vector<Question> questions=new Vector<Question>();
29 private boolean closed;
31 public Vector<Question> getQuestions() {
35 public void setQuestions(Vector<Question> questions) {
36 this.questions = questions;
40 public Event(Integer eventNumber, String description,Date eventDate) {
41 this.eventNumber = eventNumber;
42 this.description = description;
43 this.eventDate=eventDate;
47 public Event(String description,Date eventDate) {
48 this.description = description;
49 this.eventDate=eventDate;
53 public Integer getEventNumber() {
57 public void setEventNumber(Integer eventNumber) {
58 this.eventNumber = eventNumber;
61 public String getDescription() {
65 public void setDescription(String description) {
66 this.description=description;
69 public Date getEventDate() {
73 public void setEventDate(Date eventDate) {
74 this.eventDate = eventDate;
78 public String toString(){
79 return eventNumber+"; "+description;
83 * This method creates a bet with a question, minimum bet ammount and percentual profit
85 * @param question to be added to the event
86 * @param betMinimum of that question
89 public Question addQuestion(String question, float betMinimum) {
90 Question q=new Question(question,betMinimum, this);
97 * This method checks if the question already exists for that event
99 * @param question that needs to be checked if there exists
100 * @return true if the question exists and false in other case
102 public boolean DoesQuestionExists(String question) {
103 for (Question q:this.getQuestions()){
104 if (q.getQuestion().compareTo(question)==0)
113 public int hashCode() {
114 final int prime = 31;
116 result = prime * result + eventNumber;
120 public void setClosed(boolean b) {
124 public boolean getClosed() {
129 public boolean equals(Object obj) {
134 if (getClass() != obj.getClass())
136 Event other = (Event) obj;
137 if (eventNumber != other.eventNumber)