1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
package persistence;
import java.util.Date;
...
/**
*
* @author gaelvarlet
*/
@Entity
public class Event implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "PLACE")
private String place;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "BEGINDATE")
private Date beginDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "ENDDATE")
private Date endDate;
@Column(name = "VISIBILITY")
private int visibility;
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(mappedBy="relatedEvent")
private List<CustomizeEvent> customizedEvents;
@OneToOne(cascade = CascadeType.PERSIST,optional=false)
private Periodicity periodicity;
@ManyToOne(optional=false)
private UserAgenda eventOwner;
@ManyToMany
@JoinTable(name="EVENTS_BELONG_AGENDAS",joinColumns= @JoinColumn(name="EVENT_ID",referencedColumnName="ID"),inverseJoinColumns=@JoinColumn(name="AGENDA_ID",referencedColumnName="ID"))
private List<Agenda> belongToAgendas;
@ManyToMany
@JoinTable(name="EVENTS_GUESTS_AGENDAS",joinColumns= @JoinColumn(name="EVENT_ID",referencedColumnName="ID"),inverseJoinColumns=@JoinColumn(name="AGENDA_ID",referencedColumnName="ID"))
private List<Agenda> guestToAgendas;
public Event() {
}
public Event(String name, String place, Date beginDate, Date endDate, int visibility, String description, Periodicity periodicity, UserAgenda eventOwner, Agenda agenda) {
this.name = name;
this.place = place;
this.beginDate = beginDate;
this.endDate = endDate;
this.visibility = visibility;
this.description = description;
this.periodicity = periodicity;
this.eventOwner = eventOwner;
this.belongToAgendas = new ArrayList<Agenda>();
this.belongToAgendas.add(agenda);
this.customizedEvents = new ArrayList<CustomizeEvent>();
this.guestToAgendas = new ArrayList<Agenda>();
}
public Event(String name, String place, Date beginDate, Date endDate, int visibility, String description, Periodicity periodicity, UserAgenda eventOwner, Agenda agenda,List<Agenda> guests) {
this.name = name;
this.place = place;
this.beginDate = beginDate;
this.endDate = endDate;
this.visibility = visibility;
this.description = description;
this.periodicity = periodicity;
this.eventOwner = eventOwner;
this.belongToAgendas = new ArrayList<Agenda>();
this.belongToAgendas.add(agenda);
this.customizedEvents = new ArrayList<CustomizeEvent>();
this.guestToAgendas = guests;
}
// getters and setters
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Event)) {
return false;
}
Event other = (Event) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
} |
Partager