Add search by serial number in store

app-icon-change
commit 89132f4824

@ -379,6 +379,12 @@ public interface SubscriptionManagementAPI {
@QueryParam("ownership") @QueryParam("ownership")
@Size(max = 45) @Size(max = 45)
String ownership, String ownership,
@ApiParam(
name = "serialNumber",
value = "The serial number of the device.",
required = false)
@QueryParam("serialNumber")
String serialNumber,
@ApiParam( @ApiParam(
name="uuid", name="uuid",
value="uuid of the application release.", value="uuid of the application release.",

@ -314,6 +314,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
@QueryParam("name") String name, @QueryParam("name") String name,
@QueryParam("user") String user, @QueryParam("user") String user,
@QueryParam("ownership") String ownership, @QueryParam("ownership") String ownership,
@QueryParam("serialNumber") String serialNumber,
@PathParam("uuid") String uuid, @PathParam("uuid") String uuid,
@DefaultValue("0") @DefaultValue("0")
@QueryParam("offset") int offset, @QueryParam("offset") int offset,
@ -333,6 +334,9 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
RequestValidationUtil.validateOwnershipType(ownership); RequestValidationUtil.validateOwnershipType(ownership);
request.setOwnership(ownership); request.setOwnership(ownership);
} }
if (StringUtils.isNotBlank(serialNumber)) {
request.setSerialNumber(serialNumber);
}
if (status != null && !status.isEmpty()) { if (status != null && !status.isEmpty()) {
boolean isStatusEmpty = true; boolean isStatusEmpty = true;
for (String statusString : status) { for (String statusString : status) {

@ -1184,6 +1184,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
String name = request.getDeviceName(); String name = request.getDeviceName();
String user = request.getOwner(); String user = request.getOwner();
String ownership = request.getOwnership(); String ownership = request.getOwnership();
String serial = request.getSerialNumber();
String query = null; String query = null;
try { try {
List<Device> devices = new ArrayList<>(); List<Device> devices = new ArrayList<>();
@ -1197,6 +1198,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isDeviceNameProvided = false; boolean isDeviceNameProvided = false;
boolean isOwnerProvided = false; boolean isOwnerProvided = false;
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
boolean isSerialProvided = false;
StringJoiner joiner = new StringJoiner(",", StringJoiner joiner = new StringJoiner(",",
"SELECT " "SELECT "
@ -1219,6 +1221,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "DM_DEVICE.TENANT_ID = e.TENANT_ID " + "DM_DEVICE.TENANT_ID = e.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "INNER JOIN DM_DEVICE_INFO i ON "
+ "DM_DEVICE.ID = i.DEVICE_ID "
+ "AND i.KEY_FIELD = 'serial' "
+ "WHERE DM_DEVICE.ID IN (", + "WHERE DM_DEVICE.ID IN (",
") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?"); ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?");
@ -1233,6 +1238,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
query += " AND e.OWNERSHIP = ?"; query += " AND e.OWNERSHIP = ?";
isOwnershipProvided = true; isOwnershipProvided = true;
} }
if (serial != null && !serial.isEmpty()) {
query += " AND i.VALUE_FIELD LIKE ?" ;
isSerialProvided = true;
}
if (user != null && !user.isEmpty()) { if (user != null && !user.isEmpty()) {
query += " AND e.OWNER = ?"; query += " AND e.OWNER = ?";
isOwnerProvided = true; isOwnerProvided = true;
@ -1257,6 +1266,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
if (isOwnershipProvided) { if (isOwnershipProvided) {
ps.setString(index++, ownership); ps.setString(index++, ownership);
} }
if (isSerialProvided) {
ps.setString(index++, "%" + serial + "%");
}
if (isOwnerProvided) { if (isOwnerProvided) {
ps.setString(index++, user); ps.setString(index++, user);
} }

Loading…
Cancel
Save