Fix geofence update issue

revert-70ac1926
Pahansith 4 years ago
parent 7463aa6e5a
commit e1afa53560

@ -116,7 +116,7 @@ public interface GeofenceDAO {
* @param groupIdsToDelete group ids to be removed from the mapping table
* @throws DeviceManagementDAOException error occurred while deleting group id mapping records
*/
void deleteGeofenceGroupMapping(List<Integer> groupIdsToDelete) throws DeviceManagementDAOException;
void deleteGeofenceGroupMapping(List<Integer> groupIdsToDelete, int fenceId) throws DeviceManagementDAOException;
/**
* Create geofence-event mapping records

@ -356,13 +356,14 @@ public class GeofenceDAOImpl implements GeofenceDAO {
}
@Override
public void deleteGeofenceGroupMapping(List<Integer> groupIdsToDelete) throws DeviceManagementDAOException {
public void deleteGeofenceGroupMapping(List<Integer> groupIdsToDelete, int fenceId) throws DeviceManagementDAOException {
try {
Connection conn = this.getConnection();
String sql = "DELETE FROM DM_GEOFENCE_GROUP_MAPPING WHERE GROUP_ID = ?";
String sql = "DELETE FROM DM_GEOFENCE_GROUP_MAPPING WHERE GROUP_ID = ? AND FENCE_ID = ?";
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
for (Integer groupId : groupIdsToDelete) {
stmt.setInt(1, groupId);
stmt.setInt(2, fenceId);
stmt.addBatch();
}
stmt.executeBatch();

@ -1503,7 +1503,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
}
List<Integer> groupIdsOfGeoFence = geofenceDAO.getGroupIdsOfGeoFence(fenceId);
if (!groupIdsOfGeoFence.isEmpty()) {
geofenceDAO.deleteGeofenceGroupMapping(groupIdsOfGeoFence);
geofenceDAO.deleteGeofenceGroupMapping(groupIdsOfGeoFence, fenceId);
}
geofenceDAO.deleteGeofenceById(fenceId);
DeviceManagementDAOFactory.commitTransaction();
@ -1554,7 +1554,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
groupIdsToAdd.add(newGroupId);
}
}
geofenceDAO.deleteGeofenceGroupMapping(groupIdsToDelete);
geofenceDAO.deleteGeofenceGroupMapping(groupIdsToDelete, fenceId);
geofenceDAO.createGeofenceGroupMapping(geofenceData, groupIdsToAdd);
DeviceManagementDAOFactory.commitTransaction();
if (updatedRowCount > 0) {

Loading…
Cancel
Save