class ComplianceRepositoryImpl implements ComplianceRepository, Constants {

    public Map<String, Long> getPatchableAssetsByApplication(String assetGroup, String application, String resourceType)
            throws DataException {
        Map<String, Object> mustFilter = new HashMap<>();
        Map<String, Object> mustNotFilter = new HashMap<>();
        Map<String, Long> patchableassetsByApp = null;
        mustFilter.put(LATEST, true);
        String aggsFilter = "tags.Application.keyword";
        if (!Strings.isNullOrEmpty(application)) {
            mustFilter.put(TAGS_APPLICATION, application);
        }
        try {
            if ("ec2".equals(resourceType)) {
                mustFilter.put(STATE_NAME, RUNNING);
                mustNotFilter.put(PLATFORM, WINDOWS);

                patchableassetsByApp = elasticSearchRepository.getTotalDistributionForIndexAndType(assetGroup, "ec2",
                        mustFilter, mustNotFilter, null, aggsFilter, 1000, null);
            } else if (ONPREMSERVER.equals(resourceType)) {
                mustFilter.put(INSCOPE, true);
                patchableassetsByApp = elasticSearchRepository.getTotalDistributionForIndexAndType(assetGroup,
                        ONPREMSERVER, mustFilter, null, null, aggsFilter, 5000, null);
            }
        } catch (Exception e) {
            throw new DataException(e);
        }
        if (null != patchableassetsByApp && patchableassetsByApp.isEmpty()) {
            throw new DataException(NO_DATA_FOUND);
        }
        return patchableassetsByApp;
    }

}