Search in sources :

Example 6 with AppCategory

use of ai.elimu.model.project.AppCategory in project webapp by elimu-ai.

the class AppCategoryEditController method handleRequest.

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(@PathVariable Long projectId, @PathVariable Long id, Model model, HttpSession session) {
    logger.info("handleRequest");
    // Needed by breadcrumbs
    Project project = projectDao.read(projectId);
    model.addAttribute("project", project);
    AppCategory appCategory = appCategoryDao.read(id);
    model.addAttribute("appCategory", appCategory);
    return "project/app-category/edit";
}
Also used : Project(ai.elimu.model.project.Project) AppCategory(ai.elimu.model.project.AppCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with AppCategory

use of ai.elimu.model.project.AppCategory in project webapp by elimu-ai.

the class AppCategoryEditController method handleSubmit.

@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String handleSubmit(HttpSession session, @PathVariable Long projectId, @Valid AppCategory appCategory, BindingResult result, Model model) {
    logger.info("handleSubmit");
    // Disallow app categories with identical name
    Project project = projectDao.read(projectId);
    List<AppCategory> existingAppCategories = project.getAppCategories();
    for (AppCategory existingAppCategory : existingAppCategories) {
        if (existingAppCategory.getName().equals(appCategory.getName()) && !existingAppCategory.getId().equals(appCategory.getId())) {
            result.rejectValue("name", "NonUnique");
            break;
        }
    }
    if (result.hasErrors()) {
        model.addAttribute("project", project);
        model.addAttribute("appCategory", appCategory);
        return "project/app-category/edit";
    } else {
        appCategoryDao.update(appCategory);
        if (EnvironmentContextLoaderListener.env == Environment.PROD) {
            // Notify project members in Slack
            Contributor contributor = (Contributor) session.getAttribute("contributor");
            String text = URLEncoder.encode(contributor.getFirstName() + " just updated an App Category:\n" + "• Project: \"" + project.getName() + "\"\n" + "• App Category: \"" + appCategory.getName() + "\"\n" + "See ") + "http://elimu.ai/project/" + project.getId();
            SlackApiHelper.postMessage("G6UR7UH2S", text, null, null);
        }
        return "redirect:/project/" + project.getId() + "/app-category/list#" + appCategory.getId();
    }
}
Also used : Project(ai.elimu.model.project.Project) Contributor(ai.elimu.model.Contributor) AppCategory(ai.elimu.model.project.AppCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with AppCategory

use of ai.elimu.model.project.AppCategory in project webapp by elimu-ai.

the class AppGroupCreateController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(@PathVariable Long projectId, @PathVariable Long appCategoryId, Model model, HttpSession session) {
    logger.info("handleRequest");
    // Needed by breadcrumbs
    Project project = projectDao.read(projectId);
    model.addAttribute("project", project);
    AppCategory appCategory = appCategoryDao.read(appCategoryId);
    model.addAttribute("appCategory", appCategory);
    AppGroup appGroup = new AppGroup();
    model.addAttribute("appGroup", appGroup);
    return "project/app-group/create";
}
Also used : Project(ai.elimu.model.project.Project) AppGroup(ai.elimu.model.project.AppGroup) AppCategory(ai.elimu.model.project.AppCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with AppCategory

use of ai.elimu.model.project.AppCategory in project webapp by elimu-ai.

the class ProjectListController method generateProjects.

private List<Project> generateProjects(Contributor contributor) {
    logger.info("generateProjects");
    List<Project> projects = new ArrayList<>();
    Project project1 = new Project();
    project1.setName("Project #1");
    project1.setManagers(Arrays.asList(contributor));
    projectDao.create(project1);
    projects.add(project1);
    AppCategory appCategory1 = new AppCategory();
    appCategory1.setName("App category #1");
    appCategoryDao.create(appCategory1);
    List<AppCategory> appCategories = new ArrayList<>();
    appCategories.add(appCategory1);
    project1.setAppCategories(appCategories);
    projectDao.update(project1);
    AppGroup appGroup1 = new AppGroup();
    appGroupDao.create(appGroup1);
    List<AppGroup> appGroups = new ArrayList<>();
    appGroups.add(appGroup1);
    appCategory1.setAppGroups(appGroups);
    appCategoryDao.update(appCategory1);
    AppCollection appCollection1 = new AppCollection();
    appCollection1.setName("App collection #1");
    appCollection1.setProject(project1);
    appCollection1.setAppCategories(Arrays.asList(appCategory1));
    appCollectionDao.create(appCollection1);
    License license1 = new License();
    license1.setAppCollection(appCollection1);
    license1.setLicenseEmail("info@elimu.ai");
    license1.setLicenseNumber("bddf-d8f4-2adf-a365");
    license1.setFirstName("Test");
    license1.setLastName("Contributor");
    licenseDao.create(license1);
    return projects;
}
Also used : Project(ai.elimu.model.project.Project) ArrayList(java.util.ArrayList) License(ai.elimu.model.project.License) AppGroup(ai.elimu.model.project.AppGroup) AppCollection(ai.elimu.model.project.AppCollection) AppCategory(ai.elimu.model.project.AppCategory)

Example 10 with AppCategory

use of ai.elimu.model.project.AppCategory in project webapp by elimu-ai.

the class AppEditController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(@PathVariable Long projectId, @PathVariable Long appCategoryId, @PathVariable Long appGroupId, @PathVariable Long applicationId, Model model) {
    logger.info("handleRequest");
    Project project = projectDao.read(projectId);
    model.addAttribute("project", project);
    AppCategory appCategory = appCategoryDao.read(appCategoryId);
    model.addAttribute("appCategory", appCategory);
    AppGroup appGroup = appGroupDao.read(appGroupId);
    model.addAttribute("appGroup", appGroup);
    Application application = applicationDao.read(applicationId);
    model.addAttribute("application", application);
    List<ApplicationVersion> applicationVersions = applicationVersionDao.readAll(application);
    model.addAttribute("applicationVersions", applicationVersions);
    model.addAttribute("applicationStatuses", ApplicationStatus.values());
    return "project/app/edit";
}
Also used : Project(ai.elimu.model.project.Project) ApplicationVersion(ai.elimu.model.admin.ApplicationVersion) AppGroup(ai.elimu.model.project.AppGroup) Application(ai.elimu.model.admin.Application) AppCategory(ai.elimu.model.project.AppCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AppCategory (ai.elimu.model.project.AppCategory)18 Project (ai.elimu.model.project.Project)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 AppGroup (ai.elimu.model.project.AppGroup)9 Contributor (ai.elimu.model.Contributor)5 ApplicationVersion (ai.elimu.model.admin.ApplicationVersion)5 Application (ai.elimu.model.admin.Application)4 ArrayList (java.util.ArrayList)3 AppCollection (ai.elimu.model.project.AppCollection)2 ApplicationGson (ai.elimu.model.gson.admin.ApplicationGson)1 ApplicationVersionGson (ai.elimu.model.gson.admin.ApplicationVersionGson)1 AppCategoryGson (ai.elimu.model.gson.project.AppCategoryGson)1 AppCollectionGson (ai.elimu.model.gson.project.AppCollectionGson)1 License (ai.elimu.model.project.License)1 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 Date (java.util.Date)1 ByteArrayApkFile (net.dongliu.apk.parser.ByteArrayApkFile)1 ApkMeta (net.dongliu.apk.parser.bean.ApkMeta)1 JSONArray (org.json.JSONArray)1