Search in sources :

Example 1 with Application

use of ai.elimu.model.admin.Application in project webapp by elimu-ai.

the class ApplicationCreateController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model) {
    logger.info("handleRequest");
    Application application = new Application();
    application.setApplicationStatus(ApplicationStatus.MISSING_APK);
    model.addAttribute("application", application);
    model.addAttribute("literacySkills", LiteracySkill.values());
    model.addAttribute("numeracySkills", NumeracySkill.values());
    return "admin/application/create";
}
Also used : Application(ai.elimu.model.admin.Application) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Application

use of ai.elimu.model.admin.Application in project webapp by elimu-ai.

the class ApplicationCreateController method handleSubmit.

@RequestMapping(method = RequestMethod.POST)
public String handleSubmit(HttpSession session, @Valid Application application, BindingResult result, Model model) {
    logger.info("handleSubmit");
    Application existingApplication = applicationDao.readByPackageName(application.getLocale(), application.getPackageName());
    if (existingApplication != null) {
        result.rejectValue("packageName", "NonUnique");
    }
    if (result.hasErrors()) {
        model.addAttribute("application", application);
        model.addAttribute("literacySkills", LiteracySkill.values());
        model.addAttribute("numeracySkills", NumeracySkill.values());
        return "admin/application/create";
    } else {
        applicationDao.create(application);
        if (EnvironmentContextLoaderListener.env == Environment.PROD) {
            Contributor contributor = (Contributor) session.getAttribute("contributor");
            String text = URLEncoder.encode(contributor.getFirstName() + " just added a new Application:\n" + "• Language: " + application.getLocale().getLanguage() + "\n" + "• Package name: \"" + application.getPackageName() + "\"\n" + "• Literacy skills: " + application.getLiteracySkills() + "\n" + "• Numeracy skills: " + application.getNumeracySkills());
            String iconUrl = contributor.getImageUrl();
            SlackApiHelper.postMessage(SlackApiHelper.getChannelId(Team.DEVELOPMENT), text, iconUrl, null);
        }
        return "redirect:/admin/application/list";
    }
}
Also used : Contributor(ai.elimu.model.Contributor) Application(ai.elimu.model.admin.Application) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Application

use of ai.elimu.model.admin.Application in project webapp by elimu-ai.

the class ApplicationEditController method handleRequest.

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(@PathVariable Long id, Model model) {
    logger.info("handleRequest");
    Application application = applicationDao.read(id);
    model.addAttribute("application", application);
    model.addAttribute("applicationStatuses", ApplicationStatus.values());
    List<ApplicationVersion> applicationVersions = applicationVersionDao.readAll(application);
    model.addAttribute("applicationVersions", applicationVersions);
    model.addAttribute("literacySkills", LiteracySkill.values());
    model.addAttribute("numeracySkills", NumeracySkill.values());
    return "admin/application/edit";
}
Also used : ApplicationVersion(ai.elimu.model.admin.ApplicationVersion) Application(ai.elimu.model.admin.Application) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Application

use of ai.elimu.model.admin.Application in project webapp by elimu-ai.

the class ApplicationVersionCreateController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(@RequestParam Long applicationId, Model model) {
    logger.info("handleRequest");
    logger.info("applicationId: " + applicationId);
    Application application = applicationDao.read(applicationId);
    ApplicationVersion applicationVersion = new ApplicationVersion();
    applicationVersion.setApplication(application);
    model.addAttribute("applicationVersion", applicationVersion);
    return "admin/application-version/create";
}
Also used : ApplicationVersion(ai.elimu.model.admin.ApplicationVersion) Application(ai.elimu.model.admin.Application) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Application

use of ai.elimu.model.admin.Application in project webapp by elimu-ai.

the class JavaToGsonConverter method getAppGroupGson.

public static AppGroupGson getAppGroupGson(AppGroup appGroup) {
    if (appGroup == null) {
        return null;
    } else {
        AppGroupGson appGroupGson = new AppGroupGson();
        appGroupGson.setId(appGroup.getId());
        List<ApplicationGson> applications = new ArrayList<>();
        for (Application application : appGroup.getApplications()) {
            ApplicationGson applicationGson = getApplicationGson(application);
            applications.add(applicationGson);
        }
        appGroupGson.setApplications(applications);
        return appGroupGson;
    }
}
Also used : ArrayList(java.util.ArrayList) AppGroupGson(ai.elimu.model.gson.project.AppGroupGson) Application(ai.elimu.model.admin.Application) ApplicationGson(ai.elimu.model.gson.admin.ApplicationGson)

Aggregations

Application (ai.elimu.model.admin.Application)20 ApplicationVersion (ai.elimu.model.admin.ApplicationVersion)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 Contributor (ai.elimu.model.Contributor)4 ApplicationGson (ai.elimu.model.gson.admin.ApplicationGson)4 AppCategory (ai.elimu.model.project.AppCategory)4 AppGroup (ai.elimu.model.project.AppGroup)4 ArrayList (java.util.ArrayList)4 JSONObject (org.json.JSONObject)4 Test (org.junit.Test)4 ApplicationVersionGson (ai.elimu.model.gson.admin.ApplicationVersionGson)3 Project (ai.elimu.model.project.Project)3 Gson (com.google.gson.Gson)3 IOException (java.io.IOException)3 Date (java.util.Date)2 ByteArrayApkFile (net.dongliu.apk.parser.ByteArrayApkFile)2 ApkMeta (net.dongliu.apk.parser.bean.ApkMeta)2 JSONArray (org.json.JSONArray)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 LetterLearningEvent (ai.elimu.model.analytics.LetterLearningEvent)1