Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - @Override
 - @Transactional(readOnly = true)
 - public Set<Location> getAllLocationDescendants(Location location, Set<Location> descendants) {
 - if (descendants == null)
 - descendants = new HashSet<Location>();
 - if (location != null) {
 - Set<Location> childLocations = location.getChildLocations();
 - for (Location childLocation : childLocations) {
 - descendants.add(childLocation);
 - getAllLocationDescendants(childLocation, descendants);
 - }
 - }
 - return descendants;
 - }
 - @Override
 - @Transactional(readOnly = true)
 - public List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate, Location location, Provider provider,
 - AppointmentType type, String status) throws APIException {
 - List<Appointment> appointments = appointmentDAO.getAppointmentsByConstraints(fromDate, toDate, provider, type,
 - status);
 - List<Appointment> appointmentsInLocation = new LinkedList<Appointment>();
 - Set<Location> relevantLocations = getAllLocationDescendants(location, null);
 - relevantLocations.add(location);
 - for (Appointment appointment : appointments) {
 - boolean satisfyingConstraints = true;
 - //Filter by location
 - if (location != null) {
 - if (relevantLocations.contains(appointment.getTimeSlot().getAppointmentBlock().getLocation()))
 - appointmentsInLocation.add(appointment);
 - } else
 - appointmentsInLocation.add(appointment);
 - }
 - return appointmentsInLocation;
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment