private String createMetaKeywords(final PointOfServiceData pointOfServiceData) {
    final AddressData address = pointOfServiceData.getAddress();

    final String[] keywords = {
      address.getTown(), address.getPostalCode(), address.getCountry().getName()
    };
    return StringUtils.join(keywords, ',');
  }
  @RequestMapping(value = STORE_CODE_PATH_VARIABLE_PATTERN + "/map", method = RequestMethod.GET)
  public String viewMap(@PathVariable("storeCode") final String storeCode, final Model model)
      throws GeoLocatorException, MapServiceException, CMSItemNotFoundException {
    final StoreFinderForm storeFinderForm = new StoreFinderForm();
    model.addAttribute("storeFinderForm", storeFinderForm);
    final StorePositionForm storePositionForm = new StorePositionForm();
    model.addAttribute("storePositionForm", storePositionForm);

    final PointOfServiceData pointOfServiceData =
        storeFinderFacade.getPointOfServiceForName(storeCode);
    pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
    model.addAttribute("store", pointOfServiceData);

    storeCmsPageInModel(model, getStoreFinderPage());
    model.addAttribute(
        WebConstants.BREADCRUMBS_KEY,
        storeBreadcrumbBuilder.getBreadcrumbsForSubPage(
            pointOfServiceData, "storeDetails.map.link"));

    return ControllerConstants.Views.Pages.StoreFinder.StoreFinderViewMapPage;
  }
Beispiel #3
0
 /**
  * JSP EL Function to get an Image for a Store in a specific format
  *
  * @param store the store
  * @param format the desired image format
  * @return the image
  */
 public static ImageData getImageForStoreAndFormat(
     final PointOfServiceData store, final String format) {
   if (store != null && format != null) {
     final Collection<ImageData> images = store.getStoreImages();
     if (images != null && !images.isEmpty()) {
       for (final ImageData image : images) {
         if (format.equals(image.getFormat())) {
           return image;
         }
       }
     }
   }
   return null;
 }
  @Override
  public void populate(final SOURCE source, final TARGET target) {
    target.setPagination(source.getPagination());
    target.setSorts(source.getSorts());
    target.setResults(
        Converters.convertAll(source.getResults(), getPointOfServiceDistanceConverter()));

    target.setLocationText(source.getLocationText());
    target.setSourceLatitude(source.getSourceLatitude());
    target.setSourceLongitude(source.getSourceLongitude());
    target.setBoundNorthLatitude(source.getBoundNorthLatitude());
    target.setBoundSouthLatitude(source.getBoundSouthLatitude());
    target.setBoundWestLongitude(source.getBoundWestLongitude());
    target.setBoundEastLongitude(source.getBoundEastLongitude());

    if (target.getResults() != null && !target.getResults().isEmpty()) {
      final String urlPrefix = "/store/";
      final String urlQueryParams = getStoreUrlQueryParams(target);

      for (final PointOfServiceData pointOfService : target.getResults()) {
        pointOfService.setUrl(urlPrefix + pointOfService.getName() + urlQueryParams);
      }
    }
  }
  @RequestMapping(value = STORE_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
  public String storeDetail(
      @PathVariable("storeCode") final String storeCode,
      @RequestParam(value = "lat", required = false) final Double sourceLatitude,
      @RequestParam(value = "long", required = false) final Double sourceLongitude,
      @RequestParam(value = "q", required = false) final String locationQuery,
      final Model model)
      throws CMSItemNotFoundException {
    final StoreFinderForm storeFinderForm = new StoreFinderForm();
    model.addAttribute("storeFinderForm", storeFinderForm);
    final StorePositionForm storePositionForm = new StorePositionForm();
    model.addAttribute("storePositionForm", storePositionForm);

    if (sourceLatitude != null && sourceLongitude != null) {
      final GeoPoint geoPoint = new GeoPoint();
      geoPoint.setLatitude(sourceLatitude);
      geoPoint.setLongitude(sourceLongitude);

      // Get the point of service data with the formatted distance
      final PointOfServiceData pointOfServiceData =
          storeFinderFacade.getPointOfServiceForNameAndPosition(storeCode, geoPoint);
      pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
      model.addAttribute("store", pointOfServiceData);

      if (locationQuery != null && !locationQuery.isEmpty()) {
        model.addAttribute("locationQuery", locationQuery);

        // Build URL to location query
        final String storeFinderSearchUrl =
            UriComponentsBuilder.fromPath("/store-finder")
                .queryParam("q", locationQuery)
                .build()
                .toString();
        model.addAttribute(
            WebConstants.BREADCRUMBS_KEY,
            storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData, storeFinderSearchUrl));
      } else {
        // Build URL to position query
        final String storeFinderSearchUrl =
            UriComponentsBuilder.fromPath("/store-finder/position")
                .queryParam("lat", sourceLatitude)
                .queryParam("long", sourceLongitude)
                .build()
                .toString();
        model.addAttribute(
            WebConstants.BREADCRUMBS_KEY,
            storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData, storeFinderSearchUrl));
      }

      setUpMetaData(model, pointOfServiceData);
    } else {
      // No source point specified - just lookup the POS by name
      final PointOfServiceData pointOfServiceData =
          storeFinderFacade.getPointOfServiceForName(storeCode);
      pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
      model.addAttribute("store", pointOfServiceData);
      model.addAttribute(
          WebConstants.BREADCRUMBS_KEY, storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData));

      setUpMetaData(model, pointOfServiceData);
    }

    storeCmsPageInModel(model, getStoreFinderPage());
    return ControllerConstants.Views.Pages.StoreFinder.StoreFinderDetailsPage;
  }
 protected void setUpMetaData(final Model model, final PointOfServiceData pointOfServiceData) {
   final String metaKeywords = createMetaKeywords(pointOfServiceData);
   final String metaDescription =
       MetaSanitizerUtil.sanitizeDescription(pointOfServiceData.getDescription());
   setUpMetaData(model, metaKeywords, metaDescription);
 }