@Test public void testGetProductTypes() throws Exception { VoSearchContext ctx; ctx = new VoSearchContext(); ctx.setStart(0); ctx.setSize(10); VoSearchResult<VoProductTypeInfo> ptNoFilter = voProductTypeService.getFilteredTypes(ctx); assertNotNull(ptNoFilter); assertFalse(ptNoFilter.getItems().isEmpty()); ctx = new VoSearchContext(); ctx.setParameters(createSearchContextParams("filter", "Laser")); ctx.setStart(0); ctx.setSize(10); VoSearchResult<VoProductTypeInfo> ptFind = voProductTypeService.getFilteredTypes(ctx); assertNotNull(ptFind); assertFalse(ptFind.getItems().isEmpty()); final VoProductTypeInfo pt6 = ptFind.getItems().get(0); assertEquals("6", pt6.getGuid()); assertEquals("Blaster", pt6.getName()); ctx = new VoSearchContext(); ctx.setParameters(createSearchContextParams("filter", "!MP3 Player")); ctx.setStart(0); ctx.setSize(10); VoSearchResult<VoProductTypeInfo> ptExact = voProductTypeService.getFilteredTypes(ctx); assertNotNull(ptExact); assertEquals(1, ptExact.getTotal()); assertEquals("2", ptExact.getItems().get(0).getGuid()); ctx = new VoSearchContext(); ctx.setParameters(createSearchContextParams("filter", "#POWERSUPPLY")); ctx.setStart(0); ctx.setSize(10); VoSearchResult<VoProductTypeInfo> ptByAttrCode = voProductTypeService.getFilteredTypes(ctx); assertNotNull(ptByAttrCode); assertFalse(ptByAttrCode.getItems().isEmpty()); assertTrue(ptByAttrCode.getItems().stream().allMatch(pt -> "6".equals(pt.getGuid()))); }
@Override public VoSearchResult<VoProductTypeInfo> getFilteredTypes(final VoSearchContext filter) throws Exception { final VoSearchResult<VoProductTypeInfo> result = new VoSearchResult<>(); final List<VoProductTypeInfo> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter" ); final SearchResult<ProductTypeDTO> batch = dtoProductTypeService.findProductTypes(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoProductTypeInfo.class, ProductTypeDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); return result; }
VoProductTypeServiceImpl implements VoProductTypeService { @Override public VoSearchResult<VoProductTypeInfo> getFilteredTypes(final VoSearchContext filter) throws Exception { final VoSearchResult<VoProductTypeInfo> result = new VoSearchResult<>(); final List<VoProductTypeInfo> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter" ); final SearchResult<ProductTypeDTO> batch = dtoProductTypeService.findProductTypes(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoProductTypeInfo.class, ProductTypeDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); return result; } }
VoProductTypeServiceImpl implements VoProductTypeService { @Override public VoSearchResult<VoProductTypeInfo> getFilteredTypes(final VoSearchContext filter) throws Exception { final VoSearchResult<VoProductTypeInfo> result = new VoSearchResult<>(); final List<VoProductTypeInfo> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter" ); final SearchResult<ProductTypeDTO> batch = dtoProductTypeService.findProductTypes(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoProductTypeInfo.class, ProductTypeDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); return result; } VoProductTypeServiceImpl(final DtoProductTypeService dtoProductTypeService,
                                    final DtoProdTypeAttributeViewGroupService dtoProdTypeAttributeViewGroupService,
                                    final DtoProductTypeAttrService dtoProductTypeAttrService,
                                    final DtoAttributeService dtoAttributeService,
                                    final FederationFacade federationFacade,
                                    final VoAssemblySupport voAssemblySupport); }
VoProductTypeServiceImpl implements VoProductTypeService { @Override public VoSearchResult<VoProductTypeInfo> getFilteredTypes(final VoSearchContext filter) throws Exception { final VoSearchResult<VoProductTypeInfo> result = new VoSearchResult<>(); final List<VoProductTypeInfo> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter" ); final SearchResult<ProductTypeDTO> batch = dtoProductTypeService.findProductTypes(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoProductTypeInfo.class, ProductTypeDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); return result; } VoProductTypeServiceImpl(final DtoProductTypeService dtoProductTypeService,
                                    final DtoProdTypeAttributeViewGroupService dtoProdTypeAttributeViewGroupService,
                                    final DtoProductTypeAttrService dtoProductTypeAttrService,
                                    final DtoAttributeService dtoAttributeService,
                                    final FederationFacade federationFacade,
                                    final VoAssemblySupport voAssemblySupport); @Override VoSearchResult<VoProductTypeInfo> getFilteredTypes(final VoSearchContext filter); @Override VoProductType getTypeById(final long id); @Override VoProductType updateType(final VoProductType vo); @Override VoProductType createType(final VoProductTypeInfo vo); @Override VoProductType copyType(final long id, final VoProductTypeInfo vo); @Override void removeType(final long id); @Override List<VoProductTypeAttr> getTypeAttributes(final long typeId); @Override List<VoProductTypeAttr> updateTypeAttributes(final List<MutablePair<VoProductTypeAttr, Boolean>> vo); }
VoProductTypeServiceImpl implements VoProductTypeService { @Override public VoSearchResult<VoProductTypeInfo> getFilteredTypes(final VoSearchContext filter) throws Exception { final VoSearchResult<VoProductTypeInfo> result = new VoSearchResult<>(); final List<VoProductTypeInfo> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter" ); final SearchResult<ProductTypeDTO> batch = dtoProductTypeService.findProductTypes(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoProductTypeInfo.class, ProductTypeDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); return result; } VoProductTypeServiceImpl(final DtoProductTypeService dtoProductTypeService,
                                    final DtoProdTypeAttributeViewGroupService dtoProdTypeAttributeViewGroupService,
                                    final DtoProductTypeAttrService dtoProductTypeAttrService,
                                    final DtoAttributeService dtoAttributeService,
                                    final FederationFacade federationFacade,
                                    final VoAssemblySupport voAssemblySupport); @Override VoSearchResult<VoProductTypeInfo> getFilteredTypes(final VoSearchContext filter); @Override VoProductType getTypeById(final long id); @Override VoProductType updateType(final VoProductType vo); @Override VoProductType createType(final VoProductTypeInfo vo); @Override VoProductType copyType(final long id, final VoProductTypeInfo vo); @Override void removeType(final long id); @Override List<VoProductTypeAttr> getTypeAttributes(final long typeId); @Override List<VoProductTypeAttr> updateTypeAttributes(final List<MutablePair<VoProductTypeAttr, Boolean>> vo);  }