Skip to content

Commit

Permalink
MOSIP-38092 : Partner Admin: SBI - Device: API GET /devicedetail/sear…
Browse files Browse the repository at this point in the history
…ch/v2

Signed-off-by: sudeep <[email protected]>
  • Loading branch information
Sudeep7353 committed Dec 6, 2024
1 parent 9237bc2 commit 7f5dddd
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
@ColumnResult(name = "status", type = String.class),
@ColumnResult(name = "make", type = String.class),
@ColumnResult(name = "model", type = String.class),
@ColumnResult(name = "createdDateTime", type = LocalDateTime.class)
@ColumnResult(name = "createdDateTime", type = LocalDateTime.class),
@ColumnResult(name = "sbiId", type = String.class),
@ColumnResult(name = "sbiVersion", type = String.class)
}
)
}
Expand All @@ -34,7 +36,8 @@ public class DeviceDetailEntity {

public DeviceDetailEntity(
String deviceId, String partnerId, String orgName, String deviceType,
String deviceSubType, String status, String make, String model, LocalDateTime createdDateTime) {
String deviceSubType, String status, String make, String model,
LocalDateTime createdDateTime, String sbiId, String sbiVersion) {
this.deviceId = deviceId;
this.partnerId = partnerId;
this.orgName = orgName;
Expand All @@ -44,6 +47,8 @@ public DeviceDetailEntity(
this.make = make;
this.model = model;
this.createdDateTime = createdDateTime;
this.sbiId = sbiId;
this.sbiVersion = sbiVersion;
}

// No-argument constructor
Expand All @@ -69,4 +74,8 @@ public DeviceDetailEntity() {
private String model;

private LocalDateTime createdDateTime;

private String sbiId;

private String sbiVersion;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public interface DeviceDetailSummaryRepository extends BaseRepository<DeviceDeta
"WHEN (d.approvalStatus = 'pending_approval') THEN 'pending_approval' " +
"WHEN (d.approvalStatus = 'rejected') THEN 'rejected' " +
"END as status, " +
"d.make, d.model, d.crDtimes) " +
"d.make, d.model, d.crDtimes, s.id, s.swVersion) " +
"FROM DeviceDetail d " +
"LEFT JOIN DeviceDetailSBI dds ON dds.id.deviceDetailId = d.id " +
"LEFT JOIN SecureBiometricInterface s ON dds.id.sbiId = s.id " +
"WHERE (:partnerId IS NULL OR lower(d.deviceProviderId) LIKE %:partnerId%) " +
"AND (:orgName IS NULL OR lower(d.partnerOrganizationName) LIKE %:orgName%) " +
"AND (:deviceType IS NULL OR lower(d.deviceTypeCode) LIKE %:deviceType%) " +
Expand All @@ -33,7 +35,10 @@ public interface DeviceDetailSummaryRepository extends BaseRepository<DeviceDeta
" OR (:status = 'rejected' AND d.approvalStatus = 'rejected')" +
")) " +
"AND (:make IS NULL OR lower(d.make) LIKE %:make%) " +
"AND (:model IS NULL OR lower(d.model) LIKE %:model%)";
"AND (:model IS NULL OR lower(d.model) LIKE %:model%)"+
"AND (:deviceId IS NULL OR lower(d.id) LIKE %:deviceId%)"+
"AND (:sbiId IS NULL OR s.id LIKE %:sbiId%) " +
"AND (:sbiVersion IS NULL OR s.swVersion LIKE %:sbiVersion%)";

@Query(DEVICE_DETAILS_SUMMARY_QUERY)
Page<DeviceDetailEntity> getSummaryOfAllDeviceDetails(
Expand All @@ -44,6 +49,9 @@ Page<DeviceDetailEntity> getSummaryOfAllDeviceDetails(
@Param("status") String status,
@Param("make") String make,
@Param("model") String model,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("deviceId") String deviceId,
Pageable pageable
);

Expand All @@ -56,6 +64,9 @@ Page<DeviceDetailEntity> getSummaryOfAllDeviceDetailsByStatusAsc(
@Param("status") String status,
@Param("make") String make,
@Param("model") String model,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("deviceId") String deviceId,
Pageable pageable
);

Expand All @@ -68,7 +79,9 @@ Page<DeviceDetailEntity> getSummaryOfAllDeviceDetailsByStatusDesc(
@Param("status") String status,
@Param("make") String make,
@Param("model") String model,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("deviceId") String deviceId,
Pageable pageable
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,13 @@ private Page<DeviceDetailEntity> getDeviceDetails(String sortFieldName, String s
if (sortFieldName.equals("status") && sortType.equalsIgnoreCase(PartnerConstants.ASC)) {
return deviceDetailSummaryRepository.
getSummaryOfAllDeviceDetailsByStatusAsc(filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getDeviceType(),
filterDto.getDeviceSubType(), filterDto.getStatus(), filterDto.getMake(), filterDto.getModel(), pageable);
filterDto.getDeviceSubType(), filterDto.getStatus(), filterDto.getMake(), filterDto.getModel(),
filterDto.getSbiId(), filterDto.getSbiVersion(), filterDto.getDeviceId(), pageable);
} else if (sortFieldName.equals("status") && sortType.equalsIgnoreCase(PartnerConstants.DESC)) {
return deviceDetailSummaryRepository.
getSummaryOfAllDeviceDetailsByStatusDesc(filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getDeviceType(),
filterDto.getDeviceSubType(), filterDto.getStatus(), filterDto.getMake(), filterDto.getModel(), pageable);
filterDto.getDeviceSubType(), filterDto.getStatus(), filterDto.getMake(), filterDto.getModel(),
filterDto.getSbiId(), filterDto.getSbiVersion(), filterDto.getDeviceId(), pageable);
}
//Sorting for other fields
Sort sort = partnerHelper.getSortingRequest(getSortColumn(partnerHelper.deviceAliasToColumnMap, sortFieldName), sortType);
Expand All @@ -664,7 +666,8 @@ private Page<DeviceDetailEntity> getDeviceDetails(String sortFieldName, String s
//Default
return deviceDetailSummaryRepository.
getSummaryOfAllDeviceDetails(filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getDeviceType(),
filterDto.getDeviceSubType(), filterDto.getStatus(), filterDto.getMake(), filterDto.getModel(), pageable);
filterDto.getDeviceSubType(), filterDto.getStatus(), filterDto.getMake(), filterDto.getModel(),
filterDto.getSbiId(), filterDto.getSbiVersion(), filterDto.getDeviceId(), pageable);
}

public String getSortColumn(Map<String, String> aliasToColumnMap, String alias) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ public ResponseWrapperV2<PageResponseV2Dto<DeviceDetailSummaryDto>> getAllDevice
)
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "make", required = false) String make,
@RequestParam(value = "model", required = false) String model
@RequestParam(value = "model", required = false) String model,
@RequestParam(value = "sbiId", required = false) String sbiId,
@RequestParam(value = "sbiVersion", required = false) String sbiVersion,
@RequestParam(value = "deviceId", required = false) String deviceId
) {
partnerHelper.validateRequestParameters(partnerHelper.deviceAliasToColumnMap, sortFieldName, sortType, pageNo, pageSize);
DeviceDetailFilterDto filterDto = new DeviceDetailFilterDto();
Expand All @@ -313,6 +316,15 @@ public ResponseWrapperV2<PageResponseV2Dto<DeviceDetailSummaryDto>> getAllDevice
if (model != null) {
filterDto.setMake(model.toLowerCase());
}
if (sbiId != null) {
filterDto.setSbiId(sbiId.toLowerCase());
}
if (sbiVersion != null) {
filterDto.setSbiVersion(sbiVersion.toLowerCase());
}
if (deviceId != null) {
filterDto.setDeviceId(deviceId.toLowerCase());
}
return deviceDetaillService.getAllDeviceDetails(sortFieldName, sortType, pageNo, pageSize, filterDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

@Data
public class DeviceDetailFilterDto {
private String deviceId;
private String partnerId;
private String orgName;
private String deviceType;
private String deviceSubType;
private String status;
private String make;
private String model;
private String sbiId;
private String sbiVersion;

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ public class DeviceDetailSummaryDto {

@Schema(description = "Date and time when the record was created", example = "2024-08-01T14:30:00Z")
private LocalDateTime createdDateTime;

@Schema(description = "Unique identifier for the Secure Biometric Interface (SBI) associated with the device.", example = "sbi12")
private String sbiId;

@Schema(description = "Software version of the Secure Biometric Interface (SBI).", example = "sw12")
private String sbiVersion;

}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public class PartnerHelper {
public final Map<String, String> deviceAliasToColumnMap = new HashMap<>();
{
deviceAliasToColumnMap.put("deviceId", "id");
deviceAliasToColumnMap.put("sbiId", "s.id");
deviceAliasToColumnMap.put("sbiVersion", "s.swVersion");
deviceAliasToColumnMap.put("partnerId", "deviceProviderId");
deviceAliasToColumnMap.put("orgName", "partnerOrganizationName");
deviceAliasToColumnMap.put("deviceType", "deviceTypeCode");
Expand Down

0 comments on commit 7f5dddd

Please sign in to comment.