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