public void validateEndDate(FacesContext context, UIComponent component, Object value) throws ValidatorException { Date endDate = (Date) value; if (endDate == null) { ZVotesUtils.throwValidatorException("EndDateNotSet"); } UIInput startDateComponent = (UIInput) (context.getViewRoot().findComponent("pollEditForm:startDate")); Date startDate = (Date) startDateComponent.getValue(); if (startDate.after(endDate)) { ZVotesUtils.throwValidatorException("EndDateBeforeStartDate"); } if (endDate.before(new Date())) { ZVotesUtils.throwValidatorException("EndDateBeforeNow"); } if (current.getId() != null) { Date previousEndDate = getFacade().find(current.getId()).getEndDate(); if ((current.getPollState().equals(PollState.PUBLISHED) || current.getPollState().equals(PollState.STARTED) || current.getPollState().equals(PollState.VOTING)) && endDate.before(previousEndDate)) { ZVotesUtils.throwValidatorException("EndDateCantBeMovedToEarlierTime"); } } }
public void validateDescription(FacesContext context, UIComponent component, Object value) throws ValidatorException { String description = (String) value; if (description.isEmpty()) { ZVotesUtils.throwValidatorException("DescriptionNotSet"); } }
public void validateStartDate(FacesContext context, UIComponent component, Object value) throws ValidatorException { Date startDate = (Date) value; if (startDate == null) { ZVotesUtils.throwValidatorException("StartDateNotSet"); } }
public void validateTitle(FacesContext context, UIComponent component, Object value) throws ValidatorException { String title = (String) value; if (title.isEmpty()) { ZVotesUtils.throwValidatorException("TitleNotSet"); } List<Poll> polls_with_title = getFacade().findAllBy("title", title); int amt_polls_with_title = 0; for (Poll poll : polls_with_title) { if (!Objects.equals(poll.getId(), current.getId())) { amt_polls_with_title++; } } if (amt_polls_with_title >= 1) { ZVotesUtils.throwValidatorException("TitleAlreadyUsed"); } }