Coverage Report - org.kuali.student.core.comment.dao.impl.CommentDaoImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CommentDaoImpl
0%
0/54
N/A
1.182
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.core.comment.dao.impl;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import javax.persistence.EntityManager;
 21  
 import javax.persistence.NoResultException;
 22  
 import javax.persistence.PersistenceContext;
 23  
 import javax.persistence.Query;
 24  
 
 25  
 import org.kuali.student.common.dao.impl.AbstractSearchableCrudDaoImpl;
 26  
 import org.kuali.student.core.comment.dao.CommentDao;
 27  
 import org.kuali.student.core.comment.entity.Comment;
 28  
 import org.kuali.student.core.comment.entity.CommentType;
 29  
 import org.kuali.student.core.comment.entity.Reference;
 30  
 import org.kuali.student.core.comment.entity.Tag;
 31  
 
 32  
 /**
 33  
  * This is a description of what this class does - lindholm don't forget to fill this in.
 34  
  *
 35  
  * @author Kuali Rice Team (kuali-rice@googlegroups.com)
 36  
  *
 37  
  */
 38  0
 public class CommentDaoImpl extends AbstractSearchableCrudDaoImpl implements CommentDao {
 39  
     @PersistenceContext(unitName = "Comment")
 40  
     @Override
 41  
     public void setEm(EntityManager em) {
 42  0
         super.setEm(em);
 43  0
     }
 44  
 
 45  
 
 46  
     public Comment getComment(String referenceId, String referenceTypeKey){
 47  0
         Query query = em.createNamedQuery("Comment.getComment");
 48  0
         query.setParameter("refId", referenceId);
 49  0
         query.setParameter("refTypeId", referenceTypeKey);
 50  0
         Comment comment = (Comment) query.getSingleResult();
 51  0
         return comment;
 52  
 
 53  
     }
 54  
 
 55  
     public List<Comment> getComments(String referenceId, String referenceTypeKey){
 56  0
         Query query = em.createNamedQuery("Comment.getComments");
 57  0
         query.setParameter("refId", referenceId);
 58  0
         query.setParameter("refTypeId", referenceTypeKey);
 59  
         @SuppressWarnings("unchecked")
 60  0
         List<Comment> comments = query.getResultList();
 61  0
         return comments;
 62  
     }
 63  
 
 64  
     public List<Comment> getCommentsByRefId(String referenceId){
 65  0
         Query query = em.createNamedQuery("Comment.getCommentsByRefId");
 66  0
         query.setParameter("refId", referenceId);
 67  
         @SuppressWarnings("unchecked")
 68  0
         List<Comment> comments = query.getResultList();
 69  0
         return comments;
 70  
     }
 71  
 
 72  
     public List<Comment> getCommentsByType(String referenceId, String referenceTypeKey, String commentTypeKey ){
 73  0
         Query query = em.createNamedQuery("Comment.getCommentsByType");
 74  0
         query.setParameter("refId", referenceId);
 75  0
         query.setParameter("refTypeId", referenceTypeKey);
 76  0
         query.setParameter("commentTypeId", commentTypeKey);
 77  
         @SuppressWarnings("unchecked")
 78  0
         List<Comment> comments = query.getResultList();
 79  0
         return comments;
 80  
     }
 81  
 
 82  
         public List<CommentType> getCommentTypesByReferenceTypeId(String referenceTypeId) {
 83  0
         Query query = em.createNamedQuery("CommentType.getCommentTypesByReferenceTypeId");
 84  0
         query.setParameter("referenceTypeId", referenceTypeId);
 85  
         @SuppressWarnings("unchecked")
 86  0
         List<CommentType> comments = query.getResultList();
 87  0
         return comments;
 88  
 
 89  
     }
 90  
 
 91  
     public Tag getTag(String referenceId, String referenceTypeKey){
 92  0
         Query query = em.createNamedQuery("Tag.getTag");
 93  0
         query.setParameter("refId", referenceId);
 94  0
         query.setParameter("refTypeId", referenceTypeKey);
 95  0
         Tag tag = (Tag)query.getSingleResult();
 96  0
         return tag;
 97  
     }
 98  
     public List<Tag> getTags(String referenceId, String referenceTypeKey){
 99  0
         Query query = em.createNamedQuery("Tag.getTags");
 100  0
         query.setParameter("refId", referenceId);
 101  0
         query.setParameter("refTypeId", referenceTypeKey);
 102  
         @SuppressWarnings("unchecked")
 103  0
         List<Tag> tags = query.getResultList();
 104  0
         return tags;
 105  
     }
 106  
 
 107  
     public List<Tag> getTagsByRefId(String referenceId){
 108  0
         Query query = em.createNamedQuery("Tag.getTagsByRefId");
 109  0
         query.setParameter("refId", referenceId);
 110  
         @SuppressWarnings("unchecked")
 111  0
         List<Tag> tags = query.getResultList();
 112  0
         return tags;
 113  
     }
 114  
 
 115  
     public List<Tag> getTagsByType(String referenceId, String referenceTypeKey, String tagTypeKey ){
 116  0
         Query query = em.createNamedQuery("Tag.getTagsByType");
 117  0
         query.setParameter("refId", referenceId);
 118  0
         query.setParameter("refTypeId", referenceTypeKey);
 119  0
         query.setParameter("tagTypeId", tagTypeKey);
 120  
         @SuppressWarnings("unchecked")
 121  0
         List<Tag> tags = query.getResultList();
 122  0
         return tags;
 123  
     }
 124  
 
 125  
     public Reference getReference(String referenceId, String referenceType){
 126  0
         Query query = em.createNamedQuery("Reference.getReference");
 127  0
         query.setParameter("refId", referenceId);
 128  0
         query.setParameter("refTypeId", referenceType);
 129  
         try{
 130  0
         Reference reference = (Reference)query.getSingleResult();
 131  0
         return reference;
 132  
         }
 133  0
         catch(NoResultException e){
 134  0
             return null;
 135  
         }
 136  
 
 137  
 
 138  
     }
 139  
 
 140  
 
 141  
 }