Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.PollDetail


   
    public void refreshDetails(PollMaintActionForm form, PollHeader pollHeader) {
    Iterator<?> iterator = pollHeader.getPollDetails().iterator();
    int totalVoteCount = 0;
    while (iterator.hasNext()) {
      PollDetail pollDetail = (PollDetail) iterator.next();
      totalVoteCount += pollDetail.getPollVoteCount().intValue();
    }
   
    Vector<PollDetailForm> vector = new Vector<PollDetailForm>();
    iterator = pollHeader.getPollDetails().iterator();
    while (iterator.hasNext()) {
      PollDetail pollDetail = (PollDetail) iterator.next();
      PollDetailForm pollDetailForm = new PollDetailForm();
      pollDetailForm.setPollDetailId(Format.getLong(pollDetail.getPollDetailId()));
      pollDetailForm.setPollOption(pollDetail.getPollOption());
      pollDetailForm.setSeqNum(Format.getInt(pollDetail.getSeqNum()));
      pollDetailForm.setPollVoteCount(Format.getInt(pollDetail.getPollVoteCount()));
      if (totalVoteCount > 0) {
        pollDetailForm.setPollPercentage(Format.getInt(pollDetail.getPollVoteCount() * 100 / totalVoteCount) + "%");
      }
      vector.add(pollDetailForm);
    }
    PollDetailForm pollDetails[] = new PollDetailForm[vector.size()];
    vector.copyInto(pollDetails);
View Full Code Here


        form.setPollHeaderId(Format.getLong(pollHeader.getPollHeaderId()));
    form.setMode("U");
   
    for (int i = 0; i < form.getPollDetails().length; i++) {
          PollDetailForm pollDetailForm = form.getPollDetails()[i];
          PollDetail pollDetail = PollDetailDAO.load(Format.getLong(pollDetailForm.getPollDetailId()));
          pollDetail.setSeqNum(Format.getIntObj(pollDetailForm.getSeqNum()));
          pollDetail.setPollOption(pollDetailForm.getPollOption());
          pollDetail.setRecUpdateBy(adminBean.getUser().getUserId());
          pollDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(pollDetail);
    }
   
        FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
    return mapping.findForward("success");
View Full Code Here

        Long pollHeaderId = Format.getLong(form.getPollHeaderId());
        PollHeader pollHeader = PollHeaderDAO.load(site.getSiteId(), pollHeaderId);
        int seqNum = -1;
        Iterator<?> iterator = pollHeader.getPollDetails().iterator();
        while (iterator.hasNext()) {
          PollDetail pollDetail = (PollDetail) iterator.next();
          if (pollDetail.getSeqNum().intValue() > seqNum) {
            seqNum = pollDetail.getSeqNum().intValue();
          }
        }
       
        PollDetail pollDetail = new PollDetail();
        pollDetail.setPollVoteCount(new Integer(0));
        pollDetail.setPollOption(pollOption);
        pollDetail.setPollVoteCount(new Integer(0));
        pollDetail.setSeqNum(new Integer(seqNum + 1));
        pollDetail.setRecUpdateBy(adminBean.getUser().getUserId());
        pollDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        pollDetail.setRecCreateBy(adminBean.getUser().getUserId());
        pollDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    pollHeader.setRecUpdateBy(adminBean.getUser().getUserId());
    pollHeader.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    pollHeader.getPollDetails().add(pollDetail);
    em.persist(pollDetail);
View Full Code Here

          if (!pollDetailForm.isRemove()) {
            continue;
          }
          Iterator<?> iterator = pollHeader.getPollDetails().iterator();
          while (iterator.hasNext()) {
            PollDetail pollDetail = (PollDetail) iterator.next();
            if (pollDetail.getPollDetailId().equals(Format.getLong(pollDetailForm.getPollDetailId()))) {
              em.remove(pollDetail);
              removeDetails.add(pollDetail);
            }
          }
        }
View Full Code Here

        }
       
      PollHeader pollHeader = PollHeaderDAO.load(adminBean.getSite().getSiteId(), Format.getLong(form.getPollHeaderId()));
        for (int i = 0; i < form.getPollDetails().length; i++) {
          PollDetailForm pollDetailForm = form.getPollDetails()[i];
          PollDetail pollDetail = PollDetailDAO.load(Format.getLong(pollDetailForm.getPollDetailId()));
          pollDetail.setSeqNum(Format.getIntObj(pollDetailForm.getSeqNum()));
            pollDetail.setRecUpdateBy(adminBean.getUser().getUserId());
            pollDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
            em.persist(pollDetail);
        }
        em.flush();
        em.refresh(pollHeader);
       
View Full Code Here

public class PollDetailDAO extends PollDetail {
  private static final long serialVersionUID = 5086983113582891621L;

  public static PollDetail load(Long pollDetailId) throws SecurityException, Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    PollDetail polldetail = (PollDetail) em.find(PollDetail.class, pollDetailId);
    return polldetail;
  }
View Full Code Here

          json.put("pollHeaderId", Format.getLong(pollHeader.getPollHeaderId()));
          json.put("pollTopic", pollHeader.getPollTopic());
          Iterator<?> iterator = pollHeader.getPollDetails().iterator();
          int total = 0;
          while (iterator.hasNext()) {
            PollDetail pollDetail = (PollDetail) iterator.next();
            total += pollDetail.getPollVoteCount().intValue();
          }
         
          Vector<JSONEscapeObject> vector = new Vector<JSONEscapeObject>();
          iterator = pollHeader.getPollDetails().iterator();
          while (iterator.hasNext()) {
            PollDetail pollDetail = (PollDetail) iterator.next();
              JSONEscapeObject jsonDetails = new JSONEscapeObject();
            jsonDetails.put("pollDetailId", pollDetail.getPollDetailId());
            jsonDetails.put("pollOption", pollDetail.getPollOption());
            String percentage = "";
            if (total > 0) {
              percentage = String.valueOf(pollDetail.getPollVoteCount().intValue() * 100 / total) + "%";
            }
            jsonDetails.put("percentage", percentage);
            vector.add(jsonDetails);
          }
          json.put("pollDetails", vector);
View Full Code Here

        String pollHeaderId = request.getParameter("pollHeaderId");
      String pollDetailId = request.getParameter("pollDetailId");
        EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
        if (!Format.isNullOrEmpty(pollDetailId)) {
          PollDetail pollDetail = PollDetailDAO.load(Format.getLong(pollDetailId));
          pollDetail.setPollVoteCount(new Integer(pollDetail.getPollVoteCount().intValue() + 1));
        em.persist(pollDetail);
        em.flush();
        }
     
      PollHeader pollHeader = PollHeaderDAO.load(site.getSiteId(), Format.getLong(pollHeaderId));
View Full Code Here

TOP

Related Classes of com.jada.jpa.entity.PollDetail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.