Class CityServiceImpl

java.lang.Object
org.localify.city.CityServiceImpl
All Implemented Interfaces:
CityService

@Service @Transactional public class CityServiceImpl extends Object implements CityService
Implementation of the CityService interface.
  • Constructor Details

    • CityServiceImpl

      public CityServiceImpl(CityRepository cityRepository, EventRepository eventRepository, PointUtil pointUtil, ArtistCityRepository artistCityRepository, VenueRepository venueRepository, PlaylistService playlistService, UserFavoriteEventRepository userFavoriteEventRepository, UserCityRepository userCityRepository, UserRecentCityViewRepository userRecentCityViewRepository, UserRepository userRepository, LocalifyProperties properties, UserFavoriteArtistRepository userFavoriteArtistRepository)
      Constructs a new CityServiceImpl.
      Parameters:
      cityRepository - The city repository.
      eventRepository - The event repository.
      pointUtil - The point utility.
      artistCityRepository - The artist-city repository.
      venueRepository - The venue repository.
      playlistService - The playlist service.
      userFavoriteEventRepository - The user favorite event repository.
      userCityRepository - The user-city repository.
      userRecentCityViewRepository - The user recent city view repository.
      userRepository - The user repository.
      properties - The application properties.
      userFavoriteArtistRepository - The user favorite artist repository.
  • Method Details

    • getById

      public CityResponse getById(UUID cityId)
      Description copied from interface: CityService
      Gets a city by its ID.
      Specified by:
      getById in interface CityService
      Parameters:
      cityId - The ID of the city.
      Returns:
      The city response.
    • getByIdExtended

      public CityResponseExtended getByIdExtended(UUID cityId)
      Description copied from interface: CityService
      Gets an extended city response by its ID.
      Specified by:
      getByIdExtended in interface CityService
      Parameters:
      cityId - The ID of the city.
      Returns:
      The extended city response.
    • patchById

      public CityResponse patchById(UUID cityId, CityPatchRequest request)
      Description copied from interface: CityService
      Patches a city by its ID.
      Specified by:
      patchById in interface CityService
      Parameters:
      cityId - The ID of the city.
      request - The patch request.
      Returns:
      The updated city response.
    • deleteById

      public void deleteById(UUID cityId)
      Description copied from interface: CityService
      Deletes a city by its ID.
      Specified by:
      deleteById in interface CityService
      Parameters:
      cityId - The ID of the city.
    • getEvents

      public org.springframework.data.domain.Page<EventResponseExtendedLocal> getEvents(UUID cityId, PageOptions options, UUID userId)
      Description copied from interface: CityService
      Gets the events for a city.
      Specified by:
      getEvents in interface CityService
      Parameters:
      cityId - The ID of the city.
      options - The page options.
      userId - The ID of the user.
      Returns:
      A page of events.
    • getArtists

      public org.springframework.data.domain.Page<City.CityArtistApiResponse> getArtists(UUID cityId, PageOptions options, UUID userId)
      Description copied from interface: CityService
      Gets the artists for a city.
      Specified by:
      getArtists in interface CityService
      Parameters:
      cityId - The ID of the city.
      options - The page options.
      userId - The ID of the user.
      Returns:
      A page of artists.
    • getVenues

      public org.springframework.data.domain.Page<VenueEventNumResponse> getVenues(UUID cityId, PageOptions options)
      Description copied from interface: CityService
      Gets the venues for a city.
      Specified by:
      getVenues in interface CityService
      Parameters:
      cityId - The ID of the city.
      options - The page options.
      Returns:
      A page of venues.
    • getRelevantCities

      public List<CityResponse> getRelevantCities(@Nullable String query, double latitude, double longitude)
      Description copied from interface: CityService
      Gets the relevant cities for a given query and location.
      Specified by:
      getRelevantCities in interface CityService
      Parameters:
      query - The search query.
      latitude - The latitude.
      longitude - The longitude.
      Returns:
      A list of relevant cities.
    • getNearestCities

      public List<CityResponse> getNearestCities(double latitude, double longitude)
      Description copied from interface: CityService
      Gets the nearest cities to a given location.
      Specified by:
      getNearestCities in interface CityService
      Parameters:
      latitude - The latitude.
      longitude - The longitude.
      Returns:
      A list of nearest cities.
    • createPlaylist

      public PlaylistDto createPlaylist(City city)
      Description copied from interface: CityService
      Creates a playlist for a city.
      Specified by:
      createPlaylist in interface CityService
      Parameters:
      city - The city.
      Returns:
      The created playlist.
    • getOrCreatePlaylist

      public PlaylistDto getOrCreatePlaylist(UUID cityId)
      Description copied from interface: CityService
      Gets or creates a playlist for a city.
      Specified by:
      getOrCreatePlaylist in interface CityService
      Parameters:
      cityId - The ID of the city.
      Returns:
      The playlist.
    • recordUserCityView

      @Transactional public void recordUserCityView(UUID cityId, UUID userId)
      Records a user's view of a city.
      Parameters:
      cityId - The ID of the city.
      userId - The ID of the user.
    • getByIdWithArtists

      public CityArtistsResponse getByIdWithArtists(UUID userId, UUID cityId)
      Description copied from interface: CityService
      Gets a city with its artists by its ID.
      Specified by:
      getByIdWithArtists in interface CityService
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      Returns:
      The city artists response.
    • getCityArtistProportions

      public List<CityArtistProportionResponse> getCityArtistProportions(PageOptions pageOptions)
      Description copied from interface: CityService
      Gets the city-artist proportions.
      Specified by:
      getCityArtistProportions in interface CityService
      Parameters:
      pageOptions - The page options.
      Returns:
      A list of city-artist proportion responses.
    • getCityArtistProportionsByCreation

      public List<CityArtistProportionResponse> getCityArtistProportionsByCreation(PageOptions pageOptions)
      Description copied from interface: CityService
      Gets the city-artist proportions, ordered by creation date.
      Specified by:
      getCityArtistProportionsByCreation in interface CityService
      Parameters:
      pageOptions - The page options.
      Returns:
      A list of city-artist proportion responses.
    • findOrCreateCity

      @Transactional public City findOrCreateCity(String locationText)
      Description copied from interface: CityService
      Finds or creates a city from a location string.
      Specified by:
      findOrCreateCity in interface CityService
      Parameters:
      locationText - The location string.
      Returns:
      The found or created city.
    • findCityTimezone

      @Transactional public void findCityTimezone(City city)
      Description copied from interface: CityService
      Finds the timezone for a city.
      Specified by:
      findCityTimezone in interface CityService
      Parameters:
      city - The city.