@Secured("ROLE_ADMIN") public List<NewEntry<City, List<NewEntry<Speciality, List<Group>>>>> getCities() { if (cities == null) { year = semesterGetter.getCurrentYear(); List<Object[]> l = groupDao.getAllGroupsAndCities(year); City c = null; Speciality s = null; NewEntry<City, List<NewEntry<Speciality, List<Group>>>> cityEntry = null; NewEntry<Speciality, List<Group>> specialityEntry = null; List<NewEntry<Speciality, List<Group>>> specList = null; List<Group> groupList = null; cities = new ArrayList<NewEntry<City, List<NewEntry<Speciality, List<Group>>>>>(); for (Object[] e : l) { Group g = (Group) e[0]; City city = (City) e[1]; if (city != c) { specList = new ArrayList<NewEntry<Speciality, List<Group>>>(); cityEntry = new NewEntry(city, specList); cities.add(cityEntry); } if (g.getSpeciality() != s) { groupList = new ArrayList<Group>(); specialityEntry = new NewEntry<Speciality, List<Group>>(g.getSpeciality(), groupList); specList.add(specialityEntry); } groupList.add(g); c = city; s = g.getSpeciality(); } } return cities; }
public int getYear() { if (year == 0) year = semesterGetter.getCurrentYear(); return year; }