class PatchingRepositoryImpl implements PatchingRepository, Constants {

    @Override
    public Map<String, Long> getNonCompliantNumberForAgAndResourceType(
            String assetGroup, String resourceType) throws DataException {
        Map<String, Long> map = new HashMap<>();
        Map<String, Object> mustFilter = new HashMap<>();
        Map<String, Object> mustNotFilter = new HashMap<>();
        mustFilter.put(CommonUtils.convertAttributetoKeyword(ISSUE_STATUS),
                OPEN);
        String aggsFilterFieldName = CommonUtils
                .convertAttributetoKeyword(TAGS_APPLICATION);
        AssetCountDTO[] targetTypes = filterRepository.getListOfTargetTypes(
                assetGroup, null);
        for (AssetCountDTO targettype : targetTypes) {
            if (StringUtils.isNotBlank(targettype.getType())) {
                try{
                if (EC2.equals(resourceType) && resourceType.equals(targettype.getType())) {
                    mustFilter.put(
                            CommonUtils.convertAttributetoKeyword(RULEID),
                            EC2_KERNEL_COMPLIANCE_RULE);
                    mustFilter.put(HAS_PARENT,
                            addParentConditionPatching(EC2));
                    map = elasticSearchRepository
                            .getTotalDistributionForIndexAndType(assetGroup
                                    + "/issue_ec2", null, mustFilter,
                                    mustNotFilter, null, aggsFilterFieldName,
                                    FIVE_THOUSAND, null);
                }
                } catch(Exception e){
                    throw new DataException(e);
                }
            }
        }
        return map;
    }

}