PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/src/traveldashboard/server/data/UserRatingGetterUtils.java

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