PageRenderTime 72ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/src/traveldashboard/server/data/TubeStatusGetterUtils.java

https://bitbucket.org/ambientic/traveldashboard-server
Java | 33 lines | 18 code | 15 blank | 0 comment | 2 complexity | 01944d14fadc224a587cd76c3e9e91eb MD5 | raw file
  1. package traveldashboard.server.data;
  2. import org.ibicoop.sdp.config.NetworkMessage;
  3. import com.google.gson.Gson;
  4. public class TubeStatusGetterUtils extends ResponseUtils {
  5. private static final String TAG = "TubeStatusGetterUtils";
  6. public static NetworkMessage getTubeStatusMessage(NetworkMessage req) {
  7. String methodTag = "getTubeStatusMessage";
  8. if (DataConstants.DEBUG) TdServerLogger.print(TAG, methodTag, "Start getting tube status 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 = gson.toJson(MongoDbManager.getMetroStatus(city, routeId));
  14. resp.addPayload(DataConstants.TUBE_STATUS_MESSAGE, json);
  15. if (DataConstants.DEBUG) TdServerLogger.print(TAG, methodTag, "End get tube status message" + new String(resp.encode()));
  16. return resp;
  17. }
  18. }