Class ProductServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.ProductServiceImpl
-
- All Implemented Interfaces:
ProductService
@Service public class ProductServiceImpl extends java.lang.Object implements ProductService
-
-
Field Summary
Fields Modifier and Type Field Description private AccessManagementService
accessManagementService
private AttributeRepository
attributeRepository
private CategoryRepository
categoryRepository
private CommonProperties
commonProperties
private LanguageRepository
languageRepository
private static com.fasterxml.jackson.databind.ObjectMapper
mapper
private org.springframework.data.mongodb.core.MongoTemplate
mongoTemplate
private ProductRepository
productRepository
private SequenceGeneratorService
sequenceGenerator
private SKURepository
skuRepository
private MongoStorageService
storageService
private TranslationService
translationService
private TranslationsRepository
translationsRepository
-
Constructor Summary
Constructors Constructor Description ProductServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Product
addProductToCategory(java.lang.String categoryId, java.lang.String productId)
This method does a relationship between entities.Product
addProductToCategory(java.lang.String categoryId, java.util.LinkedHashMap<java.lang.String,java.lang.Object> productAsMap)
This method does a relationship between entities.private void
addRelations(Product productUI)
java.util.Optional<Product>
createProduct(Product product)
This method creates a database entity.java.util.Optional<Product>
createProduct(java.util.LinkedHashMap<java.lang.String,java.lang.Object> productAsMap)
This method creates a database entity.java.util.Deque<java.util.Map<java.lang.String,java.lang.Object>>
getPaginationFilter(java.lang.String requestJson)
This method does calculation for a pages based on the request.java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
getProductsByCategoryAndFirstLetter(java.lang.String categoryId, java.lang.String firstLetter)
This method retrieves a map, which can be processed in a templates.ProductRepository
getRepository()
java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getSortedProductsByCategory(java.lang.String categoryId)
This method retrieves a map, which can be processed in a templates.ProductDTO
mapProductToDto(Product product, boolean optimal)
Deprecated.private void
prepareRelations(Product productUI, Product productDB)
void
removeProductAndClean(java.lang.String productId)
This method removes a database entity and clean all relationships from another entities.void
removeProductFromAttribute(java.lang.String productId, java.lang.String attrId)
This method removes relationship between database entities.void
removeProductFromAttributes(java.lang.String productId)
This method removes relationship between database entities.void
removeProductFromCategories(java.lang.String productId)
This method removes relationship between database entities.void
removeProductFromCategory(java.lang.String productId, java.lang.String categoryId)
This method removes relationship between database entities.void
removeProductFromSKU(java.lang.String productId, java.lang.String skuId)
This method removes relationship between database entities.void
removeProductFromSKUs(java.lang.String productId)
This method removes relationship between database entities.void
removeProductFromTranslation(java.lang.String productId, java.lang.String tranId)
This method removes relationship between database entities.void
removeProductFromTranslations(java.lang.String productId)
This method removes relationship between database entities.void
removeProductsByIds(java.util.ArrayList<java.lang.String> productsIds)
This method removes a list of database entities.private void
removeRelations(Product productUI, Product productDB)
Product
saveProduct(Product product)
This method saves a database entity.Product
saveProduct(java.util.LinkedHashMap<java.lang.String,java.lang.Object> productAsMap)
This method save an updates of database entity.java.util.LinkedHashSet<ProductDTO>
searchProducts(java.lang.String requestJson)
Deprecated.java.util.List<Product>
searchProducts(java.lang.String query, java.lang.String offset, java.lang.String limit)
Deprecated.co.mastermindcms.modules.beans.SearchResponse
searchProducts(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)
This method does search requests and returns data as list.co.mastermindcms.modules.beans.SearchResponse
searchProductsLightweight(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)
Retrieves lightweight products based on the given request JSON.org.springframework.data.domain.Page<Product>
searchProductsPaged(java.lang.String requestJson)
Deprecated.
-
-
-
Field Detail
-
translationsRepository
@Autowired private TranslationsRepository translationsRepository
-
languageRepository
@Autowired private LanguageRepository languageRepository
-
productRepository
@Autowired private ProductRepository productRepository
-
categoryRepository
@Autowired private CategoryRepository categoryRepository
-
skuRepository
@Autowired private SKURepository skuRepository
-
attributeRepository
@Autowired private AttributeRepository attributeRepository
-
translationService
@Autowired private TranslationService translationService
-
sequenceGenerator
@Autowired private SequenceGeneratorService sequenceGenerator
-
storageService
@Autowired private MongoStorageService storageService
-
mongoTemplate
@Autowired private org.springframework.data.mongodb.core.MongoTemplate mongoTemplate
-
accessManagementService
@Autowired private AccessManagementService accessManagementService
-
commonProperties
@Autowired private CommonProperties commonProperties
-
mapper
private static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Detail
-
getRepository
public ProductRepository getRepository()
- Specified by:
getRepository
in interfaceProductService
-
getPaginationFilter
public java.util.Deque<java.util.Map<java.lang.String,java.lang.Object>> getPaginationFilter(java.lang.String requestJson)
Description copied from interface:ProductService
This method does calculation for a pages based on the request.- Specified by:
getPaginationFilter
in interfaceProductService
- Parameters:
requestJson
- JSON-object of request contains an instructions for search queries- Returns:
- map-representation of data
-
searchProducts
public co.mastermindcms.modules.beans.SearchResponse searchProducts(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)
Description copied from interface:ProductService
This method does search requests and returns data as list.- Specified by:
searchProducts
in interfaceProductService
- Parameters:
requestJson
- search request- Returns:
- database entities separated to pages
-
searchProductsLightweight
public co.mastermindcms.modules.beans.SearchResponse searchProductsLightweight(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)
Description copied from interface:ProductService
Retrieves lightweight products based on the given request JSON.- Specified by:
searchProductsLightweight
in interfaceProductService
- Parameters:
requestJson
- a LinkedHashMap containing the request parameters- Returns:
- a SearchResponse object containing the lightweight products
-
searchProducts
@Deprecated public java.util.LinkedHashSet<ProductDTO> searchProducts(java.lang.String requestJson)
Deprecated.Description copied from interface:ProductService
This method does search requests and returns data as list.- Specified by:
searchProducts
in interfaceProductService
- Parameters:
requestJson
- search request- Returns:
- data transport entities as list
-
searchProductsPaged
@Deprecated public org.springframework.data.domain.Page<Product> searchProductsPaged(java.lang.String requestJson)
Deprecated.Description copied from interface:ProductService
This method does search requests and returns data as pages.- Specified by:
searchProductsPaged
in interfaceProductService
- Parameters:
requestJson
- JSON-object of request contains an instructions for search queries- Returns:
- database entities separated to pages
-
searchProducts
@Deprecated public java.util.List<Product> searchProducts(java.lang.String query, java.lang.String offset, java.lang.String limit)
Deprecated.Description copied from interface:ProductService
This method does search requests and returns data as list.- Specified by:
searchProducts
in interfaceProductService
- Parameters:
query
- search queryoffset
- offset for returned itemslimit
- limit for returned items- Returns:
- database entities as list
-
createProduct
@Transactional public java.util.Optional<Product> createProduct(java.util.LinkedHashMap<java.lang.String,java.lang.Object> productAsMap)
Description copied from interface:ProductService
This method creates a database entity.- Specified by:
createProduct
in interfaceProductService
- Parameters:
productAsMap
- map-representation of database entity- Returns:
- database entity
-
createProduct
public java.util.Optional<Product> createProduct(Product product)
Description copied from interface:ProductService
This method creates a database entity.- Specified by:
createProduct
in interfaceProductService
- Parameters:
product
- database entity- Returns:
- optional value to externally interaction
-
addProductToCategory
@Transactional public Product addProductToCategory(java.lang.String categoryId, java.util.LinkedHashMap<java.lang.String,java.lang.Object> productAsMap)
Description copied from interface:ProductService
This method does a relationship between entities.- Specified by:
addProductToCategory
in interfaceProductService
- Parameters:
categoryId
- identification for database entity which will be updatedproductAsMap
- map-representation of database entity- Returns:
- database entity
-
addProductToCategory
public Product addProductToCategory(java.lang.String categoryId, java.lang.String productId)
Description copied from interface:ProductService
This method does a relationship between entities.- Specified by:
addProductToCategory
in interfaceProductService
- Parameters:
categoryId
- identification for database entity which will be updatedproductId
- identification for database entity which will be updated- Returns:
- database entity
-
saveProduct
@Transactional public Product saveProduct(java.util.LinkedHashMap<java.lang.String,java.lang.Object> productAsMap)
Description copied from interface:ProductService
This method save an updates of database entity.- Specified by:
saveProduct
in interfaceProductService
- Parameters:
productAsMap
- map-representation of database entity- Returns:
- saved instance of database entity
-
saveProduct
@Transactional public Product saveProduct(Product product)
Description copied from interface:ProductService
This method saves a database entity.- Specified by:
saveProduct
in interfaceProductService
- Parameters:
product
- database entity- Returns:
- saved instance of database entity
-
getSortedProductsByCategory
@Transactional public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getSortedProductsByCategory(java.lang.String categoryId)
Description copied from interface:ProductService
This method retrieves a map, which can be processed in a templates.- Specified by:
getSortedProductsByCategory
in interfaceProductService
- Parameters:
categoryId
- identification for database entity which will be retrieved- Returns:
- map-representation of data
-
getProductsByCategoryAndFirstLetter
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getProductsByCategoryAndFirstLetter(java.lang.String categoryId, java.lang.String firstLetter)
Description copied from interface:ProductService
This method retrieves a map, which can be processed in a templates.- Specified by:
getProductsByCategoryAndFirstLetter
in interfaceProductService
- Parameters:
categoryId
- identification for database entity which will be retrievedfirstLetter
- first letter of the name for the product- Returns:
- map-representation of data
-
addRelations
private void addRelations(Product productUI)
-
removeProductFromCategory
@Transactional public void removeProductFromCategory(java.lang.String productId, java.lang.String categoryId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromCategory
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removedcategoryId
- identification for database entity which will be updated
-
removeProductFromSKU
@Transactional public void removeProductFromSKU(java.lang.String productId, java.lang.String skuId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromSKU
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removedskuId
- identification for database entity which will be updated
-
removeProductFromAttribute
@Transactional public void removeProductFromAttribute(java.lang.String productId, java.lang.String attrId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromAttribute
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removedattrId
- identification for database entity which will be updated
-
removeProductFromTranslation
@Transactional public void removeProductFromTranslation(java.lang.String productId, java.lang.String tranId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromTranslation
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removedtranId
- identification for database entity which will be updated
-
removeProductFromCategories
@Transactional public void removeProductFromCategories(java.lang.String productId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromCategories
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removed
-
removeProductFromSKUs
@Transactional public void removeProductFromSKUs(java.lang.String productId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromSKUs
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removed
-
removeProductFromAttributes
@Transactional public void removeProductFromAttributes(java.lang.String productId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromAttributes
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removed
-
removeProductFromTranslations
@Transactional public void removeProductFromTranslations(java.lang.String productId)
Description copied from interface:ProductService
This method removes relationship between database entities.- Specified by:
removeProductFromTranslations
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removed
-
removeProductAndClean
@Transactional public void removeProductAndClean(java.lang.String productId)
Description copied from interface:ProductService
This method removes a database entity and clean all relationships from another entities.- Specified by:
removeProductAndClean
in interfaceProductService
- Parameters:
productId
- identification for database entity which will be removed
-
removeProductsByIds
@Transactional public void removeProductsByIds(java.util.ArrayList<java.lang.String> productsIds)
Description copied from interface:ProductService
This method removes a list of database entities.- Specified by:
removeProductsByIds
in interfaceProductService
- Parameters:
productsIds
- the list of database entities which will be removed
-
mapProductToDto
@Deprecated public ProductDTO mapProductToDto(Product product, boolean optimal)
Deprecated.Description copied from interface:ProductService
This method does map product entity to dto object- Specified by:
mapProductToDto
in interfaceProductService
- Parameters:
product
- database entity which be used to map to dtooptimal
- this pointer optimises the data transfer object- Returns:
- data transport object
-
-