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;
}
}
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();
}
Aggregations