Search in sources :

Example 86 with Word

use of ai.elimu.model.content.Word in project webapp by elimu-ai.

the class StringToWordConverter method convert.

/**
 * Convert Word id to Word entity
 */
public Word convert(String id) {
    if (StringUtils.isBlank(id)) {
        return null;
    } else {
        Long wordId = Long.parseLong(id);
        Word word = wordDao.read(wordId);
        return word;
    }
}
Also used : Word(ai.elimu.model.content.Word)

Example 87 with Word

use of ai.elimu.model.content.Word in project webapp by elimu-ai.

the class JpaToGsonConverter method getImageGson.

public static ImageGson getImageGson(Image image) {
    if (image == null) {
        return null;
    } else {
        ImageGson imageGson = new ImageGson();
        // BaseEntity
        imageGson.setId(image.getId());
        // Content
        imageGson.setRevisionNumber(image.getRevisionNumber());
        imageGson.setUsageCount(image.getUsageCount());
        // Image
        imageGson.setTitle(image.getTitle());
        imageGson.setImageFormat(image.getImageFormat());
        imageGson.setBytesUrl("/image/" + image.getId() + "_r" + image.getRevisionNumber() + "." + image.getImageFormat().toString().toLowerCase());
        imageGson.setBytesSize(image.getBytes().length / 1024);
        Set<WordGson> wordGsons = new HashSet<>();
        for (Word word : image.getWords()) {
            WordGson wordGson = new WordGson();
            wordGson.setId(word.getId());
            wordGsons.add(wordGson);
        }
        imageGson.setWords(wordGsons);
        return imageGson;
    }
}
Also used : WordGson(ai.elimu.model.v2.gson.content.WordGson) ImageGson(ai.elimu.model.v2.gson.content.ImageGson) Word(ai.elimu.model.content.Word) HashSet(java.util.HashSet)

Example 88 with Word

use of ai.elimu.model.content.Word 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;
    }
}
Also used : WordGson(ai.elimu.model.v2.gson.content.WordGson) Word(ai.elimu.model.content.Word) VideoGson(ai.elimu.model.v2.gson.content.VideoGson) HashSet(java.util.HashSet)

Aggregations

Word (ai.elimu.model.content.Word)88 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)40 HashMap (java.util.HashMap)23 Emoji (ai.elimu.model.content.Emoji)22 ArrayList (java.util.ArrayList)20 Number (ai.elimu.model.content.Number)17 Letter (ai.elimu.model.content.Letter)15 Test (org.junit.Test)12 Image (ai.elimu.model.content.multimedia.Image)11 StoryBookParagraph (ai.elimu.model.content.StoryBookParagraph)9 JSONArray (org.json.JSONArray)9 JSONObject (org.json.JSONObject)9 Contributor (ai.elimu.model.Contributor)8 Language (ai.elimu.model.v2.enums.Language)8 IOException (java.io.IOException)8 LetterSoundCorrespondence (ai.elimu.model.content.LetterSoundCorrespondence)7 Audio (ai.elimu.model.content.multimedia.Audio)7 Contributor (ai.elimu.model.contributor.Contributor)7 WordContributionEvent (ai.elimu.model.contributor.WordContributionEvent)7 WordGson (ai.elimu.model.v2.gson.content.WordGson)7