Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOSIP-29094]Updated sql queries with case insensitive search #920

Merged
merged 5 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public ResponseWrapper<PageResponseDto<UserCenterMappingExtnDto>> serachUserCent
auditUtil.auditRequest(MasterDataConstant.SEARCH_USER_DETAILS_API_IS_CALLED + SearchDto.class.getCanonicalName(),
MasterDataConstant.AUDIT_SYSTEM,
MasterDataConstant.SEARCH_USER_DETAILS_API_IS_CALLED + SearchDto.class.getCanonicalName(),"ADM-922");
responseWrapper.setResponse(userDetailsService.serachUserCenterMappingDetails(dto.getRequest()));
responseWrapper.setResponse(userDetailsService.searchUserCenterMappingDetails(dto.getRequest()));
return responseWrapper;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ public interface UserDetailsRepository extends BaseRepository<UserDetails, Strin
nativeQuery = true)
public List<UserDetails> findByRegIdAndIsDeletedFalseOrIsDeletedIsNull(String centerId, Pageable pageable);

@Query("FROM UserDetails m where m.id = ?1 and (m.isDeleted is null or m.isDeleted = false)")
@Query("FROM UserDetails m where LOWER(m.id) = LOWER(?1) and (m.isDeleted is null or m.isDeleted = false)")
UserDetails findByIdAndIsDeletedFalseorIsDeletedIsNull(String id);

@Query("FROM UserDetails m where m.id = ?1")
@Query("FROM UserDetails m where LOWER(m.id) = LOWER(?1)")
UserDetails findUserDetailsById(String id);

@Query("FROM UserDetails m where (m.isDeleted is null or m.isDeleted = false)")
List<UserDetails> findAllByAndIsDeletedFalseorIsDeletedIsNull();

@Query("FROM UserDetails m where m.id = ?1 and (m.isDeleted is null or m.isDeleted = false) and isActive = true")
@Query("FROM UserDetails m where LOWER(m.id) = LOWER(?1) and (m.isDeleted is null or m.isDeleted = false) and isActive = true")
UserDetails findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActive(String id);

@Query("FROM UserDetails m where (m.isDeleted is null or m.isDeleted = false) and m.isActive = true")
Page<UserDetails> findAllByIsDeletedFalseorIsDeletedIsNull(Pageable pageable);

@Query("FROM UserDetails m where m.id = ?1 and m.langCode = ?2 and (m.isDeleted is null or m.isDeleted = false)")
@Query("FROM UserDetails m where LOWER(m.id) = LOWER(?1) and m.langCode = ?2 and (m.isDeleted is null or m.isDeleted = false)")
UserDetails findByIdAndIsDeletedFalseorIsDeletedIsNull(String id,String langCode);

@Modifying
@Query("UPDATE UserDetails m SET m.updatedBy=?3, m.isDeleted =true, m.isActive = false, m.updatedDateTime=?2 ,m.deletedDateTime = ?2 WHERE m.id =?1 and (m.isDeleted is null or m.isDeleted =false)")
@Query("UPDATE UserDetails m SET m.updatedBy=?3, m.isDeleted =true, m.isActive = false, m.updatedDateTime=?2 ,m.deletedDateTime = ?2 WHERE LOWER(m.id) = LOWER(?1) and (m.isDeleted is null or m.isDeleted =false)")
int deleteUserCenterMapping(String id, LocalDateTime deletedDateTime, String updatedBy);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
*/
public interface ZoneUserRepository extends BaseRepository<ZoneUser, String> {

@Query("FROM ZoneUser zu WHERE zu.userId=?1 and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
@Query("FROM ZoneUser zu WHERE LOWER(zu.userId)=LOWER(?1) and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
public List<ZoneUser> findByUserIdNonDeleted(String userId);

@Query("FROM ZoneUser zu WHERE zu.userId=?1 and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
@Query("FROM ZoneUser zu WHERE LOWER(zu.userId)=LOWER(?1) and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
public ZoneUser findZoneByUserIdNonDeleted(String userId);

@Query("FROM ZoneUser zu WHERE zu.userId=?1 ")
@Query("FROM ZoneUser zu WHERE LOWER(zu.userId)=LOWER(?1) ")
public ZoneUser findByUserId(String userId);

@Query("FROM ZoneUser zu WHERE zu.userId=?1 and zu.zoneCode=?2 ")
@Query("FROM ZoneUser zu WHERE LOWER(zu.userId)=LOWER(?1) and zu.zoneCode=?2 ")
public List<ZoneUser> findByUserIdAndZoneCode(String userId, String zoneCode);

@Query("FROM ZoneUser zu WHERE zu.userId=?1 and zu.zoneCode=?2 and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
@Query("FROM ZoneUser zu WHERE LOWER(zu.userId)=LOWER(?1) and zu.zoneCode=?2 and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
public ZoneUser findByIdAndIsDeletedFalseOrIsDeletedIsNull(String userId, String zoneCode);

@Query("FROM ZoneUser zu WHERE zu.zoneCode=?1 and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
public List<ZoneUser> findtoUpdateZoneUserByCode(String zoneCode);

@Query("FROM ZoneUser zu WHERE zu.userId=?1 and zu.langCode=?2 and zu.zoneCode=?3 and (zu.isDeleted IS NULL OR zu.isDeleted = false) and zu.isActive=true")
@Query("FROM ZoneUser zu WHERE LOWER(zu.userId)=LOWER(?1) and zu.langCode=?2 and zu.zoneCode=?3 and (zu.isDeleted IS NULL OR zu.isDeleted = false) and zu.isActive=true")
public ZoneUser findZoneUserByUserIdZoneCodeLangCodeIsActive(String userId, String langCode, String zoneCode);

@Query("FROM ZoneUser zu WHERE zu.userId IN :userids")
public List<ZoneUser> findByUserIds(@Param("userids") List<String> userIds);

@Query("FROM ZoneUser zu WHERE zu.userId=?1 and zu.isActive=true and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
@Query("FROM ZoneUser zu WHERE LOWER(zu.userId)=LOWER(?1) and zu.isActive=true and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
public ZoneUser findZoneByUserIdActiveAndNonDeleted(String userId);

@Query("FROM ZoneUser zu WHERE LOWER(zu.zoneCode) like (%?1%) and (zu.isDeleted IS NULL OR zu.isDeleted = false) ")
balaji-alluru marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ public UsersDto getUsers(String roleName,int pageStart, int pageFetch,

public StatusResponseDto updateUserStatus(String id, @Valid boolean isActive);

public PageResponseDto<UserCenterMappingExtnDto> serachUserCenterMappingDetails(SearchDtoWithoutLangCode request);
public PageResponseDto<UserCenterMappingExtnDto> searchUserCenterMappingDetails(SearchDtoWithoutLangCode request);

}
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public UserDetailsCenterMapping createUser(UserDetailsDto userDetailsDto) {
}

validateMappingData(userDetailsDto.getId(), regCenters.get(0).getZoneCode(), userDetailsDto.getLangCode());
userDetailsDto.setId(userDetailsDto.getId().toLowerCase());
balaji-alluru marked this conversation as resolved.
Show resolved Hide resolved

userDetailsDto = masterdataCreationUtil.createMasterData(UserDetails.class, userDetailsDto);
ud = MetaDataUtils.setCreateMetaData(userDetailsDto, UserDetails.class);
Expand Down Expand Up @@ -653,7 +654,7 @@ public PageResponseDto<UserDetailsExtnDto> searchUserDetails(SearchDtoWithoutLan
}

@Override
public PageResponseDto<UserCenterMappingExtnDto> serachUserCenterMappingDetails(SearchDtoWithoutLangCode searchDto) {
public PageResponseDto<UserCenterMappingExtnDto> searchUserCenterMappingDetails(SearchDtoWithoutLangCode searchDto) {
PageResponseDto<ZoneUserSearchDto> pageDto = new PageResponseDto<>();
PageResponseDto<UserCenterMappingExtnDto> userCenterPageDto = new PageResponseDto<>();
List<UserCenterMappingExtnDto> userCenterMappingExtnDtos = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public ZoneUserExtnDto createZoneUserMapping(ZoneUserDto zoneUserDto) {

// Throws exception if not found
zoneservice.getZone(zoneUserDto.getZoneCode(), languageUtils.getDefaultLanguage());

zu.setUserId(zu.getUserId().toLowerCase());
balaji-alluru marked this conversation as resolved.
Show resolved Hide resolved
zu = zoneUserRepo.save(zu);
ZoneUserHistory zuh = new ZoneUserHistory();
MapperUtils.map(zu, zuh);
Expand Down Expand Up @@ -309,7 +309,7 @@ public StatusResponseDto updateZoneUserMapping(String userId, boolean isActive)
throw new MasterDataServiceException(ZoneUserErrorCode.USER_MAPPING_EXIST.getErrorCode(),
ZoneUserErrorCode.USER_MAPPING_EXIST.getErrorMessage());
}
masterdataCreationUtil.updateMasterDataStatus(ZoneUser.class, userId, isActive, "userId");
masterdataCreationUtil.updateMasterDataStatus(ZoneUser.class, userId.toLowerCase(), isActive, "userId");
balaji-alluru marked this conversation as resolved.
Show resolved Hide resolved

ZoneUserHistory zoneUserHistory = new ZoneUserHistory();
MetaDataUtils.setUpdateMetaData(zoneUser, zoneUserHistory, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,42 @@ hibernate.cache.use_second_level_cache=false
hibernate.cache.use_query_cache=false
hibernate.cache.use_structured_entries=false
hibernate.generate_statistics=false
mosip.right_to_left.orientation=ara

mosip.kernel.packet-status-update-url=https://dev.mosip.net/registrationprocessor/v1/registrationstatus/search
mosip.kernel.packet-status-update-url=https://api-internal.dev.mosip.net/registrationprocessor/v1/registrationstatus/search

mosip.kernel.registrationcenterid.length=5
mosip.kernel.machineid.length=5

masterdata_database_url=jdbc:postgresql://dev.mosip.net:30090/mosip_master
masterdata_database_username=masteruser
masterdata_database_password=mosip123
auth.server.admin.issuer.uri=https://dev.mosip.net/keycloak/auth/realms/
masterdata_database_url=jdbc:postgresql://api-internal.dev.mosip.net/mosip_master
masterdata_database_username=postgres
masterdata_database_password=mQi298ZW7p
auth.server.admin.issuer.uri=https://iam.dev.mosip.net/auth/realms/
mosip.primary-language=eng
mosip.secondary-language=
mosip.all-languages=all
auth.server.admin.allowed.audience=mosip-regproc-client,mosip-prereg-client,mosip-admin-client,mosip-partner-client,mosip-crereq-client,mosip-creser-client,mosip-datsha-client,mosip-ida-client,mosip-resident-client,mosip-reg-client

mosip.kernel.auth.appids.realm.map={prereg:'preregistration',ida:'mosip',registrationclient:'mosip',regproc:'mosip',partner:'mosip',resident:'mosip',admin:'mosip',crereq:'mosip',creser:'mosip',datsha:'mosip'}

#auth.server.validate.url=https://dev.mosip.net/v1/authmanager/authorize/validateToken
#auth.server.validate.url=https://api-internal.dev.mosip.net/v1/authmanager/authorize/validateToken
mosip.kernel.filtervalue.max_columns=200
mosip.admin.ui.configs=primaryLangCode:${mosip.primary-language};secondaryLangCode:${mosip.secondary-language};version:${aplication.configuration.level.version};filterValueMaxCount:{"default":${mosip.kernel.filtervalue.max_columns},"registrationcenters":50,"locations":100}
mosip.recommended.centers.locCode =5
auth.server.admin.offline.token.validate=false
aplication.configuration.level.version=1.1.5
mosip.optional-languages=
mosip.mandatory-languages=eng
auth.server.validate.url=https://dev.mosip.net/v1/authmanager/authorize/admin/validateToken
auth.server.admin.validate.url=https://dev.mosip.net/v1/authmanager/authorize/admin/validateToken
auth.server.validate.url=https://api-internal.dev.mosip.net/v1/authmanager/authorize/admin/validateToken
auth.server.admin.validate.url=https://api-internal.dev.mosip.net/v1/authmanager/authorize/admin/validateToken

master.search.maximum.rows=50

mosip.kernel.masterdata.audit-url=https://dev.mosip.net/v1/auditmanager/audits
mosip.kernel.masterdata.audit-url=https://api-internal.dev.mosip.net/v1/auditmanager/audits

mosip.level=2
mosip.iam.adapter.clientid=mosip-admin-client
mosip.iam.adapter.clientsecret=xyz123
mosip.iam.adapter.clientsecret=xzzvvPISDPwR2yl7
mosip.iam.adapter.appid=admin
mosip.kernel.sign-url=https://qa.mosip.io/v1/signature/sign

Expand All @@ -56,12 +57,12 @@ mosip.kernel.applicant.type.age.limit = 5
mosip.stage.environment=Staging
mosip.auth.adapter.impl.basepackage=io.mosip.kernel.auth.defaultadapter
mosip.kernel.applicantType.mvel.file=applicanttype.mvel
mosip.kernel.config.server.file.storage.uri=https://dev.mosip.net/config/kernel-masterdata-service/mz/develop-v2/
mosip.kernel.config.server.file.storage.uri=https://api-internal.dev.mosip.net/config/kernel-masterdata-service/mz/develop-v2/
mosip.kernel.masterdata.auth-manager-base-uri=http://localhost:8080/

mosip.kernel.masterdata.template_idauthentication_event=MASTERDATA_IDAUTHENTICATION_TEMPLATES
mosip.kernel.masterdata.title_event=MASTERDATA_TITLES
websub.publish.url=https://dev.mosip.net/websub/publish
websub.publish.url=https://api-internal.dev.mosip.net/websub/publish

mosip.kernel.masterdata.template_idauthentication_event_module_name=ID Authentication

Expand Down Expand Up @@ -395,6 +396,7 @@ mosip.role.admin.masterdata.getdocumenttypesmissingidslangcode=GLOBAL_ADMIN,ZONA
mosip.role.admin.masterdata.getdocumentcategoriesmissingidslangcode=GLOBAL_ADMIN,ZONAL_ADMIN
mosip.role.admin.masterdata.getdynamicfieldmissingidslangcode=GLOBAL_ADMIN,ZONAL_ADMIN

zone.user.details.url=https://dev.mosip.net/v1/authmanager/userdetails
zone.user.details.url=https://api-internal.dev.mosip.net/v1/authmanager/userdetails
mosip.kernel.masterdata.code.validate.regex=[^a-z0-9]
mosip.kernel.masterdata.name.validate.regex=[^A-Za-z]
mosip.kernel.masterdata.name.validate.regex=[^A-Za-z]
mosip.kernel.config.server.file.storage.uri=http://localhost:51000/config/resident/mz/develop/