diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/repositary/RegistrationRepositary.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/repositary/RegistrationRepositary.java index fc9a51848e0..2a53a40c226 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/repositary/RegistrationRepositary.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/repositary/RegistrationRepositary.java @@ -1,66 +1,65 @@ -/* - * - */ -package io.mosip.registration.processor.status.repositary; - -import java.time.LocalDateTime; -import java.util.List; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import io.mosip.kernel.core.dataaccess.spi.repository.BaseRepository; -import io.mosip.registration.processor.status.entity.BaseRegistrationEntity; -import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; -import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; - -/** - * The Interface RegistrationRepositary. - * - * @param - * the generic type - * @param - * the element type - */ -@Repository -public interface RegistrationRepositary extends BaseRepository { - - - @Query("SELECT registration.regId FROM RegistrationStatusEntity registration WHERE registration.regId in :regIds AND registration.statusCode in :statusCode") - public List getProcessedOrProcessingRegIds(@Param("regIds") List regIds, - @Param("statusCode") List statusCode); - - @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.id in :regIds and registration.statusCode !=:statusCode") - public List getWithoutStatusCode(@Param("regIds") List regIds, @Param("statusCode") String statusCode); - @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId = :regId AND registration.isDeleted =false AND registration.isActive=true") - public List findByRegId(@Param("regId") String regId); - - @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId IN :regIds AND registration.isDeleted =false AND registration.isActive=true") - public List findByRegIds(@Param("regIds") List regIds); - - @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId IN :regIds AND registration.isDeleted =false AND registration.isActive=true order by registration.createDateTime") - public List findByRegIdsOrderbyCreatedDateTime(@Param("regIds") List regIds); - - @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.statusCode = :statusCode AND registration.isDeleted =false AND registration.isActive=true") - public List findByStatusCode(@Param("statusCode") String statusCode); - - @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId = :regId AND registration.statusCode = :statusCode ") - public List findByRegIdANDByStatusCode(@Param("regId") String regId,@Param("statusCode") String statusCode); - - @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.id.workflowInstanceId = :workflowInstanceId AND registration.isDeleted =false AND registration.isActive=true") - public List findByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); - - @Query(value ="SELECT * FROM registration r WHERE r.latest_trn_status_code IN :status AND r.reg_process_retry_count<=:reprocessCount AND r.latest_trn_dtimes <:timeDifference AND r.status_code NOT IN :statusCodes AND r.reg_stage_name NOT IN :excludeStageNames LIMIT :fetchSize ", nativeQuery = true) - public List getUnProcessedPackets(@Param("status") List status,@Param("reprocessCount") Integer reprocessCount,@Param("timeDifference") LocalDateTime timeDifference,@Param("statusCodes") List statusCodes,@Param("fetchSize") Integer fetchSize,@Param("excludeStageNames") List excludeStageNames); - - @Query("SELECT COUNT(*) FROM RegistrationStatusEntity registration WHERE registration.latestTransactionStatusCode IN :status AND registration.regProcessRetryCount<=:reprocessCount AND registration.latestTransactionTimes<:timeDifference AND registration.statusCode NOT IN :statusCodes AND registration.registrationStageName NOT IN :excludeStageNames") - public int getUnProcessedPacketsCount(@Param("status") List status,@Param("reprocessCount") Integer reprocessCount,@Param("timeDifference") LocalDateTime timeDifference,@Param("statusCodes") List statusCodes,@Param("excludeStageNames") List excludeStageNames); - - @Query(value ="SELECT * FROM registration r WHERE r.status_code IN :statusCodes AND r.resume_timestamp < now() AND r.default_resume_action is NOT NULL order by r.upd_dtimes LIMIT :fetchSize ", nativeQuery = true) - public List getActionablePausedPackets(@Param("statusCodes") List statusCodes,@Param("fetchSize") Integer fetchSize); - - @Query(value ="SELECT * FROM registration r WHERE r.status_code =:statusCode order by r.upd_dtimes LIMIT :fetchSize ", nativeQuery = true) - public List getResumablePackets(@Param("statusCode") String statusCode,@Param("fetchSize") Integer fetchSize); -} - +/* + * + */ +package io.mosip.registration.processor.status.repositary; + +import java.time.LocalDateTime; +import java.util.List; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import io.mosip.kernel.core.dataaccess.spi.repository.BaseRepository; +import io.mosip.registration.processor.status.entity.BaseRegistrationEntity; +import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; + +/** + * The Interface RegistrationRepositary. + * + * @param + * the generic type + * @param + * the element type + */ +@Repository +public interface RegistrationRepositary extends BaseRepository { + + + @Query("SELECT registration.regId FROM RegistrationStatusEntity registration WHERE registration.regId in :regIds AND registration.statusCode in :statusCode") + public List getProcessedOrProcessingRegIds(@Param("regIds") List regIds, + @Param("statusCode") List statusCode); + + @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId in :regIds and registration.statusCode !=:statusCode") + public List getWithoutStatusCode(@Param("regIds") List regIds, @Param("statusCode") String statusCode); + @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId = :regId AND registration.isDeleted =false AND registration.isActive=true") + public List findByRegId(@Param("regId") String regId); + + @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId IN :regIds AND registration.isDeleted =false AND registration.isActive=true") + public List findByRegIds(@Param("regIds") List regIds); + + @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId IN :regIds AND registration.isDeleted =false AND registration.isActive=true order by registration.createDateTime") + public List findByRegIdsOrderbyCreatedDateTime(@Param("regIds") List regIds); + + @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.statusCode = :statusCode AND registration.isDeleted =false AND registration.isActive=true") + public List findByStatusCode(@Param("statusCode") String statusCode); + + @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId = :regId AND registration.statusCode = :statusCode ") + public List findByRegIdANDByStatusCode(@Param("regId") String regId,@Param("statusCode") String statusCode); + + @Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.id.workflowInstanceId = :workflowInstanceId AND registration.isDeleted =false AND registration.isActive=true") + public List findByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); + + @Query(value ="SELECT * FROM registration r WHERE r.latest_trn_status_code IN :status AND r.reg_process_retry_count<=:reprocessCount AND r.latest_trn_dtimes <:timeDifference AND r.status_code NOT IN :statusCodes AND r.reg_stage_name NOT IN :excludeStageNames LIMIT :fetchSize ", nativeQuery = true) + public List getUnProcessedPackets(@Param("status") List status,@Param("reprocessCount") Integer reprocessCount,@Param("timeDifference") LocalDateTime timeDifference,@Param("statusCodes") List statusCodes,@Param("fetchSize") Integer fetchSize,@Param("excludeStageNames") List excludeStageNames); + + @Query("SELECT COUNT(*) FROM RegistrationStatusEntity registration WHERE registration.latestTransactionStatusCode IN :status AND registration.regProcessRetryCount<=:reprocessCount AND registration.latestTransactionTimes<:timeDifference AND registration.statusCode NOT IN :statusCodes AND registration.registrationStageName NOT IN :excludeStageNames") + public int getUnProcessedPacketsCount(@Param("status") List status,@Param("reprocessCount") Integer reprocessCount,@Param("timeDifference") LocalDateTime timeDifference,@Param("statusCodes") List statusCodes,@Param("excludeStageNames") List excludeStageNames); + + @Query(value ="SELECT * FROM registration r WHERE r.status_code IN :statusCodes AND r.resume_timestamp < now() AND r.default_resume_action is NOT NULL order by r.upd_dtimes LIMIT :fetchSize ", nativeQuery = true) + public List getActionablePausedPackets(@Param("statusCodes") List statusCodes,@Param("fetchSize") Integer fetchSize); + + @Query(value ="SELECT * FROM registration r WHERE r.status_code =:statusCode order by r.upd_dtimes LIMIT :fetchSize ", nativeQuery = true) + public List getResumablePackets(@Param("statusCode") String statusCode,@Param("fetchSize") Integer fetchSize); +} +