View Javadoc
1   package ca.uhn.fhir.jpa.dao.data;
2   
3   import java.util.Collection;
4   import java.util.Date;
5   
6   import org.springframework.data.domain.Pageable;
7   import org.springframework.data.domain.Slice;
8   
9   /*
10   * #%L
11   * HAPI FHIR JPA Server
12   * %%
13   * Copyright (C) 2014 - 2018 University Health Network
14   * %%
15   * Licensed under the Apache License, Version 2.0 (the "License");
16   * you may not use this file except in compliance with the License.
17   * You may obtain a copy of the License at
18   * 
19   * http://www.apache.org/licenses/LICENSE-2.0
20   * 
21   * Unless required by applicable law or agreed to in writing, software
22   * distributed under the License is distributed on an "AS IS" BASIS,
23   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24   * See the License for the specific language governing permissions and
25   * limitations under the License.
26   * #L%
27   */
28  
29  import org.springframework.data.jpa.repository.JpaRepository;
30  import org.springframework.data.jpa.repository.Modifying;
31  import org.springframework.data.jpa.repository.Query;
32  import org.springframework.data.repository.query.Param;
33  
34  import ca.uhn.fhir.jpa.entity.Search;
35  
36  public interface ISearchDao extends JpaRepository<Search, Long> {
37  
38  	@Query("SELECT s FROM Search s WHERE s.myUuid = :uuid")
39  	public Search findByUuid(@Param("uuid") String theUuid);
40  
41  	@Query("SELECT s.myId FROM Search s WHERE s.mySearchLastReturned < :cutoff")
42  	public Slice<Long> findWhereLastReturnedBefore(@Param("cutoff") Date theCutoff, Pageable thePage);
43  
44  //	@Query("SELECT s FROM Search s WHERE s.myCreated < :cutoff")
45  //	public Collection<Search> findWhereCreatedBefore(@Param("cutoff") Date theCutoff);
46  
47  	@Query("SELECT s FROM Search s WHERE s.myResourceType = :type AND mySearchQueryStringHash = :hash AND s.myCreated > :cutoff")
48  	public Collection<Search> find(@Param("type") String theResourceType, @Param("hash") int theHashCode, @Param("cutoff") Date theCreatedCutoff);
49  
50  	@Modifying
51  	@Query("UPDATE Search s SET s.mySearchLastReturned = :last WHERE s.myId = :pid")
52  	public void updateSearchLastReturned(@Param("pid") long thePid, @Param("last") Date theDate);
53  
54  }