def set_speed_alert(request): speed_limit = request.POST['speedAlertValue'] alert_template = open(os.path.join(BASE_DIR, 'map_service/templates/map_service/xml/geo_speed_alert.xml')) placeholder_pattern = re.compile(r'\$speedAlertValue') alert_query = placeholder_pattern.sub(speed_limit, alert_template.read()) evnt_proc = EventProcessor() exe_plan_name = 'geo_speed_alert' exe_plan = evnt_proc.getActiveExecutionPlanConfiguration(exe_plan_name) if exe_plan: response = evnt_proc.editActiveExecutionPlanConfiguration(alert_query, exe_plan_name) else: response = evnt_proc.deployExecutionPlanConfigurationFromConfigXml(alert_query) return JsonResponse({'status': True})
def set_proximity_alert(request): evnt_proc = EventProcessor() proximity_distance = request.POST['proximityDistance'] proximity_time = request.POST['proximityTime'] alert_template = open( os.path.join(BASE_DIR, 'map_service/templates/map_service/xml/geo_proximity_alert.xml')).read() time_placeholder = re.compile(r'\$proximityTime') alert_query = time_placeholder.sub(proximity_time, alert_template) distance_placeholder = re.compile(r'\$proximityDistance') alert_query = distance_placeholder.sub(proximity_distance, alert_query) # TODO: Check why the response is {None} object response = evnt_proc.editActiveExecutionPlanConfiguration(alert_query, 'geo_proximity_alert') return JsonResponse({'status': True})