use of ai.elimu.model.project.AppGroup 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;
}
use of ai.elimu.model.project.AppGroup 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";
}
use of ai.elimu.model.project.AppGroup 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";
}
use of ai.elimu.model.project.AppGroup 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";
}
}
use of ai.elimu.model.project.AppGroup in project webapp by elimu-ai.
the class StringToAppGroupConverter method convert.
/**
* Convert AppGroup id to AppGroup entity
*/
public AppGroup convert(String id) {
if (StringUtils.isBlank(id)) {
return null;
} else {
Long appGroupId = Long.parseLong(id);
AppGroup appGroup = appGroupDao.read(appGroupId);
return appGroup;
}
}
Aggregations