Package com.google.appengine.labs.repackaged.org.json

Examples of com.google.appengine.labs.repackaged.org.json.JSONArray


  public static void StatusShowResp(JID fromJID, HTTPResponse response, int intType, String pageID, String keyword)
  {
    if(response.getResponseCode() == 200)
    {
      try {
        JSONArray jsonarr = new JSONArray(new String(response.getContent()));
        StatusJSON[] jsonStatus = new StatusJSON[20];
        int arrlen = jsonarr.length();
        if(arrlen == 0)
        {
          if(intType != 3)
          {
            sendMessage(fromJID,"无更多消息");
          }
          return;
        }
        for(int i=0;i<arrlen;i++)
        {
          jsonStatus[i] = new StatusJSON(jsonarr.getJSONObject(i));
        }
        if(intType == 8)
        {
          showStatus(fromJID,jsonStatus,8,arrlen,null,keyword);
        }
View Full Code Here


  }
 
  protected void listUser(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   
    try {
      JSONArray userList = new JSONArray();
      for(User result : UserDAO.getAll())
      {
        JSONObject user = new JSONObject();
        user.put("id", KeyFactory.keyToString(result.getKey()));
        user.put("nom", result.getNom());
        user.put("prenom", result.getPrenom());
        user.put("dateNaissance", result.getDateNaissance());
        user.put("email", result.getEmail());
        user.put("login", result.getLogin());
        user.put("role", result.getRole());
        user.put("dateCreation", result.getDateCreation());
        user.put("lastConnection", result.getDateConnexion());
        user.put("duration", result.getDureeConnexion());
        userList.put(user);
      }

      response.getWriter().print(userList);
    } catch (NumberFormatException | ParseException e) {
      e.printStackTrace();
View Full Code Here

 
  private void listeSearch(HttpServletRequest request,HttpServletResponse response) throws IOException {
    try {
      PreparedQuery researchPreparedQuery = SearchDAO.getHistoric(request);
   
      JSONArray searchList = new JSONArray();
      for(Entity result : researchPreparedQuery.asIterable())
      {       
        JSONObject search = new JSONObject();
        search.put("id", KeyFactory.keyToString(result.getKey()));
        search.put("date", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(result.getProperty("date")));
        search.put("leavingFrom", result.getProperty("leavingFrom"));
        search.put("goingTo", result.getProperty("goingTo"));
        search.put("departure", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(result.getProperty("departure")));
        search.put("responseCount", result.getProperty("responseCount"));
        searchList.put(search);
      }
      response.getWriter().print(searchList);
    } catch (NumberFormatException | ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

      search.put("leaving", (String)cache.get("leavingFrom"));
      search.put("going", (String)cache.get("goingTo"));
      search.put("time", new SimpleDateFormat("HH:mm").format((Date)cache.get("departure")));
      search.put("date", new SimpleDateFormat("yyyy-MM-dd").format((Date)cache.get("departure")));
      cache.clear();
      JSONArray volHistoricList = new JSONArray();
      volHistoricList.put(search);
      for(Entity result : preparedHistoricQuery.asIterable())
      {       
        JSONObject vol = new JSONObject();
        vol.put("id", KeyFactory.keyToString(result.getKey()));
        vol.put("departureDate", result.getProperty("departureDate"));
        vol.put("departureTime", result.getProperty("departureTime"));
        vol.put("arrivalDate", result.getProperty("arrivalDate"));
        vol.put("arrivalTime", result.getProperty("arrivalTime"));
        vol.put("duration", result.getProperty("duration"));
        vol.put("price", result.getProperty("price"));
        vol.put("availableSeats", result.getProperty("availableSeats"));
        volHistoricList.put(vol);
      }
     
      response.getWriter().print(volHistoricList);
    } catch (CacheException | NullPointerException e) {
      response.getWriter().print("{\"message\":\"No Cache\"}");
View Full Code Here

    .addSort("departureDate", SortDirection.ASCENDING)
    .addSort("departureTime", SortDirection.ASCENDING);
   
    PreparedQuery preparedQuery = datastore.prepare(volListQuery);
   
    JSONArray volList = new JSONArray();
    for(Entity result : preparedQuery.asIterable())
    {
      Date flightDate = new Date();
      try {
        flightDate = (Date) new SimpleDateFormat("yyyy-MM-dd").parse(result.getProperty("departureDate").toString());
      } catch (ParseException e1) {
        flightDate = new Date();
        e1.printStackTrace();
      }
     
      JSONObject vol = new JSONObject();
      vol.put("id", KeyFactory.keyToString(result.getKey()));
      vol.put("date", new SimpleDateFormat("yyyy-MM-dd").format(flightDate));
      vol.put("leavingFrom", result.getProperty("leavingFrom"));
      vol.put("goingTo", result.getProperty("goingTo"));
      vol.put("flightDuration", result.getProperty("duration"));
      vol.put("price", result.getProperty("price"));
      vol.put("availableSeats", result.getProperty("availableSeats"));
      volList.put(vol);
    }
    response.getWriter().print(volList);
  }
View Full Code Here

    };
   
    PreparedQuery preparedQuery = VolDAO.getSearchVol(request.getParameter("leavingFrom"),request.getParameter("goingTo"),departure);
   
    int responseCount = 0;
    JSONArray volList = new JSONArray();
   
    for(Entity result : preparedQuery.asIterable())
    {       
      JSONObject vol = new JSONObject();
      vol.put("id", KeyFactory.keyToString(result.getKey()));
      vol.put("departureDate", result.getProperty("departureDate"));
      vol.put("departureTime", result.getProperty("departureTime"));
      vol.put("arrivalDate", result.getProperty("arrivalDate"));
      vol.put("arrivalTime", result.getProperty("arrivalTime"));
      vol.put("duration", result.getProperty("duration"));
      vol.put("price", result.getProperty("price"));
      vol.put("availableSeats", result.getProperty("availableSeats"));
      volList.put(vol);
      responseCount++;
    }

    try {
      SearchDAO.addSearch(request.getParameter("leavingFrom"),request.getParameter("goingTo"),departure,responseCount,KeyFactory.keyToString(Authenticate.getConnectedUser(request).getKey()));
View Full Code Here

TOP

Related Classes of com.google.appengine.labs.repackaged.org.json.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.