|
|
@ -1319,6 +1319,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
boolean isSinceProvided = false;
|
|
|
|
boolean isSinceProvided = false;
|
|
|
|
List<String> tagList = request.getTags();
|
|
|
|
List<String> tagList = request.getTags();
|
|
|
|
boolean isTagsProvided = false;
|
|
|
|
boolean isTagsProvided = false;
|
|
|
|
|
|
|
|
String serial = request.getSerialNumber();
|
|
|
|
|
|
|
|
boolean isSerialProvided = false;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = getConnection();
|
|
|
|
Connection conn = getConnection();
|
|
|
@ -1370,6 +1372,23 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
sql += ") GROUP BY dtm.ENROLMENT_ID HAVING COUNT(DISTINCT t.NAME) = ? )";
|
|
|
|
sql += ") GROUP BY dtm.ENROLMENT_ID HAVING COUNT(DISTINCT t.NAME) = ? )";
|
|
|
|
isTagsProvided = true;
|
|
|
|
isTagsProvided = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serial != null && !serial.isEmpty()) {
|
|
|
|
|
|
|
|
sql += " AND EXISTS (" +
|
|
|
|
|
|
|
|
"SELECT VALUE_FIELD FROM DM_DEVICE_INFO di " +
|
|
|
|
|
|
|
|
"WHERE di.DEVICE_ID = d1.ID " +
|
|
|
|
|
|
|
|
"AND di.KEY_FIELD = 'serial' " +
|
|
|
|
|
|
|
|
"AND di.VALUE_FIELD LIKE ?)";
|
|
|
|
|
|
|
|
isSerialProvided = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!request.getCustomProperty().isEmpty()) {
|
|
|
|
|
|
|
|
for (Map.Entry<String, String> entry : request.getCustomProperty().entrySet()) {
|
|
|
|
|
|
|
|
sql += " AND EXISTS (" +
|
|
|
|
|
|
|
|
"SELECT VALUE_FIELD FROM DM_DEVICE_INFO di2 " +
|
|
|
|
|
|
|
|
"WHERE di2.DEVICE_ID = d1.ID " +
|
|
|
|
|
|
|
|
"AND di2.KEY_FIELD = '" + entry.getKey() + "' " +
|
|
|
|
|
|
|
|
"AND di2.VALUE_FIELD LIKE ?)";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
int paramIdx = 1;
|
|
|
|
int paramIdx = 1;
|
|
|
@ -1402,6 +1421,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.setInt(paramIdx++, tagList.size());
|
|
|
|
stmt.setInt(paramIdx++, tagList.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSerialProvided) {
|
|
|
|
|
|
|
|
stmt.setString(paramIdx++, "%" + serial + "%");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!request.getCustomProperty().isEmpty()) {
|
|
|
|
|
|
|
|
for (Map.Entry<String, String> entry : request.getCustomProperty().entrySet()) {
|
|
|
|
|
|
|
|
stmt.setString(paramIdx++, "%" + entry.getValue() + "%");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
|