Coverage Report - org.kuali.student.r2.core.class1.search.SearchServiceHardwiredImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
SearchServiceHardwiredImpl
0%
0/23
0%
0/2
2.125
 
 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  
  * Created by Daniel on 4/26/12
 16  
  */
 17  
 package org.kuali.student.r2.core.class1.search;
 18  
 
 19  
 import org.kuali.student.enrollment.dao.GenericEntityDao;
 20  
 import org.kuali.student.r2.common.dto.ContextInfo;
 21  
 import org.kuali.student.r2.common.exceptions.*;
 22  
 import org.kuali.student.r2.core.search.dto.SearchRequestInfo;
 23  
 import org.kuali.student.r2.core.search.dto.SearchResultInfo;
 24  
 import org.kuali.student.r2.core.search.dto.SearchResultRowInfo;
 25  
 import org.kuali.student.r2.core.search.service.SearchService;
 26  
 import org.kuali.student.r2.core.type.dto.TypeInfo;
 27  
 
 28  
 import javax.jws.WebParam;
 29  
 import java.text.SimpleDateFormat;
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * This class //TODO ...
 34  
  *
 35  
  * @author Kuali Student Team
 36  
  */
 37  0
 public class SearchServiceHardwiredImpl implements SearchService {
 38  
 
 39  
     private GenericEntityDao enrollmentDao;
 40  
 
 41  
     @Override
 42  
     public List<TypeInfo> getSearchTypes(@WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 43  0
         throw new UnsupportedOperationException("Method is not implemented.");
 44  
     }
 45  
 
 46  
     @Override
 47  
     public TypeInfo getSearchType(@WebParam(name = "searchTypeKey") String searchTypeKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 48  0
         throw new UnsupportedOperationException("Method is not implemented.");
 49  
     }
 50  
 
 51  
     @Override
 52  
     public List<TypeInfo> getSearchTypesByResult(@WebParam(name = "searchResultTypeKey") String searchResultTypeKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 53  0
         throw new UnsupportedOperationException("Method is not implemented.");
 54  
     }
 55  
 
 56  
     @Override
 57  
     public List<TypeInfo> getSearchTypesByCriteria(@WebParam(name = "searchCriteriaTypeKey") String searchCriteriaTypeKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 58  0
         throw new UnsupportedOperationException("Method is not implemented.");
 59  
     }
 60  
 
 61  
     @Override
 62  
     public List<TypeInfo> getSearchResultTypes(@WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 63  0
         throw new UnsupportedOperationException("Method is not implemented.");
 64  
     }
 65  
 
 66  
     @Override
 67  
     public List<TypeInfo> getSearchCriteriaTypes(@WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 68  0
         throw new UnsupportedOperationException("Method is not implemented.");
 69  
     }
 70  
 
 71  
     @Override
 72  
     public SearchResultInfo search(SearchRequestInfo searchRequestInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws MissingParameterException, OperationFailedException, PermissionDeniedException {
 73  0
         if("appt.search.appointmentCountForWindowId".equals(searchRequestInfo.getSearchKey())){
 74  
             //This is a hardwired search for AppointmentWindows
 75  
             //It gets the count of appointments for a given window Id
 76  0
             String windowId =  searchRequestInfo.getParams().get(0).getValues().get(0);
 77  0
             Object[] result = (Object[]) enrollmentDao.getEm().
 78  
                     createQuery("SELECT w.createTime, MIN(s.startDate), MAX(s.startDate), COUNT(*), COUNT(DISTINCT s.id) " +
 79  
                                 "FROM AppointmentWindowEntity w, AppointmentSlotEntity s, AppointmentEntity a " +
 80  
                                 "WHERE w.id= :windowId  AND s.apptWinEntity.id = w.id  AND a.slotEntity.id = s.id GROUP BY w.createTime").
 81  
                     setParameter("windowId", windowId).
 82  
                     getSingleResult();
 83  0
             SearchResultInfo searchResult = new SearchResultInfo();
 84  0
             SearchResultRowInfo row = new SearchResultRowInfo();
 85  0
             SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm aa");
 86  0
             row.addCell("createTime", formatter.format(result[0]));
 87  0
             row.addCell("firstSlot",formatter.format(result[1]));
 88  0
             row.addCell("lastSlot",formatter.format(result[2]));
 89  0
             row.addCell("numAppts",result[3].toString());
 90  0
             row.addCell("numSlots",result[4].toString());
 91  
 
 92  0
             searchResult.getRows().add(row);
 93  0
             return searchResult;
 94  
         }
 95  
 
 96  0
         throw new OperationFailedException("The requested search key is not configured: "+searchRequestInfo.getSearchKey());
 97  
     }
 98  
 
 99  
 
 100  
     public void setEnrollmentDao(GenericEntityDao enrollmentDao) {
 101  0
         this.enrollmentDao = enrollmentDao;
 102  0
     }
 103  
 }