public static boolean saveData(PollDataModel dataModel) throws Exception {
   PollDAOFactory daoFactory = PollDAOFactory.getInstance();
   PollDataDAO dataDAO = daoFactory.getPollDataDAO();
   PollAnswerDAO answerDAO = daoFactory.getPollAnswerDAO();
   dataModel.setIdPollData(dataDAO.generateId());
   dataModel.setDataTime(new Timestamp(System.currentTimeMillis()));
   Iterator<PollAnswerModel> itAnswer = dataModel.getListPollAnswer().iterator();
   List<OpDAO> listOp = new ArrayList<OpDAO>();
   listOp.add(dataDAO.newInsertOpDAO(dataModel));
   while (itAnswer.hasNext()) {
     PollAnswerModel answerModel = itAnswer.next();
     answerModel.setIdPollData(dataModel.getIdPollData());
     answerModel.setIdPollAnswer(answerDAO.generateId());
     listOp.add(answerDAO.newInsertOpDAO(answerModel));
   }
   return answerDAO.updateTransaction(listOp);
 }
 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;
 }