public ItemDto[] standardItems(String rulesUrl, String cartIds) { // a special item to use as fallback ItemDto special = new ItemDto(); special.setItemNo(999); special.setDescription("Special Rider Auto Part premium service"); special.setName("special"); special.setNumber(100); return new ItemDto[]{special}; }
private String itemsToCommaString(ItemDto[] items) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < items.length; i++) { ItemDto item = items[i]; sb.append(item.getItemNo()); if (i < items.length - 1) { sb.append(","); } } return sb.toString(); } }
private String itemsToCommaString(ItemDto[] items) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < items.length; i++) { ItemDto item = items[i]; sb.append(item.getItemNo()); if (i < items.length - 1) { sb.append(","); } } return sb.toString(); }
@RequestMapping(value = "rules/{cartIds}", method = RequestMethod.GET, produces = "application/json") public List<ItemDto> rules(@PathVariable String cartIds) { // find all items in inventory (use Camel to call legacy system) ItemsDto inventory = producer.request(ItemsDto.class); return inventory.getItems().stream() // filter out duplicate from the shopping cart .filter((i) -> cartIds == null || !cartIds.contains("" + i.getItemNo())) // sort the items .sorted(new ItemSorter()) // and collect to the list to use for response .collect(Collectors.toList()); }
@RequestMapping(value = "rules/{cartIds}", method = RequestMethod.GET, produces = "application/json") public List<ItemDto> rules(@PathVariable String cartIds) { // find all items in inventory (use Camel to call legacy system) ItemsDto inventory = producer.request(ItemsDto.class); return inventory.getItems().stream() // filter out duplicate from the shopping cart .filter((i) -> cartIds == null || !cartIds.contains("" + i.getItemNo())) // sort the items .sorted(new ItemSorter()) // and collect to the list to use for response .collect(Collectors.toList()); }