Search in sources :

Example 1 with Allophone

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

the class AllophoneCreateController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model) {
    logger.info("handleRequest");
    Allophone allophone = new Allophone();
    model.addAttribute("allophone", allophone);
    model.addAttribute("soundTypes", SoundType.values());
    return "content/allophone/create";
}
Also used : Allophone(ai.elimu.model.content.Allophone) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Allophone

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

the class AllophoneEditController method handleRequest.

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(Model model, @PathVariable Long id) {
    logger.info("handleRequest");
    Allophone allophone = allophoneDao.read(id);
    model.addAttribute("allophone", allophone);
    model.addAttribute("soundTypes", SoundType.values());
    return "content/allophone/edit";
}
Also used : Allophone(ai.elimu.model.content.Allophone) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Allophone

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

the class AllophoneListController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model, HttpSession session) {
    logger.info("handleRequest");
    Contributor contributor = (Contributor) session.getAttribute("contributor");
    // To ease development/testing, auto-generate Allophones
    List<Allophone> allophonesGenerated = generateAllophones(contributor.getLocale());
    for (Allophone allophone : allophonesGenerated) {
        logger.info("allophone.getValueIpa(): /" + allophone.getValueIpa() + "/, allophone.getValueSampa(): " + allophone.getValueSampa());
        Allophone existingAllophone = allophoneDao.readByValueIpa(contributor.getLocale(), allophone.getValueIpa());
        if (existingAllophone == null) {
            allophoneDao.create(allophone);
        }
    }
    List<Allophone> allophones = allophoneDao.readAllOrderedByUsage(contributor.getLocale());
    model.addAttribute("allophones", allophones);
    int maxUsageCount = 0;
    for (Allophone allophone : allophones) {
        if (allophone.getUsageCount() > maxUsageCount) {
            maxUsageCount = allophone.getUsageCount();
        }
    }
    model.addAttribute("maxUsageCount", maxUsageCount);
    return "content/allophone/list";
}
Also used : Allophone(ai.elimu.model.content.Allophone) Contributor(ai.elimu.model.Contributor) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Allophone

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

the class LetterEditController method handleRequest.

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(HttpSession session, Model model, @PathVariable Long id) {
    logger.info("handleRequest");
    Contributor contributor = (Contributor) session.getAttribute("contributor");
    Letter letter = letterDao.read(id);
    model.addAttribute("letter", letter);
    List<Allophone> allophones = allophoneDao.readAllOrderedByUsage(contributor.getLocale());
    model.addAttribute("allophones", allophones);
    return "content/letter/edit";
}
Also used : Letter(ai.elimu.model.content.Letter) Allophone(ai.elimu.model.content.Allophone) Contributor(ai.elimu.model.Contributor) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Allophone

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

the class StringToAllophoneConverter method convert.

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

Aggregations

Allophone (ai.elimu.model.content.Allophone)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)14 Contributor (ai.elimu.model.Contributor)11 Word (ai.elimu.model.content.Word)5 ArrayList (java.util.ArrayList)5 Letter (ai.elimu.model.content.Letter)4 AllophoneGson (ai.elimu.model.gson.content.AllophoneGson)4 Locale (ai.elimu.model.enums.Locale)3 Syllable (ai.elimu.model.content.Syllable)2 Audio (ai.elimu.model.content.multimedia.Audio)2 Image (ai.elimu.model.content.multimedia.Image)2 WordRevisionEvent (ai.elimu.model.contributor.WordRevisionEvent)2 Test (org.junit.Test)2 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 HashMap (java.util.HashMap)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1