|
|
@ -208,9 +208,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException {
|
|
|
|
public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException {
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
ResultSet rs;
|
|
|
|
|
|
|
|
int groupId = -1;
|
|
|
|
int groupId = -1;
|
|
|
|
boolean hasStatus = false;
|
|
|
|
boolean hasStatus = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -224,7 +223,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?)";
|
|
|
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?)";
|
|
|
|
hasStatus = true;
|
|
|
|
hasStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt = conn.prepareStatement(sql, new String[]{"ID"});
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql, new String[]{"ID"})) {
|
|
|
|
stmt.setString(1, groups.getDescription());
|
|
|
|
stmt.setString(1, groups.getDescription());
|
|
|
|
stmt.setString(2, groups.getName());
|
|
|
|
stmt.setString(2, groups.getName());
|
|
|
|
stmt.setString(3, groups.getOwner());
|
|
|
|
stmt.setString(3, groups.getOwner());
|
|
|
@ -234,19 +233,19 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
if (hasStatus) {
|
|
|
|
if (hasStatus) {
|
|
|
|
stmt.setString(7, groups.getStatus());
|
|
|
|
stmt.setString(7, groups.getStatus());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
|
try (ResultSet rs = stmt.getGeneratedKeys();) {
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
|
groupId = rs.getInt(1);
|
|
|
|
groupId = rs.getInt(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return groupId;
|
|
|
|
return groupId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" +
|
|
|
|
String msg = "Error occurred while adding deviceGroup '" +
|
|
|
|
groups.getName() + "'", e);
|
|
|
|
groups.getName() + "'";
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
GroupManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -281,12 +280,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId)
|
|
|
|
public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId)
|
|
|
|
throws GroupManagementDAOException {
|
|
|
|
throws GroupManagementDAOException {
|
|
|
|
boolean status;
|
|
|
|
boolean status;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
Connection conn = GroupManagementDAOFactory.getConnection();
|
|
|
|
stmt = conn.prepareStatement(
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(
|
|
|
|
"INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " +
|
|
|
|
"INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " +
|
|
|
|
"PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)");
|
|
|
|
"PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)")) {
|
|
|
|
for (Map.Entry<String, String> entry : groups.getGroupProperties().entrySet()) {
|
|
|
|
for (Map.Entry<String, String> entry : groups.getGroupProperties().entrySet()) {
|
|
|
|
stmt.setInt(1, groupId);
|
|
|
|
stmt.setInt(1, groupId);
|
|
|
|
stmt.setString(2, entry.getKey());
|
|
|
|
stmt.setString(2, entry.getKey());
|
|
|
@ -296,12 +294,12 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.executeBatch();
|
|
|
|
stmt.executeBatch();
|
|
|
|
status = true;
|
|
|
|
status = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while adding properties for group '" +
|
|
|
|
String msg = "Error occurred while adding properties for group '" +
|
|
|
|
groups.getName() + "' values : " + groups.getGroupProperties();
|
|
|
|
groups.getName() + "' values : " + groups.getGroupProperties();
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
throw new GroupManagementDAOException(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|