Example #1
0
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("application/json");
    PrintWriter out = res.getWriter();
    HttpSession session = req.getSession(true);

    MongoDAO mongoDAO = (MongoDAO) ServiceContext.getBean("mongoDAO");

    // Get the Repository name - Database name
    String repository = (String) session.getAttribute("DB_REPOSITORY");
    // Get the Trial & Site ids
    String trialId = (String) session.getAttribute("TRIAL_ID");
    String siteId = (String) session.getAttribute("SITE_ID");

    // Build the Collection Name to get all the documents
    String collectionName = getCollectionNameForVisitInformation(req, res, session);

    HashMap<String, String> criteria = new HashMap<String, String>();

    String result[] = mongoDAO.getAllDocuments(repository, collectionName, criteria);
    String jsonResult = getJSONString(result);
    System.out.println("Trial Visit Information : " + jsonResult);

    out.println(jsonResult);
    out.close();
  }
Example #2
0
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {

    MongoDAO mongoDAO = (MongoDAO) ServiceContext.getBean("mongoDB");

    res.setContentType("application/json");
    PrintWriter out = res.getWriter();

    // String result[] = mongoDAO.getAllDocuments("test", "PatientVisitVer2");

    Gson gson = new Gson();

    // out.println(gson.toJson(result));
    out.close();
  }