Add by serial number in store

pull/124/head
osh 2 years ago
parent e2a21c292b
commit 2b72f4890b

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

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

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

Loading…
Cancel
Save