use of ai.elimu.model.gson.admin.ApplicationVersionGson in project webapp by elimu-ai.
the class JavaToGsonConverter method getApplicationVersionGson.
public static ApplicationVersionGson getApplicationVersionGson(ApplicationVersion applicationVersion) {
if (applicationVersion == null) {
return null;
} else {
ApplicationVersionGson applicationVersionGson = new ApplicationVersionGson();
applicationVersionGson.setId(applicationVersion.getId());
applicationVersionGson.setApplication(getApplicationGson(applicationVersion.getApplication()));
applicationVersionGson.setFileSizeInKb(applicationVersion.getFileSizeInKb());
applicationVersionGson.setFileUrl("/apk/" + applicationVersion.getApplication().getPackageName() + "-" + applicationVersion.getVersionCode() + ".apk");
applicationVersionGson.setChecksumMd5(applicationVersion.getChecksumMd5());
applicationVersionGson.setContentType(applicationVersion.getContentType());
applicationVersionGson.setVersionCode(applicationVersion.getVersionCode());
applicationVersionGson.setVersionName(applicationVersion.getVersionName());
applicationVersionGson.setLabel(applicationVersion.getLabel());
applicationVersionGson.setMinSdkVersion(applicationVersion.getMinSdkVersion());
applicationVersionGson.setStartCommand(applicationVersion.getStartCommand());
applicationVersionGson.setTimeUploaded(applicationVersion.getTimeUploaded());
return applicationVersionGson;
}
}
use of ai.elimu.model.gson.admin.ApplicationVersionGson 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.ApplicationVersionGson 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.ApplicationVersionGson 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