Rev 31613 | Rev 31615 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.service.solr;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.net.HttpURLConnection;import java.net.URL;import java.net.URLConnection;import java.time.ZoneId;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Map.Entry;import java.util.stream.Collectors;import java.util.zip.GZIPInputStream;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.impl.HttpSolrClient;import org.apache.solr.common.SolrInputDocument;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Component;import com.google.gson.Gson;import com.spice.profitmandi.dao.entity.catalog.TagListing;import com.spice.profitmandi.dao.entity.catalog.TagRanking;import com.spice.profitmandi.dao.entity.dtr.WebProductListing;import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;import com.spice.profitmandi.dao.repository.dtr.Mongo;import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;import com.spice.profitmandi.service.tag.ItemTagModel;import in.shop2020.model.v1.catalog.status;@Componentpublic class FofoSolr {@Autowiredprivate Gson gson;@Autowiredprivate TagListingRepository tagListingRepository;@AutowiredTagRankingRepository tagRankingRepository;@Autowiredprivate Mongo contentMongoClient;@Autowiredprivate WebListingRepository webListingRepository;@Autowiredprivate WebProductListingRepository webProductListingRepository;@Value("${new.solr.url}")private String solrUrl;private static final Logger logger = LogManager.getLogger(FofoSolr.class);private static final List<Integer> CATEGORY_MASTER = Arrays.asList(10006, 10010, 14202, 14203);String solrPath = "http://" + solrUrl + "8984/solr/demo";String mongoHost = "localhost";SolrClient solr = new HttpSolrClient.Builder(solrPath).build();private String getAvailabilityJSON() {String url = "http://50.116.10.120/reports/run.php?execute_mode=EXECUTE&xmlin=warehousecisnew.xml&project=FOCOR&project_password=focor&target_format=JSON";return getUrlContent(url);}private String getPendingPOJSON() {String url = "http://50.116.10.120/reports/run.php?execute_mode=EXECUTE&xmlin=UnfulfilledPOItemsNew.xml&project=FOCOR&project_password=focor&target_format=JSON";return getUrlContent(url);}private static String getUrlContent(String urlString) {BufferedReader reader = null;try {URL url = new URL(urlString);URLConnection conn = url.openConnection();conn.setConnectTimeout(5000);conn.setReadTimeout(5000);reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));return reader.lines().collect(Collectors.joining(System.lineSeparator()));} catch (IOException e) {e.printStackTrace();} finally {if (reader != null) {try {reader.close();} catch (IOException e) {e.printStackTrace();}}}return null;}public JSONArray getAvailability() throws IOException, JSONException {String url = "http://50.116.10.120/reports/run.php?execute_mode=EXECUTE&xmlin=warehousecisnew.xml&project=FOCOR&project_password=focor&target_format=JSON";HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();connection.setRequestProperty("Accept-Encoding", "gzip");BufferedReader reader = null;try {InputStream inputStream = connection.getInputStream();if ("gzip".equals(connection.getContentEncoding())) {inputStream = new GZIPInputStream(inputStream);}reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));StringBuilder responseBuilder = new StringBuilder();String line;while ((line = reader.readLine()) != null) {responseBuilder.append(line);}JSONObject responseJson = new JSONObject(responseBuilder.toString());return responseJson.getJSONArray("data");} finally {if (reader != null) {try {reader.close();} catch (IOException e) {// Ignore}}}}public JSONArray getPendingPO() throws IOException, JSONException {String url = "http://50.116.10.120/reports/run.php?execute_mode=EXECUTE&xmlin=UnfulfilledPOItemsNew.xml&project=FOCOR&project_password=focor&target_format=JSON";HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();connection.setRequestProperty("Accept-Encoding", "gzip");BufferedReader reader = null;try {InputStream inputStream = connection.getInputStream();if ("gzip".equals(connection.getContentEncoding())) {inputStream = new GZIPInputStream(inputStream);}reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));StringBuilder responseBuilder = new StringBuilder();String line;while ((line = reader.readLine()) != null) {responseBuilder.append(line);}JSONObject responseJson = new JSONObject(responseBuilder.toString());return responseJson.getJSONArray("data");} finally {if (reader != null) {try {reader.close();} catch (IOException e) {// Ignore}}}}public Map<String, Map<String, Map<String, Integer>>> getItemMap() throws Exception {JSONArray availabilityJSONArray = this.getAvailability();JSONArray pendingPOJSONArray = this.getPendingPO();Map<String, Map<String, Map<String, Integer>>> availabilityItemMap = new HashMap<>();for (int i = 0; i < availabilityJSONArray.length(); i++) {JSONObject rawAvailability = availabilityJSONArray.getJSONObject(i);if (!availabilityItemMap.containsKey(rawAvailability.getString("Itemid"))) {availabilityItemMap.put(rawAvailability.getString("Itemid"),new HashMap<String, Map<String, Integer>>());}if (!availabilityItemMap.get(rawAvailability.getString("Itemid")).containsKey(rawAvailability.getString("Warehouseid"))) {availabilityItemMap.get(rawAvailability.getString("Itemid")).put(rawAvailability.getString("Warehouseid"), new HashMap<String, Integer>());availabilityItemMap.get(rawAvailability.getString("Itemid")).get(rawAvailability.getString("Warehouseid")).put("netAvailability", 0);availabilityItemMap.get(rawAvailability.getString("Itemid")).get(rawAvailability.getString("Warehouseid")).put("netPo", 0);}int netAvailability = availabilityItemMap.get(rawAvailability.getString("Itemid")).get(rawAvailability.getString("Warehouseid")).get("netAvailability")+ rawAvailability.getInt("Netavailability");availabilityItemMap.get(rawAvailability.getString("Itemid")).get(rawAvailability.getString("Warehouseid")).put("netAvailability", netAvailability);}for (int i = 0; i < pendingPOJSONArray.length(); i++) {JSONObject rawPendingPo = pendingPOJSONArray.getJSONObject(i);String itemId = rawPendingPo.getString("Itemid");String warehouseId = rawPendingPo.getString("Warehouseid");if (!availabilityItemMap.containsKey(itemId)) {availabilityItemMap.put(itemId, new HashMap<String, Map<String, Integer>>());}if (!availabilityItemMap.get(itemId).containsKey(warehouseId)) {availabilityItemMap.get(itemId).put(warehouseId, new HashMap<String, Integer>() {{put("netAvailability", 0);put("netPo", 0);}});}availabilityItemMap.get(itemId).get(warehouseId).put("netPo",availabilityItemMap.get(itemId).get(warehouseId).get("netPo") + rawPendingPo.getInt("Unfulfilled"));}return availabilityItemMap;}public Map<Integer, List<String>> getLabels() {List<String> labels = Arrays.asList("partner-best-sellers", "partner-price-drop", "new-launches");Map<Integer, String> webListing = webListingRepository.selectByUrls(labels).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getUrl()));Map<Integer, List<WebProductListing>> webProductListingMap = webProductListingRepository.selectAllByWebListingIds(new ArrayList<>(webListing.keySet())).stream().collect(Collectors.groupingBy(x -> x.getWebListingId()));Map<Integer, List<String>> catalogLabelMap = new HashMap<>();for (Entry<Integer, List<WebProductListing>> webProductListingEntry : webProductListingMap.entrySet()) {for (WebProductListing webProduct : webProductListingEntry.getValue()) {if (!catalogLabelMap.containsKey(webProduct.getEntityId())) {catalogLabelMap.put(webProduct.getEntityId(), new ArrayList<>());}List<String> itemLabels = catalogLabelMap.get(webProduct.getEntityId());itemLabels.add(webListing.get(webProduct.getWebListingId()));catalogLabelMap.put(webProduct.getEntityId(), itemLabels);}}return catalogLabelMap;}public void populateTagItems() throws Exception {Map<String, Map<String, Map<String, Integer>>> availabilityItemMap = getItemMap();List<TagRanking> tagRankingList = tagRankingRepository.getAllTagRanking();List<Integer> rankingList = new ArrayList<>();Map<Integer, String> featureMap = new HashMap<>();for (TagRanking tagRanking : tagRankingList) {rankingList.add(tagRanking.getCatalogItemId());featureMap.put(tagRanking.getCatalogItemId(), tagRanking.getFeature());}Map<Integer, Map<String, Object>> catalogMap = new HashMap<>();List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);Map<Integer, List<String>> catalogLabelMap = this.getLabels();logger.info("catalogLabelMap {}", catalogLabelMap);/** List<ItemTagModel> tuples =* tagListingRepository.getAllItemTagByStatus(statuses).stream() .filter(x ->* x.getItem().getCatalogItemId() == 1023747).collect(Collectors.toList());*/List<ItemTagModel> tuples = tagListingRepository.getAllItemTagByStatus(statuses);Map<String, Object> projection = new HashMap<>();projection.put("defaultImageUrl", 1);List<String> excludeBrands = Arrays.asList("Live Demo", "Dummy", "FOC HANDSET");for (ItemTagModel result : tuples) {TagListing tag = result.getTagListing();com.spice.profitmandi.dao.entity.catalog.Item item = result.getItem();if (excludeBrands.contains(item.getBrand())) {continue;}if (!catalogMap.containsKey(item.getCatalogItemId())) {Map<String, Object> catalogObj = new HashMap<>();catalogObj.put("feature", "");catalogObj.put("title",String.join(" ", Arrays.asList(item.getBrand(), item.getModelName(), item.getModelNumber()).stream().filter(s -> s != null && !s.isEmpty()).collect(Collectors.toList())));catalogObj.put("brand", new String[] { item.getBrand() });if (item.getBrand().equals("Huawei") || item.getBrand().equals("Honor")) {catalogObj.put("brand", new String[] { "Huawei", "Honor" });}if (item.getBrand().equals("Mi") || item.getBrand().equals("Xiaomi")|| item.getBrand().equals("Redmi")) {catalogObj.put("brand", new String[] { "Mi", "Xiaomi", "Redmi" });}catalogObj.put("identifier", item.getCatalogItemId());catalogObj.put("items", new HashMap<Integer, Map<String, Object>>());Map<String, Object> filterMap = new HashMap<>();filterMap.put("_id", item.getCatalogItemId());// Don't include if catalog not availabletry {catalogObj.put("imageUrl",contentMongoClient.getEntityById(item.getCatalogItemId()).getDefaultImageUrl());System.out.println(catalogObj.get("imageUrl"));} catch (Exception e) {try {catalogObj.put("imageUrl","https://images.smartdukaan.com/uploads/campaigns/" + item.getCatalogItemId() + ".jpg");} catch (Exception e2) {e2.printStackTrace();}}try {catalogObj.put("rank", rankingList.indexOf(item.getCatalogItemId()));} catch (Exception e) {// A very big numbere.printStackTrace();catalogObj.put("rank", 50000000);}if (featureMap.containsKey(item.getCatalogItemId())&& featureMap.get(item.getCatalogItemId()) != null) {catalogObj.put("feature", featureMap.get(item.getCatalogItemId()));catalogObj.put("categoryId",CATEGORY_MASTER.contains(item.getCategoryId()) ? item.getCategoryId() : 6);}if (item.getCategoryId() == 10006) {catalogObj.put("categoryId", 3);}catalogObj.put("subCategoryId", item.getCategoryId());catalogObj.put("create_timestamp",tag.getCreatedTimestamp().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());if (catalogLabelMap.containsKey(item.getCatalogItemId())&& catalogLabelMap.get(item.getCatalogItemId()) != null) {catalogObj.put("labels", catalogLabelMap.get(item.getCatalogItemId()));}catalogMap.put(item.getCatalogItemId(), catalogObj);catalogObj.put("avColor", new HashMap<>());}Map<String, Object> catalogObj = catalogMap.get(item.getCatalogItemId());Map<Integer, Integer> avColorMap = (Map<Integer, Integer>) catalogObj.get("avColor");if (availabilityItemMap.containsKey(String.valueOf(item.getId()))) {for (Map.Entry<String, Map<String, Integer>> entry : availabilityItemMap.get(String.valueOf(item.getId())).entrySet()) {String warehouseId = entry.getKey();Map<String, Integer> avMap = entry.getValue();if (!avColorMap.containsKey(Integer.parseInt(warehouseId))) {avColorMap.put(Integer.parseInt(warehouseId), 0);}int color = avColorMap.get(Integer.parseInt(warehouseId));if (avMap.get("netAvailability") > 0) {color = 2;} else if (avMap.get("netAvailability") + avMap.get("netPo") > 0) {color = Math.max(color, 1);} else {color = Math.max(color, 0);}avColorMap.put(Integer.parseInt(warehouseId), color);catalogObj.put("avColor", avColorMap);}}Map<Integer, Object> itemColorMap = (Map<Integer, Object>) catalogObj.get("items");if (!itemColorMap.containsKey(item.getId())) {itemColorMap.put(item.getId(), new HashMap<String, Object>() {{put("color", item.getColor().replace("f_", ""));put("tagPricing", new ArrayList<TagListing>());}});}Map<String, Object> itemMap = (Map<String, Object>) itemColorMap.get(item.getId());List<TagListing> tagPricing = (List<TagListing>) itemMap.get("tagPricing");tagPricing.add(tag);}logger.info("catalogObj {}", catalogMap);List<SolrInputDocument> catalogSolrObjs = new ArrayList<>();for (Entry<Integer, Map<String, Object>> entry : catalogMap.entrySet()) {int catalogId = entry.getKey();Map<String, Object> catalogValMap = entry.getValue();Map<Integer, Object> itemsMap = (Map<Integer, Object>) catalogValMap.get("items");boolean active = false;// Map<Integer, Object> itemsMap = (Map<String, Object>)// catalogValMap.get("items");List<SolrInputDocument> itemObjs = new ArrayList<>();float mop = 0;for (Entry<Integer, Object> itemEntry : itemsMap.entrySet()) {int itemId = itemEntry.getKey();Map<String, Object> itemMap = (Map<String, Object>) itemEntry.getValue();List<TagListing> tags = (List<TagListing>) itemMap.get("tagPricing");SolrInputDocument itemObj = new SolrInputDocument();for (TagListing taglist : tags) {active = active || (Boolean) taglist.isActive();itemObj.setField("id", "itemtag-" + itemId + "-" + taglist.getTagId());itemObj.setField("color_s", itemMap.get("color"));itemObj.setField("itemId_i", itemId);itemObj.setField("tagId_i", taglist.getTagId());itemObj.setField("mrp_f", taglist.getMrp());itemObj.setField("mop_f", taglist.getMop());itemObj.setField("sellingPrice_f", taglist.getSellingPrice());itemObj.setField("active_b", taglist.isActive());itemObj.setField("hot_deal_b", taglist.isHotDeals());mop = taglist.getMop();}itemObjs.add(itemObj);}logger.info("catalogValMap {}", catalogValMap);logger.info("rank {}", catalogValMap.get("rank"));SolrInputDocument catalogSolrObj = new SolrInputDocument();catalogSolrObj.setField("id", "catalog" + catalogId);catalogSolrObj.setField("rank_i", catalogValMap.get("rank"));catalogSolrObj.setField("title_s", catalogValMap.get("title"));// catalogSolrObj.setField("_childDocuments_", itemObjs);catalogSolrObj.addChildDocuments(itemObjs);if (itemObjs != null) {catalogSolrObj.setField("child_b", itemObjs.size() > 0);} else {catalogSolrObj.setField("child_b",false);}catalogSolrObj.setField("catalogId_i", catalogId);catalogSolrObj.setField("imageUrl_s",catalogValMap.get("imageUrl").toString().replace("saholic", "smartdukaan"));catalogSolrObj.setField("feature_s", catalogValMap.get("feature"));catalogSolrObj.setField("brand_ss", catalogValMap.get("brand"));catalogSolrObj.setField("create_s", catalogValMap.get("create_timestamp"));catalogSolrObj.setField("categoryId_i", catalogValMap.get("categoryId"));catalogSolrObj.setField("subCategoryId_i", catalogValMap.get("subCategoryId"));catalogSolrObj.setField("label_ss", catalogValMap.get("labels"));catalogSolrObj.setField("w7573_i", 0);catalogSolrObj.setField("w7678_i", 0);catalogSolrObj.setField("w7720_i", 0);catalogSolrObj.setField("w8468_i", 0);catalogSolrObj.setField("w8889_i", 0);catalogSolrObj.setField("w8947_i", 0);catalogSolrObj.setField("w9213_i", 0);catalogSolrObj.setField("w9203_i", 0);catalogSolrObj.setField("mop_f", mop);catalogSolrObj.setField("show_default_b", false);String[] brands = (String[]) catalogValMap.get("brand");for (String brand : brands) {if (brand != "FOC") {catalogSolrObj.setField("show_default_b", true);}}Map<Integer, Integer> avColorMap = (Map<Integer, Integer>) catalogValMap.get("avColor");for (Entry<Integer, Integer> avColorEntry : avColorMap.entrySet()) {int whId = avColorEntry.getKey();int color = (int) avColorEntry.getValue();catalogSolrObj.setField("w" + whId + "_i", color);}catalogSolrObj.setField("active_b", active);logger.info("catalogSolrObj {}", catalogSolrObj.get("rank_i"));catalogSolrObjs.add(catalogSolrObj);}logger.info("catalogSolrObjs {}", catalogSolrObjs);solr.deleteByQuery("*:*");solr.add(catalogSolrObjs);org.apache.solr.client.solrj.response.UpdateResponse updateResponse = solr.commit();logger.info("solr {}", updateResponse.getStatus());}/** public void populateTagItems() throws Exception { Map<String, Map<String,* Map<String, Integer>>> availabilityItemMap = getItemMap(); List<TagRanking>* tagRankingList = tagRankingRepository.getAllTagRanking();** List<Integer> rankingList = new ArrayList<>(); SolrInputDocument featureMap =* new SolrInputDocument(); for (TagRanking tagRanking : tagRankingList) {* rankingList.add(tagRanking.getCatalogItemId());* featureMap.addField(String.valueOf(tagRanking.getCatalogItemId()),* tagRanking.getFeature()); }** Map<Integer, SolrInputDocument> catalogMap = new HashMap<>(); List<status>* statuses = new ArrayList<>(); statuses.add(status.ACTIVE);* statuses.add(status.PAUSED_BY_RISK); statuses.add(status.PARTIALLY_ACTIVE);* List<ItemTagModel> tuples =* tagListingRepository.getAllItemTagByStatus(statuses); SolrInputDocument* projection = new SolrInputDocument();** projection.addField("defaultImageUrl", 1); List<String> excludeBrands =* Arrays.asList("Live Demo", "FOC", "Dummy", "FOC HANDSET");** for (ItemTagModel result : tuples) { TagListing tag = result.getTagListing();* com.spice.profitmandi.dao.entity.catalog.Item item = result.getItem(); if* (excludeBrands.contains(item.getBrand())) { continue; }** if (!catalogMap.containsKey(item.getCatalogItemId())) { SolrInputDocument* catalogObj = new SolrInputDocument(); catalogObj.addField("feature", "");* catalogObj.addField("title", String.join(" ", Arrays.asList(item.getBrand(),* item.getModelName(), item.getModelNumber()) .stream().filter(s -> s != null* && !s.isEmpty()).collect(Collectors.toList()))); catalogObj.addField("brand",* item.getBrand()); if (item.getBrand().equals("Huawei") ||* item.getBrand().equals("Honor")) { catalogObj.addField("brand", new String[]* { "Huawei", "Honor" }); } if (item.getBrand().equals("Mi") ||* item.getBrand().equals("Xiaomi") || item.getBrand().equals("Redmi")) {* catalogObj.addField("brand", new String[] { "Mi", "Xiaomi", "Redmi" }); }* catalogObj.addField("identifier", item.getCatalogItemId());* catalogObj.addField("items", new SolrInputDocument()); SolrInputDocument* filterMap = new SolrInputDocument(); filterMap.addField("_id",* item.getCatalogItemId());** try {** BrandCatalog brandCatalog = brandsRepository.selectByBrand(item.getBrand());* catalogObj.addField("imageUrl", brandCatalog.getLogoUrl());* System.out.println(catalogObj.get("imageUrl")); } catch (Exception e) { try {* catalogObj.addField("imageUrl",* "https://images.smartdukaan.com/uploads/campaigns/" + item.getCatalogItemId()* + ".jpg"); } catch (Exception e2) { e2.printStackTrace(); } } try {* catalogObj.addField("rank", rankingList.indexOf(item.getCatalogItemId())); }* catch (Exception e) { // A very big number e.printStackTrace();* catalogObj.addField("rank", 50000000); } if* (featureMap.containsKey(String.valueOf(item.getCatalogItemId())) &&* featureMap.get(String.valueOf(item.getCatalogItemId())) != null) {* catalogObj.addField("feature", featureMap.get(item.getCatalogItemId()));** catalogObj.addField("categoryId",* CATEGORY_MASTER.contains(item.getCategoryId()) ? item.getCategoryId() : 6);** }** if (item.getCategoryId() == 10006) { catalogObj.addField("categoryId", 3); }* catalogObj.addField("subCategoryId", item.getCategoryId());* catalogObj.addField("create_timestamp", tag.getCreatedTimestamp());* catalogMap.put(item.getCatalogItemId(), catalogObj);* catalogObj.addField("avColor", new SolrInputDocument());** // Don't include if catalog not available** catalogObj = catalogMap.get(item.getCatalogItemId()); if* (availabilityItemMap.containsKey(String.valueOf(item.getId()))) { for* (Map.Entry<String, Map<String, Integer>> entry : availabilityItemMap* .get(String.valueOf(item.getId())).entrySet()) { String warehouseId =* entry.getKey(); Map<String, Integer> avMap = entry.getValue();** SolrInputDocument avColorDoc = (SolrInputDocument)* catalogObj.getFieldValue("avColor"); //.catalogObj.get if* (!avColorDoc.containsKey(warehouseId)) { avColorDoc.addField(warehouseId, 0);* } int color = (int) avColorDoc.getFieldValue(warehouseId);** if (avMap.get("netAvailability") > 0) { color = 2; } else if* (avMap.get("netAvailability") + avMap.get("netPo") > 0) { color =* Math.max(color, 1); } else { color = Math.max(color, 0); }** avColorDoc.addField(warehouseId, 0);** }** }** SolrInputDocument itemColorDoc = (SolrInputDocument)* catalogObj.getFieldValue("items");** if (!itemColorDoc.containsKey(item.getId())) {** itemColorDoc.addField(String.valueOf(item.getId()), new SolrInputDocument() {* { addField("color", item.getColor().replace("f_", ""));* addField("tagPricing", new ArrayList<TagListing>()); } }); }** SolrInputDocument itemMap = (SolrInputDocument) itemColorDoc* .getFieldValue(String.valueOf(item.getId()));** List<TagListing> tagPricing = (List<TagListing>)* itemMap.getFieldValue("tagPricing"); tagPricing.add(tag);** List<Map<String, Object>> catalogObjs = new ArrayList<>(); for* (Entry<Integer, HashMap<String, Object>> entry : catalogMap.entrySet()) { int* catalogId = entry.getKey(); Map<String, Object> catalogValMap =* entry.getValue();** boolean active = false; Map<String, Object> itemsMap = (Map<String, Object>)* catalogValMap.get("items"); List<Map<String, Object>> itemObjs = new* ArrayList<>(); float mop = 0;** for (Entry<String, Object> itemEntry : itemsMap.entrySet()) { int itemId =* Integer.parseInt(itemEntry.getKey()); Map<String, Object> itemValMap =* (Map<String, Object>) itemEntry.getValue(); List<TagListing> tags =* (List<TagListing>) catalogValMap.get("tagPricing");** for (TagListing taglist : tags) { active = active || (Boolean)* taglist.isActive(); Map<String, Object> itemObj = new HashMap<>();* itemObj.put("id", "itemtag-" + itemId + "-" + tag.getTagId());* itemObj.put("color_s", itemMap.get("color")); itemObj.put("itemId_i",* itemId); itemObj.put("tagId_i", tag.getTagId()); itemObj.put("mrp_f",* tag.getMrp()); itemObj.put("mop_f", tag.getMop());* itemObj.put("sellingPrice_f", tag.getSellingPrice()); itemObj.put("active_b",* tag.isActive()); itemObj.put("hot_deal_b", tag.isHotDeals()); mop =* tag.getMop(); itemObjs.add(itemObj); } } // Map<String, Object> catalogObj =* new HashMap<String, Object>(); catalogObj.put("id", "catalog" + catalogId);* catalogObj.put("rank_i", catalogMap.get("rank")); catalogObj.put("title_s",* catalogMap.get("title")); catalogObj.put("_childDocuments_", itemObjs);* catalogObj.put("child_b", itemObjs.size() > 0); catalogObj.put("catalogId_i",* catalogId); catalogObj.put("imageUrl_s",* catalogMap.get("imageUrl").toString().replace("saholic", "smartdukaan"));* catalogObj.put("feature_s", catalogMap.get("feature"));* catalogObj.put("brand_ss", catalogMap.get("brand"));* catalogObj.put("create_s", catalogMap.get("create_timestamp"));* catalogObj.put("categoryId_i", catalogMap.get("categoryId"));* catalogObj.put("subCategoryId_i", catalogMap.get("subCategoryId"));* catalogObj.put("w7573_i", 0); catalogObj.put("w7678_i", 0);* catalogObj.put("w7720_i", 0); catalogObj.put("w8468_i", 0);* catalogObj.put("w8889_i", 0); catalogObj.put("w8947_i", 0);* catalogObj.put("w9213_i", 0); catalogObj.put("w9203_i", 0);* catalogObj.put("mop_f", mop); for (Entry<Integer, Integer> avColorEntry :* avColorMap.entrySet()) { int whId = avColorEntry.getKey(); int color = (int)* avColorEntry.getValue(); catalogObj.put("w" + whId + "_i", color);** catalogObj.put("active_b", active); catalogObjs.add(catalogObj);* solr.deleteByQuery("*:*"); // solr.add((catalogObjs); }** } } }** }*/public void pushData() throws Exception {this.populateTagItems();}}