|
|
@ -1441,7 +1441,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int tenantId, int offset, int limit)
|
|
|
|
public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List<String> allowedStatuses, int tenantId, int offset, int limit)
|
|
|
|
throws GroupManagementDAOException {
|
|
|
|
throws GroupManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName);
|
|
|
|
log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName);
|
|
|
@ -1454,6 +1454,14 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
Map<Integer, String> deviceTypes = new HashMap<>();
|
|
|
|
Map<Integer, String> deviceTypes = new HashMap<>();
|
|
|
|
Map<Integer, String> deviceIdentifiers = new HashMap<>();
|
|
|
|
Map<Integer, String> deviceIdentifiers = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder deviceFilters = new StringBuilder();
|
|
|
|
|
|
|
|
for (int i = 0; i < allowedStatuses.size(); i++) {
|
|
|
|
|
|
|
|
deviceFilters.append("?");
|
|
|
|
|
|
|
|
if (i < allowedStatuses.size() - 1) {
|
|
|
|
|
|
|
|
deviceFilters.append(",");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String sql =
|
|
|
|
String sql =
|
|
|
|
"SELECT " +
|
|
|
|
"SELECT " +
|
|
|
|
" g.ID AS GROUP_ID, " +
|
|
|
|
" g.ID AS GROUP_ID, " +
|
|
|
@ -1473,16 +1481,21 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
"WHERE " +
|
|
|
|
"WHERE " +
|
|
|
|
" g.GROUP_NAME = ? " +
|
|
|
|
" g.GROUP_NAME = ? " +
|
|
|
|
" AND g.TENANT_ID = ? " +
|
|
|
|
" AND g.TENANT_ID = ? " +
|
|
|
|
|
|
|
|
" AND e.STATUS IN (" + deviceFilters.toString() + ") " +
|
|
|
|
"LIMIT ? OFFSET ?";
|
|
|
|
"LIMIT ? OFFSET ?";
|
|
|
|
|
|
|
|
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
stmt.setString(1, groupName);
|
|
|
|
int index = 1;
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setString(index++, groupName);
|
|
|
|
stmt.setInt(3, limit);
|
|
|
|
stmt.setInt(index++, tenantId);
|
|
|
|
stmt.setInt(4, offset);
|
|
|
|
for (String status : allowedStatuses) {
|
|
|
|
|
|
|
|
stmt.setString(index++, status);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt.setInt(index++, limit);
|
|
|
|
|
|
|
|
stmt.setInt(index++, offset);
|
|
|
|
|
|
|
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
@ -1500,19 +1513,19 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
groupDetails.setDeviceIds(deviceIds);
|
|
|
|
groupDetails.setDeviceIds(deviceIds);
|
|
|
|
groupDetails.setDeviceCount(deviceIds.size());
|
|
|
|
groupDetails.setDeviceCount(deviceIds.size());
|
|
|
|
groupDetails.setDeviceOwners(deviceOwners);
|
|
|
|
groupDetails.setDeviceOwners(deviceOwners);
|
|
|
|
groupDetails.setDeviceStatuses(deviceStatuses);
|
|
|
|
groupDetails.setDeviceStatuses(deviceStatuses);
|
|
|
|
groupDetails.setDeviceNames(deviceNames);
|
|
|
|
groupDetails.setDeviceNames(deviceNames);
|
|
|
|
groupDetails.setDeviceTypes(deviceTypes);
|
|
|
|
groupDetails.setDeviceTypes(deviceTypes);
|
|
|
|
groupDetails.setDeviceIdentifiers(deviceIdentifiers);
|
|
|
|
groupDetails.setDeviceIdentifiers(deviceIdentifiers);
|
|
|
|
return groupDetails;
|
|
|
|
return groupDetails;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName;
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName;
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|