diff options
Diffstat (limited to 'dozentenmodulserver/src/main/java/sql/SQL.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/sql/SQL.java | 96 |
1 files changed, 69 insertions, 27 deletions
diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java index a7aefbe7..235874c2 100644 --- a/dozentenmodulserver/src/main/java/sql/SQL.java +++ b/dozentenmodulserver/src/main/java/sql/SQL.java @@ -181,7 +181,7 @@ public class SQL { public String setPerson(String login, String lastname, String firstname,
String mail, Date lastlogin, String Institution) {
- DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Connection con = getConnection();
Statement stm = con.createStatement();
@@ -242,7 +242,7 @@ public class SQL { String desc, String imagePath, long filesize, String shareMode,
String pk_os) {
- DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int internet_bol = 0;
int license_bol = 0;
@@ -428,12 +428,16 @@ public class SQL { stm = con.createStatement();
- // ResultSet
- ResultSet res = stm
- .executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE pmi.userID='"
- + userID
- + "' AND u.userID = pmi.userID AND pmi.link_allowed = 1 AND pmi.GUID_imageID = vl.GUID_imageID AND vl.content_operatingSystem=os.operatingSystemID;");
+ // ResultSet WITHOUT templates
+ //ResultSet res = stm
+ // .executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE pmi.userID='"
+ // + userID
+ // + "' AND u.userID = pmi.userID AND (pmi.link_allowed=1 OR vl.image_isTemplate=1) AND pmi.GUID_imageID = vl.GUID_imageID AND vl.content_operatingSystem=os.operatingSystemID;");
+ // ResultSet WITH templates
+ ResultSet res = stm
+ .executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name, vl.image_description, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE (vl.image_isTemplate=1 OR (pmi.userID='"+userID+"' AND pmi.link_allowed=1)) AND vl.image_owner=u.userID AND pmi.GUID_imageID = vl.GUID_imageID AND vl.content_operatingSystem=os.operatingSystemID;");
+
while (res.next()) {
list.add(new Image(
res.getString("GUID_imageID"),
@@ -467,7 +471,9 @@ public class SQL { // ResultSet
ResultSet res = stm
+ .executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name,vl_image_description, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE pmi.userID='"
+ + userID
+ "' AND u.userID = pmi.userID AND pmi.image_admin = 1 AND pmi.GUID_imageID = vl.GUID_imageID AND vl.content_operatingSystem=os.operatingSystemID;");
@@ -485,9 +491,6 @@ public class SQL { res.getString("image_description")
)
);
-
-
-
}
con.close();
} catch (SQLException e) {
@@ -495,7 +498,46 @@ public class SQL { e.printStackTrace();
}
return list;
- }
+ }//end getImageListPermissionAdmin
+
+
+
+ public List<Image> getImageListAllTemplates(){
+ Connection con = getConnection();
+ Statement stm;
+
+ List<Image> list = new ArrayList<Image>();
+ try {
+
+ stm = con.createStatement();
+
+ // ResultSet
+ ResultSet res = stm
+ .executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name, vl.image_description, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE vl.image_isTemplate=1 AND vl.content_operatingSystem=os.operatingSystemID AND vl.image_owner=u.userID;");
+
+ while (res.next()) {
+ list.add(new Image(
+ res.getString("GUID_imageID"),
+ res.getString("imageVersion"),
+ res.getString("image_name"),
+ res.getString("cond_hasLicenseRestriction"),
+ res.getString("name") + " " + res.getString("architecture") + " bit",
+ res.getString("lecture"),
+ res.getString("image_update_time"),
+ res.getString("user"),
+ res.getString("image_isTemplate"),
+ res.getString("image_description")
+ )
+ );
+ }
+ con.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return list;
+ }//end getImageListAllTemplates
+
@@ -508,7 +550,7 @@ public class SQL { ResultSet res = stm
.executeQuery("SELECT DISTINCT l.lectureID, l.name, l.isActive, l.startTime, l.endTime, l.lastUsed, l.description, i.image_name, concat(u.Nachname,' ',u.Vorname) as user "
+ "FROM bwLehrpool.m_VLData_lecture l, bwLehrpool.m_VLData_imageInfo i, bwLehrpool.pm_VLData_lecture pml, bwLehrpool.m_user u "
- + "WHERE i.GUID_imageID=l.imageID AND pml.rec_read=true AND u.userID=pml.userID AND u.userID='"
+ + "WHERE i.GUID_imageID=l.imageID AND l.lectureID=pml.lectureID AND pml.rec_read=true AND u.userID=pml.userID AND u.userID='"
+ userID + "';");
while (res.next()) {
@@ -569,7 +611,7 @@ public class SQL { ResultSet res = stm
.executeQuery("SELECT DISTINCT l.lectureID, l.name, l.isActive, l.startTime, l.endTime, l.lastUsed, l.description, i.image_name, concat(u.Nachname,' ',u.Vorname) as user "
+ "FROM bwLehrpool.m_VLData_lecture l, bwLehrpool.m_VLData_imageInfo i, bwLehrpool.pm_VLData_lecture pml, bwLehrpool.m_user u "
- + "WHERE i.GUID_imageID=l.imageID AND pml.rec_admin=true AND u.userID=pml.userID AND u.userID='"
+ + "WHERE i.GUID_imageID=l.imageID AND pml.rec_admin=true AND l.lectureID=pml.lectureID AND u.userID=pml.userID AND u.userID='"
+ userID + "';");
while (res.next()) {
@@ -672,7 +714,7 @@ public class SQL { int imageversion, String name, String desc, String shortdesc,
String start, String end, boolean isactive) {
- DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int active_bol = 0;
if (isactive == true) {
@@ -790,7 +832,7 @@ public class SQL { long filesize, String shareMode, String ospk) {
try {
Connection con = getConnection();
- DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Statement stm = con.createStatement();
int newVersion = Integer.parseInt(version) + 1;
@@ -803,7 +845,7 @@ public class SQL { license_bol = 1;
}
/*
- log.info(new Date() + " - 'image_name` = '" + newName
+ log.info("'image_name` = '" + newName
+ "\n length of name=" + newName.length());
log.info("now in UpdateImageData()");
@@ -851,13 +893,13 @@ public class SQL { + "',`image_isTemplate` = '"
// + isTemplate
+ "0'"
- + "',`content_operatingSystem` = "
+ + ",`content_operatingSystem` = "
+ ospk
+ ",`image_filesize` = "
+ filesize
- + ",`image_syncMode` = "
+ + ",`image_syncMode` = '"
+ shareMode
- + " WHERE GUID_imageID = '"
+ + "' WHERE GUID_imageID = '"
+ id
+ "' AND imageVersion = "
+ version + ";");
@@ -903,7 +945,7 @@ public class SQL { String name, String newName, String desc, String shortdesc,
String start, String end, boolean isactive, String id) {
- DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int active_bol = 0;
if (isactive == true) {
@@ -1098,7 +1140,7 @@ public class SQL { try {
Connection con = getConnection();
Statement stm = con.createStatement();
- //log.info(new Date() + " - Getting PrimaryKey for OS: " + os + " architecture: " + architecture);
+ //log.info("Getting PrimaryKey for OS: " + os + " architecture: " + architecture);
ResultSet rs = stm
.executeQuery("SELECT operatingSystemID FROM bwLehrpool.m_operatingSystem where name like '"
+ os
@@ -1117,6 +1159,7 @@ public class SQL { e.printStackTrace();
}
+
return null;
}
@@ -1550,11 +1593,11 @@ public class SQL { + ");");
con.commit();
con.close();
- log.info(new Date() + " - Written additional image rights.");
+ log.info("Written additional image rights.");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- log.info(new Date() + " - Failed to write additional image rights.");
+ log.info("Failed to write additional image rights.");
}
return success;
}// end writeAdditionalImageRights
@@ -1581,7 +1624,7 @@ public class SQL { con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + "Failed to setLectureRights.");
+ log.info("Failed to setLectureRights.");
e.printStackTrace();
}
return 0;
@@ -1605,13 +1648,12 @@ public class SQL { + isAdmin + ");");
con.commit();
con.close();
- log.info(new Date() + " - Written additional lecture rights for '"
+ log.info("Written additional lecture rights for '"
+ userID + "'.");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- log.info(new Date()
- + " - Failed to write additional lecture rights.");
+ log.info("Failed to write additional lecture rights.");
}
return success;
}// end writeAdditionalLectureRights
|
