69 lines
1.8 KiB
Java
69 lines
1.8 KiB
Java
package DB;
|
|
|
|
import Exceptions.NotFoundInTable;
|
|
import lombok.Getter;
|
|
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
|
|
public class Projection extends Table {
|
|
@Getter final private int id;
|
|
|
|
public Projection(int id) throws NotFoundInTable {
|
|
super("Projection", "id", Integer.toString(id));
|
|
this.id = id;
|
|
}
|
|
|
|
public Date getStartDate() {
|
|
return get(Date.class, "startDate");
|
|
}
|
|
|
|
public Competition getCompetition() {
|
|
return get(Competition.class, "CompetitionName");
|
|
}
|
|
|
|
public Room getRoom() {
|
|
return get(Room.class, "RoomName");
|
|
}
|
|
|
|
public Movie getMovie() {
|
|
return get(Movie.class, "MovieName");
|
|
}
|
|
|
|
public boolean setStartDate(Date startDate) {
|
|
return set("startDate", startDate.toString());
|
|
}
|
|
|
|
public boolean setCompetition(Competition competition) {
|
|
return set("CompetitionName", competition.getName());
|
|
}
|
|
|
|
public boolean setRoom(Room room) {
|
|
return set("RoomName", room.getName());
|
|
}
|
|
|
|
public boolean setMovie(Movie movie) {
|
|
return set("MovieName", movie.getName());
|
|
}
|
|
|
|
static public ArrayList<Projection> getAll() {
|
|
ArrayList<Projection> list = new ArrayList<>();
|
|
try {
|
|
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Projection");
|
|
for (ResultSet rs = ps.executeQuery(); rs.next();)
|
|
list.add(new Projection(rs.getInt("id")));
|
|
ps.close();
|
|
} catch (SQLException | NullPointerException | NotFoundInTable e) {
|
|
return null;
|
|
}
|
|
return list;
|
|
}
|
|
|
|
@Override
|
|
public boolean delete() {
|
|
return false;
|
|
}
|
|
}
|