@hibernate.class table="SESSIONS" schema = "TIMETABLE" @author Tomas Muller, Stephanie Schluttenhofer, Zuzana Mullerova
| 69 | * @author Tomas Muller, Stephanie Schluttenhofer, Zuzana Mullerova |
| 70 | */ |
| 71 | @Entity |
| 72 | @Table(name = "sessions") |
| 73 | public class Session extends BaseSession implements Comparable<Session>, Qualifiable { |
| 74 | protected static GwtConstants CONST = Localization.create(GwtConstants.class); |
| 75 | protected static CourseMessages MSG = Localization.create(CourseMessages.class); |
| 76 | |
| 77 | public static final int sHolidayTypeNone = 0; |
| 78 | |
| 79 | public static final int sHolidayTypeHoliday = 1; |
| 80 | |
| 81 | public static final int sHolidayTypeBreak = 2; |
| 82 | |
| 83 | public static String[] sHolidayTypeColors = new String[] { |
| 84 | "rgb(240,240,240)", "rgb(200,30,20)", "rgb(240,50,240)" }; |
| 85 | |
| 86 | @Transient |
| 87 | public static String[] getHolidayNames() { |
| 88 | return new String[] { |
| 89 | MSG.legendNoHoliday(), |
| 90 | MSG.legendHoliday(), |
| 91 | MSG.legendBreak() |
| 92 | }; |
| 93 | } |
| 94 | |
| 95 | private static final long serialVersionUID = 3691040980400813366L; |
| 96 | |
| 97 | /* |
| 98 | * @return all sessions |
| 99 | */ |
| 100 | @Transient |
| 101 | public static TreeSet<Session> getAllSessions() throws HibernateException { |
| 102 | TreeSet<Session> ret = new TreeSet<Session>(); |
| 103 | for (Session session: SessionDAO.getInstance().findAll()) { |
| 104 | if (session.getStatusType() != null && !session.getStatusType().isTestSession()) |
| 105 | ret.add(session); |
| 106 | } |
| 107 | return ret; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @param id |
| 112 | * @return |
| 113 | * @throws HibernateException |
| 114 | */ |
| 115 | public static Session getSessionById(Long id) throws HibernateException { |
| 116 | return (SessionDAO.getInstance()).get(id); |
| 117 | } |
| 118 | |
| 119 | private static void deleteObjects(org.hibernate.Session hibSession, String objectName, Iterator<Long> idIterator) { |
| 120 | StringBuffer ids = new StringBuffer(); |
| 121 | int idx = 0; |
| 122 | while (idIterator.hasNext()) { |
| 123 | ids.append(idIterator.next()); idx++; |
| 124 | if (idx==100) { |
| 125 | hibSession.createMutationQuery("delete "+objectName+" as x where x.uniqueId in ("+ids+")").executeUpdate(); |
| 126 | ids = new StringBuffer(); |
| 127 | idx = 0; |
| 128 | } else if (idIterator.hasNext()) { |