class ComplianceServiceImpl implements ComplianceService, Constants {

    public PolicyViolationDetails getPolicyViolationDetailsByIssueId(String assetGroup, String issueId)
            throws ServiceException {

        String policyViolated = null;
        String policyDescription = null;
        String resourceId = null;
        String ruleId = null;
        String issueDetails = null;
        List<Map<String, Object>> violationList = new ArrayList<>();
        Map<String, Object> violation = null;
        Map<String, Object> policyViolationByIssueId;
        try {
            policyViolationByIssueId = repository.getPolicyViolationDetailsByIssueId(assetGroup, issueId);
        } catch (DataException e) {
            throw new ServiceException(e);
        }
        if (!policyViolationByIssueId.isEmpty()) {
            ruleId = policyViolationByIssueId.get(RULEID).toString();
            resourceId = policyViolationByIssueId.get(RESOURCEID).toString();
            // get policy description from DB
            policyDescription = (null != getRuleDescription(ruleId).get(RULE_DESC)) ? getRuleDescription(ruleId).get(
                    RULE_DESC).toString() : "";
            // get policy title from DB
            policyViolated = (null != getRuleDescription(ruleId).get(DISPLAY_NAME)) ? getRuleDescription(ruleId).get(
                    DISPLAY_NAME).toString() : "";
            issueDetails = (null != policyViolationByIssueId.get(ISSUE_DETAILS)) ? policyViolationByIssueId.get(
                    ISSUE_DETAILS).toString() : null;
            if (null != issueDetails) {
                issueDetails = issueDetails.substring(TWO, issueDetails.length() - TWO);
                violation = Arrays.stream(issueDetails.trim().split(", ")).map(s -> s.split("="))
                        .collect(Collectors.toMap(a -> a[0], // key
                                a -> a[1] // value
                                ));
                violation.remove("violationReason");
                violationList.add(violation);
            }
            return new PolicyViolationDetails(policyViolationByIssueId.get(TARGET_TYPE).toString(),
                    policyViolationByIssueId.get(ISSUE_STATUS).toString(), policyViolationByIssueId.get(SEVERITY)
                            .toString(), policyViolationByIssueId.get(RULE_CATEGORY).toString(), resourceId,
                    policyViolated, policyDescription, policyViolationByIssueId.get(ISSUE_REASON).toString(),
                    policyViolationByIssueId.get(CREATED_DATE).toString(), policyViolationByIssueId.get(MODIFIED_DATE)
                            .toString(), policyViolationByIssueId.get(POLICYID).toString(), ruleId, violationList);

        } else {
            throw new ServiceException(NO_DATA_FOUND);
        }

    }

}