Search in sources :

Example 1 with VideoGson

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;
    }
}
Also used : Letter(ai.elimu.model.content.Letter) WordGson(ai.elimu.model.gson.content.WordGson) Word(ai.elimu.model.content.Word) Number(ai.elimu.model.content.Number) ArrayList(java.util.ArrayList) VideoGson(ai.elimu.model.gson.content.multimedia.VideoGson) LetterGson(ai.elimu.model.gson.content.LetterGson) NumberGson(ai.elimu.model.gson.content.NumberGson)

Example 2 with 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();
}
Also used : JSONObject(org.json.JSONObject) Video(ai.elimu.model.content.multimedia.Video) JSONArray(org.json.JSONArray) VideoGson(ai.elimu.model.gson.content.multimedia.VideoGson) Gson(com.google.gson.Gson) VideoGson(ai.elimu.model.gson.content.multimedia.VideoGson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

VideoGson (ai.elimu.model.gson.content.multimedia.VideoGson)2 Letter (ai.elimu.model.content.Letter)1 Number (ai.elimu.model.content.Number)1 Word (ai.elimu.model.content.Word)1 Video (ai.elimu.model.content.multimedia.Video)1 LetterGson (ai.elimu.model.gson.content.LetterGson)1 NumberGson (ai.elimu.model.gson.content.NumberGson)1 WordGson (ai.elimu.model.gson.content.WordGson)1 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1