use of ai.elimu.model.admin.Application in project webapp by elimu-ai.
the class LetterLearningEventDaoTest method testReadAllByApplication.
@Test
public void testReadAllByApplication() {
Application application = new Application();
application.setPackageName("ai.elimu.handwriting");
applicationDao.create(application);
List<LetterLearningEvent> letterLearningEvents = letterLearningEventDao.readAll(application);
assertThat(letterLearningEvents.size(), is(0));
LetterLearningEvent letterLearningEvent = new LetterLearningEvent();
letterLearningEvent.setApplication(application);
letterLearningEventDao.create(letterLearningEvent);
letterLearningEvents = letterLearningEventDao.readAll(application);
assertThat(letterLearningEvents.size(), is(1));
assertThat(letterLearningEvents.get(0).getApplication().getPackageName(), is("ai.elimu.handwriting"));
}
use of ai.elimu.model.admin.Application in project webapp by elimu-ai.
the class NumberLearningEventDaoTest method testReadAllByApplication.
@Test
public void testReadAllByApplication() {
Application application = new Application();
application.setPackageName("ai.elimu.handwriting");
applicationDao.create(application);
List<NumberLearningEvent> numberLearningEvents = numberLearningEventDao.readAll(application);
assertThat(numberLearningEvents.size(), is(0));
NumberLearningEvent numberLearningEvent = new NumberLearningEvent();
numberLearningEvent.setApplication(application);
numberLearningEventDao.create(numberLearningEvent);
numberLearningEvents = numberLearningEventDao.readAll(application);
assertThat(numberLearningEvents.size(), is(1));
assertThat(numberLearningEvents.get(0).getApplication().getPackageName(), is("ai.elimu.handwriting"));
}
use of ai.elimu.model.admin.Application in project webapp by elimu-ai.
the class ApplicationVersionDaoTest method testCacheable.
@Test
public void testCacheable() {
Application application = new Application();
applicationDao.create(application);
List<ApplicationVersion> applicationVersions = applicationVersionDao.readAll(application);
assertThat(applicationVersions.isEmpty(), is(true));
}
use of ai.elimu.model.admin.Application in project webapp by elimu-ai.
the class ApkController method handleRequest.
@RequestMapping(value = "/{packageName}-{versionCode}.apk", method = RequestMethod.GET)
public void handleRequest(@PathVariable String packageName, @PathVariable Integer versionCode, @RequestParam String deviceId, @RequestParam String checksum, @RequestParam Locale locale, @RequestParam String deviceModel, @RequestParam Integer osVersion, @RequestParam Integer appVersionCode, // Custom Project
@RequestParam(required = false) String licenseEmail, @RequestParam(required = false) String licenseNumber, @RequestParam(required = false) Long applicationId, HttpServletRequest request, HttpServletResponse response, OutputStream outputStream) {
logger.info("handleRequest");
logger.info("packageName: " + packageName);
logger.info("versionCode: " + versionCode);
logger.info("request.getQueryString(): " + request.getQueryString());
logger.info("request.getRemoteAddr(): " + request.getRemoteAddr());
// TODO: validate checksum
// See AppCollectionRestController#addInfrastructureApps
boolean isInfrastructureApp = "ai.elimu.appstore".equals(packageName) || "ai.elimu.appstore_custom".equals(packageName) || "ai.elimu.analytics".equals(packageName) || "ai.elimu.launcher".equals(packageName) || "ai.elimu.launcher_custom".equals(packageName);
Application application = null;
if (TextUtils.isBlank(licenseEmail) || isInfrastructureApp) {
application = applicationDao.readByPackageName(locale, packageName);
} else {
// Custom Project
License license = licenseDao.read(licenseEmail, licenseNumber);
if (license != null) {
// TODO: fetch Application based on License instead of additional applicationId parameter
application = applicationDao.read(applicationId);
}
}
ApplicationVersion applicationVersion = applicationVersionDao.read(application, versionCode);
response.setContentType(applicationVersion.getContentType());
byte[] bytes = applicationVersion.getBytes();
response.setContentLength(bytes.length);
try {
outputStream.write(bytes);
} catch (EOFException ex) {
// org.eclipse.jetty.io.EofException (occurs when download is aborted before completion)
logger.warn(ex);
} catch (IOException ex) {
logger.error(null, ex);
} finally {
try {
try {
outputStream.flush();
outputStream.close();
} catch (EOFException ex) {
// org.eclipse.jetty.io.EofException (occurs when download is aborted before completion)
logger.warn(ex);
}
} catch (IOException ex) {
logger.error(null, ex);
}
}
}
use of ai.elimu.model.admin.Application in project webapp by elimu-ai.
the class ApplicationListController method handleRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model, HttpSession session) {
logger.info("handleRequest");
Contributor contributor = (Contributor) session.getAttribute("contributor");
logger.info("contributor.getLocale(): " + contributor.getLocale());
// List count of active Android applications for each EGRA/EGMA skill
List<Application> activeApplications = applicationDao.readAllByStatus(contributor.getLocale(), ApplicationStatus.ACTIVE);
logger.info("activeApplications.size(): " + activeApplications.size());
Map<LiteracySkill, Integer> literacySkillCountMap = new LinkedHashMap<>();
for (LiteracySkill literacySkill : LiteracySkill.values()) {
literacySkillCountMap.put(literacySkill, 0);
}
for (Application application : activeApplications) {
for (LiteracySkill literacySkill : application.getLiteracySkills()) {
int count = literacySkillCountMap.get(literacySkill);
literacySkillCountMap.put(literacySkill, count + 1);
}
}
model.addAttribute("literacySkillCountMap", literacySkillCountMap);
int maxLiteracySkillCount = 0;
Collection<Integer> literacySkillCountCollection = literacySkillCountMap.values();
for (int count : literacySkillCountCollection) {
if (count > maxLiteracySkillCount) {
maxLiteracySkillCount = count;
}
}
model.addAttribute("maxLiteracySkillCount", maxLiteracySkillCount);
Map<NumeracySkill, Integer> numeracySkillCountMap = new LinkedHashMap<>();
for (NumeracySkill numeracySkill : NumeracySkill.values()) {
numeracySkillCountMap.put(numeracySkill, 0);
}
for (Application application : activeApplications) {
for (NumeracySkill numeracySkill : application.getNumeracySkills()) {
int count = numeracySkillCountMap.get(numeracySkill);
numeracySkillCountMap.put(numeracySkill, count + 1);
}
}
model.addAttribute("numeracySkillCountMap", numeracySkillCountMap);
int maxNumeracySkillCount = 0;
Collection<Integer> numeracySkillCountCollection = numeracySkillCountMap.values();
for (int count : numeracySkillCountCollection) {
if (count > maxNumeracySkillCount) {
maxNumeracySkillCount = count;
}
}
model.addAttribute("maxNumeracySkillCount", maxNumeracySkillCount);
List<Application> applications = applicationDao.readAll(contributor.getLocale());
model.addAttribute("applications", applications);
return "admin/application/list";
}
Aggregations