View Javadoc

1   /**
2    * Copyright 2012 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not
3    * use this file except in compliance with the License. You may obtain a copy of the License at
4    *
5    * http://www.osedu.org/licenses/ECL-2.0
6    *
7    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
8    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
9    * governing permissions and limitations under the License.
10   *
11   * Created by Daniel on 4/26/12
12   */
13  package org.kuali.student.r2.common.class1.search;
14  
15  import org.kuali.student.r2.common.dto.ContextInfo;
16  import org.kuali.student.r2.common.exceptions.DoesNotExistException;
17  import org.kuali.student.r2.common.exceptions.InvalidParameterException;
18  import org.kuali.student.r2.common.exceptions.MissingParameterException;
19  import org.kuali.student.r2.common.exceptions.OperationFailedException;
20  import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
21  import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
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.service.SearchService;
25  
26  import javax.annotation.Resource;
27  import javax.persistence.EntityManager;
28  import java.util.Arrays;
29  import java.util.List;
30  
31  /**
32   * Abstract class for hard wired impls
33   *
34   * @author Kuali Student Team
35   */
36  public abstract class SearchServiceAbstractHardwiredImplBase
37          implements SearchService {
38  
39  
40      @Resource
41      private EntityManager entityManager;
42  
43      /**
44       * Get the search type that the sub class implements.
45       */
46      public abstract TypeInfo getSearchType();
47  
48      @Override
49      public TypeInfo getSearchType(String searchTypeKey, ContextInfo contextInfo)
50              throws DoesNotExistException,
51              InvalidParameterException,
52              MissingParameterException,
53              OperationFailedException {
54          TypeInfo st = this.getSearchType();
55          if (!searchTypeKey.equals(st.getKey())) {
56              throw new DoesNotExistException(searchTypeKey);
57          }
58          return st;
59      }
60  
61      @Override
62      public List<TypeInfo> getSearchTypes(ContextInfo contextInfo)
63              throws InvalidParameterException,
64              MissingParameterException,
65              OperationFailedException {
66          return Arrays.asList(this.getSearchType());
67      }
68  
69  
70      @Override
71      public abstract SearchResultInfo search(SearchRequestInfo searchRequestInfo, ContextInfo contextInfo)
72              throws
73              MissingParameterException,
74              OperationFailedException,
75              PermissionDeniedException;
76  
77      public EntityManager getEntityManager() {
78          return entityManager;
79      }
80  
81      public void setEntityManager(EntityManager entityManager) {
82          this.entityManager = entityManager;
83      }
84  }