-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlanningControllerCode.txt
85 lines (66 loc) · 2.89 KB
/
PlanningControllerCode.txt
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
package controller;
import jfxtras.scene.control.agenda.Agenda;
import entity.*;
import java.sql.Array;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import util.HibernateUtil;
public class PlanningController {
/**
*
* @param coPromotor
*/
public Agenda.AppointmentImpl[] retrievePresentations() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
List<Agenda.AppointmentImpl> presentaties = new ArrayList();
Agenda.AppointmentImpl[] presentations = new Agenda.AppointmentImpl[0];
Calendar cal = GregorianCalendar.getInstance();
Calendar cal2 = GregorianCalendar.getInstance();
session.beginTransaction();
Query q = session.createQuery("SELECT p FROM " + Presentation.class.getSimpleName() + " p ORDER BY DAY(p.startTime) ASC");
for(Presentation p : (List<Presentation>)q.list())
{
cal.setTime(p.getStartTime());
cal2.setTime(p.getEndTime());
presentaties.add(new Agenda.AppointmentImpl()
.withStartTime(cal)
.withEndTime(cal2)
.withSummary("")
.withDescription("")
);
}
session.close();
presentations = presentaties.toArray(presentations);
return presentations;
}
public void addPresentation(Timestamp startTime, Timestamp endTime, Location location, List<User> users){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Presentation presentation = new Presentation(startTime,endTime,location);
presentation.setUsers(users);
Query q = session.createQuery("INSERT INTO Presentation(begin_time, end_time, location) VALUES ("+
presentation.getStartTime() +"," + presentation.getEndTime()
+"," +presentation.getLocation()+")");
session.close();
}
public void removePresentation(Presentation presentation)
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Query q = session.createQuery("DELETE FROM Presentation WHERE id =" + presentation.getId() + ")");
session.close();
}
public Planning filterOnCopromotor(User coPromotor) {
// TODO - implement PlanningController.filterOnCopromotor
throw new UnsupportedOperationException();
}
public Planning filterOnAvailable() {
// TODO - implement PlanningController.filterOnAvailable
throw new UnsupportedOperationException();
}
}