class IssueTrendServiceImpl implements IssueTrendService, Constants {

    @Override
    public Map<String, Object> getComplianceTrendProgress(String assetGroup,
            LocalDate fromDate, String domain) throws ServiceException {
        Map<String, Object> parentMap = new HashMap<>();
        parentMap.put("ag", assetGroup);
        // get list of targetypes mapped
        String ttypes = complianceRepository.getTargetTypeForAG(assetGroup,
                domain);
        List<Map<String, Object>> ruleDetails = null;
        List<Map<String, Object>> inputList;
        List<Map<String, Object>> complianceInfoList;
        
        if (!Strings.isNullOrEmpty(ttypes)) {
            try {
                ruleDetails = complianceRepository
                        .getRuleIdWithDisplayNameQuery(ttypes);
            } catch (DataException e) {
              throw new ServiceException(e);
            }
        }
        // Make map of rule severity,category
        Set<String> ruleCat = new HashSet<>();
        List<Map<String, Object>> ruleSevCatDetails;
    
            ruleSevCatDetails = complianceService
                    .getRuleSevCatDetails(ruleDetails);
       
        
        
        Map<String, Object> ruleCatDetails = ruleSevCatDetails.parallelStream()
                .collect(
                        Collectors.toMap(c -> c.get(RULEID).toString(),
                                c -> c.get(RULE_CATEGORY),
                                (oldvalue, newValue) -> newValue));
        ruleCatDetails.entrySet().parallelStream()
                .forEach(entry -> ruleCat.add(entry.getValue().toString()));
        complianceInfoList = new ArrayList<>();

         try {
            inputList = repository
                    .getComplianceTrendProgress(assetGroup, fromDate, domain,
                            ruleCat);
         } catch (DataException e) {
             throw new ServiceException(e);
           }
       
        if (!inputList.isEmpty()) {
            // Sort the list by the date in ascending order
            Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse(
                    m1.get("date").toString(), DateTimeFormatter.ISO_DATE)
                    .compareTo(
                            LocalDate.parse(m2.get("date").toString(),
                                    DateTimeFormatter.ISO_DATE));

            Collections.sort(inputList, comp);
            useRealTimeDataForLatestDate(inputList, assetGroup,
                    COMPLIANCE_PERCENTAGE, null, domain);
            inputList.forEach(inputMap -> {
                Map<String, Object> outputMap = new HashMap<>();
                inputMap.forEach((key, value) -> {
                    // Other than the specified keys, ignore all other kv pairs
                    if ((!Strings.isNullOrEmpty(key))
                            && !("_id".equalsIgnoreCase(key))) {

                        outputMap.put(key, value);
                    }
                });

                complianceInfoList.add(outputMap);
            });

            Collections.sort(complianceInfoList, comp);
        }
        parentMap.put("compliance_info", complianceInfoList);
        return parentMap;
    }

}