Ejemplo n.º 1
0
  /**
   * @deprecated DB직접 접근해서 JSON 으로 출력해서 그래프 그리기 위한 경우 쓸모가 아리까리해서 안씀... 나중에 쓸일있을수도 있을까 해서 남겨둠
   * @param request
   * @param response
   * @return
   * @throws ServletRequestBindingException
   */
  @SuppressWarnings({"unused", "unchecked"})
  private JSONArray doChartStd(HttpServletRequest request, HttpServletResponse response)
      throws ServletRequestBindingException {
    String miliseconds = request.getParameter("miliseconds");
    String count = request.getParameter("count");
    String flag = request.getParameter("flag");

    BtaDealCtrl dealMgr = new BtaDealCtrl();
    BtaPriceCtrl priceMgr = new BtaPriceCtrl();

    JSONArray json = new JSONArray();
    BtaDeals btaDeals = dealMgr.getBtaDealsBySelling(TYPE.PRICE);
    Iterator<BtaDeal> deals = btaDeals.iterator();

    while (deals.hasNext()) {
      BtaDeal deal = deals.next();
      LOG.debug(
          deal.getKey() + ":" + deal.getTitle() + ":" + miliseconds + ":" + count + ":" + flag);
      BtaPrices prices =
          priceMgr.getBtaPrices(
              deal.getKey(),
              miliseconds,
              BooleanUtils.toBoolean(flag),
              NumberUtils.toInt(count, BTA.DEFAULT_JSON_COUNT));
      json.add(JSONParser.getLineChartJSON(deal, prices));
    }
    return json;
  }
Ejemplo n.º 2
0
 /**
  * Memcache 에 있는 현재 거래 중인 BtaDeal JSON 데이터 추출
  *
  * @return JSONArray Line Chart 용 JSON
  * @throws ServletRequestBindingException
  */
 @SuppressWarnings("unchecked")
 private JSONArray doLineChartMemcache(boolean flag, long miliseconds, int period)
     throws ServletRequestBindingException {
   JSONArray jsonArray = new JSONArray();
   List<String> header = null;
   if (null != (header = MemcacheUtils.getBtaHeader())) {
     Iterator<String> iteratorHeader = header.iterator();
     while (iteratorHeader.hasNext()) {
       try {
         jsonArray.add(JSONParser.getSwipeJSON(iteratorHeader.next(), flag, period, miliseconds));
       } catch (NullPointerException exception) {
         LOG.error(exception);
       }
     }
   } else {
     MemcacheUtils.setBtaHeader();
     doLineChartMemcache(flag, miliseconds, period);
   }
   return jsonArray;
 }