Search in sources :

Example 6 with Sound

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

the class StringToSoundConverter method convert.

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

Example 7 with Sound

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

the class SoundListController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model) {
    logger.info("handleRequest");
    List<Sound> sounds = soundDao.readAllOrderedByUsage();
    model.addAttribute("sounds", sounds);
    int maxUsageCount = 0;
    for (Sound sound : sounds) {
        if (sound.getUsageCount() > maxUsageCount) {
            maxUsageCount = sound.getUsageCount();
        }
    }
    model.addAttribute("maxUsageCount", maxUsageCount);
    return "content/sound/list";
}
Also used : Sound(ai.elimu.model.content.Sound) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Sound

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

the class SyllableCsvExportController method handleRequest.

@RequestMapping(value = "/syllables.csv", method = RequestMethod.GET)
public void handleRequest(HttpServletResponse response, OutputStream outputStream) {
    logger.info("handleRequest");
    // Generate CSV file
    String csvFileContent = "id,text,sound_ids,usage_count" + "\n";
    List<Syllable> syllables = syllableDao.readAllOrderedByUsage();
    logger.info("syllables.size(): " + syllables.size());
    for (Syllable syllable : syllables) {
        long[] soundIdsArray = new long[syllable.getSounds().size()];
        int index = 0;
        for (Sound sound : syllable.getSounds()) {
            soundIdsArray[index] = sound.getId();
            index++;
        }
        csvFileContent += syllable.getId() + "," + "\"" + syllable.getText() + "\"," + Arrays.toString(soundIdsArray) + "," + syllable.getUsageCount() + "\n";
    }
    response.setContentType("text/csv");
    byte[] bytes = csvFileContent.getBytes();
    response.setContentLength(bytes.length);
    try {
        outputStream.write(bytes);
        outputStream.flush();
        outputStream.close();
    } catch (IOException ex) {
        logger.error(ex);
    }
}
Also used : Sound(ai.elimu.model.content.Sound) IOException(java.io.IOException) Syllable(ai.elimu.model.content.Syllable) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Sound

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

the class SoundCreateController method handleRequest.

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

Example 10 with Sound

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

the class SoundEditController method handleRequest.

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(Model model, @PathVariable Long id) {
    logger.info("handleRequest");
    Sound sound = soundDao.read(id);
    model.addAttribute("sound", sound);
    model.addAttribute("timeStart", System.currentTimeMillis());
    model.addAttribute("soundTypes", SoundType.values());
    model.addAttribute("soundContributionEvents", soundContributionEventDao.readAll(sound));
    return "content/sound/edit";
}
Also used : Sound(ai.elimu.model.content.Sound) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Sound (ai.elimu.model.content.Sound)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 Letter (ai.elimu.model.content.Letter)10 LetterSoundCorrespondence (ai.elimu.model.content.LetterSoundCorrespondence)10 IOException (java.io.IOException)6 Word (ai.elimu.model.content.Word)5 ArrayList (java.util.ArrayList)5 CSVFormat (org.apache.commons.csv.CSVFormat)5 JSONArray (org.json.JSONArray)4 LetterSoundCorrespondenceContributionEvent (ai.elimu.model.contributor.LetterSoundCorrespondenceContributionEvent)3 Reader (java.io.Reader)3 Path (java.nio.file.Path)3 CSVParser (org.apache.commons.csv.CSVParser)3 CSVRecord (org.apache.commons.csv.CSVRecord)3 SoundContributionEvent (ai.elimu.model.contributor.SoundContributionEvent)2 SoundGson (ai.elimu.model.v2.gson.content.SoundGson)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 CSVPrinter (org.apache.commons.csv.CSVPrinter)2 JSONObject (org.json.JSONObject)2