Subversion Repositories SmartDukaan

Rev

Rev 37823 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37823 Rev 37869
Line 164... Line 164...
164
    public String getVendor(Model model, @RequestParam String query,
164
    public String getVendor(Model model, @RequestParam String query,
165
                            @RequestParam(required = false) Integer warehouseId) throws Throwable {
165
                            @RequestParam(required = false) Integer warehouseId) throws Throwable {
166
        // With a warehouse, offer only suppliers mapped to it - those with a vendor warehouse there to receive into.
166
        // With a warehouse, offer only suppliers mapped to it - those with a vendor warehouse there to receive into.
167
        Set<Integer> mappedSupplierIds = warehouseId == null || warehouseId <= 0 ? null
167
        Set<Integer> mappedSupplierIds = warehouseId == null || warehouseId <= 0 ? null
168
                : inventoryWarehouseRepository.selectSupplierIdsWithGoodWarehouse(warehouseId);
168
                : inventoryWarehouseRepository.selectSupplierIdsWithGoodWarehouse(warehouseId);
169
        List<Supplier> vendors = supplierRepository.selectAll().stream().filter(x -> x.getName().toLowerCase().matches(".*?" + query.toLowerCase() + ".*?"))
169
        List<Supplier> vendors = supplierRepository.selectAll().stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase()))
170
                .filter(x -> x.isStatus())
170
                .filter(x -> x.isStatus())
171
                .filter(x -> mappedSupplierIds == null || mappedSupplierIds.contains(x.getId()))
171
                .filter(x -> mappedSupplierIds == null || mappedSupplierIds.contains(x.getId()))
172
                .collect(Collectors.toList());
172
                .collect(Collectors.toList());
173
        model.addAttribute("response1", mvcResponseSender.createResponseString(vendors));
173
        model.addAttribute("response1", mvcResponseSender.createResponseString(vendors));
174
        return "response";
174
        return "response";