class ComplianceServiceImpl implements ComplianceService, Constants {

    public List<Map<String, Object>> getRuleDetailsbyEnvironment(String assetGroup, String ruleId, String application,
            String searchText) throws ServiceException {
        List<Map<String, Object>> environmentList = new ArrayList<>();
        String targetType = getTargetTypeByRuleId(ruleId);

        JsonArray buckets;
        try {
            buckets = repository.getRuleDetailsByEnvironmentFromES(assetGroup, ruleId, application, searchText,targetType);

        } catch (DataException e) {
        	logger.error("Error @ getRuleDetailsbyEnvironment while getting the env by rule and application from ES", e);
            throw new ServiceException(e);
        }
        Gson googleJson = new Gson();
        List<Map<String, Object>> issuesForApplcationByEnvList = googleJson.fromJson(buckets, ArrayList.class);
        Map<String, Long> issuesByApplcationListMap = issuesForApplcationByEnvList.parallelStream().collect(
                Collectors.toMap(issue -> issue.get(KEY).toString(),
                        issue -> (long) Double.parseDouble(issue.get(DOC_COUNT).toString())));
         
        Map<String,Long>  assetCountByEnv = repository.getTotalAssetCountByEnvironment(assetGroup, application, targetType);
        
        formComplianceDetailsForApplicationByEnvironment(ruleId, assetCountByEnv, issuesByApplcationListMap,assetGroup,application,environmentList,targetType,searchText);
        return environmentList;

    }

}