class RecommendationsRepository {

	public Map<String,Object> getRecommendationDetail(String assetGroup, String recommendationId, String application) throws DataException {
		
		Map<String,Object> recommendationDetail = new HashMap<>();
		List<Map<String,Object>> resources = new ArrayList<>();
		
		String parentType = "";
		if(StringUtils.isNotBlank(application)) {
			String query = "SELECT type FROM Recommendation_Mappings WHERE checkId =\""+recommendationId+"\"";
	        try {
	        	parentType = rdsRepository.queryForString(query);
	        } catch (Exception exception) {
	            LOGGER.error("Error in getRecommendationDetail for getting parent type " , exception);
	        }
		}
		
		StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append(assetGroup).append("/")
    			.append("recommendation").append("/").append(Constants.SEARCH).append("?scroll=")
                .append(Constants.ES_PAGE_SCROLL_TTL);

        String urlToQuery = urlToQueryBuffer.toString();
        String urlToScroll = new StringBuilder(esUrl).append("/").append(Constants.SEARCH).append("/scroll")
                .toString();
		
		StringBuilder requestBody = new StringBuilder("{\"size\":10000,\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}},{\"match\":{\"recommendationId.keyword\":\"");
		requestBody.append(recommendationId).append("\"}}");
		if(StringUtils.isNotBlank(application)) {
			requestBody.append(",{\"has_parent\":{\"parent_type\":\"");
			requestBody.append(parentType);
			requestBody.append("\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":true}},{\"match\":{\"_entity.keyword\":true}},{\"match\":{\"tags.Application.keyword\":\"");
			requestBody.append(application);
			requestBody.append("\"}}]}}}}");
		}
		requestBody.append("]}}}");
		long totalDocs = getTotalDocCount(assetGroup, "recommendation", "{" + requestBody.toString().substring(14));
		String request = requestBody.toString();
        String scrollId = null;
        if(totalDocs > 0){
            for (int index = 0; index <= (totalDocs / Constants.ES_PAGE_SIZE); index++) {
                String responseDetails = null;
                try {
                    if (StringUtils.isNotBlank(scrollId)) {
                        request = elasticSearchRepository.buildScrollRequest(scrollId, Constants.ES_PAGE_SCROLL_TTL);
                        urlToQuery = urlToScroll;
                    }
                    responseDetails = PacHttpUtils.doHttpPost(urlToQuery, request);
                    scrollId = processResponseAndSendTheScrollBack(responseDetails, resources);
                } catch (Exception e) {
                }
            }
        }
		
		recommendationDetail.put("resources", resources);
		return recommendationDetail;
	}

}