public RatingPollingQuestion saveQuestion(RatingPollingQuestion pollingQuestion) throws Exception { if (voteDao.isRepeatedQuestion(pollingQuestion)) throw new RepeatedQuestionException("question_is_repeated"); else if (voteDao.isAnsweredQuestion(pollingQuestion)) throw new UsedQuestionException("edit_used_question_message"); else return (RatingPollingQuestion) voteDao.save(pollingQuestion); }
public Vote saveVote(Vote vote) throws Exception { // totalRate = (((answer1 calculated rate)/q1 total rate)+(((answer2 calculated rate)/q2 total // rate)+...)/(sum of all template question's wight) // MultipleChoice answer rate and "total rate" will be evaluated according to selected options // Rating answer rate is "value/maxRate" vote.setTotalRate(calculateVoteTotalRate(vote)); return (Vote) voteDao.save(vote); }
public MultipleChoicePollingQuestion saveQuestion(MultipleChoicePollingQuestion pollingQuestion) throws Exception { if (isRepeatedMultipleChoiceQuestion(pollingQuestion)) throw new RepeatedQuestionException("question_is_repeated"); else if (voteDao.isAnsweredQuestion(pollingQuestion)) throw new UsedQuestionException("edit_used_question_message"); else { return (MultipleChoicePollingQuestion) voteDao.save(pollingQuestion); } }
public AbstractPollingTemplate savePollingTemplate(AbstractPollingTemplate pollingTemplate) throws UsedTemplateException { // if (voteDao.isUsedTemplate(pollingTemplate)) { // throw new UsedTemplateException("template_is_used"); // // } if (pollingTemplate instanceof BibliographicPollingTemplate) { ConstantTableItem docType = ((BibliographicPollingTemplate) pollingTemplate).getDocType(); ConstantTableItem gmdType = ((BibliographicPollingTemplate) pollingTemplate).getGmdType(); String language = pollingTemplate.getLanguage(); if (pollingTemplate.isDefaultTemplate()) { AbstractPollingTemplate defaultTemplate = voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(docType, gmdType, language, true); if (defaultTemplate != null && !defaultTemplate.equals(pollingTemplate)) { defaultTemplate.setDefaultTemplate(false); voteDao.save(defaultTemplate); } } } if (pollingTemplate.getCreationDate() == null) { pollingTemplate.setCreationDate(new Date()); } return (AbstractPollingTemplate) voteDao.saveByMerge(pollingTemplate); }
public EntityObject save(EntityObject obj) throws Exception { return voteDao.save(obj); }