/** Loads an advertisement category by id */ @RequestMapping(value = "adCategories/{id}", method = RequestMethod.GET) @ResponseBody public AdCategoryHierarchicalVO loadById(@PathVariable final Long id) { AdCategory category; try { category = adCategoryService.load(id); } catch (Exception e) { throw new EntityNotFoundException(Ad.class); } return adCategoryService.getHierarchicalVO(category); }
/** Lists the category hierarchy */ @RequestMapping(value = "adCategories", method = RequestMethod.GET) @ResponseBody public List<AdCategoryHierarchicalVO> listChildren() { List<AdCategoryHierarchicalVO> vos = new ArrayList<AdCategoryHierarchicalVO>(); for (AdCategory category : adCategoryService.listRoot()) { AdCategoryHierarchicalVO vo = adCategoryService.getHierarchicalVO(category); if (vo != null) { vos.add(vo); } } return vos; }