diff options
| author | Simon Rettberg | 2015-05-27 20:27:58 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-05-27 20:27:58 +0200 |
| commit | e3c94b5d842c937d7a5f3284b3ff0f91bb51eec4 (patch) | |
| tree | 5fba5c89f03e7be40886a1da02e789b955c9ddf5 /dozentenmodulserver/src/main/java/sql/SQL.java | |
| parent | [server] Applied Eclipse code format (with line width extended to 110) (diff) | |
| download | tutor-module-e3c94b5d842c937d7a5f3284b3ff0f91bb51eec4.tar.gz tutor-module-e3c94b5d842c937d7a5f3284b3ff0f91bb51eec4.tar.xz tutor-module-e3c94b5d842c937d7a5f3284b3ff0f91bb51eec4.zip | |
[server] Added some TODOs
Diffstat (limited to 'dozentenmodulserver/src/main/java/sql/SQL.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/sql/SQL.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java index c953de34..890e6e39 100644 --- a/dozentenmodulserver/src/main/java/sql/SQL.java +++ b/dozentenmodulserver/src/main/java/sql/SQL.java @@ -27,6 +27,7 @@ public class SQL { private static final Logger log = Logger.getLogger(SQL.class);
public Connection getConnection() {
+ // TODO: Connection pooling, better yet some abstraction layer for mysql, eg. like dalesbred in master-server
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
@@ -140,6 +141,13 @@ public class SQL { }
public String setInstitution(String university) {
+ // TODO: WTF!?
+ // 1) This method is called set* and has a return value (other than boolean)
+ // 2) This method generates a random ID for an institution name (which is called university in the
+ // parameter), so every satellite server has a different ID for the same institution
+ // 3) If an institution is renamed, it gets a new id, and the old one remains in the db
+ // 4) In case it inserts a new institution with an ID, it queries the DB for the ID right
+ // after doing so. So it's expected to be different from what was just inserted!??
try {
Connection con = getConnection();
@@ -242,6 +250,9 @@ public class SQL { con.commit();
+ // TODO: why... WHY!? We had the user id from the beginning! We just inserted it!
+ // Also if there are two users with same first and last name we might get
+ // the wrong id! JUST WHY!!!!!?
sql = "SELECT userID FROM bwLehrpool.m_user where Nachname like " + "?"
+ " and Vorname like " + "?" + ";";
@@ -352,6 +363,7 @@ public class SQL { log.info("Failed to setImageData.");
e.printStackTrace();
+ // TODO: Yeah great - it failed, we log it, but we still return true....
}
return true;
@@ -385,6 +397,8 @@ public class SQL { } catch (SQLException e) {
e.printStackTrace();
+ // TODO: Shouldn't we return null or something that gives the client a chance
+ // to detect the failure and notify the user?
}
return list;
}
@@ -484,6 +498,7 @@ public class SQL { return list;
}
+ // TODO: OK this method is pretty much the tenth copy&paste version of the stuff above. Maybe refactor something here?
public List<Image> getImageListPermissionAdmin(String userID) {
Connection con = getConnection();
@@ -783,6 +798,7 @@ public class SQL { // if map is empty, then itemID does not belong to an image -> must
// be a lecture
+ // TODO: Errr what? Why? Trial and error until we find the right table?
if (map.isEmpty() == true) {
// check if itemID belongs to a lecture
sql = "SELECT admin_owner FROM bwLehrpool.m_VLData_lecture WHERE lectureID=?;";
@@ -928,6 +944,8 @@ public class SQL { ResultSet data = prest.executeQuery();
con.commit();
while (data.next()) {
+ // TODO: This is just a horrible idea. Make a typo anywhere for the key, it still compiles but doesn't work.
+ // Somebody was too lazy to create a proper struct/class here....
map.put("name", data.getString("image_name"));
map.put("internet", data.getString("cond_hasInternetRestriction"));
map.put("license", data.getString("cond_hasLicenseRestriction"));
@@ -1516,6 +1534,7 @@ public class SQL { link_allowed = false;
image_admin = false;
+ // TODO: Are those really non-numeric columns? If yes, keep in mind parseInt can throw an exception...
if (Integer.parseInt(res.getString("image_read")) != 0) {
image_read = true;
}
|
