PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/traveldashboard/server/data/TubeRatingGetterUtils.java

https://bitbucket.org/ambientic/traveldashboard-server
Java | 33 lines | 19 code | 14 blank | 0 comment | 0 complexity | d39c9f965f7631fd771431540530bdbb MD5 | raw file
  1. package traveldashboard.server.data;
  2. import org.ibicoop.sdp.config.NetworkMessage;
  3. import com.google.gson.Gson;
  4. public class TubeRatingGetterUtils extends ResponseUtils {
  5. private static final String TAG = "TubeRatingGetterUtils";
  6. public static NetworkMessage getTubeRatingMessage(NetworkMessage req) {
  7. String methodTag = "getTubeRatingMessage";
  8. TdServerLogger.print(TAG, methodTag, "Start getting tube rating message");
  9. NetworkMessage resp = prepareMsgReturn(req);
  10. String city = req.getPayload(DataConstants.PARAM_KEY_CITY_TYPE);
  11. String routeId = req.getPayload(DataConstants.PARAM_KEY_ROUTE_ID);
  12. Gson gson = new Gson();
  13. String json = "null";
  14. json = gson.toJson(MongoDbManager.getMetroGeneralRating(city, routeId));
  15. resp.addPayload(DataConstants.TUBE_RATING_MESSAGE, json);
  16. TdServerLogger.print(TAG, methodTag, "End get tube rating message : " + new String(resp.encode()));
  17. return resp;
  18. }
  19. }