Changeset 8867 for trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/profiles/Subscription.java
- Timestamp:
- 2004-12-21T12:11:00+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/profiles/Subscription.java
r8798 r8867 78 78 rssNotification = valueMap.containsKey("way") && ((List)valueMap.get("way")).contains("rss"); 79 79 eventsSincePageNotification = valueMap.containsKey("way") && ((List)valueMap.get("way")).contains("page"); 80 id = saveToDatabase( true);80 id = saveToDatabase(); 81 81 82 82 for (Iterator iter = getPredicates().iterator(); iter.hasNext();) { … … 157 157 } 158 158 159 private int saveToDatabase( boolean initial) throws DatabaseException, SQLException {159 private int saveToDatabase() throws DatabaseException, SQLException { 160 160 Connection conn = DatabaseManager.getInstance().getDatabaseConnection(); 161 161 Statement statement = conn.createStatement(); 162 162 String sqlString; 163 boolean initial = true; 164 165 sqlString = "SELECT id FROM subscriptions WHERE name like '" + name + 166 "' AND email like '" + email + "' AND rss=" + (rssNotification ? 1 : 0) 167 + " AND page=" + (eventsSincePageNotification ? 1 : 0) + " AND user like '" + 168 username + "';"; 169 ResultSet result = statement.executeQuery(sqlString); 170 if (result.next()) { 171 initial = false; 172 this.id = result.getInt("id"); 173 } 174 163 175 if (initial) { 164 176 sqlString = "INSERT INTO subscriptions (name, email, rss, page, user) " + … … 168 180 sqlString = "UPDATE subscriptions SET name='" + name + "', email='" + 169 181 email + "', rss=" + (rssNotification ? 1 : 0) + ",page=" + 170 (eventsSincePageNotification ? 1 : 0)+ " WHERE id=" +id + ";";182 (eventsSincePageNotification ? 1 : 0)+ " WHERE id=" + this.id + ";"; 171 183 // cannot change user 172 184 } … … 178 190 username + "';"; 179 191 System.out.println(sqlString); 180 ResultSetresult = statement.executeQuery(sqlString);181 int id;192 result = statement.executeQuery(sqlString); 193 182 194 if (result.next()) { 183 195 id = result.getInt("id");
Note:
See TracChangeset
for help on using the changeset viewer.