@Override public JSONObject getProductListingByPlsid(int plsid) { ProductListing prod = productListingRepository.findOne(plsid); JSONObject object = new JSONObject(); if (prod != null) { object.put("partyid", prod.getParty().getPtyId()); object.put("productlisting", getProductlsiting(prod)); } return object; }
@Override public JSONArray getProductListingByPartyid(int partyid) { List<ProductListing> prdlisting = productListingRepository.findByptyId(partyid); JSONArray jsonrecords = new JSONArray(); JSONObject object; if (prdlisting != null) { for (ProductListing prdlist : prdlisting) { object = new JSONObject(); object.put("productlisting", getProductlsiting(prdlist)); object.put("partyid", prdlist.getParty().getPtyId()); jsonrecords.add(object); } } return jsonrecords; }
private String getProductlsiting(ProductListing prdlist) { String productlisting = ""; Product pdt = prdlist.getProduct(); String featurelist = ""; productlisting = prdlist.getPlsId() + "," + pdt.getCategory().getCatName() + "," + pdt.getPrdName() + "," + pdt.getPrdDescription() + "," + pdt.getPrdPhotoLink(); for (ListedProductFeature feature : prdlist.getListedProductFeatures()) { featurelist = featurelist.equals("") ? (featurelist + feature.getId().getFtrName() + "," + feature.getLpfFtrValue()) : featurelist + "," + feature.getId().getFtrName() + "," + feature.getLpfFtrValue(); } return featurelist.equals("") ? productlisting : productlisting + "," + featurelist; }