Exemplo n.º 1
0
 @ResponseBody
 @RequestMapping
 public List<Area> findAreas(String cityId) {
   City city = areaService.findCity(new ObjectId(cityId));
   List<Area> areaList = new ArrayList<Area>();
   for (Area area : city.getAreas()) {
     area.setCity(null);
     areaList.add(area);
   }
   return areaList;
 }
Exemplo n.º 2
0
 @Override
 public Area createArea(ObjectId cityId, String name) {
   City city = findCity(cityId);
   if (city == null) {
     return null;
   }
   Area area = new Area();
   area.setName(name);
   area.setCity(city);
   dao.save(area);
   city.getAreas().add(area);
   dao.save(city);
   return area;
 }