Search in sources :

Example 1 with StoryBookGson

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

the class JavaToGsonConverter method getStoryBookGson.

public static StoryBookGson getStoryBookGson(StoryBook storyBook) {
    if (storyBook == null) {
        return null;
    } else {
        StoryBookGson storyBookGson = new StoryBookGson();
        storyBookGson.setId(storyBook.getId());
        storyBookGson.setLocale(storyBook.getLocale());
        storyBookGson.setTimeLastUpdate(storyBook.getTimeLastUpdate());
        storyBookGson.setRevisionNumber(storyBook.getRevisionNumber());
        storyBookGson.setContentStatus(storyBook.getContentStatus());
        storyBookGson.setTitle(storyBook.getTitle());
        storyBookGson.setCoverImage(getImageGson(storyBook.getCoverImage()));
        storyBookGson.setGradeLevel(storyBook.getGradeLevel());
        return storyBookGson;
    }
}
Also used : StoryBookGson(ai.elimu.model.gson.content.StoryBookGson)

Example 2 with StoryBookGson

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

the class StoryBookRestController 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 storyBooks = new JSONArray();
    for (StoryBook storyBook : storyBookDao.readAllOrdered(locale)) {
        StoryBookGson storyBookGson = JavaToGsonConverter.getStoryBookGson(storyBook);
        String json = new Gson().toJson(storyBookGson);
        storyBooks.put(new JSONObject(json));
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("result", "success");
    jsonObject.put("storyBooks", storyBooks);
    logger.info("jsonObject: " + jsonObject);
    return jsonObject.toString();
}
Also used : StoryBook(ai.elimu.model.content.StoryBook) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) StoryBookGson(ai.elimu.model.gson.content.StoryBookGson) StoryBookGson(ai.elimu.model.gson.content.StoryBookGson) Gson(com.google.gson.Gson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

StoryBookGson (ai.elimu.model.gson.content.StoryBookGson)2 StoryBook (ai.elimu.model.content.StoryBook)1 Gson (com.google.gson.Gson)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1