Package model

Examples of model.Unit


     }
   }

  @Transactional
  public void deleteDataById(Long id) {
    Unit unit = em.find(Unit.class, id);
    if (unit != null) {
      em.remove(unit);
    }
  }
View Full Code Here


    private Dao dao;
   
  @RequestMapping("/view/{unitCode}")
  public String view(@ModelAttribute("viewForm") UnitForm form,
      @PathVariable("unitCode") String unitCode, ModelMap model) {
    Unit unit = dao.getUnitByCode(unitCode);
    if (unit != null) {
      form.setUnit(unit);
      Unit superUnit;
      if (unit.getSuper_unit_id() == null) {
        superUnit = new Unit();
        superUnit.setName("");
        superUnit.setCode("");
      } else {
        superUnit = dao.getUnitById(unit.getSuper_unit_id());
      }
      model.addAttribute("superUnit", superUnit);
      model.addAttribute("subUnits", dao.getSubUnitById(unit.getId()));
View Full Code Here

  @RequestMapping("/addForm")
  public String addForm(@ModelAttribute("addForm") UnitForm form,
      ModelMap model) {
    List<Unit> unitNames = new ArrayList<Unit>();
    unitNames = dao.findAllDepartments();
    unitNames.add(0, new Unit());
    model.addAttribute("unitNames", unitNames);
    form.setMap(dao.getChannelTypes());
    return "add";
  }
View Full Code Here

  @RequestMapping(value = "/save", method = RequestMethod.POST)
  public String save(ModelMap model,
      @Valid @ModelAttribute("addForm") UnitForm saveForm,
      BindingResult result) {
    String code = saveForm.getSuperUnitCode();
    Unit unit = saveForm.getUnit();



      if (saveForm.getChannelWithDeletePressed() != null) {
        saveForm.removeChannel(saveForm.getChannelWithDeletePressed());
        return "add";
      } else if (saveForm.getAddChannelButton() != null) {
        saveForm.getChannels().add(new Channel());
        return "add";
      } else {
        Unit units = saveForm.getUnit();
        units.addChannels(saveForm.getChannels());
        if (code != null && !code.isEmpty()) {
          Long superUnit = dao.getUnitByCode(code).getId();
          unit.setSuper_unit_id(superUnit);
        }
        units.setChannels(saveForm.getChannels());
      if (result.hasErrors()) {
        return "add";
      }
        dao.save(units);
      return "redirect:/search";
View Full Code Here

TOP

Related Classes of model.Unit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.