| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AppointmentDao |
|
| 1.0;1 |
| 1 | /** | |
| 2 | * Copyright 2012 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.r2.core.class1.appointment.dao; | |
| 17 | ||
| 18 | import org.kuali.student.enrollment.dao.GenericEntityDao; | |
| 19 | import org.kuali.student.r2.core.class1.appointment.model.AppointmentEntity; | |
| 20 | ||
| 21 | import java.util.List; | |
| 22 | ||
| 23 | /** | |
| 24 | * JPQL Queries which primarily accesses Appointment Entity | |
| 25 | * | |
| 26 | * @author Kuali Student Team | |
| 27 | */ | |
| 28 | 0 | public class AppointmentDao extends GenericEntityDao<AppointmentEntity> { |
| 29 | /** | |
| 30 | * Retrieve all appointments in a given slot | |
| 31 | * @param apptSlotId The slot ID to retrieve by | |
| 32 | * @return A list of appointment entities with the slot ID | |
| 33 | */ | |
| 34 | public List<AppointmentEntity> getAppointmentsBySlotId(String apptSlotId) { | |
| 35 | 0 | return em.createQuery("FROM AppointmentEntity a WHERE a.slotEntity.id = :apptSlotId") |
| 36 | .setParameter("apptSlotId", apptSlotId).getResultList(); | |
| 37 | } | |
| 38 | ||
| 39 | /** | |
| 40 | * Relatively fast way to count number of appointments with appointment window id | |
| 41 | * @param apptWinId The appointment window ID | |
| 42 | * @return A count of how many appointments are in a window | |
| 43 | */ | |
| 44 | public Long countAppointmentsByWindowId(String apptWinId) { | |
| 45 | 0 | String query = "SELECT COUNT(*) FROM AppointmentSlotEntity slot, AppointmentEntity appt " + |
| 46 | "WHERE slot.apptWinEntity.id = :apptWinId AND appt.slotEntity.id = slot.id"; | |
| 47 | 0 | return (Long) em.createQuery(query).setParameter("apptWinId", apptWinId).getSingleResult(); |
| 48 | } | |
| 49 | } |