use of com.salesmanager.shop.model.catalog.product.type.ReadableProductTypeFull in project shopizer by shopizer-ecommerce.
the class ReadableProductTypeMapper method type.
private ReadableProductType type(ProductType type, Language language) {
ReadableProductType readableType = null;
if (language != null) {
readableType = new ReadableProductType();
if (!CollectionUtils.isEmpty(type.getDescriptions())) {
Optional<ProductTypeDescription> desc = type.getDescriptions().stream().filter(t -> t.getLanguage().getCode().equals(language.getCode())).map(d -> typeDescription(d)).findFirst();
if (desc.isPresent()) {
readableType.setDescription(desc.get());
}
}
} else {
readableType = new ReadableProductTypeFull();
List<ProductTypeDescription> descriptions = type.getDescriptions().stream().map(t -> this.typeDescription(t)).collect(Collectors.toList());
((ReadableProductTypeFull) readableType).setDescriptions(descriptions);
}
readableType.setCode(type.getCode());
readableType.setId(type.getId());
readableType.setVisible(type.getVisible() != null && type.getVisible().booleanValue() ? true : false);
readableType.setAllowAddToCart(type.getAllowAddToCart() != null && type.getAllowAddToCart().booleanValue() ? true : false);
return readableType;
}
Aggregations