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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.safedriving.managedbeans;
import com.safedriving.model.Calendrier;
import com.safedriving.sessionbean.AvailabilityOfInstructorFacadeLocal;
import com.safedriving.sessionbean.AvailabilityOfTeacherFacadeLocal;
import com.safedriving.sessionbean.CalendrierFacadeLocal;
import com.safedriving.sessionbean.PersonFacadeLocal;
import com.safedriving.tools.AvailabilityTeacherRow;
import com.safedriving.tools.Utils;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.ejb.EJB;
import javax.faces.context.FacesContext;
/**
*
* @author j.a.garcia.gonzalez
*/
public class IntervenantAdministration {
private ArrayList<AvailabilityTeacherRow> availabilities;
private ArrayList<Calendar> days = new ArrayList<Calendar>();
private int idPerson;
@EJB
private PersonFacadeLocal personFL;
// <editor-fold defaultstate="collapsed" desc="Properties">
public int getIdPerson() {
return idPerson;
}
public void setIdPerson(int idPerson) {
this.idPerson = idPerson;
}
public ArrayList<Calendar> getDays() {
return days;
}
public void setDays(ArrayList<Calendar> days) {
this.days = days;
}
public ArrayList<AvailabilityTeacherRow> getAvailabilities() {
return availabilities;
}
public void setAvailabilities(ArrayList<AvailabilityTeacherRow> availabilities) {
this.availabilities = availabilities;
}// </editor-fold>
/** Creates a new instance of IntervenantAdministration */
public IntervenantAdministration() {
days = new ArrayList<Calendar>();
Calendar cal = GregorianCalendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -(cal.get(Calendar.DAY_OF_WEEK)-Calendar.MONDAY));
days.add(Utils.copyCalendar(cal));
cal.add(Calendar.DAY_OF_MONTH, 1);
days.add(Utils.copyCalendar(cal));
cal.add(Calendar.DAY_OF_MONTH, 1);
days.add(Utils.copyCalendar(cal));
cal.add(Calendar.DAY_OF_MONTH, 1);
days.add(Utils.copyCalendar(cal));
cal.add(Calendar.DAY_OF_MONTH, 1);
days.add(Utils.copyCalendar(cal));
cal.add(Calendar.DAY_OF_MONTH, 1);
days.add(Utils.copyCalendar(cal));
availabilities = new ArrayList<AvailabilityTeacherRow>();
//TODO: To Remove
idPerson = 3;
}
public ArrayList<String> getDaysOfWeek(){
ArrayList<String> daysOfWeek = new ArrayList<String>();
daysOfWeek.add("Lundi " + days.get(0).get(Calendar.DAY_OF_MONTH));
daysOfWeek.add("Mardi " + days.get(1).get(Calendar.DAY_OF_MONTH));
daysOfWeek.add("Mercredi " + days.get(2).get(Calendar.DAY_OF_MONTH));
daysOfWeek.add("Jeudi " + days.get(3).get(Calendar.DAY_OF_MONTH));
daysOfWeek.add("Vendredi " + days.get(4).get(Calendar.DAY_OF_MONTH));
daysOfWeek.add("Samedi " + days.get(5).get(Calendar.DAY_OF_MONTH));
return daysOfWeek;
}
public ArrayList<AvailabilityTeacherRow> getAvailabilityTeacherRows(){
availabilities = new ArrayList<AvailabilityTeacherRow>();
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),9)));
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),10)));
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),11)));
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),13)));
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),14)));
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),15)));
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),16)));
availabilities.add(new AvailabilityTeacherRow(personFL.find(idPerson), new Calendrier(days.get(0),17)));
for(AvailabilityTeacherRow item: availabilities){
item.manageAvailability();
}
return availabilities;
}
@EJB
CalendrierFacadeLocal calendrierFL;
@EJB
AvailabilityOfInstructorFacadeLocal availabilityOfInstructorFL;
@EJB
AvailabilityOfTeacherFacadeLocal availabilityOfTeacherFL;
public String applyChanges(){
FacesContext cf = FacesContext.getCurrentInstance();
String row = cf.getExternalContext().getRequestParameterMap().get("row");
String day = cf.getExternalContext().getRequestParameterMap().get("day");
for(AvailabilityTeacherRow item: availabilities){
item.updateStatus(calendrierFL,availabilityOfInstructorFL,availabilityOfTeacherFL);
}
return null;
}
} |
Partager