Search in sources :

Example 16 with Project

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

the class AppListController method handlRequest.

@RequestMapping(value = "/list", method = RequestMethod.GET)
public String handlRequest(Model model, @PathVariable Long projectId, @PathVariable Long appCategoryId, @PathVariable Long appGroupId, HttpSession session) {
    logger.info("handleRequest");
    logger.info("projectId: " + projectId);
    Project project = projectDao.read(projectId);
    model.addAttribute("project", project);
    logger.info("appCategoryId: " + appCategoryId);
    AppCategory appCategory = appCategoryDao.read(appCategoryId);
    model.addAttribute("appCategory", appCategory);
    logger.info("appGroupId: " + appGroupId);
    AppGroup appGroup = appGroupDao.read(appGroupId);
    model.addAttribute("appGroup", appGroup);
    return "project/app/list";
}
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 17 with Project

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

the class AppCategoryCreateController method handleRequest.

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

Example 18 with Project

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

the class AppCategoryCreateController method handleSubmit.

@RequestMapping(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())) {
            result.rejectValue("name", "NonUnique");
            break;
        }
    }
    if (result.hasErrors()) {
        model.addAttribute("project", project);
        model.addAttribute("appCategory", appCategory);
        return "project/app-category/create";
    } else {
        appCategoryDao.create(appCategory);
        project.getAppCategories().add(appCategory);
        projectDao.update(project);
        if (EnvironmentContextLoaderListener.env == Environment.PROD) {
            // Notify project members in Slack
            Contributor contributor = (Contributor) session.getAttribute("contributor");
            String text = URLEncoder.encode(contributor.getFirstName() + " just added a new 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 19 with Project

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

the class AppCategoryListController method handlRequest.

@RequestMapping(value = "/list", method = RequestMethod.GET)
public String handlRequest(Model model, @PathVariable Long projectId, HttpSession session) {
    logger.info("handleRequest");
    logger.info("projectId: " + projectId);
    Project project = projectDao.read(projectId);
    model.addAttribute("project", project);
    List<AppCollection> appCollections = appCollectionDao.readAll(project);
    model.addAttribute("appCollections", appCollections);
    return "project/app-category/list";
}
Also used : Project(ai.elimu.model.project.Project) AppCollection(ai.elimu.model.project.AppCollection) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with Project

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

the class AppCollectionCreateController method handleSubmit.

@RequestMapping(method = RequestMethod.POST)
public String handleSubmit(HttpSession session, @Valid AppCollection appCollection, BindingResult result, Model model) {
    logger.info("handleSubmit");
    Project project = appCollection.getProject();
    model.addAttribute("project", project);
    // Disallow app collections with identical name
    List<AppCollection> existingAppCollections = appCollectionDao.readAll(project);
    for (AppCollection existingAppCollection : existingAppCollections) {
        if (existingAppCollection.getName().equals(appCollection.getName())) {
            result.rejectValue("name", "NonUnique");
            break;
        }
    }
    if (result.hasErrors()) {
        model.addAttribute("appCollection", appCollection);
        return "project/app-collection/create";
    } else {
        appCollectionDao.create(appCollection);
        if (EnvironmentContextLoaderListener.env == Environment.PROD) {
            // Notify project members in Slack
            Contributor contributor = (Contributor) session.getAttribute("contributor");
            String text = URLEncoder.encode(contributor.getFirstName() + " just added a new App Collection:\n" + "• Project: \"" + appCollection.getProject().getName() + "\"\n" + "• App Collection: \"" + appCollection.getName() + "\"\n" + "See ") + "http://elimu.ai/project/" + appCollection.getProject().getId();
            SlackApiHelper.postMessage("G6UR7UH2S", text, null, null);
        }
        return "redirect:/project/" + appCollection.getProject().getId();
    }
}
Also used : Project(ai.elimu.model.project.Project) Contributor(ai.elimu.model.Contributor) AppCollection(ai.elimu.model.project.AppCollection) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Project (ai.elimu.model.project.Project)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)24 AppCategory (ai.elimu.model.project.AppCategory)14 Contributor (ai.elimu.model.Contributor)12 AppCollection (ai.elimu.model.project.AppCollection)8 AppGroup (ai.elimu.model.project.AppGroup)8 License (ai.elimu.model.project.License)5 ApplicationVersion (ai.elimu.model.admin.ApplicationVersion)4 Application (ai.elimu.model.admin.Application)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ByteArrayApkFile (net.dongliu.apk.parser.ByteArrayApkFile)1 ApkMeta (net.dongliu.apk.parser.bean.ApkMeta)1 Test (org.junit.Test)1