use of ai.elimu.model.v2.gson.content.VideoGson in project webapp by elimu-ai.
the class VideosRestController method handleGetRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleGetRequest(HttpServletRequest request) {
logger.info("handleGetRequest");
JSONArray videosJsonArray = new JSONArray();
for (Video video : videoDao.readAllOrdered()) {
VideoGson videoGson = JpaToGsonConverter.getVideoGson(video);
String json = new Gson().toJson(videoGson);
videosJsonArray.put(new JSONObject(json));
}
String jsonResponse = videosJsonArray.toString();
logger.info("jsonResponse: " + jsonResponse);
return jsonResponse;
}
use of ai.elimu.model.v2.gson.content.VideoGson in project webapp by elimu-ai.
the class JpaToGsonConverter method getVideoGson.
public static VideoGson getVideoGson(Video video) {
if (video == null) {
return null;
} else {
VideoGson videoGson = new VideoGson();
// BaseEntity
videoGson.setId(video.getId());
// Content
videoGson.setRevisionNumber(video.getRevisionNumber());
videoGson.setUsageCount(video.getUsageCount());
// Video
videoGson.setTitle(video.getTitle());
videoGson.setVideoFormat(video.getVideoFormat());
videoGson.setBytesUrl("/video/" + video.getId() + "_r" + video.getRevisionNumber() + "." + video.getVideoFormat().toString().toLowerCase());
videoGson.setBytesSize(video.getBytes().length / 1024);
Set<WordGson> wordGsons = new HashSet<>();
for (Word word : video.getWords()) {
WordGson wordGson = new WordGson();
wordGson.setId(word.getId());
wordGsons.add(wordGson);
}
videoGson.setWords(wordGsons);
return videoGson;
}
}
Aggregations