|
|
@ -367,6 +367,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|
|
|
if (previousLocation == null) {
|
|
|
|
if (previousLocation == null) {
|
|
|
|
deviceDetailsDAO.addDeviceLocation(deviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
deviceDetailsDAO.addDeviceLocation(deviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("Update location on IOTS");
|
|
|
|
deviceDetailsDAO.updateDeviceLocation(deviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
deviceDetailsDAO.updateDeviceLocation(deviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
deviceDetailsDAO.addDeviceLocationInfo(device, deviceLocation,
|
|
|
|
deviceDetailsDAO.addDeviceLocationInfo(device, deviceLocation,
|
|
|
@ -390,8 +391,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|
|
|
//Tracker update GPS Location
|
|
|
|
//Tracker update GPS Location
|
|
|
|
if (HttpReportingUtil.isLocationPublishing() && HttpReportingUtil.isTrackerEnabled()) {
|
|
|
|
if (HttpReportingUtil.isLocationPublishing() && HttpReportingUtil.isTrackerEnabled()) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
log.info("--- Location Pushing to Traccar starts ---");
|
|
|
|
DeviceManagementDataHolder.getInstance().getDeviceAPIClientService()
|
|
|
|
DeviceManagementDataHolder.getInstance().getDeviceAPIClientService()
|
|
|
|
.updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
.updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
|
|
|
|
log.info("--- Location Pushing to Traccar end ---");
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
log.error("ExecutionException : " + e);
|
|
|
|
log.error("ExecutionException : " + e);
|
|
|
|
//throw new RuntimeException(e);
|
|
|
|
//throw new RuntimeException(e);
|
|
|
@ -435,17 +438,44 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
|
|
|
DeviceLocation mostRecentDeviceLocation = deviceLocations.get(deviceLocations.size() - 1);
|
|
|
|
DeviceLocation mostRecentDeviceLocation = deviceLocations.get(deviceLocations.size() - 1);
|
|
|
|
mostRecentDeviceLocation.setDeviceId(device.getId());
|
|
|
|
mostRecentDeviceLocation.setDeviceId(device.getId());
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
DeviceLocation previousLocation = deviceDetailsDAO.getDeviceLocation(device.getId(),
|
|
|
|
boolean previousLocation = deviceDetailsDAO.hasLocations(device.getId(),
|
|
|
|
device.getEnrolmentInfo().getId());
|
|
|
|
device.getEnrolmentInfo().getId());
|
|
|
|
if (previousLocation == null) {
|
|
|
|
if (previousLocation) {
|
|
|
|
deviceDetailsDAO.addDeviceLocation(mostRecentDeviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
deviceDetailsDAO.updateDeviceLocation(mostRecentDeviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
deviceDetailsDAO.updateDeviceLocation(mostRecentDeviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
deviceDetailsDAO.addDeviceLocation(mostRecentDeviceLocation, device.getEnrolmentInfo().getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
deviceDetailsDAO.addDeviceLocationsInfo(device, deviceLocations,
|
|
|
|
deviceDetailsDAO.addDeviceLocationsInfo(device, deviceLocations,
|
|
|
|
CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (DeviceLocation deviceLocation: deviceLocations) {
|
|
|
|
|
|
|
|
//Tracker update GPS Location
|
|
|
|
|
|
|
|
if (HttpReportingUtil.isLocationPublishing() && HttpReportingUtil.isTrackerEnabled()) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
log.info("--- Location Pushing to Traccar starts ---");
|
|
|
|
|
|
|
|
DeviceManagementDataHolder.getInstance().getDeviceAPIClientService()
|
|
|
|
|
|
|
|
.updateLocation(device, deviceLocation, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
|
|
|
|
log.info("--- Location Pushing to Traccar end ---");
|
|
|
|
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
|
|
|
|
log.error("ExecutionException : " + e);
|
|
|
|
|
|
|
|
//throw new RuntimeException(e);
|
|
|
|
|
|
|
|
//Exception was not thrown due to being conflicted with non-traccar features
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
log.error("InterruptedException : " + e);
|
|
|
|
|
|
|
|
//throw new RuntimeException(e);
|
|
|
|
|
|
|
|
//Exception was not thrown due to being conflicted with non-traccar features
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if(!HttpReportingUtil.isLocationPublishing()) {
|
|
|
|
|
|
|
|
log.info("Location publishing is disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!HttpReportingUtil.isTrackerEnabled()) {
|
|
|
|
|
|
|
|
log.info("Traccar is disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
throw new DeviceDetailsMgtException("Transactional error occurred while adding the device location " +
|
|
|
|
throw new DeviceDetailsMgtException("Transactional error occurred while adding the device location " +
|
|
|
|