use of ai.elimu.model.gson.content.multimedia.VideoGson in project webapp by elimu-ai.
the class JavaToGsonConverter method getVideoGson.
public static VideoGson getVideoGson(Video video) {
if (video == null) {
return null;
} else {
VideoGson videoGson = new VideoGson();
videoGson.setId(video.getId());
videoGson.setLocale(video.getLocale());
videoGson.setTimeLastUpdate(video.getTimeLastUpdate());
videoGson.setRevisionNumber(video.getRevisionNumber());
videoGson.setContentStatus(video.getContentStatus());
videoGson.setDownloadUrl("/video/" + video.getId() + "." + video.getVideoFormat().toString().toLowerCase());
videoGson.setDownloadSize(video.getBytes().length / 1024);
videoGson.setContentType(video.getContentType());
videoGson.setLiteracySkills(video.getLiteracySkills());
videoGson.setNumeracySkills(video.getNumeracySkills());
List<LetterGson> letters = new ArrayList<>();
for (Letter letter : video.getLetters()) {
LetterGson letterGson = getLetterGson(letter);
letters.add(letterGson);
}
videoGson.setLetters(letters);
List<NumberGson> numbers = new ArrayList<>();
for (Number number : video.getNumbers()) {
NumberGson numberGson = getNumberGson(number);
numbers.add(numberGson);
}
videoGson.setNumbers(numbers);
List<WordGson> words = new ArrayList<>();
for (Word word : video.getWords()) {
WordGson wordGson = getWordGson(word);
words.add(wordGson);
}
videoGson.setWords(words);
videoGson.setTitle(video.getTitle());
videoGson.setVideoFormat(video.getVideoFormat());
videoGson.setThumbnailDownloadUrl("/video/" + video.getId() + "/thumbnail.png");
return videoGson;
}
}
use of ai.elimu.model.gson.content.multimedia.VideoGson in project webapp by elimu-ai.
the class VideoRestController method list.
@RequestMapping("/list")
public String list(HttpServletRequest request, @RequestParam String deviceId, // TODO: checksum,
@RequestParam Locale locale) {
logger.info("list");
logger.info("request.getQueryString(): " + request.getQueryString());
JSONArray jsonArray = new JSONArray();
for (Video video : videoDao.readAllOrdered(locale)) {
VideoGson videoGson = JavaToGsonConverter.getVideoGson(video);
String json = new Gson().toJson(videoGson);
jsonArray.put(new JSONObject(json));
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("result", "success");
jsonObject.put("videos", jsonArray);
logger.info("jsonObject: " + jsonObject);
return jsonObject.toString();
}
Aggregations