1
0
Fork 0

Fix duplicated slot and order them

This commit is contained in:
Ethanell 2021-01-14 09:57:38 +01:00
parent dd8a94a492
commit 19344bd9d5
2 changed files with 4 additions and 4 deletions

View file

@ -69,7 +69,7 @@ public class Slot extends Table {
static public ArrayList<Slot> getAll(Competition competition) {
ArrayList<Slot> list = new ArrayList<>();
try {
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Slot WHERE CompetitionName = ?");
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Slot WHERE CompetitionName = ? ORDER BY startTime");
ps.setString(1, competition.getName());
for (ResultSet rs = ps.executeQuery(); rs.next(); )
list.add(new Slot(rs.getInt("id")));
@ -83,7 +83,7 @@ public class Slot extends Table {
static public ArrayList<Slot> getAll(Competition competition, Date date) {
ArrayList<Slot> list = new ArrayList<>();
try {
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S INNER JOIN Projection P on S.id = P.SlotId WHERE S.CompetitionName = ? AND P.startDate = ? GROUP BY S.id");
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S INNER JOIN Projection P on S.id = P.SlotId WHERE S.CompetitionName = ? AND P.startDate = ? GROUP BY S.id, S.startTime ORDER BY S.startTime");
ps.setString(1, competition.getName());
ps.setDate(2, date);
for (ResultSet rs = ps.executeQuery(); rs.next(); )
@ -98,7 +98,7 @@ public class Slot extends Table {
static public ArrayList<Slot> getAvailable(Competition competition, Date date) {
ArrayList<Slot> list = new ArrayList<>();
try {
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S LEFT JOIN Projection P ON S.id = P.SlotId WHERE S.CompetitionName = ? AND P.id IS NULL OR P.startDate != ?");
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S LEFT JOIN Projection P ON S.id = P.SlotId WHERE S.CompetitionName = ? AND (P.id IS NULL OR P.startDate != ?) GROUP BY S.id, S.startTime ORDER BY S.startTime");
ps.setString(1, competition.getName());
ps.setDate(2, date);
for (ResultSet rs = ps.executeQuery(); rs.next();)

View file

@ -48,6 +48,7 @@ public class ProjectionHandler extends JDialog {
this.projectionType = projectionType;
this.agenda = agenda;
competitionComboBox.getModel().setSelectedItem(agenda.getCompetition());
createUI();
if (agenda.getDate() != null || agenda.getSlot() != null) {
updateMovies();
updateDates();
@ -56,7 +57,6 @@ public class ProjectionHandler extends JDialog {
slotComboBox.getModel().setSelectedItem(agenda.getSlot());
updateRooms();
}
createUI();
}
public ProjectionHandler(ProjectionType projectionType, Agenda agenda, Projection projection) {