summaryrefslogtreecommitdiff
path: root/src/lq/DropData.java
blob: b46d3d1b81ca162f1f065004066e3ab4eaf8a5fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
            }
            // List<Administrator> admins =
            //         (List<Administrator>) pm.newQuery(Administrator.class).execute();
            // for (Administrator a : admins) {
            //     pm.deletePersistent(a);
            // }
        }
        finally {
            pm.close();
        }
    }
}