diff options
author | Simon Rettberg | 2017-06-02 16:23:15 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-06-02 16:23:15 +0200 |
commit | 2da0472b6c59b0a69befa969fa035cb865bd27c3 (patch) | |
tree | 32d2d4c81f18fe862c1f22c154db93fe66b4e5cb /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java | |
parent | [server] Add versioning and modification checking to mail templates (diff) | |
download | tutor-module-2da0472b6c59b0a69befa969fa035cb865bd27c3.tar.gz tutor-module-2da0472b6c59b0a69befa969fa035cb865bd27c3.tar.xz tutor-module-2da0472b6c59b0a69befa969fa035cb865bd27c3.zip |
[server] Send mails when lecture gets deactivated
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java index 147b6b8a..ff160917 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java @@ -574,20 +574,25 @@ public class DbLecture { throw e; } } + + public static List<LectureSummary> getLecturesUsingImageVersion(MysqlConnection connection, String imageVersionId) + throws SQLException { + MysqlStatement stmt = connection.prepareStatement(summaryBaseSql + + " WHERE l.imageversionid = :imageversionid"); + stmt.setString("userid", "-"); + stmt.setString("imageversionid", imageVersionId); + ResultSet rs = stmt.executeQuery(); + List<LectureSummary> list = new ArrayList<>(); + while (rs.next()) { + list.add(fillSummary(null, rs)); + } + return list; + } public static List<LectureSummary> getLecturesUsingImageVersion(String imageVersionId) throws SQLException { try (MysqlConnection connection = Database.getConnection()) { - MysqlStatement stmt = connection.prepareStatement(summaryBaseSql - + " WHERE l.imageversionid = :imageversionid"); - stmt.setString("userid", "-"); - stmt.setString("imageversionid", imageVersionId); - ResultSet rs = stmt.executeQuery(); - List<LectureSummary> list = new ArrayList<>(); - while (rs.next()) { - list.add(fillSummary(null, rs)); - } - return list; + return getLecturesUsingImageVersion(connection, imageVersionId); } catch (SQLException e) { LOGGER.error("Query failed in DbLecture.getExpiringLectures()", e); throw e; @@ -606,10 +611,12 @@ public class DbLecture { protected static void unlinkFromImageVersion(MysqlConnection connection, String imageVersionId) throws SQLException { - MysqlStatement stmt = connection.prepareStatement("UPDATE lecture SET imageversionid = NULL" + List<LectureSummary> lectures = getLecturesUsingImageVersion(connection, imageVersionId); + MysqlStatement uStmt = connection.prepareStatement("UPDATE lecture SET imageversionid = NULL" + " WHERE imageversionid = :imageversionid"); - stmt.setString("imageversionid", imageVersionId); - stmt.executeUpdate(); + uStmt.setString("imageversionid", imageVersionId); + uStmt.executeUpdate(); + MailGenerator.lectureDeactivated(lectures); } } |