Search in sources :

Example 1 with AllophoneGson

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

the class JavaToGsonConverter method getSyllableGson.

public static SyllableGson getSyllableGson(Syllable syllable) {
    if (syllable == null) {
        return null;
    } else {
        SyllableGson syllableGson = new SyllableGson();
        syllableGson.setId(syllable.getId());
        syllableGson.setLocale(syllable.getLocale());
        syllableGson.setTimeLastUpdate(syllable.getTimeLastUpdate());
        syllableGson.setRevisionNumber(syllable.getRevisionNumber());
        syllableGson.setContentStatus(syllable.getContentStatus());
        syllableGson.setText(syllable.getText());
        List<AllophoneGson> allophones = new ArrayList<>();
        for (Allophone allophone : syllable.getAllophones()) {
            AllophoneGson allophoneGson = getAllophoneGson(allophone);
            allophones.add(allophoneGson);
        }
        syllableGson.setAllophones(allophones);
        syllableGson.setUsageCount(syllable.getUsageCount());
        return syllableGson;
    }
}
Also used : AllophoneGson(ai.elimu.model.gson.content.AllophoneGson) Allophone(ai.elimu.model.content.Allophone) SyllableGson(ai.elimu.model.gson.content.SyllableGson) ArrayList(java.util.ArrayList)

Example 2 with AllophoneGson

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

the class JavaToGsonConverter method getWordGson.

public static WordGson getWordGson(Word word) {
    if (word == null) {
        return null;
    } else {
        WordGson wordGson = new WordGson();
        wordGson.setId(word.getId());
        wordGson.setLocale(word.getLocale());
        wordGson.setTimeLastUpdate(word.getTimeLastUpdate());
        wordGson.setRevisionNumber(word.getRevisionNumber());
        wordGson.setContentStatus(word.getContentStatus());
        wordGson.setText(word.getText());
        wordGson.setPhonetics(word.getPhonetics());
        List<AllophoneGson> allophones = new ArrayList<>();
        for (Allophone allophone : word.getAllophones()) {
            AllophoneGson allophoneGson = getAllophoneGson(allophone);
            allophones.add(allophoneGson);
        }
        wordGson.setAllophones(allophones);
        wordGson.setUsageCount(word.getUsageCount());
        wordGson.setWordType(word.getWordType());
        wordGson.setSpellingConsistency(word.getSpellingConsistency());
        return wordGson;
    }
}
Also used : WordGson(ai.elimu.model.gson.content.WordGson) AllophoneGson(ai.elimu.model.gson.content.AllophoneGson) Allophone(ai.elimu.model.content.Allophone) ArrayList(java.util.ArrayList)

Example 3 with AllophoneGson

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

the class JavaToGsonConverter method getLetterGson.

public static LetterGson getLetterGson(Letter letter) {
    if (letter == null) {
        return null;
    } else {
        LetterGson letterGson = new LetterGson();
        letterGson.setId(letter.getId());
        letterGson.setLocale(letter.getLocale());
        letterGson.setTimeLastUpdate(letter.getTimeLastUpdate());
        letterGson.setRevisionNumber(letter.getRevisionNumber());
        letterGson.setContentStatus(letter.getContentStatus());
        letterGson.setText(letter.getText());
        List<AllophoneGson> allophones = new ArrayList<>();
        for (Allophone allophone : letter.getAllophones()) {
            AllophoneGson allophoneGson = getAllophoneGson(allophone);
            allophones.add(allophoneGson);
        }
        letterGson.setAllophones(allophones);
        letterGson.setBraille(letter.getBraille());
        letterGson.setUsageCount(letter.getUsageCount());
        return letterGson;
    }
}
Also used : AllophoneGson(ai.elimu.model.gson.content.AllophoneGson) Allophone(ai.elimu.model.content.Allophone) ArrayList(java.util.ArrayList) LetterGson(ai.elimu.model.gson.content.LetterGson)

Example 4 with AllophoneGson

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

the class AllophoneRestController 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 allophones = new JSONArray();
    for (Allophone allophone : allophoneDao.readAllOrdered(locale)) {
        AllophoneGson allophoneGson = JavaToGsonConverter.getAllophoneGson(allophone);
        String json = new Gson().toJson(allophoneGson);
        allophones.put(new JSONObject(json));
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("result", "success");
    jsonObject.put("allophones", allophones);
    logger.info("jsonObject: " + jsonObject);
    return jsonObject.toString();
}
Also used : JSONObject(org.json.JSONObject) Allophone(ai.elimu.model.content.Allophone) AllophoneGson(ai.elimu.model.gson.content.AllophoneGson) JSONArray(org.json.JSONArray) AllophoneGson(ai.elimu.model.gson.content.AllophoneGson) Gson(com.google.gson.Gson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with AllophoneGson

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

the class JavaToGsonConverter method getAllophoneGson.

public static AllophoneGson getAllophoneGson(Allophone allophone) {
    if (allophone == null) {
        return null;
    } else {
        AllophoneGson allophoneGson = new AllophoneGson();
        allophoneGson.setId(allophone.getId());
        allophoneGson.setLocale(allophone.getLocale());
        allophoneGson.setTimeLastUpdate(allophone.getTimeLastUpdate());
        allophoneGson.setRevisionNumber(allophone.getRevisionNumber());
        allophoneGson.setContentStatus(allophone.getContentStatus());
        allophoneGson.setValueIpa(allophone.getValueIpa());
        allophoneGson.setValueSampa(allophone.getValueSampa());
        allophoneGson.setAudio(getAudioGson(allophone.getAudio()));
        allophoneGson.setDiacritic(allophone.isDiacritic());
        allophoneGson.setSoundType(allophone.getSoundType());
        allophoneGson.setUsageCount(allophone.getUsageCount());
        return allophoneGson;
    }
}
Also used : AllophoneGson(ai.elimu.model.gson.content.AllophoneGson)

Aggregations

AllophoneGson (ai.elimu.model.gson.content.AllophoneGson)5 Allophone (ai.elimu.model.content.Allophone)4 ArrayList (java.util.ArrayList)3 LetterGson (ai.elimu.model.gson.content.LetterGson)1 SyllableGson (ai.elimu.model.gson.content.SyllableGson)1 WordGson (ai.elimu.model.gson.content.WordGson)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