@Test public void testCreate() { ProductTypeService productTypeService = (ProductTypeService) ctx().getBean(ServiceSpringKeys.PRODUCT_TYPE_SERVICE); BrandService brandService = (BrandService) ctx().getBean(ServiceSpringKeys.BRAND_SERVICE); EntityFactory entityFactory = productService.getGenericDao().getEntityFactory(); Product product = entityFactory.getByIface(Product.class); product.setCode("PROD_CODE_123"); product.setName("product"); product.setDescription("description"); product.setProducttype(productTypeService.findById(1L)); product.setBrand(brandService.findById(101L)); product = productService.create(product); assertTrue(product.getProductId() > 0); assertFalse(product.getSku().isEmpty()); assertEquals(product.getCode(), product.getSku().iterator().next().getCode()); }
@Override public Product create(final Product instance) { ProductSku sku = productDao.getEntityFactory().getByIface(ProductSku.class); sku.setCode(instance.getCode()); sku.setName(instance.getName()); sku.setDisplayName(instance.getDisplayName()); sku.setDescription(instance.getDescription()); sku.setProduct(instance); sku.setRank(0); sku.setSupplierCatalogCode(instance.getSupplierCatalogCode()); instance.getSku().add(sku); return getGenericDao().create(instance); }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public Product create(final Product instance) { ProductSku sku = productDao.getEntityFactory().getByIface(ProductSku.class); sku.setCode(instance.getCode()); sku.setName(instance.getName()); sku.setDisplayName(instance.getDisplayName()); sku.setDescription(instance.getDescription()); sku.setProduct(instance); sku.setRank(0); sku.setSupplierCatalogCode(instance.getSupplierCatalogCode()); instance.getSku().add(sku); return getGenericDao().create(instance); } }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public Product create(final Product instance) { ProductSku sku = productDao.getEntityFactory().getByIface(ProductSku.class); sku.setCode(instance.getCode()); sku.setName(instance.getName()); sku.setDisplayName(instance.getDisplayName()); sku.setDescription(instance.getDescription()); sku.setProduct(instance); sku.setRank(0); sku.setSupplierCatalogCode(instance.getSupplierCatalogCode()); instance.getSku().add(sku); return getGenericDao().create(instance); } ProductServiceImpl(final GenericFTSCapableDAO<Product, Long, Object> productDao,
                              final GenericFTSCapableDAO<ProductSku, Long, Object> productSkuDao,
                              final ProductSkuService productSkuService,
                              final ProductTypeAttrService productTypeAttrService,
                              final AttributeService attributeService,
                              final GenericDAO<ProductCategory, Long> productCategoryDao,
                              final GenericDAO<ProductTypeAttr, Long> productTypeAttrDao,
                              final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public Product create(final Product instance) { ProductSku sku = productDao.getEntityFactory().getByIface(ProductSku.class); sku.setCode(instance.getCode()); sku.setName(instance.getName()); sku.setDisplayName(instance.getDisplayName()); sku.setDescription(instance.getDescription()); sku.setProduct(instance); sku.setRank(0); sku.setSupplierCatalogCode(instance.getSupplierCatalogCode()); instance.getSku().add(sku); return getGenericDao().create(instance); } ProductServiceImpl(final GenericFTSCapableDAO<Product, Long, Object> productDao,
                              final GenericFTSCapableDAO<ProductSku, Long, Object> productSkuDao,
                              final ProductSkuService productSkuService,
                              final ProductTypeAttrService productTypeAttrService,
                              final AttributeService attributeService,
                              final GenericDAO<ProductCategory, Long> productCategoryDao,
                              final GenericDAO<ProductTypeAttr, Long> productTypeAttrDao,
                              final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); @Override ProductSku getSkuById(final Long skuId); @Override ProductSku getSkuById(final Long skuId, final boolean withAttributes); @Override String getDefaultImage(final Long productId); @Override ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId); @Override ProductCompareModel getCompareAttributes(final List<Long> productId,
                                                    final List<Long> skuId); @Override Map<Long, String> getAllProductsAttributeValues(final String attributeCode); @Override ProductSku getProductSkuByCode(final String skuCode); @Override Product getProductBySkuCode(final String skuCode); @Override Product getProductById(final Long productId); @Override Product getProductById(final Long productId, final boolean withAttribute); @Override ProductSearchResultPageDTO getProductSearchResultDTOByQuery(final NavigationContext navigationContext,
                                                                       final int firstResult,
                                                                       final int maxResults,
                                                                       final String sortFieldName,
                                                                       final boolean reverse); @Override ProductSearchResultNavDTO findFilteredNavigationRecords(final NavigationContext baseNavigationContext, final List<FilteredNavigationRecordRequest> request); @Override int getProductQty(final NavigationContext navigationContext); @Override Pair<Integer, Integer> findProductQtyAll(); @Override List<Product> getProductByIdList(final List idList); @Override Long findProductIdBySeoUri(final String seoUri); @Override Long findProductIdByGUID(final String guid); @Override Long findProductIdByCode(final String code); @Override List<Long> findProductIdsByManufacturerCode(final String code); @Override List<Long> findProductIdsByBarCode(final String code); @Override List<Long> findProductIdsByBarCodes(final Collection<String> codes); @Override List<Long> findProductIdsByPimCode(final String code); @Override List<Long> findProductIdsByAttributeValue(final String attrCode, final String attrValue); @Override String findSeoUriByProductId(final Long productId); @Override Long findProductSkuIdBySeoUri(final String seoUri); @Override Long findProductSkuIdByGUID(final String guid); @Override Long findProductSkuIdByCode(final String code); @Override String findSeoUriByProductSkuId(final Long skuId); @Override IndexBuilder.FTIndexState getProductsFullTextIndexState(); @Override IndexBuilder.FTIndexState getProductsSkuFullTextIndexState(); @Override void reindexProducts(final int batchSize); @Override void reindexProducts(final int batchSize, final boolean async); @Override void reindexProductsSku(final int batchSize); @Override void reindexProductsSku(final int batchSize, final boolean async); @Override void reindexProducts(final Long shopId, final int batchSize); @Override void reindexProductsSku(final Long shopId, final int batchSize); @Override void reindexProduct(final Long pk); @Override void reindexProductSku(final Long pk); @Override void reindexProductSku(final String code); @Override List<Product> findProducts(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findProductCount(final Map<String, List> filter); @Override List<Product> findProductByCodeNameBrandType(final String code,
                                                        final String name,
                                                        final Long brandId,
                                                        final Long productTypeId); @Override List<String> findProductSupplierCatalogCodes(); @Override Product create(final Product instance); ProductService getSelf(); }
ProductServiceImpl extends BaseGenericServiceImpl<Product> implements ProductService { @Override public Product create(final Product instance) { ProductSku sku = productDao.getEntityFactory().getByIface(ProductSku.class); sku.setCode(instance.getCode()); sku.setName(instance.getName()); sku.setDisplayName(instance.getDisplayName()); sku.setDescription(instance.getDescription()); sku.setProduct(instance); sku.setRank(0); sku.setSupplierCatalogCode(instance.getSupplierCatalogCode()); instance.getSku().add(sku); return getGenericDao().create(instance); } ProductServiceImpl(final GenericFTSCapableDAO<Product, Long, Object> productDao,
                              final GenericFTSCapableDAO<ProductSku, Long, Object> productSkuDao,
                              final ProductSkuService productSkuService,
                              final ProductTypeAttrService productTypeAttrService,
                              final AttributeService attributeService,
                              final GenericDAO<ProductCategory, Long> productCategoryDao,
                              final GenericDAO<ProductTypeAttr, Long> productTypeAttrDao,
                              final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); @Override ProductSku getSkuById(final Long skuId); @Override ProductSku getSkuById(final Long skuId, final boolean withAttributes); @Override String getDefaultImage(final Long productId); @Override ProductAttributesModel getProductAttributes(final long productId, final long skuId, final long productTypeId); @Override ProductCompareModel getCompareAttributes(final List<Long> productId,
                                                    final List<Long> skuId); @Override Map<Long, String> getAllProductsAttributeValues(final String attributeCode); @Override ProductSku getProductSkuByCode(final String skuCode); @Override Product getProductBySkuCode(final String skuCode); @Override Product getProductById(final Long productId); @Override Product getProductById(final Long productId, final boolean withAttribute); @Override ProductSearchResultPageDTO getProductSearchResultDTOByQuery(final NavigationContext navigationContext,
                                                                       final int firstResult,
                                                                       final int maxResults,
                                                                       final String sortFieldName,
                                                                       final boolean reverse); @Override ProductSearchResultNavDTO findFilteredNavigationRecords(final NavigationContext baseNavigationContext, final List<FilteredNavigationRecordRequest> request); @Override int getProductQty(final NavigationContext navigationContext); @Override Pair<Integer, Integer> findProductQtyAll(); @Override List<Product> getProductByIdList(final List idList); @Override Long findProductIdBySeoUri(final String seoUri); @Override Long findProductIdByGUID(final String guid); @Override Long findProductIdByCode(final String code); @Override List<Long> findProductIdsByManufacturerCode(final String code); @Override List<Long> findProductIdsByBarCode(final String code); @Override List<Long> findProductIdsByBarCodes(final Collection<String> codes); @Override List<Long> findProductIdsByPimCode(final String code); @Override List<Long> findProductIdsByAttributeValue(final String attrCode, final String attrValue); @Override String findSeoUriByProductId(final Long productId); @Override Long findProductSkuIdBySeoUri(final String seoUri); @Override Long findProductSkuIdByGUID(final String guid); @Override Long findProductSkuIdByCode(final String code); @Override String findSeoUriByProductSkuId(final Long skuId); @Override IndexBuilder.FTIndexState getProductsFullTextIndexState(); @Override IndexBuilder.FTIndexState getProductsSkuFullTextIndexState(); @Override void reindexProducts(final int batchSize); @Override void reindexProducts(final int batchSize, final boolean async); @Override void reindexProductsSku(final int batchSize); @Override void reindexProductsSku(final int batchSize, final boolean async); @Override void reindexProducts(final Long shopId, final int batchSize); @Override void reindexProductsSku(final Long shopId, final int batchSize); @Override void reindexProduct(final Long pk); @Override void reindexProductSku(final Long pk); @Override void reindexProductSku(final String code); @Override List<Product> findProducts(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findProductCount(final Map<String, List> filter); @Override List<Product> findProductByCodeNameBrandType(final String code,
                                                        final String name,
                                                        final Long brandId,
                                                        final Long productTypeId); @Override List<String> findProductSupplierCatalogCodes(); @Override Product create(final Product instance); ProductService getSelf();  }