Ejemplo n.º 1
0
 /**
  * Method return json list of stations
  *
  * @return
  */
 @Override
 public String getJsonListOfStations() {
   LOG.info("getJsonListOfStations");
   List<Station> stationList = getAllStations();
   JSONObject jsonObjectAnswer = new JSONObject();
   for (Station station : stationList) {
     jsonObjectAnswer.put(station.getId() + "", station.getName());
   }
   return jsonObjectAnswer.toString();
 }
Ejemplo n.º 2
0
  /**
   * Method return full json list of stations
   *
   * @return
   */
  @Override
  public String getJsonListOfStationsFull() {
    List<Station> listOfStations = this.getAllStations();

    JSONArray data = new JSONArray();

    for (Station station : listOfStations) {
      JSONObject dataItem = new JSONObject();

      dataItem.put("stationId", station.getId());
      dataItem.put("stationName", station.getName());

      data.put(dataItem);
    }

    return data.toString();
  }