SHARE
TWEET

Untitled

a guest Jan 21st, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public List<ModelDTO> getFiltredAndSortedModels(List<String> filterBy,double priceFrom, double priceTo, int page, int size, String order, String sortby) {
  2.         List<Model> modelList;
  3.         if(filterBy != null){
  4.             List<Collection> collections = new LinkedList<>();
  5.             for(String name : filterBy){
  6.                 collections.add(collectionService.getCollectionByName(name));
  7.             }
  8.             if(order.equals("asc"))
  9.                 modelList = getAllModelsAvaiableFromCollection(PageRequest.of(page, size, Sort.Direction.ASC, sortby),priceFrom,priceTo,collections);
  10.             else
  11.                 modelList = getAllModelsAvaiableFromCollection(PageRequest.of(page, size, Sort.Direction.DESC, sortby),priceFrom,priceTo,collections);
  12.         }else{
  13.             if(order.equals("asc"))
  14.                 modelList = getAllModelsAvaiable(PageRequest.of(page, size, Sort.Direction.ASC, sortby),priceFrom,priceTo);
  15.             else
  16.                 modelList = getAllModelsAvaiable(PageRequest.of(page, size, Sort.Direction.DESC, sortby),priceFrom,priceTo);
  17.  
  18.         }
  19.         List<ModelDTO> result = new LinkedList<>();
  20.         Sale sale;
  21.         ModelDTO tmp;
  22.         for(Model model : modelList){
  23.             tmp = castToModelDTO(model);
  24.             tmp.setMiniature(photoService.getMiniaturePhoto(model));
  25.             sale = getSale(model);
  26.             if(sale != null) {
  27.                 tmp.setSalePrice(tmp.getBasicPrice() - sale.getDiscount());
  28.                 tmp.setSaleAfter(sale.getMinNumber());
  29.             }
  30.             result.add(tmp);
  31.         }
  32.         return result;
  33.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top