Package eu.planets_project.tb.impl.model

Examples of eu.planets_project.tb.impl.model.CommentImpl


        ExperimentBean expBean = (ExperimentBean)JSFUtil.getManagedObject("ExperimentBean");
        exp = expBean.getExperiment();
       
        log.debug("Recieved comment " + getComment() + " for " + expBean.getEname());
       
        Comment cmt = new CommentImpl(exp.getEntityID(), getExpPhase() );
        if( title == null || "".equals(title) ) {
            title = getComment();
            if ( title.length() > CommentBacking.TITLE_LENGTH )
                title = getComment().substring(0, CommentBacking.TITLE_LENGTH );
        }
        // User is?
        UserBean user = (UserBean)JSFUtil.getManagedObject("UserBean");
        // Existing comment?
        if( ! "".equals(commentId) && commentId != null ) {
            cmt = cm.getComment(this.getlCommentID());
        } else {
            cmt.setAuthorID(user.getUserid());
            cmt.setExperimentPhaseID( expBean.getCurrentPhaseName() );
        }
        // Edit/update the comment:
        cmt.setParentID( getlParentID() );
        cmt.setExperimentID(exp.getEntityID());
        cmt.setPostDate( java.util.Calendar.getInstance() );
        cmt.setComment(title , this.comment );
       

        // Add or update, depending on commendId:
        if( "".equals(commentId) ) {
            cm.registerComment(cmt, expBean.getID(), getExpPhase() );
View Full Code Here


  @PersistenceContext(unitName="testbed", type=PersistenceContextType.TRANSACTION)
  private EntityManager manager;
 
  public void deleteComment(long id) {
    CommentImpl t_helper = manager.find(CommentImpl.class, id);
    manager.remove(t_helper);
  }
View Full Code Here

    CommentImpl t_helper = manager.find(CommentImpl.class, id);
    manager.remove(t_helper);
  }

  public void deleteComment(CommentImpl comment) {
    CommentImpl t_helper = manager.find(CommentImpl.class, comment.getCommentID());
    manager.remove(t_helper);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see eu.planets_project.tb.api.CommentManager#getNewComment()
   */
  public Comment getNewRootComment(long lExperimentID, String sExperimentPhaseID) {
    CommentImpl c1 = new CommentImpl(lExperimentID, sExperimentPhaseID);
    return c1;
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    CommentManagerImpl manager = CommentManagerImpl.getInstance();
    CommentImpl com1 = (CommentImpl)manager.getNewRootComment(1, "setup");
    Long lExpID = com1.getExperimentID();
    String sPhaseID = com1.getExperimentPhaseID();
    System.out.println("ID: "+lExpID+" Phase: "+sPhaseID);
   
  }
View Full Code Here

      //create two test Comments, note their ID and persist them
      //new root comment with Comment(long lExperimentID, String sExperimentPhaseID)
      //please note: phaseID are not correct
      CommentManagerImpl manager = CommentManagerImpl.getInstance();
      CommentImpl com1 = (CommentImpl)manager.getNewRootComment(1, "setup");
      //Comment com1 = new Comment(1, "setup");
      //System.out.println("Contains? "+manager.containsComment(1));
      commentID1 = dao_r.persistComment(com1);
      CommentImpl find_com1 = dao_r.findComment(commentID1);
      manager.registerComment(find_com1, find_com1.getExperimentID(),find_com1.getExperimentPhaseID());
      System.out.println("XXXContains? "+manager.containsComment(commentID1));
     
      //new root comment
      CommentImpl com2 = (CommentImpl)manager.getNewRootComment(2, "evaluation");
      commentID2 = dao_r.persistComment(com2);
      CommentImpl find_com2 = dao_r.findComment(commentID2);
      manager.registerComment(find_com2, find_com2.getExperimentID(),find_com2.getExperimentPhaseID());
      System.out.println("XXXContains? "+manager.containsComment(commentID2));
     
     
    } catch (NamingException e) {
      //TODO integrate message into logging mechanism
View Full Code Here

  }
 
  public void testEJBEntityDeleted(){
    dao_r.deleteComment(this.commentID1);
    dao_r.deleteComment(dao_r.findComment(commentID2));
    CommentImpl c1,c2;
    try{
      c1 = dao_r.findComment(commentID1);
      c2 = dao_r.findComment(commentID2);
     
    }catch(Exception e){
View Full Code Here

    assertNull(c1);
    assertNull(c2)
  }
 
  public void testEJBEntityUpdated(){
    CommentImpl test_find1 =  dao_r.findComment(commentID1);
    //modify the bean
    long l1 = 1;
    test_find1.setTitle("Title1");
    test_find1.setExperimentID(l1);
    dao_r.updateComment(test_find1);
    //Test1: updating existing entity
    test_find1 =  dao_r.findComment(commentID1);
    assertEquals("Title1",test_find1.getTitle())
  }
View Full Code Here

    test_find1 =  dao_r.findComment(commentID1);
    assertEquals("Title1",test_find1.getTitle())
  }
 
  public void testEJBEntityMerged(){
    CommentImpl test_find1 =  dao_r.findComment(commentID1);
    //modify the bean
    long l1 = 12;
    test_find1.setTitle("Title1");
    test_find1.setExperimentID(l1);
    dao_r.updateComment(test_find1);
    //Test1: updating existing entity
    assertEquals("Title1",test_find1.getTitle());
   
    //Test2: checking if merging entity works
    test_find1 =  dao_r.findComment(commentID1);
    test_find1.setTitle("TitleUpdated");
    dao_r.updateComment(test_find1);
   
    test_find1 =  dao_r.findComment(commentID1);
    assertEquals(l1,test_find1.getExperimentID())
    assertEquals("TitleUpdated",test_find1.getTitle())
  }
View Full Code Here

  }
 
  //Tests for the underlying Entity Bean's methods setter and getter's without any EJB issues
  public void testAddChildComment(){
    //TODO: Add CommentManager registration
    CommentImpl test_find1 =  dao_r.findComment(commentID1);
    System.out.println("Comment Partent ID: "+test_find1.getCommentID());
    CommentImpl com_child = new CommentImpl(test_find1.getCommentID());
    com_child.setComment("Andrew", "TestChild", "Comment Text");
    dao_r.persistComment(com_child);

    test_find1 =  dao_r.findComment(commentID1);
    System.out.println("Comment Partent ID: "+test_find1.getCommentID());
    System.out.println("Comment Child ID: "+com_child.getCommentID());
   
    Vector<Comment> vChilds = (Vector<Comment>)test_find1.getReplies();
   
    assertEquals(1,vChilds.size())
   
View Full Code Here

TOP

Related Classes of eu.planets_project.tb.impl.model.CommentImpl

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.