summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLectureNetshare.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLectureNetshare.java')
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLectureNetshare.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLectureNetshare.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLectureNetshare.java
index c60de376..30843d31 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLectureNetshare.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLectureNetshare.java
@@ -17,7 +17,7 @@ public class DbLectureNetshare {
private static final Logger LOGGER = Logger.getLogger(DbLectureNetshare.class);
- public static void writeNetworkShares(MysqlConnection connection, String lectureId, List<NetShare> shares)
+ public static void writeForLecture(MysqlConnection connection, String lectureId, List<NetShare> shares)
throws SQLException {
if (lectureId == null || lectureId.isEmpty()) {
return;
@@ -53,16 +53,7 @@ public class DbLectureNetshare {
}
}
- public static List<NetShare> getLectureNetshares(String lectureId) throws SQLException {
- try (MysqlConnection connection = Database.getConnection()) {
- return getLectureNetshares(connection, lectureId);
- } catch (SQLException e) {
- LOGGER.error("Query failed in DbNetshare.getLectureNetshares()", e);
- throw e;
- }
- }
-
- public static List<NetShare> getLectureNetshares(MysqlConnection connection, String lectureId)
+ public static List<NetShare> getCombinedForLecture(MysqlConnection connection, String lectureId)
throws SQLException {
List<NetShare> list = new ArrayList<>();
MysqlStatement netsharestmt = connection.prepareStatement(
@@ -78,7 +69,23 @@ public class DbLectureNetshare {
return list;
}
- public static List<NetShare> getPredefinedNetshares() throws SQLException {
+ public static void getSplitForLecture(MysqlConnection connection, String lectureId,
+ List<NetShare> custom, List<Integer> predef) throws SQLException {
+ MysqlStatement netsharestmt = connection
+ .prepareStatement("SELECT sharepresetid, sharedata FROM networkshare WHERE lectureid = :lectureid");
+ netsharestmt.setString("lectureid", lectureId);
+ ResultSet rs = netsharestmt.executeQuery();
+ while (rs.next()) {
+ int id = rs.getInt("sharepresetid");
+ if (id == 0) {
+ custom.add(Json.deserialize(rs.getString("sharedata"), NetShare.class).setShareId(0));
+ } else {
+ predef.add(id);
+ }
+ }
+ }
+
+ public static List<NetShare> getPredefined() throws SQLException {
try (MysqlConnection connection = Database.getConnection()) {
List<NetShare> list = new ArrayList<>();
MysqlStatement stmt = connection