Example #1
0
def deleteEmergency():
    try:
        from json import dumps
        jsondata = request.get_json(force=True)
        jsonobj = JsonController().serialize_emergency_delete(jsondata)
        EmergencyObject = SendEmergencyController(jsonobj).getCoTObject()
        APIPipe.send(EmergencyObject)
        return 'success', 200
    except Exception as e:
        return str(e), 500
Example #2
0
    def delete_emergency(json_data: dict) -> object:
        """
        remove an existing emergency

        @rtype: object
        """
        obj = Obj("DELETE")
        jsonobj = serialize_json_to_object(obj, json_data)
        EmergencyObject = SendEmergencyController(jsonobj).getCoTObject()
        return EmergencyObject
Example #3
0
def postEmergency():
    try:
        from json import dumps

        jsondata = request.get_json(force=True)
        jsonobj = JsonController().serialize_emergency_post(jsondata)
        EmergencyObject = SendEmergencyController(jsonobj).getCoTObject()
        APIPipe.send(EmergencyObject)
        return EmergencyObject.modelObject.getuid(), 200
    except Exception as e:
        return str(e), 200
Example #4
0
    def create_emergency(json_data: dict) -> object:
        """

        @rtype: Event 
        @param json_data:
        @type json_data: dict
        @return emergency_object:
        """
        json_obj = JsonController().serialize_emergency_post(json_data)
        emergency_object = SendEmergencyController(json_obj).getCoTObject()
        return emergency_object
Example #5
0
 def test_json_serializer_with_emergency_adapter(self):
     from FreeTAKServer.controllers.RestMessageControllers.SendEmergencyController import SendEmergencyController
     from FreeTAKServer.controllers.serializers.api_adapters.api_adapters import EmergencyOnAdapter
     basejson = {"emergencyType": "911 Alert", "name": "test"}
     jsonobj = JsonController().serialize_emergency_post(basejson)
     EmergencyObject = SendEmergencyController(jsonobj).getCoTObject()
     xml_legacy = etree.fromstring(EmergencyObject.xmlString)
     xml_legacy.attrib['uid'] = '123'
     xml_legacy.attrib['time'] = '24'
     xml_legacy.attrib['start'] = '849'
     xml_legacy.attrib['stale'] = '3333'
     newObject = EmergencyOnAdapter().from_api_to_fts_object(basejson)
     xml_updated = etree.fromstring(newObject.xmlString)
     xml_updated.attrib['uid'] = '123'
     xml_updated.attrib['time'] = '24'
     xml_updated.attrib['start'] = '849'
     xml_updated.attrib['stale'] = '3333'
     xml_legacy = etree.tostring(xml_legacy).decode()
     xml_updated = etree.tostring(xml_updated).decode()
     self.assertEqual(xml_legacy, xml_updated)