use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.
the class ReadableProductPopulator method type.
private ReadableProductType type(ProductType type, Language language) {
ReadableProductType readableType = new ReadableProductType();
readableType.setCode(type.getCode());
readableType.setId(type.getId());
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());
}
}
return readableType;
}
use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription 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;
}
use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.
the class ReadableProductTypeMapper method typeDescription.
private ProductTypeDescription typeDescription(com.salesmanager.core.model.catalog.product.type.ProductTypeDescription description) {
ProductTypeDescription desc = new ProductTypeDescription();
desc.setId(description.getId());
desc.setName(description.getName());
desc.setDescription(description.getDescription());
desc.setLanguage(description.getLanguage().getCode());
return desc;
}
use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.
the class ReadableProductPopulator method typeDescription.
private ProductTypeDescription typeDescription(com.salesmanager.core.model.catalog.product.type.ProductTypeDescription description) {
ProductTypeDescription desc = new ProductTypeDescription();
desc.setId(description.getId());
desc.setName(description.getName());
desc.setDescription(description.getDescription());
desc.setLanguage(description.getLanguage().getCode());
return desc;
}
use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.
the class PersistableProductTypeMapper method type.
private ProductType type(PersistableProductType type, ProductType destination) throws ServiceException {
if (destination == null) {
destination = new ProductType();
}
destination.setCode(type.getCode());
destination.setId(type.getId());
destination.setAllowAddToCart(type.isAllowAddToCart());
destination.setVisible(type.isVisible());
// destination.set
List<com.salesmanager.core.model.catalog.product.type.ProductTypeDescription> descriptions = new ArrayList<com.salesmanager.core.model.catalog.product.type.ProductTypeDescription>();
if (!CollectionUtils.isEmpty(type.getDescriptions())) {
for (ProductTypeDescription d : type.getDescriptions()) {
com.salesmanager.core.model.catalog.product.type.ProductTypeDescription desc = typeDescription(d, destination, d.getLanguage());
descriptions.add(desc);
}
destination.setDescriptions(new HashSet<com.salesmanager.core.model.catalog.product.type.ProductTypeDescription>(descriptions));
}
return destination;
}
Aggregations