diff options
| author | Nino Breuer | 2014-10-09 10:06:54 +0200 |
|---|---|---|
| committer | Nino Breuer | 2014-10-09 10:06:54 +0200 |
| commit | f62790c173b8e90e51c4b170ab4ee30865900e61 (patch) | |
| tree | 3eed331231789d9c5bb3d139d44f73808e59d7c4 /dozentenmodulserver/src/main/java/sql/SQL.java | |
| parent | fg (diff) | |
| parent | Merge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module (diff) | |
| download | tutor-module-f62790c173b8e90e51c4b170ab4ee30865900e61.tar.gz tutor-module-f62790c173b8e90e51c4b170ab4ee30865900e61.tar.xz tutor-module-f62790c173b8e90e51c4b170ab4ee30865900e61.zip | |
Merge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module
Diffstat (limited to 'dozentenmodulserver/src/main/java/sql/SQL.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/sql/SQL.java | 153 |
1 files changed, 147 insertions, 6 deletions
diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java index 92af9f14..cb9464eb 100644 --- a/dozentenmodulserver/src/main/java/sql/SQL.java +++ b/dozentenmodulserver/src/main/java/sql/SQL.java @@ -20,6 +20,9 @@ import org.apache.log4j.Logger; import server.BinaryListener;
import server.generated.Image;
import server.generated.Lecture;
+import server.generated.Person;
+
+
public class SQL {
@@ -249,7 +252,8 @@ public class SQL { try {
Connection con=getConnection();
Statement stm = con.createStatement();
-
+
+ //create a UUID
String uid = UUID.randomUUID().toString();
log.info(" - Query is: "+"INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`image_description`,`image_path`,`image_lastCall`,`image_create_time`,`image_update_time`,`image_owner`,`image_change_by`,`rec_create_time`,`rec_change_time`,`rec_owner`,`rec_change_by`,`content_operatingSystem`,`status_isCompressed`,`status_isSecure`,`status_isOptimzed`,`status_isValid`,`status_isReady`,`status_isDeleted`,`status_isLastOfficialVersion`,`cond_hasLicenseRestriction`,`cond_hasInternetRestriction`,`cond_minRAM`,`cond_minCPUs`,`image_isTemplate`,`image_filesize`,`image_syncMode`)VALUES('"
@@ -938,7 +942,7 @@ public class SQL { return ret;
}
- public int setImageRights(String pk_person, String pk_image,int role ,int read, int write, int changePermission, int admin,int linkallowed) {
+ public int setImageRights(String pk_person, String pk_image,int role ,int read, int write, int admin,int linkallowed) {
@@ -947,7 +951,7 @@ public class SQL { Statement stm = con.createStatement();
String uid = UUID.randomUUID().toString();
- stm.executeUpdate("INSERT INTO `bwLehrpool`.`pm_VLData_image`(`GUID`,`GUID_imageID`,`roleID`,`userID`,`image_read`,`image_write`,`image_admin`,`image_changePermission`,`link_allowed`)VALUES('"
+ stm.executeUpdate("INSERT INTO `bwLehrpool`.`pm_VLData_image`(`GUID`,`GUID_imageID`,`roleID`,`userID`,`image_read`,`image_write`,`image_admin`,`link_allowed`)VALUES('"
+ uid
+ "','"
+ pk_image
@@ -962,8 +966,6 @@ public class SQL { + "','"
+ admin
+ "','"
- + changePermission
- + "','"
+ linkallowed+ "');");
con.commit();
con.close();
@@ -1051,4 +1053,143 @@ public class SQL { }
return id;
}
-}
+
+ //get all users from HS OG -- temp, tb replaced by allUsers bwLehrpool
+ //does -NOT- return the user himself
+ public List<Person> getAllOtherSatelliteUsers(String userID){
+ Connection con=getConnection();
+ Statement stm=null;
+ ResultSet res = null;
+ //Map<String, String> map = new HashMap<String, String>();
+ List<Person> list = new ArrayList<Person>();
+
+
+ try {
+ stm = con.createStatement();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ res = stm.executeQuery("SELECT userID, Nachname, Vorname FROM m_user WHERE userID !='"+userID+"' ORDER BY Nachname ASC;");
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ while (res.next()) {
+
+
+ list.add(new Person(res.getString("userID"),
+ res.getString("Nachname"),
+ res.getString("Vorname")));
+
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return list;
+
+ }
+
+
+
+ public boolean updateImagePermissions(){
+ boolean success=true;
+
+ Connection con=getConnection();
+ Statement stm=null;
+ try {
+ stm = con.createStatement();
+ stm.executeQuery("");
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return success;
+ }// end setImagePermissions()
+
+ public boolean deleteImagePermissions(){
+ boolean success=true;
+
+ Connection con=getConnection();
+ Statement stm=null;
+ try {
+ stm = con.createStatement();
+ stm.executeQuery("");
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return success;
+ }// end setImagePermissions()
+
+ public boolean writeAdditionalImageRights(String imageID, String userID, boolean isRead, boolean isWrite, boolean isLinkAllowed, boolean isAdmin){
+ boolean success= true;
+
+ String uid = UUID.randomUUID().toString();
+ Connection con=getConnection();
+ Statement stm=null;
+
+ try {
+ stm=con.createStatement();
+
+ log.info(new Date() + " - INSERT INTO pm_VLData_image (" +
+ "GUID, " +
+ "GUID_imageID, " +
+ "roleID, " +
+ "userID, " +
+ "image_read, " +
+ "image_write, " +
+ "Image_admin, " +
+ "link_allowed)" +
+ "VALUES(" +
+ "'"+uid+"'," +
+ "'"+imageID+"'," +
+ "1," +
+ "'"+userID+"'," +
+ isRead+"," +
+ isWrite+"," +
+ isLinkAllowed+"," +
+ isAdmin+"" +
+ ")");
+
+ stm.executeUpdate("INSERT INTO pm_VLData_image (" +
+ "GUID, " +
+ "GUID_imageID, " +
+ "roleID, " +
+ "userID, " +
+ "image_read, " +
+ "image_write, " +
+ "Image_admin, " +
+ "link_allowed)" +
+ "VALUES(" +
+ "'"+uid+"'," +
+ "'"+imageID+"'," +
+ "1," +
+ "'"+userID+"'," +
+ isRead+"," +
+ isWrite+"," +
+ isLinkAllowed+"," +
+ isAdmin+"" +
+ ");");
+ con.commit();
+ con.close();
+ log.info(new Date() + " - Written additional image rights.");
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ log.info(new Date() + " - Failed to write additional image rights.");
+ }
+
+
+ return success;
+
+ }// end
+
+}//end class
|
