Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.Comment


    JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    Iterator<?> iterator = content.getComments().iterator();
    Vector<JSONEscapeObject> comments = new Vector<JSONEscapeObject>();
    while (iterator.hasNext()) {
      Comment comment = (Comment) iterator.next();
      JSONEscapeObject jsonComment = new JSONEscapeObject();
      jsonComment.put("commentId", comment.getCommentId());
      jsonComment.put("commentTitle", comment.getCommentTitle());
      jsonComment.put("comment", comment.getComment());
      jsonComment.put("moderation", comment.getModeration());
      jsonComment.put("commentApproved", comment.getCommentApproved());
      jsonComment.put("custEmail", comment.getCustomer().getCustEmail());
      jsonComment.put("custPublicName", comment.getCustomer().getCustPublicName());
      jsonComment.put("recCreateDatetime", Format.getFullDatetime(comment.getRecCreateDatetime()));
      jsonComment.put("agreeCount", comment.getAgreeCustomers().size());
      jsonComment.put("disagreeCount", comment.getDisagreeCustomers().size());
      comments.add(jsonComment);
    }
    jsonResult.put("comments", comments);
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
View Full Code Here


    }
   
    if (attributes.size() == 0) {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Content content = (Content) ContentDAO.loadNatural(siteDomain.getSite().getSiteId(), contentNaturalKey);
      Comment comment = new Comment();
      comment.setCommentTitle(commentTitle);
      comment.setComment(commentLine);
      comment.setCommentRating(0);
      comment.setActive(Constants.VALUE_YES);
      String custName = customer.getCustEmail();
      if (custName.length() > 20) {
        custName = custName.substring(0, 19);
      }
      comment.setRecCreateBy(custName);
      comment.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      comment.setRecUpdateBy(custName);
      comment.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      comment.setCustomer(customer);
      comment.setContent(content);
      content.getComments().add(comment);
      em.persist(comment);
     
      attributes.put("commentTitle", "");
      attributes.put("comment", "");
View Full Code Here

    }

    if (attributes.size() == 0) {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Item item = (Item) ItemDAO.loadNatural(siteDomain.getSite().getSiteId(), itemNaturalKey);
      Comment comment = new Comment();
      comment.setCommentTitle(commentTitle);
      comment.setComment(commentLine);
      comment.setCommentRating(Integer.valueOf(commentRating));
      comment.setActive(Constants.VALUE_YES);
      String custName = customer.getCustEmail();
      if (custName.length() > 20) {
        custName = custName.substring(0, 19);
      }
      comment.setRecCreateBy(custName);
      comment.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      comment.setRecUpdateBy(custName);
      comment.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      comment.setCustomer(customer);
      comment.setItem(item);
      item.getComments().add(comment);
      em.persist(comment);
     
      attributes.put("commentTitle", "");
      attributes.put("comment", "");
View Full Code Here

      streamWebService(response, jsonString);
      return null;
    }
   
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Comment comment = (Comment) em.find(Comment.class, Format.getLong(commentId));

      if (alertType.equals(Constants.ALERT_TYPE_MODERATOR)) {
        comment.setModeration(Constants.VALUE_YES);
        em.persist(comment);
      }
      else {
        Iterator<?> iterator = comment.getAgreeCustomers().iterator();
        while (iterator.hasNext()) {
          Customer c = (Customer) iterator.next();
          if (c.getCustId().equals(customer.getCustId())) {
            iterator.remove();
            break;
          }
        }
        iterator = comment.getDisagreeCustomers().iterator();
        while (iterator.hasNext()) {
          Customer c = (Customer) iterator.next();
          if (c.getCustId().equals(customer.getCustId())) {
            iterator.remove();
            break;
          }
        }
        if (alertType.equals(Constants.ALERT_TYPE_AGREE)) {
          comment.getAgreeCustomers().add(customer);
        }
        else {
          comment.getDisagreeCustomers().add(customer);
        }
      }
     
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("agreeCount", comment.getAgreeCustomers().size());
    jsonResult.put("disagreeCount", comment.getDisagreeCustomers().size());
    jsonResult.put("moderation", String.valueOf(comment.getModeration()));
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
      return null;
    }
View Full Code Here

TOP

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

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.