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 AccessManagementServiceaccessManagementServiceprivate AttributeRepositoryattributeRepositoryprivate CategoryRepositorycategoryRepositoryprivate CommonPropertiescommonPropertiesprivate LanguageRepositorylanguageRepositoryprivate static com.fasterxml.jackson.databind.ObjectMappermapperprivate org.springframework.data.mongodb.core.MongoTemplatemongoTemplateprivate ProductRepositoryproductRepositoryprivate SequenceGeneratorServicesequenceGeneratorprivate SKURepositoryskuRepositoryprivate MongoStorageServicestorageServiceprivate TranslationServicetranslationServiceprivate TranslationsRepositorytranslationsRepository
-
Constructor Summary
Constructors Constructor Description ProductServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ProductaddProductToCategory(java.lang.String categoryId, java.lang.String productId)This method does a relationship between entities.ProductaddProductToCategory(java.lang.String categoryId, java.util.LinkedHashMap<java.lang.String,java.lang.Object> productAsMap)This method does a relationship between entities.private voidaddRelations(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.ProductRepositorygetRepository()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.ProductDTOmapProductToDto(Product product, boolean optimal)Deprecated.private voidprepareRelations(Product productUI, Product productDB)voidremoveProductAndClean(java.lang.String productId)This method removes a database entity and clean all relationships from another entities.voidremoveProductFromAttribute(java.lang.String productId, java.lang.String attrId)This method removes relationship between database entities.voidremoveProductFromAttributes(java.lang.String productId)This method removes relationship between database entities.voidremoveProductFromCategories(java.lang.String productId)This method removes relationship between database entities.voidremoveProductFromCategory(java.lang.String productId, java.lang.String categoryId)This method removes relationship between database entities.voidremoveProductFromSKU(java.lang.String productId, java.lang.String skuId)This method removes relationship between database entities.voidremoveProductFromSKUs(java.lang.String productId)This method removes relationship between database entities.voidremoveProductFromTranslation(java.lang.String productId, java.lang.String tranId)This method removes relationship between database entities.voidremoveProductFromTranslations(java.lang.String productId)This method removes relationship between database entities.voidremoveProductsByIds(java.util.ArrayList<java.lang.String> productsIds)This method removes a list of database entities.private voidremoveRelations(Product productUI, Product productDB)ProductsaveProduct(Product product)This method saves a database entity.ProductsaveProduct(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.SearchResponsesearchProducts(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)This method does search requests and returns data as list.co.mastermindcms.modules.beans.SearchResponsesearchProductsLightweight(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:
getRepositoryin interfaceProductService
-
getPaginationFilter
public java.util.Deque<java.util.Map<java.lang.String,java.lang.Object>> getPaginationFilter(java.lang.String requestJson)
Description copied from interface:ProductServiceThis method does calculation for a pages based on the request.- Specified by:
getPaginationFilterin 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:ProductServiceThis method does search requests and returns data as list.- Specified by:
searchProductsin 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:ProductServiceRetrieves lightweight products based on the given request JSON.- Specified by:
searchProductsLightweightin 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:ProductServiceThis method does search requests and returns data as list.- Specified by:
searchProductsin 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:ProductServiceThis method does search requests and returns data as pages.- Specified by:
searchProductsPagedin 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:ProductServiceThis method does search requests and returns data as list.- Specified by:
searchProductsin 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:ProductServiceThis method creates a database entity.- Specified by:
createProductin interfaceProductService- Parameters:
productAsMap- map-representation of database entity- Returns:
- database entity
-
createProduct
public java.util.Optional<Product> createProduct(Product product)
Description copied from interface:ProductServiceThis method creates a database entity.- Specified by:
createProductin 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:ProductServiceThis method does a relationship between entities.- Specified by:
addProductToCategoryin 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:ProductServiceThis method does a relationship between entities.- Specified by:
addProductToCategoryin 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:ProductServiceThis method save an updates of database entity.- Specified by:
saveProductin 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:ProductServiceThis method saves a database entity.- Specified by:
saveProductin 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:ProductServiceThis method retrieves a map, which can be processed in a templates.- Specified by:
getSortedProductsByCategoryin 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:ProductServiceThis method retrieves a map, which can be processed in a templates.- Specified by:
getProductsByCategoryAndFirstLetterin 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:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromCategoryin 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:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromSKUin 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:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromAttributein 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:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromTranslationin 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:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromCategoriesin interfaceProductService- Parameters:
productId- identification for database entity which will be removed
-
removeProductFromSKUs
@Transactional public void removeProductFromSKUs(java.lang.String productId)
Description copied from interface:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromSKUsin interfaceProductService- Parameters:
productId- identification for database entity which will be removed
-
removeProductFromAttributes
@Transactional public void removeProductFromAttributes(java.lang.String productId)
Description copied from interface:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromAttributesin interfaceProductService- Parameters:
productId- identification for database entity which will be removed
-
removeProductFromTranslations
@Transactional public void removeProductFromTranslations(java.lang.String productId)
Description copied from interface:ProductServiceThis method removes relationship between database entities.- Specified by:
removeProductFromTranslationsin interfaceProductService- Parameters:
productId- identification for database entity which will be removed
-
removeProductAndClean
@Transactional public void removeProductAndClean(java.lang.String productId)
Description copied from interface:ProductServiceThis method removes a database entity and clean all relationships from another entities.- Specified by:
removeProductAndCleanin 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:ProductServiceThis method removes a list of database entities.- Specified by:
removeProductsByIdsin 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:ProductServiceThis method does map product entity to dto object- Specified by:
mapProductToDtoin interfaceProductService- Parameters:
product- database entity which be used to map to dtooptimal- this pointer optimises the data transfer object- Returns:
- data transport object
-
-