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