Search in sources :

Example 6 with ModuleProgress

use of org.motechproject.mots.domain.ModuleProgress in project mots by motech-implementations.

the class ModuleProgressService method updateModuleProgress.

/**
 * Update Module Progress after call ends.
 * @param votoCallLogDto log containing all Voto tree interactions in specific call
 * @param callInterrupted true if last call was interrupted
 */
public void updateModuleProgress(VotoCallLogDto votoCallLogDto, boolean callInterrupted) {
    String chwIvrId = votoCallLogDto.getChwIvrId();
    Optional<ModuleProgress> interruptedModuleProgress = moduleProgressRepository.findByCommunityHealthWorkerIvrIdAndInterrupted(chwIvrId, true);
    Iterator<VotoBlockDto> blockIterator = votoCallLogDto.getInteractions().iterator();
    try {
        if (interruptedModuleProgress.isPresent()) {
            ModuleProgress moduleProgress = interruptedModuleProgress.get();
            if (parseVotoModuleBlocks(votoCallLogDto, blockIterator, moduleProgress.getCourseModule().getIvrId(), callInterrupted)) {
                return;
            }
        }
        parseVotoMainMenuBlocks(votoCallLogDto, blockIterator, callInterrupted);
    } catch (MotsException ex) {
        LOGGER.error("Could not parse CallLog with id: " + votoCallLogDto.getLogId(), ex);
    }
}
Also used : VotoBlockDto(org.motechproject.mots.dto.VotoBlockDto) ModuleProgress(org.motechproject.mots.domain.ModuleProgress) MotsException(org.motechproject.mots.exception.MotsException)

Aggregations

ModuleProgress (org.motechproject.mots.domain.ModuleProgress)6 VotoBlockDto (org.motechproject.mots.dto.VotoBlockDto)2 UUID (java.util.UUID)1 Course (org.motechproject.mots.domain.Course)1 CourseModule (org.motechproject.mots.domain.CourseModule)1 UnitProgress (org.motechproject.mots.domain.UnitProgress)1 CourseProgressException (org.motechproject.mots.exception.CourseProgressException)1 MotsException (org.motechproject.mots.exception.MotsException)1