//Retrieving the current user
User user = userAPI.getLoggedInUser(request);
boolean respectFrontendRoles = true;
Event ev = eventAPI.find(id, live, user, respectFrontendRoles);
Map<String, Object> eventMap = ev.getMap();
//Loading categories
List<Map<String, Object>> categoryMaps = new ArrayList<Map<String,Object>>();
List<Category> eventCategories = categoryAPI.getParents(ev, user, respectFrontendRoles);
for(Category cat : eventCategories) {
categoryMaps.add(cat.getMap());
}
eventMap.put("categories", categoryMaps);
eventMap.put("rating", RatingAPI.getAverageRating(ev.getIdentifier()));
eventMap.put("votes", RatingAPI.getRatingVotesNumber(ev.getIdentifier()));
eventMap.put("hasReadPermission", perAPI.doesUserHavePermission(ev, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles));
eventMap.put("hasWritePermission", perAPI.doesUserHavePermission(ev, PermissionAPI.PERMISSION_WRITE, user, respectFrontendRoles));
eventMap.put("hasPublishPermission", perAPI.doesUserHavePermission(ev, PermissionAPI.PERMISSION_PUBLISH, user, respectFrontendRoles));
eventMap.put("readPermission", perAPI.doesUserHavePermission(ev, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles));
eventMap.put("writePermission", perAPI.doesUserHavePermission(ev, PermissionAPI.PERMISSION_WRITE, user, respectFrontendRoles));
eventMap.put("publishPermission", perAPI.doesUserHavePermission(ev, PermissionAPI.PERMISSION_PUBLISH, user, respectFrontendRoles));
eventMap.put("isDisconnected", UtilMethods.isSet(ev.getDisconnectedFrom()));
CommentsWebAPI cAPI = new CommentsWebAPI();
cAPI.setUser(user);
cAPI.setRespectFrontendRoles(respectFrontendRoles);
eventMap.put("commentsCount", cAPI.getCommentsCount(ev.getInode()));
return eventMap;
}