View Javadoc
1   package ca.uhn.fhir.jpa.dao.data;
2   
3   import ca.uhn.fhir.jpa.entity.ResourceReindexJobEntity;
4   import org.springframework.data.domain.Pageable;
5   import org.springframework.data.jpa.repository.JpaRepository;
6   import org.springframework.data.jpa.repository.Modifying;
7   import org.springframework.data.jpa.repository.Query;
8   import org.springframework.data.repository.query.Param;
9   
10  import java.util.Collection;
11  import java.util.Date;
12  import java.util.List;
13  import java.util.Optional;
14  
15  /*
16   * #%L
17   * HAPI FHIR JPA Server
18   * %%
19   * Copyright (C) 2014 - 2019 University Health Network
20   * %%
21   * Licensed under the Apache License, Version 2.0 (the "License");
22   * you may not use this file except in compliance with the License.
23   * You may obtain a copy of the License at
24   *
25   *      http://www.apache.org/licenses/LICENSE-2.0
26   *
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS,
29   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30   * See the License for the specific language governing permissions and
31   * limitations under the License.
32   * #L%
33   */
34  
35  public interface IResourceReindexJobDao extends JpaRepository<ResourceReindexJobEntity, Long> {
36  
37  	@Modifying
38  	@Query("UPDATE ResourceReindexJobEntity j SET j.myDeleted = true WHERE j.myResourceType = :type")
39  	void markAllOfTypeAsDeleted(@Param("type") String theType);
40  
41  	@Modifying
42  	@Query("UPDATE ResourceReindexJobEntity j SET j.myDeleted = true")
43  	void markAllOfTypeAsDeleted();
44  
45  	@Modifying
46  	@Query("UPDATE ResourceReindexJobEntity j SET j.myDeleted = true WHERE j.myId = :pid")
47  	void markAsDeletedById(@Param("pid") Long theId);
48  
49  	@Query("SELECT j FROM ResourceReindexJobEntity j WHERE j.myDeleted = :deleted")
50  	List<ResourceReindexJobEntity> findAll(Pageable thePage, @Param("deleted") boolean theDeleted);
51  
52  	@Modifying
53  	@Query("UPDATE ResourceReindexJobEntity j SET j.mySuspendedUntil = :suspendedUntil")
54  	void setSuspendedUntil(@Param("suspendedUntil") Date theSuspendedUntil);
55  
56  	@Modifying
57  	@Query("UPDATE ResourceReindexJobEntity j SET j.myThresholdLow = :low WHERE j.myId = :id")
58  	void setThresholdLow(@Param("id") Long theId, @Param("low") Date theLow);
59  
60  	@Query("SELECT j.myReindexCount FROM ResourceReindexJobEntity j WHERE j.myId = :id")
61  	Optional<Integer> getReindexCount(@Param("id") Long theId);
62  
63  	@Query("UPDATE ResourceReindexJobEntity j SET j.myReindexCount = :newCount WHERE j.myId = :id")
64  	@Modifying
65  	void setReindexCount(@Param("id") Long theId, @Param("newCount") int theNewCount);
66  
67  }