001package ca.uhn.fhir.jpa.dao.data;
002
003import ca.uhn.fhir.jpa.entity.ResourceReindexJobEntity;
004import org.springframework.data.domain.Pageable;
005import org.springframework.data.jpa.repository.JpaRepository;
006import org.springframework.data.jpa.repository.Modifying;
007import org.springframework.data.jpa.repository.Query;
008import org.springframework.data.repository.query.Param;
009
010import java.util.Date;
011import java.util.List;
012import java.util.Optional;
013
014/*
015 * #%L
016 * HAPI FHIR JPA Server
017 * %%
018 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
019 * %%
020 * Licensed under the Apache License, Version 2.0 (the "License");
021 * you may not use this file except in compliance with the License.
022 * You may obtain a copy of the License at
023 *
024 *      http://www.apache.org/licenses/LICENSE-2.0
025 *
026 * Unless required by applicable law or agreed to in writing, software
027 * distributed under the License is distributed on an "AS IS" BASIS,
028 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
029 * See the License for the specific language governing permissions and
030 * limitations under the License.
031 * #L%
032 */
033
034@Deprecated
035public interface IResourceReindexJobDao extends JpaRepository<ResourceReindexJobEntity, Long> {
036
037        @Modifying
038        @Query("UPDATE ResourceReindexJobEntity j SET j.myDeleted = true WHERE j.myResourceType = :type")
039        void markAllOfTypeAsDeleted(@Param("type") String theType);
040
041        @Modifying
042        @Query("UPDATE ResourceReindexJobEntity j SET j.myDeleted = true")
043        void markAllOfTypeAsDeleted();
044
045        @Modifying
046        @Query("UPDATE ResourceReindexJobEntity j SET j.myDeleted = true WHERE j.myId = :pid")
047        void markAsDeletedById(@Param("pid") Long theId);
048
049        @Query("SELECT j FROM ResourceReindexJobEntity j WHERE j.myDeleted = :deleted")
050        List<ResourceReindexJobEntity> findAll(Pageable thePage, @Param("deleted") boolean theDeleted);
051
052        @Modifying
053        @Query("UPDATE ResourceReindexJobEntity j SET j.mySuspendedUntil = :suspendedUntil")
054        void setSuspendedUntil(@Param("suspendedUntil") Date theSuspendedUntil);
055
056        @Modifying
057        @Query("UPDATE ResourceReindexJobEntity j SET j.myThresholdLow = :low WHERE j.myId = :id")
058        void setThresholdLow(@Param("id") Long theId, @Param("low") Date theLow);
059
060        @Query("SELECT j.myReindexCount FROM ResourceReindexJobEntity j WHERE j.myId = :id")
061        Optional<Integer> getReindexCount(@Param("id") Long theId);
062
063        @Query("UPDATE ResourceReindexJobEntity j SET j.myReindexCount = :newCount WHERE j.myId = :id")
064        @Modifying
065        void setReindexCount(@Param("id") Long theId, @Param("newCount") int theNewCount);
066
067}