Search in sources :

Example 1 with Contributor

use of ai.elimu.model.Contributor in project webapp by elimu-ai.

the class MailChimpScheduler method executeDataSync.

/**
 * Sync data registered for existing subscribers.
 */
// 20 past every hour
@Scheduled(cron = "00 20 * * * *")
public synchronized void executeDataSync() {
    logger.info("executeDataSync");
    if (EnvironmentContextLoaderListener.env != Environment.PROD) {
        return;
    }
    List<Contributor> contributors = contributorDao.readAll();
    logger.info("contributors.size(): " + contributors.size());
    for (Contributor contributor : contributors) {
        try {
            String memberInfo = MailChimpApiHelper.getMemberInfo(contributor.getEmail());
            if (StringUtils.isNotBlank(memberInfo)) {
                // Sync Contributor data with mailing list
                MailChimpApiHelper.updateTeams(contributor.getEmail(), contributor.getTeams());
            }
        } catch (IOException ex) {
            logger.error(null, ex);
            break;
        }
    }
    logger.info("executeDataSync complete");
}
Also used : Contributor(ai.elimu.model.Contributor) IOException(java.io.IOException) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 2 with Contributor

use of ai.elimu.model.Contributor in project webapp by elimu-ai.

the class AdminProjectEditController method handleRequest.

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(Model model, @PathVariable Long id) {
    logger.info("handleRequest");
    Project project = projectDao.read(id);
    model.addAttribute("project", project);
    List<Contributor> contributors = contributorDao.readAll();
    model.addAttribute("managers", contributors);
    return "admin/project/edit";
}
Also used : Project(ai.elimu.model.project.Project) Contributor(ai.elimu.model.Contributor) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Contributor

use of ai.elimu.model.Contributor in project webapp by elimu-ai.

the class ApplicationOpenedEventListController 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 events
    if (EnvironmentContextLoaderListener.env != Environment.PROD) {
        generateEvents(contributor.getLocale());
    }
    List<ApplicationOpenedEvent> applicationOpenedEvents = applicationOpenedEventDao.readAll(contributor.getLocale());
    model.addAttribute("applicationOpenedEvents", applicationOpenedEvents);
    return "analytics/application-opened-event/list";
}
Also used : ApplicationOpenedEvent(ai.elimu.model.analytics.ApplicationOpenedEvent) Contributor(ai.elimu.model.Contributor) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Contributor

use of ai.elimu.model.Contributor in project webapp by elimu-ai.

the class DeviceListController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model, HttpSession session) {
    logger.info("handleRequest");
    Contributor contributor = (Contributor) session.getAttribute("contributor");
    List<Device> devices = deviceDao.readAll(contributor.getLocale());
    model.addAttribute("devices", devices);
    return "analytics/device/list";
}
Also used : Device(ai.elimu.model.Device) Contributor(ai.elimu.model.Contributor) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Contributor

use of ai.elimu.model.Contributor 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)

Aggregations

Contributor (ai.elimu.model.Contributor)57 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)51 Project (ai.elimu.model.project.Project)12 IOException (java.io.IOException)10 Allophone (ai.elimu.model.content.Allophone)9 Word (ai.elimu.model.content.Word)8 Image (ai.elimu.model.content.multimedia.Image)8 Audio (ai.elimu.model.content.multimedia.Audio)6 Letter (ai.elimu.model.content.Letter)5 Number (ai.elimu.model.content.Number)5 AppCategory (ai.elimu.model.project.AppCategory)5 StoryBook (ai.elimu.model.content.StoryBook)4 Video (ai.elimu.model.content.multimedia.Video)4 Scheduled (org.springframework.scheduling.annotation.Scheduled)4 AppCollection (ai.elimu.model.project.AppCollection)3 AppGroup (ai.elimu.model.project.AppGroup)3 Locale (java.util.Locale)3 Application (ai.elimu.model.admin.Application)2 ApplicationVersion (ai.elimu.model.admin.ApplicationVersion)2 Syllable (ai.elimu.model.content.Syllable)2