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