use of ai.elimu.model.v2.gson.content.SoundGson in project webapp by elimu-ai.
the class SoundsRestController method handleGetRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleGetRequest() {
logger.info("handleGetRequest");
JSONArray soundsJsonArray = new JSONArray();
for (Sound sound : soundDao.readAllOrdered()) {
SoundGson soundGson = JpaToGsonConverter.getSoundGson(sound);
String json = new Gson().toJson(soundGson);
soundsJsonArray.put(new JSONObject(json));
}
String jsonResponse = soundsJsonArray.toString();
logger.info("jsonResponse: " + jsonResponse);
return jsonResponse;
}
use of ai.elimu.model.v2.gson.content.SoundGson in project webapp by elimu-ai.
the class JpaToGsonConverter method getLetterSoundCorrespondenceGson.
public static LetterSoundCorrespondenceGson getLetterSoundCorrespondenceGson(LetterSoundCorrespondence letterSoundCorrespondence) {
if (letterSoundCorrespondence == null) {
return null;
} else {
LetterSoundCorrespondenceGson letterSoundCorrespondenceGson = new LetterSoundCorrespondenceGson();
// BaseEntity
letterSoundCorrespondenceGson.setId(letterSoundCorrespondence.getId());
// LetterSoundCorrespondence
List<LetterGson> letters = new ArrayList<>();
for (Letter letter : letterSoundCorrespondence.getLetters()) {
LetterGson letterGson = getLetterGson(letter);
letters.add(letterGson);
}
letterSoundCorrespondenceGson.setLetters(letters);
List<SoundGson> sounds = new ArrayList<>();
for (Sound sound : letterSoundCorrespondence.getSounds()) {
SoundGson soundGson = getSoundGson(sound);
sounds.add(soundGson);
}
letterSoundCorrespondenceGson.setSounds(sounds);
letterSoundCorrespondenceGson.setUsageCount(letterSoundCorrespondence.getUsageCount());
return letterSoundCorrespondenceGson;
}
}
use of ai.elimu.model.v2.gson.content.SoundGson in project webapp by elimu-ai.
the class JpaToGsonConverter method getSoundGson.
public static SoundGson getSoundGson(Sound sound) {
if (sound == null) {
return null;
} else {
SoundGson soundGson = new SoundGson();
// BaseEntity
soundGson.setId(sound.getId());
// Content
soundGson.setRevisionNumber(sound.getRevisionNumber());
soundGson.setUsageCount(sound.getUsageCount());
// Sound
soundGson.setValueIpa(sound.getValueIpa());
soundGson.setDiacritic(sound.isDiacritic());
soundGson.setSoundType(sound.getSoundType());
return soundGson;
}
}
Aggregations