PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/src/traveldashboard/server/data/AllUserRatingGetterUtils.java

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