Search in sources :

Example 21 with Project

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

the class AppCollectionCreateController method handleRequest.

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

Example 22 with Project

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

the class AppCollectionEditController 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);
    AppCollection appCollection = appCollectionDao.read(id);
    model.addAttribute("appCollection", appCollection);
    List<License> licenses = licenseDao.readAll(appCollection);
    model.addAttribute("licenses", licenses);
    return "project/app-collection/edit";
}
Also used : Project(ai.elimu.model.project.Project) License(ai.elimu.model.project.License) AppCollection(ai.elimu.model.project.AppCollection) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with Project

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

the class AppGroupCreateController method handleSubmit.

@RequestMapping(method = RequestMethod.POST)
public String handleSubmit(HttpSession session, @PathVariable Long projectId, @PathVariable Long appCategoryId, @Valid AppGroup appGroup, BindingResult result, Model model) {
    logger.info("handleSubmit");
    Project project = projectDao.read(projectId);
    model.addAttribute("project", project);
    AppCategory appCategory = appCategoryDao.read(appCategoryId);
    model.addAttribute("appCategory", appCategory);
    List<AppGroup> appGroups = appCategory.getAppGroups();
    if (!appGroups.isEmpty()) {
        // Do not allow creation of a new AppGroup if an empty one already exists
        for (AppGroup existingAppGroup : appGroups) {
            if (existingAppGroup.getApplications().isEmpty()) {
                result.reject("EmptyAppGroup");
                break;
            }
        }
    }
    if (result.hasErrors()) {
        model.addAttribute("appGroup", appGroup);
        return "project/app-group/create";
    } else {
        appGroupDao.create(appGroup);
        appCategory.getAppGroups().add(appGroup);
        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 added a new App Group:\n" + "• Project: \"" + project.getName() + "\"\n" + "• App Category: \"" + appCategory.getName() + "\"\n" + "See ") + "http://elimu.ai/project/" + project.getId() + "/app-category/" + appCategory.getId() + "/app-group/list";
            SlackApiHelper.postMessage("G6UR7UH2S", text, null, null);
        }
        return "redirect:/project/" + project.getId() + "/app-category/" + appCategory.getId() + "/app-group/list";
    }
}
Also used : Project(ai.elimu.model.project.Project) Contributor(ai.elimu.model.Contributor) AppGroup(ai.elimu.model.project.AppGroup) AppCategory(ai.elimu.model.project.AppCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with Project

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

the class AppGroupListController method handlRequest.

@RequestMapping(value = "/list", method = RequestMethod.GET)
public String handlRequest(Model model, @PathVariable Long projectId, @PathVariable Long appCategoryId, 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);
    return "project/app-group/list";
}
Also used : Project(ai.elimu.model.project.Project) AppCategory(ai.elimu.model.project.AppCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with Project

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

the class LicenseCreateController method handleRequest.

@RequestMapping(method = RequestMethod.GET)
public String handleRequest(@PathVariable Long projectId, @PathVariable Long appCollectionId, Model model, HttpSession session) {
    logger.info("handleRequest");
    // Needed by breadcrumbs
    Project project = projectDao.read(projectId);
    model.addAttribute("project", project);
    AppCollection appCollection = appCollectionDao.read(appCollectionId);
    model.addAttribute("appCollection", appCollection);
    License license = new License();
    license.setLicenseNumber(LicenseGenerator.generateLicenseNumber());
    license.setAppCollection(appCollection);
    model.addAttribute("license", license);
    return "project/license/create";
}
Also used : Project(ai.elimu.model.project.Project) License(ai.elimu.model.project.License) 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