package models;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.OneToMany;

import play.data.validation.Required;
import play.db.jpa.Model;

@SuppressWarnings("serial")
@Entity
public class TemporarySlot extends Model {
	
	@Field("startDate")
	@Required
	public Date startDate;
	
	@Field("endDate")
	@Required
	public Date endDate;
	
	@Field("labelEN")
	public String labelEN;
	@Field("labelFR")
	public String labelFR;
	
	@Override
	public String toString() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
		
		StringBuffer strbuf = new StringBuffer();
		
		strbuf.append(dateFormat.format(startDate))
		      .append(" [")
		      .append(timeFormat.format(startDate))
			  .append(" - ")
			  .append(timeFormat.format(endDate))
			  .append("]");

		strbuf.append(" " + labelEN);
		
		return strbuf.toString();
	}
	
	public static List<Slot> findPerDay(Date day){
		return find("date_trunc('day', startDate) = ?1 ORDER BY startDate", day).fetch();
	}
	
}
@@ -153,16 +153,88 @@
 Entity;%0A
+import javax.persistence.EnumType;%0Aimport javax.persistence.Enumerated;%0A
 import j
@@ -261,16 +261,16 @@
 ToMany;%0A
-
 %0Aimport 
@@ -608,16 +608,85 @@
 elFR;%0A%09%0A
+%09@Required%0A%09@Enumerated(EnumType.STRING)%0A%09public BreakType isBreak;%0A%0A
 %09@Overri
@@ -1124,19 +1124,99 @@
 belEN);%0A
-
 %09%09%0A
+%09%09if (isBreak != null) %7B%0A%09%09%09strbuf.append(%22 (%22 + isBreak.getCode() + %22)%22);%0A%09%09%7D%0A%0A
 %09%09return

Add breaks in TemporarySlot