package org.optaconf.domain;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.CompareToBuilder;
import org.optaplanner.core.api.domain.solution.cloner.DeepPlanningClone;
import com.fasterxml.jackson.annotation.JsonManagedReference;
@DeepPlanningClone
@Entity(name = "optaconf_day")
public class Day extends AbstractConferencedPersistable implements Comparable<Day> {
@NotNull @Size(max = 120)
private String name;
@NotNull @Size(max = 120)
private String date;
@OneToMany(mappedBy = "day", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JsonManagedReference
private List<Timeslot> timeslotList = new ArrayList<Timeslot>();
protected Day() {}
public Day(Conference conference, String externalId, String name, String date) {
super(conference, externalId);
this.name = name;
this.date = date;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public List<Timeslot> getTimeslotList() {
return timeslotList;
}
public void setTimeslotList(List<Timeslot> timeslotList) {
this.timeslotList = timeslotList;
}
// ************************************************************************
// Real methods
// ************************************************************************
@Override
public int compareTo(Day other) {
return new CompareToBuilder()
.append(date, other.date)
.append(id, other.id)
.toComparison();
}
}