private boolean deleteNonServerUniversity(List<String> incomingUniversityNames) { boolean changed = false; List<University> mealsInDbAndServer = universityDao.notInNamesList(incomingUniversityNames); for (University university : mealsInDbAndServer) { universityDao.delete(university.getId()); changed = true; } return changed; }
private boolean syncMealsServer( List<University> mealsInDbAndServer, List<University> incomingUniversities) { boolean changed = false; for (University databaseUniversity : mealsInDbAndServer) { for (University serverUniversity : incomingUniversities) { if (serverUniversity.getName().equals(databaseUniversity.getName())) { serverUniversity.setId(databaseUniversity.getId()); } } } for (University university : incomingUniversities) { boolean changedMeal = mealService.syncMeals(university.getMeals(), university); if (changedMeal) changed = true; } return changed; }