@Override public void populate(final SOURCE productModel, final TARGET productData) throws ConversionException { final BaseSiteModel baseSiteModel = getBaseSiteService().getCurrentBaseSite(); if (baseSiteModel != null) { final PromotionGroupModel defaultPromotionGroup = baseSiteModel.getDefaultPromotionGroup(); final Date currentTimeRoundedToMinute = DateUtils.round(getTimeService().getCurrentTime(), Calendar.MINUTE); if (defaultPromotionGroup != null) { final List<ProductPromotionModel> promotions = getPromotionsService() .getProductPromotions( Collections.singletonList(defaultPromotionGroup), productModel, true, currentTimeRoundedToMinute); productData.setPotentialPromotions( Converters.convertAll(promotions, getPromotionsConverter())); } } }
@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); } } }
/* * Extracts (and converts to POJOs) promotions from given results. */ protected List<PromotionResultData> getPromotions(final List<PromotionResult> promotionsResults) { final ArrayList<PromotionResultModel> promotionResultModels = modelService.getAll(promotionsResults, new ArrayList<PromotionResultModel>()); return Converters.convertAll(promotionResultModels, getPromotionResultConverter()); }
protected void addEntries(final AbstractOrderModel source, final AbstractOrderData prototype) { prototype.setEntries(Converters.convertAll(source.getEntries(), getOrderEntryConverter())); }