|
|
|
@ -165,7 +165,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString()
|
|
|
|
|
+ " in tenant: " + tenantId;
|
|
|
|
|
+ " in tenant: " + tenantId;
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -185,7 +185,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
for (int i = 0; i < deviceGroupIdsCount; i++) {
|
|
|
|
|
sql += (deviceGroupIdsCount - 1 != i) ? "?," : "?";
|
|
|
|
|
}
|
|
|
|
|
sql += ")";
|
|
|
|
|
sql += ")";
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
int paramIndex = 1;
|
|
|
|
|
stmt.setInt(paramIndex++, tenantId);
|
|
|
|
@ -203,7 +203,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds
|
|
|
|
|
+ " in tenant: " + tenantId;
|
|
|
|
|
+ " in tenant: " + tenantId;
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -228,7 +228,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
sql += " AND OWNER LIKE ?";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(request.getParentPath())) {
|
|
|
|
|
if(isWithParentPath){
|
|
|
|
|
if (isWithParentPath) {
|
|
|
|
|
sql += " AND PARENT_PATH LIKE ?";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -251,7 +251,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
stmt.setString(paramIndex++, request.getOwner() + "%");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(request.getParentPath())) {
|
|
|
|
|
if(isWithParentPath){
|
|
|
|
|
if (isWithParentPath) {
|
|
|
|
|
stmt.setString(paramIndex++, request.getParentPath());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -272,7 +272,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString()
|
|
|
|
|
+ " in tenant: " + tenantId;
|
|
|
|
|
+ " in tenant: " + tenantId;
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -485,7 +485,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
Connection conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
|
String sql = "UPDATE DM_GROUP SET DESCRIPTION = ?, GROUP_NAME = ?, OWNER = ?, STATUS = ?, "
|
|
|
|
|
+ "PARENT_PATH = ?, PARENT_GROUP_ID = ? WHERE ID = ? AND TENANT_ID = ?";
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)){
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
for (DeviceGroup deviceGroup : deviceGroups) {
|
|
|
|
|
stmt.setString(1, deviceGroup.getDescription());
|
|
|
|
|
stmt.setString(2, deviceGroup.getName());
|
|
|
|
@ -610,6 +610,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteGroups(List<Integer> groupIds, int tenantId) throws GroupManagementDAOException {
|
|
|
|
|
try {
|
|
|
|
@ -1167,7 +1168,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
if (StringUtils.isNotBlank(parentPath)) {
|
|
|
|
|
sql += " AND g.PARENT_PATH = ? ";
|
|
|
|
|
}
|
|
|
|
|
sql += "GROUP BY g.ID";
|
|
|
|
|
sql += "GROUP BY g.ID";
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
int index = 0;
|
|
|
|
|
while (index++ < rolesCount) {
|
|
|
|
@ -1280,7 +1281,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
return devices;
|
|
|
|
|
}
|
|
|
|
|
Connection conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
|
StringJoiner joiner = new StringJoiner(",","SELECT "
|
|
|
|
|
StringJoiner joiner = new StringJoiner(",", "SELECT "
|
|
|
|
|
+ "d1.DEVICE_ID, "
|
|
|
|
|
+ "d1.DESCRIPTION, "
|
|
|
|
|
+ "d1.NAME AS DEVICE_NAME, "
|
|
|
|
@ -1445,12 +1446,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GroupDetailsDTO groupDetails = new GroupDetailsDTO();
|
|
|
|
|
List<Integer> deviceIds = new ArrayList<>();
|
|
|
|
|
Map<Integer, String> deviceOwners = new HashMap<>();
|
|
|
|
|
Map<Integer, String> deviceStatuses = new HashMap<>();
|
|
|
|
|
Map<Integer, String> deviceNames = new HashMap<>(); // New map for device names
|
|
|
|
|
Map<Integer, String> deviceNames = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
String sql =
|
|
|
|
|
"SELECT " +
|
|
|
|
@ -1471,32 +1471,35 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
" AND g.TENANT_ID = ? " +
|
|
|
|
|
"LIMIT ? OFFSET ?";
|
|
|
|
|
|
|
|
|
|
try (Connection conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
|
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setString(1, groupName);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
stmt.setInt(3, limit);
|
|
|
|
|
stmt.setInt(4, offset);
|
|
|
|
|
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
if (groupDetails.getGroupId() == 0) {
|
|
|
|
|
groupDetails.setGroupId(rs.getInt("GROUP_ID"));
|
|
|
|
|
groupDetails.setGroupName(rs.getString("GROUP_NAME"));
|
|
|
|
|
groupDetails.setGroupOwner(rs.getString("GROUP_OWNER"));
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setString(1, groupName);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
stmt.setInt(3, limit);
|
|
|
|
|
stmt.setInt(4, offset);
|
|
|
|
|
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
if (groupDetails.getGroupId() == 0) {
|
|
|
|
|
groupDetails.setGroupId(rs.getInt("GROUP_ID"));
|
|
|
|
|
groupDetails.setGroupName(rs.getString("GROUP_NAME"));
|
|
|
|
|
groupDetails.setGroupOwner(rs.getString("GROUP_OWNER"));
|
|
|
|
|
}
|
|
|
|
|
int deviceId = rs.getInt("DEVICE_ID");
|
|
|
|
|
deviceIds.add(deviceId);
|
|
|
|
|
deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER"));
|
|
|
|
|
deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS"));
|
|
|
|
|
deviceNames.put(deviceId, rs.getString("DEVICE_NAME"));
|
|
|
|
|
}
|
|
|
|
|
int deviceId = rs.getInt("DEVICE_ID");
|
|
|
|
|
deviceIds.add(deviceId);
|
|
|
|
|
deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER"));
|
|
|
|
|
deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS"));
|
|
|
|
|
deviceNames.put(deviceId, rs.getString("DEVICE_NAME"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new GroupManagementDAOException("Error occurred while retrieving group details and device IDs for group: "
|
|
|
|
|
+ groupName, e);
|
|
|
|
|
String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
groupDetails.setDeviceIds(deviceIds);
|
|
|
|
|
groupDetails.setDeviceCount(deviceIds.size());
|
|
|
|
|
groupDetails.setDeviceOwners(deviceOwners);
|
|
|
|
@ -1504,4 +1507,4 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
|
groupDetails.setDeviceNames(deviceNames);
|
|
|
|
|
return groupDetails;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|