Coverage Report - org.kuali.student.core.statement.dao.impl.StatementDaoImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
StatementDaoImpl
60%
20/33
N/A
1.375
 
 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.statement.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.core.dao.impl.AbstractSearchableCrudDaoImpl;
 26  
 import org.kuali.student.core.exceptions.DoesNotExistException;
 27  
 import org.kuali.student.core.statement.dao.StatementDao;
 28  
 import org.kuali.student.core.statement.entity.RefStatementRelation;
 29  
 import org.kuali.student.core.statement.entity.ReqComponent;
 30  
 import org.kuali.student.core.statement.entity.Statement;
 31  
 
 32  14
 public class StatementDaoImpl extends AbstractSearchableCrudDaoImpl implements StatementDao {
 33  
 
 34  
         @PersistenceContext(unitName = "Statement")
 35  
         @Override
 36  
         public void setEm(EntityManager em) {
 37  1
                 super.setEm(em);
 38  1
         }
 39  
 
 40  
         @Override
 41  
     public List<ReqComponent> getReqComponents(List<String> reqComponentIdList) {
 42  0
         Query query = em.createNamedQuery("ReqComponent.getReqComponents");
 43  0
         query.setParameter("reqComponentIdList", reqComponentIdList);
 44  
         @SuppressWarnings("unchecked")
 45  0
         List<ReqComponent> resultList = query.getResultList();
 46  0
         return resultList;
 47  
     }
 48  
 
 49  
     @Override
 50  
     public List<Statement> getStatements(List<String> statementIdList) {
 51  0
         Query query = em.createNamedQuery("Statement.getStatements");
 52  0
         query.setParameter("statementIdList", statementIdList);
 53  
         @SuppressWarnings("unchecked")
 54  0
         List<Statement> resultList = query.getResultList();
 55  0
         return resultList;
 56  
     }
 57  
 
 58  
     @Override
 59  
     public List<ReqComponent> getReqComponentsByType(String reqComponentTypeKey) {
 60  2
         Query query = em.createNamedQuery("ReqComponent.getReqComponentsByType");
 61  2
         query.setParameter("reqComponentTypeKey", reqComponentTypeKey);
 62  
         @SuppressWarnings("unchecked")
 63  2
         List<ReqComponent> resultList = query.getResultList();
 64  2
         return resultList;
 65  
     }
 66  
 
 67  
     @Override
 68  
     public List<Statement> getStatementsForStatementType(String statementTypeKey) {
 69  2
         Query query = em.createNamedQuery("Statement.getStatementsForStatementType");
 70  2
         query.setParameter("statementTypeKey", statementTypeKey);
 71  
         @SuppressWarnings("unchecked")
 72  2
         List<Statement> resultList = query.getResultList();
 73  2
         return resultList;
 74  
     }
 75  
 
 76  
     @Override
 77  
     public List<Statement> getStatementsForReqComponent(String reqComponentId) {
 78  1
         Query query = em.createNamedQuery("Statement.getStatementsForReqComponent");
 79  1
         query.setParameter("reqComponentId", reqComponentId);
 80  
         @SuppressWarnings("unchecked")
 81  1
         List<Statement> resultList = query.getResultList();
 82  1
         return resultList;
 83  
     }
 84  
 
 85  
     @Override
 86  
     public List<RefStatementRelation> getRefStatementRelations(String refObjectTypeKey, String refObjectId) {
 87  0
         Query query = em.createNamedQuery("RefStatementRelation.getRefStatementRelations");
 88  0
         query.setParameter("refObjectTypeKey", refObjectTypeKey);
 89  0
         query.setParameter("refObjectId", refObjectId);
 90  
         @SuppressWarnings("unchecked")
 91  0
         List<RefStatementRelation> resultList = query.getResultList();
 92  0
         return resultList;
 93  
     }
 94  
 
 95  
     @Override
 96  
     public Statement getParentStatement(String childId) throws DoesNotExistException {
 97  2
         Query query = em.createNamedQuery("Statement.getParentStatement");
 98  2
         query.setParameter("childId", childId);
 99  
         try{
 100  2
                 return (Statement)query.getSingleResult();
 101  1
         }catch(NoResultException e){
 102  1
                 throw new DoesNotExistException("No entity for key '" + childId + "' found",e);
 103  
         }
 104  
     }
 105  
 }