summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-18 15:04:17 +0200
committerSimon Rettberg2015-08-18 15:04:17 +0200
commitc87ec3599fb22bd4b97d7ffbb7542fdbb22f3ca9 (patch)
treef7fe4d94708729459ae136fe2d981a0d8f6417d4 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
parent[client] Handle TTransferRejectedException in ThriftError.showMessage (diff)
downloadtutor-module-c87ec3599fb22bd4b97d7ffbb7542fdbb22f3ca9.tar.gz
tutor-module-c87ec3599fb22bd4b97d7ffbb7542fdbb22f3ca9.tar.xz
tutor-module-c87ec3599fb22bd4b97d7ffbb7542fdbb22f3ca9.zip
[server] Update lectures and images when image versions change or get deleted
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.java16
1 files changed, 14 insertions, 2 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 cbc4c690..c44d40ed 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
@@ -308,6 +308,15 @@ public class DbLecture {
return affected == 1;
}
+ /**
+ * 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
+ * @throws SQLException
+ */
protected static void autoUpdateUsedImage(MysqlConnection connection, String imageBaseId,
String imageVersionId) throws SQLException {
// TODO: select first so we can email
@@ -324,9 +333,12 @@ public class DbLecture {
* Called when an image version is deleted or marked for deletion, so that
* linking lectures switch over to other available versions.
*/
- protected static void autoSwitchUsedImage(MysqlConnection connection, ImageVersionDetails oldVersion,
+ protected static void forcefullySwitchUsedImage(MysqlConnection connection, ImageVersionDetails oldVersion,
ImageVersionDetails newVersion) throws TNotFoundException, SQLException {
- // First, get list of lectures using the image version to switch away to
+ if (oldVersion == newVersion
+ || (newVersion != null && newVersion.versionId.equals(oldVersion.versionId)))
+ return;
+ // First, get list of lectures using the image version to switch away from
List<String> lectures = getAllUsingImageVersion(connection, oldVersion.versionId);
if (lectures.isEmpty())
return;