content: package com.example.demo.service.impl;
  
  import com.example.demo.domain.Location;
  import com.example.demo.repository.LocationRepository;
  import com.example.demo.service.LocationService;
  import java.util.List;
  import java.util.Optional;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  
  /**
   * Service Implementation for managing {@link Location}.
   */
  @Service
  @Transactional
  public class LocationServiceImpl implements LocationService {
  
      private final Logger log = LoggerFactory.getLogger(LocationServiceImpl.class);
  
      private final LocationRepository locationRepository;
  
      public LocationServiceImpl(LocationRepository locationRepository) {
          this.locationRepository = locationRepository;
      }
  
      @Override
      public Location save(Location location) {
          log.debug("Request to save Location : {}", location);
          return locationRepository.save(location);
      }
  
      @Override
      public Optional<Location> partialUpdate(Location location) {
          log.debug("Request to partially update Location : {}", location);
  
          return locationRepository
              .findById(location.getId())
              .map(existingLocation -> {
                  if (location.getStreetAddress() != null) {
                      existingLocation.setStreetAddress(location.getStreetAddress());
                  }
                  if (location.getPostalCode() != null) {
                      existingLocation.setPostalCode(location.getPostalCode());
                  }
                  if (location.getCity() != null) {
                      existingLocation.setCity(location.getCity());
                  }
                  if (location.getStateProvince() != null) {
                      existingLocation.setStateProvince(location.getStateProvince());
                  }
  
                  return existingLocation;
              })
              .map(locationRepository::save);
      }
  
      @Override
      @Transactional(readOnly = true)
      public List<Location> findAll() {
          log.debug("Request to get all Locations");
          return locationRepository.findAll();
      }
  
      @Override
      @Transactional(readOnly = true)
      public Optional<Location> findOne(Long id) {
          log.debug("Request to get Location : {}", id);
          return locationRepository.findById(id);
      }
  
      @Override
      public void delete(Long id) {
          log.debug("Request to delete Location : {}", id);
          locationRepository.deleteById(id);
      }
  }
  