コード例 #1
0
  @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";
  }
コード例 #2
0
  @RequestMapping(value = "/editkitchen", method = RequestMethod.GET)
  public String editKitchen(@RequestParam("kit") Integer Id, ModelMap map) {

    EBKitchen kit = ebKitchenService.searchKitchen(Id);
    map.addAttribute("kitedit", "true");
    map.addAttribute("kitscount", kit.getSrvCount());
    map.addAttribute("kitlat", kit.getLat());
    map.addAttribute("kitlng", kit.getLng());
    map.addAttribute("kitfund", kit.getFunds());
    map.addAttribute("kitid", Id);
    map.addAttribute("object1", ebOrgService.findAllOrganization());

    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_KITCHEN_USER")) check = true;
      }
      if (check == true) list.add(e);
    }
    map.addAttribute("object2", list);
    map.addAttribute("orgid", kit.getKitchenOrg().getId());
    map.addAttribute("adminid", kit.getEbUser().getId());

    return "addkitchen";
  }
コード例 #3
0
  @RequestMapping(value = "/addkitchen", method = RequestMethod.GET)
  public String addKitchen(
      ModelMap map, @RequestParam("lat") Double lat, @RequestParam("lng") Double lng) {

    map.addAttribute("object1", ebOrgService.findAllOrganization());
    map.addAttribute("kitedit", "false");

    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_KITCHEN_USER")) check = true;
      }
      if (check == true) list.add(e);
    }
    if (list.isEmpty()) {

      map.addAttribute("status", "No Kitchen Admin Found");
      return "sAdmin";
    }
    map.addAttribute("object2", list);
    map.addAttribute("kitlat", lat);
    map.addAttribute("kitlng", lng);
    return "addkitchen";
  }
コード例 #4
0
  @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";
  }
コード例 #5
0
  @RequestMapping(value = "/addorg", method = RequestMethod.GET)
  public String addorg(ModelMap map) {

    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);
    }
    if (list.isEmpty()) {

      map.addAttribute("status", "No Organization Admin Found");
      return "sAdmin";
    }
    map.addAttribute("object", list);
    map.addAttribute("orgedit", "false");
    return "addorg";
  }
コード例 #6
0
  @RequestMapping(value = "/newkitchen", method = RequestMethod.POST)
  public String newKitchen(
      @RequestParam("funds") String fund,
      @RequestParam("srvCount") String srvCount,
      @RequestParam("lng") double lng,
      @RequestParam("lat") double lat,
      @RequestParam("org") Integer oId,
      @RequestParam("edit") String edit,
      @RequestParam("id") Integer kId,
      @RequestParam("kitadmin") Integer admin,
      ModelMap map) {

    try {
      ebDoubleValidator.validate(fund);
      ebDoubleValidator.validate(srvCount);
    } 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_KITCHEN_USER")) check = true;
        }
        if (check == true) list.add(u);
      }
      map.addAttribute("object2", list);

      if (edit.equals("false")) {
        map.addAttribute("object1", ebOrgService.findAllOrganization());
        map.addAttribute("kitedit", "false");
        map.addAttribute("kitlat", lat);
        map.addAttribute("kitlng", lng);
        map.addAttribute("kitscount", srvCount);
        map.addAttribute("kitfund", fund);

      } else if (edit.equals("true")) {

        EBKitchen kit = ebKitchenService.searchKitchen(kId);
        map.addAttribute("kitedit", "true");
        map.addAttribute("kitscount", kit.getSrvCount());
        map.addAttribute("kitlat", kit.getLat());
        map.addAttribute("kitlng", kit.getLng());
        map.addAttribute("kitfund", kit.getFunds());
        map.addAttribute("kitid", kId);
        map.addAttribute("object1", ebOrgService.findAllOrganization());
        map.addAttribute("orgid", kit.getKitchenOrg().getId());
        map.addAttribute("adminid", kit.getEbUser().getId());
      }
      map.addAttribute("error", e.getErrorMessage());
      return "addkitchen";
    }

    EBKitchen k = null;
    EBKitchenOrg e = ebOrgService.getOrgById(oId);

    if (edit.equals("false")) {
      k = new EBKitchen();
    } else if (edit.equals("true")) {
      k = ebKitchenService.searchKitchen(kId);
    }
    k.setFunds(new Float(fund));
    k.setSrvCount(new Integer(srvCount));
    k.setLng(lng);
    k.setLat(lat);
    e.setKitchenCount(ebKitchenService.getKitchenCount(oId));
    ebKitchenService.newKitchen(k);
    k.setKitchenOrg(e);
    k.setEbUser(ebUserService.getUserById(admin));
    ebKitchenService.newKitchen(k);
    ebOrgService.saveKitchenOrg(e);

    map.addAttribute("object", ebKitchenService.getAll());
    return "viewkitchen";
  }
コード例 #7
-1
  @RequestMapping(value = "/new", method = RequestMethod.POST)
  public String newUser(
      @RequestParam("fname") String fname,
      @RequestParam("lname") String lname,
      @RequestParam("username") String username,
      @RequestParam("password") String pass,
      @RequestParam("role") String role,
      ModelMap map) {
    try {
      ebFirstNameValidator.validate(fname);
      ebLastNameValidator.validate(lname);
      ebUsernameValidator.validate(username);
      ebPasswordValidator.validate(pass);

    } catch (EBException e) {
      map.addAttribute("fname", fname);
      map.addAttribute("lname", lname);
      map.addAttribute("username", username);
      map.addAttribute("pass", pass);
      map.addAttribute("error", e.getErrorMessage());
      return "newuser";
    }

    PasswordEncoder encoder = new Md5PasswordEncoder();
    String hashedPass = encoder.encodePassword(pass, null);
    ebUserService.addUser(fname, lname, username, hashedPass);
    EBUser e = ebUserService.getUser(username);
    EBUserRole r = ebUserRoleService.getRoleByName(role);
    List<EBUserRole> list = new ArrayList<EBUserRole>();
    list.add(r);
    e.setUserRole(list);
    ebUserService.addUser(e);

    return "sAdmin";
  }