// alias della tabellea - START
 // alias della tabellea - END
 public PollIndexModel getModel() {
   PollIndexModel model = new PollIndexModel();
   model.setIdPollIndex(toDAOID(idPollIndex));
   model.setQuestionaryType(toDAOID(questionaryType));
   model.setQuestionaryName(toString(questionaryName));
   model.setQuestionaryDescription(toString(questionaryDescription));
   return model;
 }
Example #2
0
 public static PollModel loadQuestionary(String name) throws Exception {
   PollModel pollModel = new PollModel();
   PollDAOFactory daoFactory = PollDAOFactory.getInstance();
   PollIndexDAO indexDAO = daoFactory.getPollIndexDAO();
   PollQuestionDAO questionDAO = daoFactory.getPollQuestionDAO();
   PollOptionDAO optionDAO = daoFactory.getPollOptionDAO();
   // carico il questionario
   PollIndexModel indexModel = indexDAO.loadOneByName(name);
   pollModel.setPollIndexModel(indexModel);
   List<PollQuestionModel> listQuestion = questionDAO.loadAllByIndex(indexModel.getIdPollIndex());
   indexModel.setListPollQuestion(listQuestion);
   Iterator<PollQuestionModel> itQuestion = listQuestion.iterator();
   while (itQuestion.hasNext()) {
     PollQuestionModel questionModel = itQuestion.next();
     List<PollOptionModel> listOption =
         optionDAO.loadAllByQuestion(questionModel.getIdPollQuestion());
     Iterator<PollOptionModel> itOption = listOption.iterator();
     questionModel.setListPollOption(listOption);
     pollModel.populateOptionMap(questionModel);
     while (itOption.hasNext()) {
       PollOptionModel optionModel = itOption.next();
       if (optionModel.getIdPollOptionParent() != null
           && optionModel.getIdPollOptionParent().longValue() != 0
           && optionModel.getIdPollOptionParent().longValue()
               != optionModel.getIdPollOption().longValue()) {
         itOption.remove();
         PollOptionModel optionParentMadel =
             pollModel.getOptionMap().get(optionModel.getIdPollOptionParent().toString());
         List<PollOptionModel> kids = optionParentMadel.getListPollOptionKids();
         if (kids == null) {
           kids = new ArrayList<PollOptionModel>();
           optionParentMadel.setListPollOptionKids(kids);
         }
         kids.add(optionModel);
       }
     }
   }
   return pollModel;
 }
Example #3
0
 public static boolean populate(PollModel pollModel, ParamMap map) {
   boolean ok = true;
   PollIndexModel indexModel = pollModel.getPollIndexModel();
   List<PollQuestionModel> listQuestion = indexModel.getListPollQuestion();
   Iterator<PollQuestionModel> itQuestion = listQuestion.iterator();
   PollDataModel dataModel = new PollDataModel();
   dataModel.setListPollAnswer(new ArrayList<PollAnswerModel>());
   dataModel.setIdPollIndex(indexModel.getIdPollIndex());
   while (itQuestion.hasNext() && ok) {
     PollQuestionModel questionModel = itQuestion.next();
     List<PollOptionModel> listOption = questionModel.getListPollOption();
     String paramQuestion = "question_" + questionModel.getIdPollQuestion();
     String[] paramValue = map.getParams(paramQuestion);
     if (paramValue != null) {
       String id = paramValue[0];
       PollAnswerModel answerModel = new PollAnswerModel();
       answerModel.setIdPollOption(DAOID.valueOf(id));
       dataModel.getListPollAnswer().add(answerModel);
       String paramKids = "question_kids_" + questionModel.getIdPollQuestion();
       String[] paramKidsValue = map.getParams(paramKids);
       if (paramKidsValue != null) {
         for (int k = 0; k < paramKidsValue.length; k++) {
           String current = paramKidsValue[k];
           PollAnswerModel answerKidModel = new PollAnswerModel();
           answerKidModel.setIdPollOption(DAOID.valueOf(current));
           dataModel.getListPollAnswer().add(answerKidModel);
         }
       }
     } else {
       ok = false;
     }
   }
   pollModel.setPollDataModel(dataModel);
   pollModel.populateAnswerMap();
   return ok;
 }