class VulnerabilityService implements Constants {

	public List<Map<String, Object>> getVulnerabilitiesDetails(String assetGroup, Map<String, String> filter)
			throws Exception {
		List<Map<String, Object>> vulnerabilitiesDetails = new ArrayList<>();
		try {
			List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup);
			if (!vulnTargetTypes.isEmpty()) {
				for (String parentType : vulnTargetTypes) {
					Map<String, Long> vulnAssetsAffected = vulnerabilityRepository.getAssetsAffectedCount(assetGroup,
							filter, parentType);
					List<Map<String, Object>> vulnerabilitiesData = formVulnerabilitiesData(vulnerabilityRepository
							.getAllVulnerabilities(new ArrayList<String>(vulnAssetsAffected.keySet())),
							vulnAssetsAffected);
					List<Map<String, Object>> vulnerabilitiesDetailsTemp = new ArrayList<>();
					if (vulnerabilitiesDetails.isEmpty()) {
						vulnerabilitiesDetails = new ArrayList<>(vulnerabilitiesData);
					} else {
						for (Map<String, Object> vulnData : vulnerabilitiesData) {
							boolean qidMatched = false;
							for (Map<String, Object> vulnDetail : vulnerabilitiesDetails) {
								if (vulnData.get("qid").equals(vulnDetail.get("qid"))) {
									vulnDetail.put(ASSETS_AFFECTED,
											Long.valueOf(vulnDetail.get(ASSETS_AFFECTED).toString())
													+ Long.valueOf(vulnData.get(ASSETS_AFFECTED).toString()));
									qidMatched = true;
									break;
								}
							}
							if (!qidMatched) {
								vulnerabilitiesDetailsTemp.add(vulnData);
							}
						}
						vulnerabilitiesDetails.addAll(vulnerabilitiesDetailsTemp);
					}
				}
			}

		} catch (Exception e) {
			logger.error("Error in getVulnerabilitiesDetails ", e);
			throw e;
		}

		return vulnerabilitiesDetails;
	}

}