diff options
author | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2010-09-03 01:13:15 -0400 |
---|---|---|
committer | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2010-09-03 01:13:15 -0400 |
commit | 1fb83a8c3edefbc2a43d26cc6db835e592d65934 (patch) | |
tree | 73047a16e263ae3f84031bc2d82e3961d2140430 /src/lq/DropData.java | |
parent | b2dd8bf148b70c3076625840f908b5c7d32e9ee1 (diff) |
Quote listing
Ported the quotes.jsp page from the old quote system. This commit
contains some utility classes related to this.
DropData is a temporary hack to remove all data in the datastore.
TODO: Remove this when we are finished migrating the application.
Diffstat (limited to 'src/lq/DropData.java')
-rw-r--r-- | src/lq/DropData.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lq/DropData.java b/src/lq/DropData.java new file mode 100644 index 0000000..06f3583 --- /dev/null +++ b/src/lq/DropData.java @@ -0,0 +1,30 @@ +package lq; + +import java.io.IOException; +import java.util.List; +import javax.jdo.PersistenceManager; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class DropData extends HttpServlet { + + @Override + public void doGet(HttpServletRequest req, HttpServletResponse resp) + throws IOException { + PersistenceManager pm = PMF.get().getPersistenceManager(); + try { + List<Quote> quotes = (List<Quote>) pm.newQuery(Quote.class).execute(); + for (Quote q : quotes) { + pm.deletePersistent(q); + } + List<Vote> votes = (List<Vote>) pm.newQuery(Vote.class).execute(); + for (Vote v : votes) { + pm.deletePersistent(v); + } + } + finally { + pm.close(); + } + } +} |