Package org.vosao.entity

Examples of org.vosao.entity.CommentEntity


  @Override
  public CommentEntity addComment(String name, String content,
      PageEntity page) {

    ConfigEntity config = VosaoContext.getInstance().getConfig();
    CommentEntity comment = new CommentEntity(name, content,
        new Date(), page.getFriendlyURL());
    getDao().getCommentDao().save(comment);
    getBusiness().getSystemService().getPageCache().remove(
        page.getFriendlyURL());
    List<String> toAddresses = StrUtil.fromCSV(config.getCommentsEmail());
View Full Code Here


    return b.toString();
  }

  private boolean isChangeGranted(List<Long> ids) {
    if (ids.size() > 0) {
      CommentEntity comment = getDao().getCommentDao().getById(ids.get(0));
      ContentPermissionEntity permission = getContentPermissionBusiness()
          .getPermissioncomment.getPageUrl(),
              VosaoContext.getInstance().getUser());
      if (permission != null) {
        return permission.isChangeGranted();
      }
    }   
View Full Code Here

    }   
  }

  private void clearPageCache(List<Long> commentIds) {
    for(Long id : commentIds) {
      CommentEntity comment = getDao().getCommentDao().getById(id);
      if (comment != null) {
        getBusiness().getSystemService().getPageCache().remove(
            comment.getPageUrl());
      }
    }
  }
View Full Code Here

 
  @Override
  public void disable(List<Long> ids) {
    getQueryCache().removeQueries(CommentEntity.class);
    for (Long id : ids) {
      CommentEntity comment = getById(id);
      if (comment != null) {
        comment.setDisabled(true);
        save(comment);
        getEntityCache().removeEntity(CommentEntity.class, id);
      }
    }
  }
View Full Code Here

  @Override
  public void enable(List<Long> ids) {
    getQueryCache().removeQueries(CommentEntity.class);
    for (Long id : ids) {
      CommentEntity comment = getById(id);
      if (comment != null) {
        comment.setDisabled(false);
        save(comment);
        getEntityCache().removeEntity(CommentEntity.class, id);
      }
    }
  }
View Full Code Here

  }   


  public void testSave() {
    PageEntity page = pageTool.addPage("test");
    CommentEntity comment = commentTool.addComment("alex", "content", page);
    CommentEntity comment2 = getDao().getCommentDao().getById((Long)null);
    assertNull(comment2);
    List<CommentEntity> comments = getDao().getCommentDao().getById((List<Long>)null);
    assertEquals(0, comments.size());
    comment2 = getDao().getCommentDao().getById(0L);
    assertNull(comment2);
    comment2 = getDao().getCommentDao().getById(
        comment.getId());
    assertNotNull(comment2);
    assertEquals("alex", comment2.getName());
    assertEquals("content", comment2.getContent());
 
View Full Code Here

    assertEquals("content", comment2.getContent());
 
 
  public void testUpdate() {
    PageEntity page = pageTool.addPage("test");
    CommentEntity comment = commentTool.addComment("alex", "content", page);
    CommentEntity comment2 = getDao().getCommentDao().getById(
        comment.getId());
    assertNotNull(comment2);
    assertEquals("alex", comment2.getName());
    assertEquals("content", comment2.getContent());
    comment2.setName("yuri");
    getDao().getCommentDao().save(comment2);
    CommentEntity comment3 = getDao().getCommentDao().getById(
        comment.getId());
    assertNotNull(comment3);
    assertEquals("yuri", comment3.getName());
  }
View Full Code Here

  public void testDelete() {
    PageEntity page = pageTool.addPage("test");
    PageEntity page2 = pageTool.addPage("test2");
    commentTool.addComment("alex", "content1", page);
    commentTool.addComment("yuri", "content2", page2);
    CommentEntity comment = commentTool.addComment("roma", "content3", page);
    getDao().getCommentDao().remove(comment.getId());
    List<CommentEntity> list = getDao().getCommentDao().getByPage(
        page.getFriendlyURL());
    assertEquals(1, list.size());
    assertEquals("alex", list.get(0).getName());
    list = getDao().getCommentDao().getByPage(page2.getFriendlyURL());
View Full Code Here

    assertEquals(1, list.size());
 
 
  public void testGetById()  {
    PageEntity page = pageTool.addPage("test");
    CommentEntity c = commentTool.addComment("alex", "content1", page);
    CommentEntity c2 = getDao().getCommentDao().getById((Long)null);
    assertNull(c2);
    c2 = getDao().getCommentDao().getById(c.getId());
    assertNotNull(c2);
    assertEquals(c.getId(), c2.getId());
  }
View Full Code Here

    assertEquals(c.getId(), c2.getId());
  }

  public void testDisableEnable() {
    PageEntity page = pageTool.addPage("test");
    CommentEntity alex = commentTool.addComment("alex", "content1", page);
    CommentEntity roma = commentTool.addComment("roma", "content3", page);
    CommentEntity roma1 = commentTool.addComment("roma1", "content4", page);
    CommentEntity roma3 = commentTool.addComment("roma3", "content6", page);
    List<Long> ids = new ArrayList<Long>();
    ids.add(null);
    ids.add(alex.getId());
    ids.add(roma.getId());
    getDao().getCommentDao().disable(ids);
    CommentEntity r = getDao().getCommentDao().getById(alex.getId());
    assertTrue(r.isDisabled());
    r = getDao().getCommentDao().getById(roma.getId());
    assertTrue(r.isDisabled());
    r = getDao().getCommentDao().getById(roma1.getId());
    assertFalse(r.isDisabled());
    r = getDao().getCommentDao().getById(roma3.getId());
    assertFalse(r.isDisabled());
    getDao().getCommentDao().enable(ids);
    r = getDao().getCommentDao().getById(alex.getId());
    assertFalse(r.isDisabled());
    r = getDao().getCommentDao().getById(roma.getId());
    assertFalse(r.isDisabled());
 
View Full Code Here

TOP

Related Classes of org.vosao.entity.CommentEntity

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.