All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mosip.admin.bulkdataupload.repositories.RegistrationCenterUserRepository Maven / Gradle / Ivy

There is a newer version: 1.2.1.0
Show newest version
package io.mosip.admin.bulkdataupload.repositories;

import java.util.List;

import org.springframework.data.jpa.repository.Query;

import io.mosip.admin.bulkdataupload.entity.RegistrationCenterUser;
import io.mosip.admin.bulkdataupload.entity.id.RegistrationCenterUserID;
import io.mosip.kernel.core.dataaccess.spi.repository.BaseRepository;

/**
 * Registration Center User Repository
 * 
 * @author Abhishek Kumar
 * @author Megha Tanga
 * @since 1.0.0
 */
public interface RegistrationCenterUserRepository
		extends BaseRepository {

	@Query(value = "select count(*) from  master.reg_center_user where regcntr_id=?1 and (is_deleted is null or is_deleted=false);", nativeQuery = true)
	public Long countCenterUsers(String centerId);

	/**
	 * Method that returns the list of registration centers mapped to users.
	 * 
	 * @param regCenterID the center ID of the reg-center which needs to be
	 *                    decommissioned.
	 * @return the list of registration centers mapped to users.
	 */
	@Query(value = "FROM RegistrationCenterUser ru WHERE ru.registrationCenterUserID.regCenterId =?1 and (ru.isDeleted is null or ru.isDeleted =false) ")
	public List registrationCenterUserMappings(String regCenterID);

	/**
	 * Method to find valid RegistrationCenterUser based on User Id and Registration
	 * Center Id Type code provided.
	 * 
	 * @param userId      the User Id.
	 * @param regCenterId the registration center Id .
	 * @return RegistrationCenterUser
	 */
	@Query(value = "FROM RegistrationCenterUser rc WHERE rc.registrationCenterUserID.userId = ?1 and rc.registrationCenterUserID.regCenterId = ?2 AND (rc.isDeleted is null OR rc.isDeleted = false)")
	public RegistrationCenterUser findByUserIdAndRegCenterId(String userId, String regCenterId);

	/**
	 * Method that returns the list of registration centers mapped to users.
	 * 
	 * @param userID the user ID
	 * @return the list of registration centers mapped to users.
	 */
	@Query(value = "FROM RegistrationCenterUser ru WHERE ru.registrationCenterUserID.userId =?1 and (ru.isDeleted is null or ru.isDeleted =false) and ru.isActive = true")
	public List findByUserId(String userId);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy