class VulnerabilityRepository implements Constants {

	public List<Map<String, Object>> getTrendAnnotations(String ag, Date from) {

		List<Map<String, Object>> notes = new ArrayList<>();
		SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");

		StringBuilder urlToQuery = new StringBuilder(esUrl).append("/")
				.append("assetgroup_annotations/annotations/_search");
		StringBuilder requestBody = new StringBuilder(
				"{\"size\":10000,\"query\":{\"bool\":{\"must\":[{\"range\":{\"date\":{\"gte\":\"");
		requestBody.append(dateformat.format(from));
		requestBody.append("\",\"lte\":\"");
		requestBody.append(dateformat.format(new Date()));
		requestBody.append("\",\"format\":\"yyyy-MM-dd\"}}}");
		requestBody.append(",{\"terms\":{\"ag.keyword\":[\"\",\"");
		requestBody.append(ag).append("\"]}}]}}}");

		String responseJson = "";
		try {
			responseJson = PacHttpUtils.doHttpPost(urlToQuery.toString(), requestBody.toString());
		} catch (Exception e) {
			LOGGER.error("Error in getTrendAnnotations from ES", e);
		}
		JsonParser jsonParser = new JsonParser();
		if (StringUtils.isNotEmpty(responseJson)) {
			JsonObject resultJson = (JsonObject) jsonParser.parse(responseJson);
			JsonArray hits = resultJson.get("hits").getAsJsonObject().get("hits").getAsJsonArray();
			Map<String, Object> note;
			if (hits.size() > 0) {
				for (int i = 0; i < hits.size(); i++) {
					JsonObject obj = (JsonObject) hits.get(i);
					JsonObject sourceJson = (JsonObject) obj.get("_source");
					if (sourceJson != null) {
						note = new Gson().fromJson(sourceJson, new TypeToken<Map<String, Object>>() {
						}.getType());
						notes.add(note);
					}
				}
			}
		}
		return notes;
	}

}