View Javadoc
1   package ca.uhn.fhir.jpa.dao.data;
2   
3   import ca.uhn.fhir.jpa.entity.Search;
4   import ca.uhn.fhir.jpa.entity.SearchResult;
5   import org.springframework.data.domain.Page;
6   import org.springframework.data.domain.Pageable;
7   import org.springframework.data.domain.Slice;
8   import org.springframework.data.jpa.repository.JpaRepository;
9   import org.springframework.data.jpa.repository.Modifying;
10  import org.springframework.data.jpa.repository.Query;
11  import org.springframework.data.repository.query.Param;
12  
13  import java.util.Iterator;
14  import java.util.List;
15  import java.util.Set;
16  
17  /*
18   * #%L
19   * HAPI FHIR JPA Server
20   * %%
21   * Copyright (C) 2014 - 2018 University Health Network
22   * %%
23   * Licensed under the Apache License, Version 2.0 (the "License");
24   * you may not use this file except in compliance with the License.
25   * You may obtain a copy of the License at
26   * 
27   *      http://www.apache.org/licenses/LICENSE-2.0
28   * 
29   * Unless required by applicable law or agreed to in writing, software
30   * distributed under the License is distributed on an "AS IS" BASIS,
31   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32   * See the License for the specific language governing permissions and
33   * limitations under the License.
34   * #L%
35   */
36  
37  public interface ISearchResultDao  extends JpaRepository<SearchResult, Long> {
38  	
39  	@Query(value="SELECT r.myResourcePid FROM SearchResult r WHERE r.mySearch = :search ORDER BY r.myOrder ASC")
40  	Page<Long> findWithSearchUuid(@Param("search") Search theSearch, Pageable thePage);
41  
42  	@Query(value="SELECT r.myResourcePid FROM SearchResult r WHERE r.mySearch = :search ORDER BY r.myOrder ASC")
43  	List<Long> findWithSearchUuid(@Param("search") Search theSearch);
44  
45  	@Query(value="SELECT r.myId FROM SearchResult r WHERE r.mySearchPid = :search")
46  	Slice<Long> findForSearch(Pageable thePage, @Param("search") Long theSearchPid);
47  
48  	@Modifying
49  	@Query("DELETE FROM SearchResult s WHERE s.myResourcePid IN :ids")
50  	void deleteByResourceIds(@Param("ids") List<Long> theContent);
51  
52  	@Modifying
53  	@Query("DELETE FROM SearchResult s WHERE s.myId IN :ids")
54  	void deleteByIds(@Param("ids") List<Long> theContent);
55  }