Voter voter = voterManager.getVoter(currentUser.getUsername(), remoteAddress, surveyInfo.getId());
return (voter != null);
}
private static boolean isVotedByUser(SurveyRecord surveyInfo, HttpServletRequest request) throws ApsSystemException {
//String remoteAddress = request.getRemoteAddr();
IVoterManager voterManager = (IVoterManager) ApsWebApplicationUtils.getBean(SurveySystemConstants.SURVEY_VOTER_MANAGER, request);
UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
FieldSearchFilter usernameFilter = new FieldSearchFilter((IVoterManager.FIELD_USERNAME), currentUser.getUsername(), false);
FieldSearchFilter surveyIdFilter = new FieldSearchFilter((IVoterManager.FIELD_SURVEY_ID), new Integer(surveyInfo.getId()), false);
FieldSearchFilter[] filters = new FieldSearchFilter[]{usernameFilter, surveyIdFilter};
List<Integer> voters = voterManager.searchVoters(filters);
return (null != voters && !voters.isEmpty());
}