| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 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 | |
|
| 34 | |
|
| 35 | |
|
| 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 | |
|
| 75 | |
|
| 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 | |
} |