use of ai.elimu.model.project.Project in project webapp by elimu-ai.
the class AppEditController method handleSubmit.
@RequestMapping(method = RequestMethod.POST)
public String handleSubmit(@PathVariable Long projectId, @PathVariable Long appCategoryId, @PathVariable Long appGroupId, @PathVariable Long applicationId, HttpSession session, @Valid Application application, 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);
AppGroup appGroup = appGroupDao.read(appGroupId);
model.addAttribute("appGroup", appGroup);
if (result.hasErrors()) {
model.addAttribute("application", application);
List<ApplicationVersion> applicationVersions = applicationVersionDao.readAll(application);
model.addAttribute("applicationVersions", applicationVersions);
model.addAttribute("applicationStatuses", ApplicationStatus.values());
return "project/app/edit";
} else {
applicationDao.update(application);
if (application.getApplicationStatus() == ApplicationStatus.DELETED) {
// Delete corresponding ApplicationVersions
List<ApplicationVersion> applicationVersions = applicationVersionDao.readAll(application);
for (ApplicationVersion applicationVersion : applicationVersions) {
applicationVersionDao.delete(applicationVersion);
}
// Refresh REST API cache
// jsonService.refreshApplicationsInAppCollection(appCollection);
jsonService.refreshApplicationsInAppCollection();
if (EnvironmentContextLoaderListener.env == Environment.PROD) {
// Notify project members in Slack
Contributor contributor = (Contributor) session.getAttribute("contributor");
String text = URLEncoder.encode(contributor.getFirstName() + " just deleted an Application:\n" + "• Project: \"" + project.getName() + "\"\n" + "• App Category: \"" + appCategory.getName() + "\"\n" + "• Package name: \"" + application.getPackageName() + "\"\n" + "See ") + "http://elimu.ai/project/" + project.getId() + "/app-category/" + appCategory.getId() + "/app-group/" + appGroup.getId() + "/app/" + application.getId() + "/edit";
SlackApiHelper.postMessage("G6UR7UH2S", text, null, null);
}
}
return "redirect:/project/" + projectId + "/app-category/" + appCategoryId + "/app-group/" + appGroupId + "/app/list";
}
}
use of ai.elimu.model.project.Project 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";
}
use of ai.elimu.model.project.Project 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();
}
}
use of ai.elimu.model.project.Project in project webapp by elimu-ai.
the class AppCollectionEditController method handleSubmit.
@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String handleSubmit(HttpSession session, @PathVariable Long projectId, @Valid AppCollection appCollection, BindingResult result, Model model) {
logger.info("handleSubmit");
// Disallow app collections with identical name
Project project = projectDao.read(projectId);
List<AppCollection> existingAppCollections = appCollectionDao.readAll(project);
for (AppCollection existingAppCollection : existingAppCollections) {
if (existingAppCollection.getName().equals(appCollection.getName()) && !existingAppCollection.getId().equals(appCollection.getId())) {
result.rejectValue("name", "NonUnique");
break;
}
}
if (result.hasErrors()) {
model.addAttribute("project", project);
model.addAttribute("appCollection", appCollection);
List<License> licenses = licenseDao.readAll(appCollection);
model.addAttribute("licenses", licenses);
return "project/app-collection/edit";
} else {
appCollectionDao.update(appCollection);
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 Collection:\n" + "• Project: \"" + project.getName() + "\"\n" + "• App Collection: \"" + appCollection.getName() + "\"\n" + "See ") + "http://elimu.ai/project/" + project.getId() + "/app-collection/edit/" + appCollection.getId();
SlackApiHelper.postMessage("G6UR7UH2S", text, null, null);
}
return "redirect:/project/" + project.getId();
}
}
use of ai.elimu.model.project.Project 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";
}
Aggregations