class ComplianceServiceImpl implements ComplianceService, Constants {

    @Override
    public Map<String, Object> getDistribution(String assetGroup, String domain) throws ServiceException {
        try {
            Map<String, Object> distribution = new HashMap<>();
            // get Rules mapped to targetType
            String targetTypes = repository.getTargetTypeForAG(assetGroup, domain);
            List<Object> rules = repository.getRuleIds(targetTypes);
            // get issue count
            Long totalIssues = getIssuesCount(assetGroup, null, domain);
            // get severity distribution
            Map<String, Long> ruleSeverityDistribution = repository.getRulesDistribution(assetGroup, domain, rules,
                    SEVERITY);
            // get category distribution
            Map<String, Long> ruleCategoryDistribution = repository.getRulesDistribution(assetGroup, domain, rules,
                    RULE_CATEGORY);
            // get rule category distribution
            Map<String, Object> ruleCategoryPercentage = repository.getRuleCategoryPercentage(ruleCategoryDistribution,
                    totalIssues);
            distribution.put("distribution_by_severity", ruleSeverityDistribution);
            distribution.put("distribution_ruleCategory", ruleCategoryDistribution);
            distribution.put("ruleCategory_percentage", ruleCategoryPercentage);
            distribution.put("total_issues", totalIssues);
            return distribution;
        } catch (DataException e) {
            throw new ServiceException(e);
        }
    }

}