@RequestMapping(value = "/editorg", method = RequestMethod.GET) public String editOrg(@RequestParam("org") Integer Id, ModelMap map) { EBKitchenOrg org = ebOrgService.getOrgById(Id); String name = org.getName(); float fund = org.getFunds(); map.addAttribute("orgedit", "true"); map.addAttribute("orgname", name); map.addAttribute("orgfund", fund); map.addAttribute("orgid", Id); map.addAttribute("adminid", org.getEbUser().getId()); List<EBUser> list = new ArrayList<EBUser>(); boolean check = false; for (EBUser e : ebUserService.getAllUser()) { check = false; for (EBUserRole r : e.getUserRole()) { if (r.getRoleName().equals("ROLE_ORG_USER")) check = true; } if (check == true) list.add(e); } map.addAttribute("object", list); return "addorg"; }
@RequestMapping(value = "/neworg", method = RequestMethod.POST) public String newOrg( @RequestParam("organization") String name, @RequestParam("fund") String fund, @RequestParam("edit") String edit, @RequestParam("id") Integer Id, @RequestParam("orgadmin") Integer admin, ModelMap map) { try { ebOrganizationValidator.validate(name); ebDoubleValidator.validate(fund); } catch (EBException e) { List<EBUser> list = new ArrayList<EBUser>(); boolean check = false; for (EBUser u : ebUserService.getAllUser()) { check = false; for (EBUserRole r : u.getUserRole()) { if (r.getRoleName().equals("ROLE_ORG_USER")) check = true; } if (check == true) list.add(u); } map.addAttribute("object", list); if (edit.equals("false")) { map.addAttribute("orgedit", "false"); } else if (edit.equals("true")) { EBKitchenOrg org = ebOrgService.getOrgById(Id); String Oname = org.getName(); float Ofund = org.getFunds(); map.addAttribute("orgedit", "true"); map.addAttribute("orgname", Oname); map.addAttribute("orgfund", Ofund); map.addAttribute("orgid", Id); map.addAttribute("adminid", org.getEbUser().getId()); } map.addAttribute("error", e.getErrorMessage()); return "addorg"; } EBKitchenOrg org = null; if (edit.equals("false")) { org = new EBKitchenOrg(); org.setKitchenCount(0); } else if (edit.equals("true")) { org = ebOrgService.getOrgById(Id); } org.setName(name); org.setFunds(new Float(fund)); ebOrgService.saveKitchenOrg(org); org.setEbUser(ebUserService.getUserById(admin)); ebOrgService.saveKitchenOrg(org); map.addAttribute("object", ebOrgService.findAllOrganization()); return "vieworg"; }