use of ai.elimu.model.gson.admin.ApplicationGson 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;
}
}
use of ai.elimu.model.gson.admin.ApplicationGson in project webapp by elimu-ai.
the class JsonService method addInfrastructureApps.
/**
* As AppCollections in Custom Projects do not include all the Applications from the open source
* version, some apps are required to form the basic infrastructure.
*/
private void addInfrastructureApps(JSONArray applications) {
logger.info("addInfrastructureApps");
// Appstore
Application applicationAppstore = applicationDao.readByPackageName(Locale.EN, "ai.elimu.appstore_custom");
if (applicationAppstore != null) {
ApplicationGson applicationGson = JavaToGsonConverter.getApplicationGson(applicationAppstore);
// Fetch the Application's ApplicationVersions
List<ApplicationVersionGson> applicationVersions = new ArrayList<>();
for (ApplicationVersion applicationVersion : applicationVersionDao.readAll(applicationAppstore)) {
ApplicationVersionGson applicationVersionGson = JavaToGsonConverter.getApplicationVersionGson(applicationVersion);
applicationVersions.add(applicationVersionGson);
}
applicationGson.setApplicationVersions(applicationVersions);
String json = new Gson().toJson(applicationGson);
applications.put(new JSONObject(json));
}
// Analytics
Application applicationAnalytics = applicationDao.readByPackageName(Locale.EN, "ai.elimu.analytics");
if (applicationAnalytics != null) {
ApplicationGson applicationGson = JavaToGsonConverter.getApplicationGson(applicationAnalytics);
// Fetch the Application's ApplicationVersions
List<ApplicationVersionGson> applicationVersions = new ArrayList<>();
for (ApplicationVersion applicationVersion : applicationVersionDao.readAll(applicationAnalytics)) {
ApplicationVersionGson applicationVersionGson = JavaToGsonConverter.getApplicationVersionGson(applicationVersion);
applicationVersions.add(applicationVersionGson);
}
applicationGson.setApplicationVersions(applicationVersions);
String json = new Gson().toJson(applicationGson);
applications.put(new JSONObject(json));
}
// Custom Launcher
Application applicationLauncher = applicationDao.readByPackageName(Locale.EN, "ai.elimu.launcher_custom");
if (applicationLauncher != null) {
ApplicationGson applicationGson = JavaToGsonConverter.getApplicationGson(applicationLauncher);
// Fetch the Application's ApplicationVersions
List<ApplicationVersionGson> applicationVersions = new ArrayList<>();
for (ApplicationVersion applicationVersion : applicationVersionDao.readAll(applicationLauncher)) {
ApplicationVersionGson applicationVersionGson = JavaToGsonConverter.getApplicationVersionGson(applicationVersion);
applicationVersions.add(applicationVersionGson);
}
applicationGson.setApplicationVersions(applicationVersions);
String json = new Gson().toJson(applicationGson);
applications.put(new JSONObject(json));
}
}
use of ai.elimu.model.gson.admin.ApplicationGson in project webapp by elimu-ai.
the class JsonService method getApplications.
/**
* Returns app collection for custom project.
*/
@Cacheable(value = "applicationsInAppCollection", key = "#appCollection.id")
public JSONArray getApplications(AppCollection appCollection) {
logger.info("getApplications_appCollection");
Date dateStart = new Date();
JSONArray applications = new JSONArray();
addInfrastructureApps(applications);
for (AppCategory appCategory : appCollection.getAppCategories()) {
for (AppGroup appGroup : appCategory.getAppGroups()) {
for (Application application : appGroup.getApplications()) {
ApplicationGson applicationGson = JavaToGsonConverter.getApplicationGson(application);
// Fetch the Application's ApplicationVersions
List<ApplicationVersionGson> applicationVersions = new ArrayList<>();
logger.info("applicationVersionDao.readAll(" + application.getPackageName() + ") - " + new Date());
for (ApplicationVersion applicationVersion : applicationVersionDao.readAll(application)) {
logger.info("applicationVersion: " + applicationVersion.getVersionCode() + " - " + new Date());
ApplicationVersionGson applicationVersionGson = JavaToGsonConverter.getApplicationVersionGson(applicationVersion);
applicationVersions.add(applicationVersionGson);
}
applicationGson.setApplicationVersions(applicationVersions);
String json = new Gson().toJson(applicationGson);
applications.put(new JSONObject(json));
}
}
}
Date dateEnd = new Date();
logger.info("getApplicationVersions duration: " + (dateEnd.getTime() - dateStart.getTime()) + " ms");
return applications;
}
use of ai.elimu.model.gson.admin.ApplicationGson in project webapp by elimu-ai.
the class JavaToGsonConverter method getApplicationGson.
public static ApplicationGson getApplicationGson(Application application) {
if (application == null) {
return null;
} else {
ApplicationGson applicationGson = new ApplicationGson();
applicationGson.setId(application.getId());
applicationGson.setLocale(application.getLocale());
applicationGson.setPackageName(application.getPackageName());
applicationGson.setLiteracySkills(application.getLiteracySkills());
applicationGson.setNumeracySkills(application.getNumeracySkills());
applicationGson.setApplicationStatus(application.getApplicationStatus());
return applicationGson;
}
}
use of ai.elimu.model.gson.admin.ApplicationGson in project webapp by elimu-ai.
the class JsonService method getApplications.
@Cacheable("applications")
public JSONArray getApplications(Locale locale) {
logger.info("getApplications");
Date dateStart = new Date();
JSONArray applications = new JSONArray();
for (Application application : applicationDao.readAll(locale)) {
ApplicationGson applicationGson = JavaToGsonConverter.getApplicationGson(application);
List<ApplicationVersionGson> applicationVersions = new ArrayList<>();
logger.info("applicationVersionDao.readAll(" + application.getPackageName() + ") - " + new Date());
for (ApplicationVersion applicationVersion : applicationVersionDao.readAll(application)) {
logger.info("applicationVersion: " + applicationVersion.getVersionCode() + " - " + new Date());
ApplicationVersionGson applicationVersionGson = JavaToGsonConverter.getApplicationVersionGson(applicationVersion);
applicationVersions.add(applicationVersionGson);
}
applicationGson.setApplicationVersions(applicationVersions);
String json = new Gson().toJson(applicationGson);
applications.put(new JSONObject(json));
}
Date dateEnd = new Date();
logger.info("getApplications duration: " + (dateEnd.getTime() - dateStart.getTime()) + " ms");
return applications;
}
Aggregations