use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method convertCustomerListToReadableCustomerList.
private ReadableCustomerList convertCustomerListToReadableCustomerList(CustomerList customerList, MerchantStore store, Language language) {
List<ReadableCustomer> readableCustomers = customerList.getCustomers().stream().map(customer -> convertCustomerToReadableCustomer(customer, store, language)).collect(Collectors.toList());
ReadableCustomerList readableCustomerList = new ReadableCustomerList();
readableCustomerList.setCustomers(readableCustomers);
readableCustomerList.setTotalPages(Math.toIntExact(customerList.getTotalCount()));
return readableCustomerList;
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class SearchFacadeImpl method convertToSearchProductList.
@Override
public SearchProductList convertToSearchProductList(SearchResponse searchResponse, MerchantStore merchantStore, int start, int count, Language language) {
SearchProductList returnList = new SearchProductList();
List<SearchEntry> entries = searchResponse.getEntries();
if (CollectionUtils.isNotEmpty(entries)) {
List<Long> ids = entries.stream().map(SearchEntry::getIndexProduct).map(IndexProduct::getId).map(Long::parseLong).collect(Collectors.toList());
ProductCriteria searchCriteria = new ProductCriteria();
searchCriteria.setMaxCount(count);
searchCriteria.setStartIndex(start);
searchCriteria.setProductIds(ids);
searchCriteria.setAvailable(true);
ProductList productList = productService.listByStore(merchantStore, language, searchCriteria);
List<ReadableProduct> readableProducts = productList.getProducts().stream().map(product -> convertProductToReadableProduct(product, merchantStore, language)).collect(Collectors.toList());
returnList.getProducts().addAll(readableProducts);
returnList.setProductCount(productList.getProducts().size());
}
// Facets
Map<String, List<SearchFacet>> facets = Optional.ofNullable(searchResponse.getFacets()).orElse(Collections.emptyMap());
List<ReadableCategory> categoryProxies = getCategoryFacets(merchantStore, language, facets);
returnList.setCategoryFacets(categoryProxies);
List<SearchFacet> manufacturersFacets = facets.entrySet().stream().filter(e -> MANUFACTURER_FACET_NAME.equals(e.getKey())).findFirst().map(Entry::getValue).orElse(Collections.emptyList());
if (CollectionUtils.isNotEmpty(manufacturersFacets)) {
// TODO add manufacturer facets
}
return returnList;
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ShippingFacadeImpl method shipToCountry.
@Override
public List<ReadableCountry> shipToCountry(MerchantStore store, Language language) {
try {
List<Country> countries = shippingService.getShipToCountryList(store, language);
List<ReadableCountry> countryList = new ArrayList<ReadableCountry>();
if (!CollectionUtils.isEmpty(countries)) {
countryList = countries.stream().map(c -> {
try {
return convert(c, store, language);
} catch (ConversionException e) {
throw new ConversionRuntimeException("Error converting Country to readable country,e");
}
}).sorted(Comparator.comparing(ReadableCountry::getName)).collect(Collectors.toList());
}
return countryList;
} catch (Exception e) {
throw new ServiceRuntimeException("Error getting shipping country", e);
}
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ProductImageApi method images.
/**
* Get product images
* @param id
* @param imageId
* @param merchantStore
* @param language
* @return
*/
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = { "/products/{productId}/images" }, method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "Get images for a given product")
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of ProductImage found", response = List.class) })
@ResponseBody
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public List<ReadableImage> images(@PathVariable Long productId, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
Product p = productService.getById(productId);
if (p == null) {
throw new ResourceNotFoundException("Product images not found for product id [" + productId + "] and merchant [" + merchantStore.getCode() + "]");
}
if (p.getMerchantStore().getId() != merchantStore.getId()) {
throw new ResourceNotFoundException("Product images not found for product id [" + productId + "] and merchant [" + merchantStore.getCode() + "]");
}
List<ReadableImage> target = new ArrayList<ReadableImage>();
Set<ProductImage> images = p.getImages();
if (images != null && images.size() > 0) {
target = images.stream().map(i -> image(i, merchantStore, language)).sorted(Comparator.comparingInt(ReadableImage::getOrder)).collect(Collectors.toList());
}
return target;
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class InitializationDatabaseImpl method createLanguages.
private void createLanguages() throws ServiceException {
LOGGER.info(String.format("%s : Populating Languages ", name));
for (String code : SchemaConstant.LANGUAGE_ISO_CODE) {
Language language = new Language(code);
languageService.create(language);
}
}
Aggregations