|
|
@ -1527,8 +1527,12 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateGeofence(GeofenceData geofenceData, int fenceId)
|
|
|
|
public boolean updateGeofence(GeofenceData geofenceData, int fenceId)
|
|
|
|
throws GeoLocationBasedServiceException, EventConfigurationException {
|
|
|
|
throws GeoLocationBasedServiceException {
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId;
|
|
|
|
int tenantId;
|
|
|
|
|
|
|
|
List<Integer> groupIdsToDelete = new ArrayList<>();
|
|
|
|
|
|
|
|
List<Integer> groupIdsToAdd = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
tenantId = DeviceManagementDAOUtil.getTenantId();
|
|
|
|
tenantId = DeviceManagementDAOUtil.getTenantId();
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
@ -1543,8 +1547,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
int updatedRowCount = geofenceDAO.updateGeofence(geofenceData, fenceId);
|
|
|
|
int updatedRowCount = geofenceDAO.updateGeofence(geofenceData, fenceId);
|
|
|
|
savedGroupIds = geofenceDAO.getGroupIdsOfGeoFence(fenceId);
|
|
|
|
savedGroupIds = geofenceDAO.getGroupIdsOfGeoFence(fenceId);
|
|
|
|
geofenceData.setId(fenceId);
|
|
|
|
geofenceData.setId(fenceId);
|
|
|
|
List<Integer> groupIdsToDelete = new ArrayList<>();
|
|
|
|
|
|
|
|
List<Integer> groupIdsToAdd = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Integer savedGroupId : savedGroupIds) {
|
|
|
|
for (Integer savedGroupId : savedGroupIds) {
|
|
|
|
if (!geofenceData.getGroupIds().contains(savedGroupId)) {
|
|
|
|
if (!geofenceData.getGroupIds().contains(savedGroupId)) {
|
|
|
|
groupIdsToDelete.add(savedGroupId);
|
|
|
|
groupIdsToDelete.add(savedGroupId);
|
|
|
@ -1573,6 +1575,10 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
EventManagementDAOFactory.closeConnection();
|
|
|
|
EventManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!groupIdsToDelete.isEmpty()) {
|
|
|
|
|
|
|
|
this.deleteGeoFenceGroups(geofenceData, groupIdsToDelete);
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1606,8 +1612,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
|
|
|
|
|
|
|
|
List<Integer> createdEventIds;
|
|
|
|
List<Integer> createdEventIds;
|
|
|
|
int tenantId;
|
|
|
|
int tenantId;
|
|
|
|
List<Integer> groupIdsToDelete = new ArrayList<>();
|
|
|
|
|
|
|
|
List<Integer> savedGroupIds;
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
tenantId = DeviceManagementDAOUtil.getTenantId();
|
|
|
|
tenantId = DeviceManagementDAOUtil.getTenantId();
|
|
|
|
setEventSource(geofenceData.getEventConfig());
|
|
|
|
setEventSource(geofenceData.getEventConfig());
|
|
|
@ -1618,15 +1622,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
throw new GeoLocationBasedServiceException(msg);
|
|
|
|
throw new GeoLocationBasedServiceException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createdEventIds = eventConfigService.updateEventsOfDeviceGroup(geofenceData.getEventConfig(), removedEventIdList, groupIds);
|
|
|
|
createdEventIds = eventConfigService.updateEventsOfDeviceGroup(geofenceData.getEventConfig(), removedEventIdList, groupIds);
|
|
|
|
EventManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
savedGroupIds = geofenceDAO.getGroupIdsOfGeoFence(fenceId);
|
|
|
|
|
|
|
|
geofenceData.setId(fenceId);
|
|
|
|
|
|
|
|
for (Integer savedGroupId : savedGroupIds) {
|
|
|
|
|
|
|
|
if (!geofenceData.getGroupIds().contains(savedGroupId)) {
|
|
|
|
|
|
|
|
groupIdsToDelete.add(savedGroupId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EventManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (EventConfigurationException e) {
|
|
|
|
} catch (EventConfigurationException e) {
|
|
|
|
String msg = "Error occurred while updating event configuration data";
|
|
|
|
String msg = "Error occurred while updating event configuration data";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -1635,11 +1630,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
String msg = "Error occurred while retrieving tenant id while update geofence data";
|
|
|
|
String msg = "Error occurred while retrieving tenant id while update geofence data";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new GeoLocationBasedServiceException(msg, e);
|
|
|
|
throw new GeoLocationBasedServiceException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
finally {
|
|
|
|
|
|
|
|
EventManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -1666,11 +1656,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
log.debug("Update geofence event completed.");
|
|
|
|
log.debug("Update geofence event completed.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!groupIdsToDelete.isEmpty()) {
|
|
|
|
|
|
|
|
eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_REVOKE,
|
|
|
|
|
|
|
|
DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData),
|
|
|
|
|
|
|
|
tenantId, groupIdsToDelete);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_UPDATE,
|
|
|
|
eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_UPDATE,
|
|
|
|
DeviceManagementConstants.EventServices.GEOFENCE,
|
|
|
|
DeviceManagementConstants.EventServices.GEOFENCE,
|
|
|
|
new GeoFenceEventMeta(geofenceData), tenantId, geofenceData.getGroupIds());
|
|
|
|
new GeoFenceEventMeta(geofenceData), tenantId, geofenceData.getGroupIds());
|
|
|
@ -1824,4 +1809,37 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
|
|
|
|
throw new GeoLocationBasedServiceException(msg, e);
|
|
|
|
throw new GeoLocationBasedServiceException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param geofenceData
|
|
|
|
|
|
|
|
* @param groupIdsToDelete
|
|
|
|
|
|
|
|
* @throws GeoLocationBasedServiceException
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void deleteGeoFenceGroups(GeofenceData geofenceData, List<Integer> groupIdsToDelete)
|
|
|
|
|
|
|
|
throws GeoLocationBasedServiceException {
|
|
|
|
|
|
|
|
int tenantId;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
tenantId = DeviceManagementDAOUtil.getTenantId();
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while retrieving tenant id while get geofence data";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GeoLocationBasedServiceException(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
EventConfigurationProviderService eventConfigService = DeviceManagementDataHolder
|
|
|
|
|
|
|
|
.getInstance().getEventConfigurationService();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eventConfigService.deleteGroups(groupIdsToDelete);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_REVOKE,
|
|
|
|
|
|
|
|
DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData),
|
|
|
|
|
|
|
|
tenantId, groupIdsToDelete);
|
|
|
|
|
|
|
|
} catch (EventConfigurationException e) {
|
|
|
|
|
|
|
|
String msg = "Failed to delete Geofence event configurations";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GeoLocationBasedServiceException(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|