summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-22 23:04:10 +0200
committerSimon Rettberg2015-08-22 23:04:10 +0200
commitcb84995967e523443b2590f169af0694e3107c90 (patch)
tree5ceb1b7d38b070a4ac35663a01a95b9d15ca2bab /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
parent[server] Foundations for the maintenance module (diff)
downloadtutor-module-cb84995967e523443b2590f169af0694e3107c90.tar.gz
tutor-module-cb84995967e523443b2590f169af0694e3107c90.tar.xz
tutor-module-cb84995967e523443b2590f169af0694e3107c90.zip
[server] Work on version deletion/change/validity logic
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.java11
1 files changed, 6 insertions, 5 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 bfd1513a..2623a9b6 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
@@ -315,19 +315,20 @@ public class DbLecture {
* Called when a new version for an image is uploaded. Update all lectures
* using the same base image which have the autoUpdate-flag set.
*
- * @param connection
- * @param imageBaseId
- * @param imageVersionId
+ * @param connection mysql connection to use
+ * @param imageBaseId base image that got a new version
+ * @param newVersion the latest (valid) version
* @throws SQLException
*/
protected static void autoUpdateUsedImage(MysqlConnection connection, String imageBaseId,
- String imageVersionId) throws SQLException {
+ LocalImageVersion newVersion) throws SQLException {
// TODO: select first so we can email
+ // TODO: If new version is null, do not change, but send warning mail
MysqlStatement stmt = connection.prepareStatement("UPDATE lecture l, imageversion v SET"
+ " l.imageversionid = :imageversionid"
+ " WHERE v.imageversionid = l.imageversionid AND v.imagebaseid = :imagebaseid"
+ " AND l.autoupdate = 1");
- stmt.setString("imageversionid", imageVersionId);
+ stmt.setString("imageversionid", newVersion.imageVersionId);
stmt.setString("imagebaseid", imageBaseId);
stmt.executeUpdate();
}