Class SKUServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.SKUServiceImpl
-
- All Implemented Interfaces:
SKUService
@Service public class SKUServiceImpl extends java.lang.Object implements SKUService
-
-
Field Summary
Fields Modifier and Type Field Description private AccessManagementService
accessManagementService
private AttributeRepository
attributeRepository
private CategoryRepository
categoryRepository
private CommonProperties
commonProperties
private JobsManagementService
jobService
private LanguageRepository
languageRepository
private static com.fasterxml.jackson.databind.ObjectMapper
mapper
private org.springframework.data.mongodb.core.MongoTemplate
mongoTemplate
private ProductRepository
productRepository
private SellerSkuRepository
sellerSkuRepository
private SequenceGeneratorService
sequenceGenerator
private SKURepository
skuRepository
private MongoStorageService
storageService
private TranslationService
translationService
private TranslationsRepository
translationsRepository
private WebSocketService
webSocketService
-
Constructor Summary
Constructors Constructor Description SKUServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
addRelations(SKU skuUI)
SKU
addSKUToProduct(java.lang.String productId, java.util.LinkedHashMap<java.lang.String,java.lang.Object> skuAsMap)
This method does a relationship between entities.java.util.Optional<SKU>
createSKU(SKU sku)
This method creates a database entity.java.util.Optional<SKU>
createSKU(java.util.LinkedHashMap<java.lang.String,java.lang.Object> skuAsMap)
This method creates a database entity.SKU
findById(java.lang.String skuId)
This method does search requests and returns data as list.java.util.List<SKU>
findSKUs()
This method returns database entities as list.java.util.List<Category>
getCategoriesBySkuId(java.lang.String skuId)
This method retrieves a map, which can be processed in a templates.java.util.LinkedHashSet<EmbeddedBean>
getFallIntoProducts(java.lang.String[] productIds)
This method returns data as set.java.util.Deque<java.util.Map<java.lang.String,java.lang.Object>>
getPaginationFilter(java.lang.String requestJson)
Deprecated.SKURepository
getRepository()
java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
getSkusByProductAndFirstLetter(java.lang.String productId, java.lang.String firstLetter)
This method retrieves a map, which can be processed in a templates.java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getSortedProductSkus(java.lang.String productId)
This method sorted and retrieves a map, which can be processed in a templates.boolean
isSKUExists(java.lang.String name)
This method checks is exists database entity.SkuDTO
mapSkuToDto(SKU sku, boolean optimal)
Deprecated.private void
prepareRelations(SKU skuUI, SKU skuDB)
private void
removeRelations(SKU skuUI, SKU skuDB)
void
removeSKUAndClean(java.lang.String skuId)
This method removes a database entity and clean all relationships from another entities.void
removeSKUFromAttribute(java.lang.String skuId, java.lang.String attributeId)
This method removes relationship between database entities.void
removeSKUFromAttributes(java.lang.String skuId)
This method removes relationship between database entities.void
removeSKUFromProduct(java.lang.String skuId, java.lang.String productId)
This method removes relationship between database entities.void
removeSKUFromProducts(java.lang.String skuId)
This method removes relationship between database entities.void
removeSKUFromSellerSKU(java.lang.String skuId, java.lang.String sellerSkuId)
This method removes relationship between database entities.void
removeSKUFromSellerSKUs(java.lang.String skuId)
This method removes relationship between database entities.void
removeSKUFromTranslation(java.lang.String skuId, java.lang.String translationId)
This method removes relationship between database entities.void
removeSKUFromTranslations(java.lang.String skuId)
This method removes relationship between database entities.void
removeSkusByIds(java.util.ArrayList<java.lang.String> skusIds)
This method removes a list of database entities.SKU
saveSKU(SKU sku)
This method saves a database entity.SKU
saveSKU(java.util.LinkedHashMap<java.lang.String,java.lang.Object> skuAsMap)
This method save an updates of database entity.java.util.LinkedHashSet<SkuDTO>
searchSKUs(java.lang.String requestJson)
Deprecated.java.util.List<SkuDTO>
searchSKUs(java.lang.String query, java.lang.String offset, java.lang.String limit)
Deprecated.co.mastermindcms.modules.beans.SearchResponse
searchSKUs(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
searchSkusLightweight(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)
Retrieves lightweight skus based on the given request JSON.org.springframework.data.domain.Page<SKU>
searchSkusPaged(java.lang.String requestJson)
Deprecated.java.util.List<SkuDTO>
searchWithProductFilter(java.lang.String query, java.lang.String productId, java.lang.String offset, java.lang.String limit)
This method does search requests and returns data as list.SKU
updateMetaInfo(java.lang.String skuId, java.util.LinkedHashMap<java.lang.String,java.lang.Object> metaInfo)
Updates the meta information of a SKU with the given SKU ID.void
uploadSKU(java.io.File file, java.lang.String lang, java.lang.String username)
Uploads a file with SKU information to the system.
-
-
-
Field Detail
-
translationsRepository
@Autowired private TranslationsRepository translationsRepository
-
languageRepository
@Autowired private LanguageRepository languageRepository
-
sellerSkuRepository
@Autowired private SellerSkuRepository sellerSkuRepository
-
categoryRepository
@Autowired private CategoryRepository categoryRepository
-
skuRepository
@Autowired private SKURepository skuRepository
-
productRepository
@Autowired private ProductRepository productRepository
-
attributeRepository
@Autowired private AttributeRepository attributeRepository
-
translationService
@Autowired private TranslationService translationService
-
sequenceGenerator
@Autowired private SequenceGeneratorService sequenceGenerator
-
accessManagementService
@Autowired private AccessManagementService accessManagementService
-
storageService
@Autowired private MongoStorageService storageService
-
mongoTemplate
@Autowired private org.springframework.data.mongodb.core.MongoTemplate mongoTemplate
-
webSocketService
@Autowired private WebSocketService webSocketService
-
jobService
@Autowired private JobsManagementService jobService
-
commonProperties
@Autowired private CommonProperties commonProperties
-
mapper
private static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Detail
-
getRepository
public SKURepository getRepository()
- Specified by:
getRepository
in interfaceSKUService
-
getPaginationFilter
@Deprecated public java.util.Deque<java.util.Map<java.lang.String,java.lang.Object>> getPaginationFilter(java.lang.String requestJson)
Deprecated.Description copied from interface:SKUService
This method does calculation for a pages based on the request.- Specified by:
getPaginationFilter
in interfaceSKUService
- Parameters:
requestJson
- JSON-object of request contains an instructions for search queries- Returns:
- map-representation of data
-
searchSKUs
public co.mastermindcms.modules.beans.SearchResponse searchSKUs(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)
Description copied from interface:SKUService
This method does search requests and returns data as list.- Specified by:
searchSKUs
in interfaceSKUService
- Parameters:
requestJson
- search request- Returns:
- data transport entities as list
-
searchSkusLightweight
public co.mastermindcms.modules.beans.SearchResponse searchSkusLightweight(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestJson)
Description copied from interface:SKUService
Retrieves lightweight skus based on the given request JSON.- Specified by:
searchSkusLightweight
in interfaceSKUService
- Parameters:
requestJson
- a LinkedHashMap containing the request parameters- Returns:
- a SearchResponse object containing the lightweight skus
-
searchSKUs
@Deprecated public java.util.LinkedHashSet<SkuDTO> searchSKUs(java.lang.String requestJson)
Deprecated.Description copied from interface:SKUService
This method does search requests and returns data as list.- Specified by:
searchSKUs
in interfaceSKUService
- Parameters:
requestJson
- search request- Returns:
- data transport entities as list
-
searchSkusPaged
@Deprecated public org.springframework.data.domain.Page<SKU> searchSkusPaged(java.lang.String requestJson)
Deprecated.Description copied from interface:SKUService
This method does search requests and returns data as pages.- Specified by:
searchSkusPaged
in interfaceSKUService
- Parameters:
requestJson
- JSON-object of request contains an instructions for search queries- Returns:
- database entities separated to pages
-
findById
public SKU findById(java.lang.String skuId)
Description copied from interface:SKUService
This method does search requests and returns data as list.- Specified by:
findById
in interfaceSKUService
- Parameters:
skuId
- sku unique id- Returns:
- database entity as object
-
searchSKUs
@Deprecated public java.util.List<SkuDTO> searchSKUs(java.lang.String query, java.lang.String offset, java.lang.String limit)
Deprecated.Description copied from interface:SKUService
This method does search requests and returns data as list.- Specified by:
searchSKUs
in interfaceSKUService
- Parameters:
query
- search queryoffset
- offset for returned itemslimit
- limit for returned items- Returns:
- database entities as list
-
searchWithProductFilter
public java.util.List<SkuDTO> searchWithProductFilter(java.lang.String query, java.lang.String productId, java.lang.String offset, java.lang.String limit)
Description copied from interface:SKUService
This method does search requests and returns data as list.- Specified by:
searchWithProductFilter
in interfaceSKUService
- Parameters:
query
- search queryproductId
- field "_id" for filter and return itemsoffset
- offset for returned itemslimit
- limit for returned items- Returns:
- database entities as list
-
findSKUs
public java.util.List<SKU> findSKUs()
Description copied from interface:SKUService
This method returns database entities as list.- Specified by:
findSKUs
in interfaceSKUService
- Returns:
- database entities as list
-
getCategoriesBySkuId
public java.util.List<Category> getCategoriesBySkuId(java.lang.String skuId)
Description copied from interface:SKUService
This method retrieves a map, which can be processed in a templates.- Specified by:
getCategoriesBySkuId
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be retrieved- Returns:
- map-representation of data
-
createSKU
@Transactional public java.util.Optional<SKU> createSKU(java.util.LinkedHashMap<java.lang.String,java.lang.Object> skuAsMap)
Description copied from interface:SKUService
This method creates a database entity.- Specified by:
createSKU
in interfaceSKUService
- Parameters:
skuAsMap
- map-representation of database entity- Returns:
- database entity
-
createSKU
public java.util.Optional<SKU> createSKU(SKU sku)
Description copied from interface:SKUService
This method creates a database entity.- Specified by:
createSKU
in interfaceSKUService
- Parameters:
sku
- map-representation of database entity- Returns:
- database entity
-
addSKUToProduct
@Transactional public SKU addSKUToProduct(java.lang.String productId, java.util.LinkedHashMap<java.lang.String,java.lang.Object> skuAsMap)
Description copied from interface:SKUService
This method does a relationship between entities.- Specified by:
addSKUToProduct
in interfaceSKUService
- Parameters:
productId
- identification for database entity which will be updatedskuAsMap
- map-representation of database entity- Returns:
- database entity
-
saveSKU
@Transactional public SKU saveSKU(java.util.LinkedHashMap<java.lang.String,java.lang.Object> skuAsMap)
Description copied from interface:SKUService
This method save an updates of database entity.- Specified by:
saveSKU
in interfaceSKUService
- Parameters:
skuAsMap
- map-representation of database entity- Returns:
- saved instance of database entity
-
saveSKU
@Transactional public SKU saveSKU(SKU sku)
Description copied from interface:SKUService
This method saves a database entity.- Specified by:
saveSKU
in interfaceSKUService
- Parameters:
sku
- database entity- Returns:
- saved instance of database entity
-
addRelations
private void addRelations(SKU skuUI)
-
removeSKUFromAttribute
@Transactional public void removeSKUFromAttribute(java.lang.String skuId, java.lang.String attributeId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromAttribute
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removedattributeId
- identification for database entity which will be updated
-
removeSKUFromAttributes
@Transactional public void removeSKUFromAttributes(java.lang.String skuId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromAttributes
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removed
-
removeSKUFromSellerSKU
@Transactional public void removeSKUFromSellerSKU(java.lang.String skuId, java.lang.String sellerSkuId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromSellerSKU
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removedsellerSkuId
- identification for database entity which will be updated
-
removeSKUFromSellerSKUs
@Transactional public void removeSKUFromSellerSKUs(java.lang.String skuId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromSellerSKUs
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removed
-
removeSKUFromProduct
@Transactional public void removeSKUFromProduct(java.lang.String skuId, java.lang.String productId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromProduct
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removedproductId
- identification for database entity which will be updated
-
removeSKUFromProducts
@Transactional public void removeSKUFromProducts(java.lang.String skuId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromProducts
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removed
-
removeSKUFromTranslation
@Transactional public void removeSKUFromTranslation(java.lang.String skuId, java.lang.String translationId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromTranslation
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removedtranslationId
- identification for database entity which will be updated
-
removeSKUFromTranslations
@Transactional public void removeSKUFromTranslations(java.lang.String skuId)
Description copied from interface:SKUService
This method removes relationship between database entities.- Specified by:
removeSKUFromTranslations
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removed
-
removeSKUAndClean
@Transactional public void removeSKUAndClean(java.lang.String skuId)
Description copied from interface:SKUService
This method removes a database entity and clean all relationships from another entities.- Specified by:
removeSKUAndClean
in interfaceSKUService
- Parameters:
skuId
- identification for database entity which will be removed
-
removeSkusByIds
@Transactional public void removeSkusByIds(java.util.ArrayList<java.lang.String> skusIds)
Description copied from interface:SKUService
This method removes a list of database entities.- Specified by:
removeSkusByIds
in interfaceSKUService
- Parameters:
skusIds
- the list of database entities which will be removed
-
isSKUExists
public boolean isSKUExists(java.lang.String name)
Description copied from interface:SKUService
This method checks is exists database entity.- Specified by:
isSKUExists
in interfaceSKUService
- Parameters:
name
- field "name" for database entity which will be checked- Returns:
- value as boolean
-
getSortedProductSkus
@Transactional public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getSortedProductSkus(java.lang.String productId)
Description copied from interface:SKUService
This method sorted and retrieves a map, which can be processed in a templates.- Specified by:
getSortedProductSkus
in interfaceSKUService
- Parameters:
productId
- identification for database entity which will be retrieved- Returns:
- map-representation of data
-
getSkusByProductAndFirstLetter
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getSkusByProductAndFirstLetter(java.lang.String productId, java.lang.String firstLetter)
Description copied from interface:SKUService
This method retrieves a map, which can be processed in a templates.- Specified by:
getSkusByProductAndFirstLetter
in interfaceSKUService
- Parameters:
productId
- identification for database entity which will be retrievedfirstLetter
- first letter of the name for the sku- Returns:
- map-representation of data
-
mapSkuToDto
@Deprecated public SkuDTO mapSkuToDto(SKU sku, boolean optimal)
Deprecated.Description copied from interface:SKUService
This method does map product entity to dto object- Specified by:
mapSkuToDto
in interfaceSKUService
- Parameters:
sku
- database entity which be used to map to dtooptimal
- this pointer optimises the data transfer object- Returns:
- data transport object
-
uploadSKU
@Async("asyncTaskExecutor") public void uploadSKU(java.io.File file, java.lang.String lang, java.lang.String username)
Description copied from interface:SKUService
Uploads a file with SKU information to the system.- Specified by:
uploadSKU
in interfaceSKUService
- Parameters:
file
- the file containing SKU information to be uploadedlang
- the language for SKU informationusername
- the username of the user uploading the SKU information
-
updateMetaInfo
public SKU updateMetaInfo(java.lang.String skuId, java.util.LinkedHashMap<java.lang.String,java.lang.Object> metaInfo)
Description copied from interface:SKUService
Updates the meta information of a SKU with the given SKU ID.- Specified by:
updateMetaInfo
in interfaceSKUService
- Parameters:
skuId
- the ID of the SKU to updatemetaInfo
- a LinkedHashMap containing the new meta information for the SKU- Returns:
- the updated SKU object with the new meta information
-
getFallIntoProducts
public java.util.LinkedHashSet<EmbeddedBean> getFallIntoProducts(java.lang.String[] productIds)
Description copied from interface:SKUService
This method returns data as set.- Specified by:
getFallIntoProducts
in interfaceSKUService
- Parameters:
productIds
- the list of database entities which will be retrieved- Returns:
- database entities as list
-
-