/** * Save Product into the application for the merchant. * * @param request product details * @param productId product Id of the product to delete. * @return Status of the operation. */ @SuppressWarnings("unchecked") public ProductDetailsResponseDTO deleteProduct( String merchantId, String productId, String businessCategory) { ProductDetailsResponseDTO response = new ProductDetailsResponseDTO(); boolean result = true; result = deleteProduct(productId); if (result == true) { logger.info("Product Deleted with ID: " + productId); } response.setMerchantId(merchantId); return response; }
@SuppressWarnings("unchecked") private Product registerProduct(String merchantID, String businessCategory) { IIdGenerator<String> generator = AbstractIdGeneratorFactory.getIdGenerator(GeneratorType.PRODUCT_ID); productRegistrationId = generator.nextId(); Product product = new ProductAssembler() .productEntity(productRegistrationId, merchantID, businessCategory, true); logger.info("Product persisted with ID : " + product.getProductId()); return product; }
@SuppressWarnings("unchecked") private void persistFashionProduct(Product product, ProductDetailsRequestDTO request) { ProductFashion productFashion = new ProductAssembler().productFashionEntity(product.getProductId(), request); IRepositoryAdapter<Product, ?> adapter = RepositoryAdapterFactory.getRepositoryAdapter( super.getORMProvider( "com.yoku.server.core.services.product.ProductService.createAndregister")); product.setProductFashion(productFashion); productFashion.setProduct(product); adapter.save(product); logger.info("Fashion Product with product ID: " + product.getProductId() + " persisted"); }
@SuppressWarnings("unchecked") public MerchantBusinessViewEntity getMerchantBusinessDetails(String merchantId) { String query; List<MerchantBusinessViewEntity> merchantBusinessViewEntity = new ArrayList<MerchantBusinessViewEntity>(); IRepositoryAdapter<MerchantBusinessViewEntity, ?> adapter = RepositoryAdapterFactory.getRepositoryAdapter( super.getORMProvider( "com.yoku.server.core.services.product.ProductService.createAndregister")); logger.info( "New Product Registration initiated. Product Registration ID : " + productRegistrationId + " For the Merchant ID : " + merchantId); query = "from MerchantBusinessViewEntity merchantBusinessViewEntity where merchantBusinessViewEntity.merchantID='" + merchantId + "'"; merchantBusinessViewEntity = adapter.executeReadQuery(query); return (MerchantBusinessViewEntity) merchantBusinessViewEntity.get(0); }
@SuppressWarnings("unchecked") private MerchantProductListingResponseDTO getAllFashionProduct( String merchantID, String businessCategory, MerchantProductListingResponseDTO response) { String query; List<ProductFashion> products = new ArrayList<ProductFashion>(); IRepositoryAdapter<ProductFashion, ?> adapter = RepositoryAdapterFactory.getRepositoryAdapter( super.getORMProvider( "com.yoku.server.core.services.product.ProductService..readAllProductsForMerchant")); query = "select productFashion from ProductFashion productFashion, Product product where product.merchantId = '" + merchantID + "' and product.productId=productFashion.productId"; products = (List<ProductFashion>) adapter.executeReadQuery(query); logger.info("Total product found------" + products.size()); response = new ProductAssembler() .createResponseForMerchantProductFashionListingResponseDTO( (List<ProductFashion>) products, businessCategory, response); return response; }