From ab519278d5aadca7d8210e40ec4435aa7e6de5cd Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Mon, 12 Sep 2022 11:51:49 -0400 Subject: [PATCH 1/9] WIP drop point component --- .../extended/drop_point/base/__init__.py | 4 + .../base/drop_point_action_mapper.py | 9 ++ .../drop_point/base/drop_point_domain.py | 25 ++++ .../drop_point/configuration/__init__.py | 0 .../configuration/business_rules.json | 0 .../configuration/drop_point_constants.py | 68 ++++++++++ .../configuration/external_action_mapping.ini | 0 .../configuration/internal_action_mapping.ini | 0 .../drop_point/configuration/logging.conf | 0 .../model_definitions/drop_point.json | Bin 0 -> 42828 bytes .../configuration/type_mapping.json | 0 .../drop_point/controller/__init__.py | 0 .../extended/drop_point/domain/__init__.py | 0 .../extended/drop_point/domain/_contact.py | 89 +++++++++++++ .../extended/drop_point/domain/_detail.py | 0 .../extended/drop_point/domain/_event.py | 121 ++++++++++++++++++ .../extended/drop_point/domain/_link.py | 0 .../extended/drop_point/domain/_point.py | 0 .../drop_point/domain/_precision_location.py | 0 .../extended/drop_point/domain/_user_icon.py | 0 .../extended/drop_point/drop_point.py | 9 +- .../extended/drop_point/drop_point_facade.py | 43 +++++++ 22 files changed, 367 insertions(+), 1 deletion(-) create mode 100644 FreeTAKServer/components/extended/drop_point/base/__init__.py create mode 100644 FreeTAKServer/components/extended/drop_point/base/drop_point_action_mapper.py create mode 100644 FreeTAKServer/components/extended/drop_point/base/drop_point_domain.py create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/__init__.py create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/business_rules.json create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/logging.conf create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/model_definitions/drop_point.json create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/type_mapping.json create mode 100644 FreeTAKServer/components/extended/drop_point/controller/__init__.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/__init__.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_contact.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_detail.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_event.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_link.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_point.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_precision_location.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_user_icon.py create mode 100644 FreeTAKServer/components/extended/drop_point/drop_point_facade.py diff --git a/FreeTAKServer/components/extended/drop_point/base/__init__.py b/FreeTAKServer/components/extended/drop_point/base/__init__.py new file mode 100644 index 00000000..7ee19c98 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/base/__init__.py @@ -0,0 +1,4 @@ +"""This module contains all the supporting components without business logic +it should also be noted that the component action mapper must be exposed as action mapper. +""" +from .drop_point_action_mapper import DropPointActionMapper as ActionMapper \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/base/drop_point_action_mapper.py b/FreeTAKServer/components/extended/drop_point/base/drop_point_action_mapper.py new file mode 100644 index 00000000..812e76ea --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/base/drop_point_action_mapper.py @@ -0,0 +1,9 @@ +from digitalpy.routing.impl.default_action_mapper import DefaultActionMapper + + +class DropPointActionMapper(DefaultActionMapper): + """This is the DropPoint component action mapper. + + Each component must have its own action mapper to be loaded with the internal + action mapping configuration and to be used by the facade for internal routing. + """ \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/base/drop_point_domain.py b/FreeTAKServer/components/extended/drop_point/base/drop_point_domain.py new file mode 100644 index 00000000..6db1bd65 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/base/drop_point_domain.py @@ -0,0 +1,25 @@ +from FreeTAKServer.components.core.abstract_component.domain import Domain +from ..configuration.drop_point_constants import CONFIGURATION_PATH_TEMPLATE +from .. import domain + + +class DropPointDomain(Domain): + """This class is to be used for all interactions with the DropPoint domain model. + This class exposes and handles all domain model functions. + """ + + def __init__(self, request, response, configuration, action_mapper): + super().__init__( + # the template of the path to the model configurations + CONFIGURATION_PATH_TEMPLATE, + # the module containing all the domain objects + domain, + # the request object (passed by constructor) + request=request, + # the response object (passed by constructor) + response=response, + # the configuration object (passed by constructor) + configuration=configuration, + # the action mapper (passed by constructor) + action_mapper=action_mapper, + ) diff --git a/FreeTAKServer/components/extended/drop_point/configuration/__init__.py b/FreeTAKServer/components/extended/drop_point/configuration/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/configuration/business_rules.json b/FreeTAKServer/components/extended/drop_point/configuration/business_rules.json new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py new file mode 100644 index 00000000..0e1856a5 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py @@ -0,0 +1,68 @@ +import json +import pathlib +from string import Template + +COMPONENT_NAME = "DropPoint" + +CONFIGURATION_FORMAT = "json" + +CURRENT_COMPONENT_PATH = pathlib.Path(__file__).parent.parent.absolute() + +CONFIGURATION_PATH_TEMPLATE = Template( + str( + pathlib.PurePath( + CURRENT_COMPONENT_PATH, "configuration/model_definitions/$message_type" + ) + ) + + f".{CONFIGURATION_FORMAT}" +) + +LOGGING_CONFIGURATION_PATH = str( + pathlib.PurePath(CURRENT_COMPONENT_PATH, "configuration/logging.conf") +) + +ACTION_MAPPING_PATH = str( + pathlib.PurePath( + CURRENT_COMPONENT_PATH, "configuration/external_action_mapping.ini" + ) +) + +INTERNAL_ACTION_MAPPING_PATH = str( + pathlib.PurePath( + CURRENT_COMPONENT_PATH, "configuration/internal_action_mapping.ini" + ) +) + +TYPE_MAPPINGS = json.load( + open( + str( + pathlib.PurePath(CURRENT_COMPONENT_PATH, "configuration/type_mapping.json") + ), + "r", + encoding="utf-8", + ) +) + +BUSINESS_RULES_PATH = str( + pathlib.PurePath(CURRENT_COMPONENT_PATH, "configuration/business_rules.json") +) + +# EMERGENCY_OFF_BUSINESS_RULES_PATH = str( +# pathlib.PurePath( +# CURRENT_COMPONENT_PATH, +# "configuration/business_rules/emergency_off_business_rules.json", +# ) +# ) + +# EMERGENCY_ON_BUSINESS_RULES_PATH = str( +# pathlib.PurePath( +# CURRENT_COMPONENT_PATH, +# "configuration/business_rules/emergency_on_business_rules.json", +# ) +# ) + +BASE_OBJECT_NAME = "Event" + +# EMERGENCY_OFF = "emergency_delete" + +# EMERGENCY_ALERT = "emergency_alert" diff --git a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/configuration/logging.conf b/FreeTAKServer/components/extended/drop_point/configuration/logging.conf new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/configuration/model_definitions/drop_point.json b/FreeTAKServer/components/extended/drop_point/configuration/model_definitions/drop_point.json new file mode 100644 index 0000000000000000000000000000000000000000..5c1125b81adb85eceed3e83ca77daf7836544694 GIT binary patch literal 42828 zcmeI5dvhGeb;ajjr7GXRsoGF3iz*A?LwtyoLKjGo6cX`K1Qa>8Qz`-kNk{-l1E5GM z_E%4Ge|>Opdmany0!tCJU0cBJ&h&KOzRz=S_sss^|Nc+&&&@wIA2ny1UpKqWTJyYF zZ?>Ap@%?%;ivQ1>y?DKhZ|CCmL$rC(Y&UbQw)1gpr+F6VpTzs)=4o6p*PL%I#gV$t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$pg5Lh)QYt%NprxouPe|D#5}+(1qV)^+4-#?Rtf4`f%gtG8(o9 z&GPrGL+Cl$n{oVX>|sf-gWE;v(%&GRep13_agxj)V5E<*9WD(t+U*l@dr-QSz(CLNHM7&Ar zHCY!J4$mSTXXQ@_lw)=EqV}eJkI3~$XXNzxb*whrj`#Gj|L~^u{qN3oPKVy%&1PZI z^uyZKac%m;vR@;%@jK3h8S1@uztqk%qa&?V$o9JkMo2(+*wz&pupxK1*HQO4i14^~ zz#NrPdv3m`rd#FmxL`V}lik^~GSjblEe8tbx2nhgo}4iA_i^n)*;55_zT13%P&d0- z)o?B7VV`l_Fkq(c)TQ z3qGyKnWyoIH77XvI6i+7S6mLN?gd9cHB{2b*3N~G=C?+!#65uXfpxInHof)luzeE! zUM+vn!VBcHTKb2U)fnSy9J>~6R^tUNtbnaY%L_rv=kZ#N7T03jyMd~B#vD7w&PBXZ zMSbUhicjKbo06=7!7X_Ts)<7DtW2{aq&;9YPG+5*-3ETrmg;EqQO|9hY?n)pw6ZVr zb7fYp0q({Ow}MXicR60H@pUVLNp;(v#^Denb0jfz1yvdJMzzw}Ja2B;kLjrHGtmG4 E2T`>2w*UYD literal 0 HcmV?d00001 diff --git a/FreeTAKServer/components/extended/drop_point/configuration/type_mapping.json b/FreeTAKServer/components/extended/drop_point/configuration/type_mapping.json new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/controller/__init__.py b/FreeTAKServer/components/extended/drop_point/controller/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/domain/__init__.py b/FreeTAKServer/components/extended/drop_point/domain/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/domain/_contact.py b/FreeTAKServer/components/extended/drop_point/domain/_contact.py new file mode 100644 index 00000000..e876c74b --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/_contact.py @@ -0,0 +1,89 @@ +from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode +from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty + + +class contact(CoTNode): + def __init__(self, configuration, model): + super().__init__(self.__class__.__name__, configuration, model) + self.cot_attributes["callsign"] = None + self.cot_attributes["endpoint"] = None + self.cot_attributes["iconsetpath"] = None + self.cot_attributes["uid"] = None + self.cot_attributes["name"] = None + self.cot_attributes["emailAddress"] = None + self.cot_attributes["xmppUsername"] = None + self.cot_attributes["sipAddress"] = None + + @CoTProperty + def iconsetpath(self): + return self.cot_attributes.get("iconsetpath", None) + + @iconsetpath.setter + def iconsetpath(self, iconsetpath=None): + self.cot_attributes["iconsetpath"]=iconsetpath + + @CoTProperty + def sipAddress(self): + return self.cot_attributes.get("sipAddress", None) + + @sipAddress.setter + def sipAddress(self, sipAddress=None): + self.cot_attributes["sipAddress"]=sipAddress + + @CoTProperty + def emailAddress(self): + return self.cot_attributes.get("emailAddress", None) + + @emailAddress.setter + def emailAddress(self, emailAddress=None): + self.cot_attributes["emailAddress"]=emailAddress + + @CoTProperty + def xmppUsername(self): + return self.cot_attributes.get("xmppUsername", None) + + @xmppUsername.setter + def xmppUsername(self, xmppUsername=None): + self.cot_attributes["xmppUsername"]=xmppUsername + + @CoTProperty + def callsign(self): + return self.cot_attributes.get("callsign", None) + + @callsign.setter + def callsign(self, callsign=None): + self.cot_attributes["callsign"]=callsign + + + @CoTProperty + def endpoint(self): + return self.cot_attributes.get("endpoint", None) + + @endpoint.setter + def endpoint(self, endpoint=None): + self.cot_attributes["endpoint"]=endpoint + + @CoTProperty + def uid(self): + return self.cot_attributes.get("uid", None) + + # uid setter + @uid.setter + def uid(self, uid=None): + self.uid = uid + + @CoTProperty + def name(self): + return self.cot_attributes.get("name", None) + + @name.setter + def name(self, name=None): + self.name = name + + @CoTProperty + def phone(self): + return self.cot_attributes.get("phone", None) + + @phone.setter + def phone(self, phone=None): + self.phone = phone \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_detail.py b/FreeTAKServer/components/extended/drop_point/domain/_detail.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/domain/_event.py b/FreeTAKServer/components/extended/drop_point/domain/_event.py new file mode 100644 index 00000000..9c3dc892 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/_event.py @@ -0,0 +1,121 @@ +from digitalpy.model.load_configuration import Configuration +from .model_constants import EventVariables as vars +import uuid +from datetime import datetime as dt +from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode +from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty + +class Event(CoTNode): + + # event as an XML + # + + def __init__(self, configuration: Configuration, model): + + super().__init__(self.__class__.__name__, configuration, model) + self.cot_attributes["version"] = None + self.cot_attributes["uid"] = None + self.cot_attributes["type"] = None + self.cot_attributes["how"] = None + self.cot_attributes["stale"] = None + self.cot_attributes["start"] = None + self.cot_attributes["time"] = None + + @CoTProperty + def start(self): + return self.cot_attributes.get("start", None) + + @start.setter + def start(self, start=0): + DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%fZ" + if start == None: + timer = dt.datetime + now = timer.utcnow() + zulu = now.strftime(DATETIME_FMT) + self.cot_attributes["start"]=zulu + else: + self.cot_attributes["start"]=start + + @CoTProperty + def how(self): + return self.cot_attributes.get("how", None) + + @how.setter + def how(self, how=0): + self.cot_attributes["how"]=how + + @CoTProperty + def uid(self): + return self.cot_attributes.get("uid", None) + + @uid.setter + def uid(self, uid): + if uid == None: + self.uid = str(uuid.uuid1()) + + else: + self.cot_attributes["uid"]=uid + + @CoTProperty + def version(self): + return self.cot_attributes.get("version", None) + + @version.setter + def version(self, version): + self.cot_attributes["version"]=version + + @CoTProperty + def time(self): + return self.cot_attributes.get("time", None) + + @time.setter + def time(self, time=0): + DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%fZ" + if time == None: + timer = dt.datetime + now = timer.utcnow() + zulu = now.strftime(DATETIME_FMT) + self.time = zulu + else: + self.cot_attributes["time"]=time + + @CoTProperty + def stale(self): + return self.cot_attributes.get("stale", None) + + @stale.setter + def stale(self, stale = None,staletime=60): + if stale == None: + DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%fZ" + timer = dt.datetime + now = timer.utcnow() + zulu = now.strftime(DATETIME_FMT) + add = dt.timedelta(seconds=staletime) + stale_part = dt.datetime.strptime(zulu, DATETIME_FMT) + add + self.cot_attributes["stale"]=stale_part.strftime(DATETIME_FMT) + else: + self.cot_attributes["stale"]=stale + + @CoTProperty + def type(self): + return self.cot_attributes.get("type", None) + + @type.setter + def type(self, type=0): + self.cot_attributes["type"]=type + + @CoTProperty + def point(self): + return self.cot_attributes.get("point", None) + + @point.setter + def point(self, point=None): + self.cot_attributes["point"]=point + + @CoTProperty + def detail(self): + return self.cot_attributes.get("detail", None) + + @detail.setter + def detail(self, detail=None): + self.cot_attributes["detail"]=detail diff --git a/FreeTAKServer/components/extended/drop_point/domain/_link.py b/FreeTAKServer/components/extended/drop_point/domain/_link.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/domain/_point.py b/FreeTAKServer/components/extended/drop_point/domain/_point.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/domain/_precision_location.py b/FreeTAKServer/components/extended/drop_point/domain/_precision_location.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/domain/_user_icon.py b/FreeTAKServer/components/extended/drop_point/domain/_user_icon.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/drop_point.py b/FreeTAKServer/components/extended/drop_point/drop_point.py index cee48c22..716a20e3 100644 --- a/FreeTAKServer/components/extended/drop_point/drop_point.py +++ b/FreeTAKServer/components/extended/drop_point/drop_point.py @@ -3,6 +3,12 @@ class DropPoint(Controller): + """ + Facade + Domain + + + """ def accept_visitor(self, visitor): pass @@ -16,6 +22,7 @@ def execute(self, method=None): def drop_point_broadcast(self, message, **kwargs): self.response.set_values(kwargs) + domain = _DropPointDomain() request = ObjectFactory.get_new_instance('request') request.set_action('ParseCoT') @@ -29,4 +36,4 @@ def drop_point_broadcast(self, message, **kwargs): def drop_point_recieve(self, **kwargs): self.response.set_values(kwargs) - self.response.set_action("oint_broadcast") \ No newline at end of file + self.response.set_action("point_broadcast") \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/drop_point_facade.py b/FreeTAKServer/components/extended/drop_point/drop_point_facade.py new file mode 100644 index 00000000..d516c807 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/drop_point_facade.py @@ -0,0 +1,43 @@ +from FreeTAKServer.components.core.abstract_component.facade import Facade +from FreeTAKServer.components.extended.drop_point.configuration.drop_point_constants import ( + ACTION_MAPPING_PATH, + TYPE_MAPPINGS, + LOGGING_CONFIGURATION_PATH, + INTERNAL_ACTION_MAPPING_PATH, +) +from . import base + + +class DropPoint(Facade): + """Facade class for the DropPoint component. + Responsible for handling all public routing. + Forwards all requests to the internal router. + """ + + def __init__( + self, + drop_point_action_mapper, + request, + response, + configuration, + ): + super().__init__( + # the path to the external action mapping + action_mapping_path=ACTION_MAPPING_PATH, + # the path to the internal action mapping + internal_action_mapping_path=INTERNAL_ACTION_MAPPING_PATH, + # the type mapping in dictionary form + type_mapping=TYPE_MAPPINGS, + # the path to the logger configuration + logger_configuration=LOGGING_CONFIGURATION_PATH, + # the package containing the base classes + base=base, + # the component specific action mapper (passed by constructor) + action_mapper=drop_point_action_mapper, + # the request object (passed by constructor) + request=request, + # the response object (passed by constructor) + response=response, + # the configuration object (passed by constructor) + configuration=configuration, + ) \ No newline at end of file From 96ce2993a19e6f4532f15688c9114cee92365bfb Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Tue, 4 Oct 2022 14:41:24 -0400 Subject: [PATCH 2/9] WIP --- .../business_rules}/__init__.py | 0 .../drop_point_business_rules.json | 20 ++++++ .../configuration/drop_point_constants.py | 24 +++---- .../configuration/external_action_mapping.ini | 29 +++++++++ .../configuration/internal_action_mapping.ini | 21 +++++++ .../drop_point/configuration/logging.conf | 33 ++++++++++ .../configuration/type_mapping.json | 6 ++ .../__init__.py} | 0 .../controllers/drop_point_controller.py | 63 +++++++++++++++++++ .../drop_point_sender_controller.py | 27 ++++++++ .../extended/drop_point/drop_point.py | 39 ------------ 11 files changed, 206 insertions(+), 56 deletions(-) rename FreeTAKServer/components/extended/drop_point/{controller => configuration/business_rules}/__init__.py (100%) create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json rename FreeTAKServer/components/extended/drop_point/{configuration/business_rules.json => controllers/__init__.py} (100%) create mode 100644 FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py create mode 100644 FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py delete mode 100644 FreeTAKServer/components/extended/drop_point/drop_point.py diff --git a/FreeTAKServer/components/extended/drop_point/controller/__init__.py b/FreeTAKServer/components/extended/drop_point/configuration/business_rules/__init__.py similarity index 100% rename from FreeTAKServer/components/extended/drop_point/controller/__init__.py rename to FreeTAKServer/components/extended/drop_point/configuration/business_rules/__init__.py diff --git a/FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json b/FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json new file mode 100644 index 00000000..4047cc73 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json @@ -0,0 +1,20 @@ +{ + "actions": [ + "ParseDropPoint" + ], + "matchable": "model_object", + "rules": { + "type == 'Unknown'": { + "actions": [] + }, + "type == 'Neutral'": { + "actions": [] + }, + "type == 'Friendly'": { + "actions": [] + }, + "type == 'Hostile'": { + "actions": [] + } + } +} \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py index 0e1856a5..9b52bdb9 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py +++ b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py @@ -43,26 +43,16 @@ ) ) +# TODO not needed? BUSINESS_RULES_PATH = str( pathlib.PurePath(CURRENT_COMPONENT_PATH, "configuration/business_rules.json") ) -# EMERGENCY_OFF_BUSINESS_RULES_PATH = str( -# pathlib.PurePath( -# CURRENT_COMPONENT_PATH, -# "configuration/business_rules/emergency_off_business_rules.json", -# ) -# ) - -# EMERGENCY_ON_BUSINESS_RULES_PATH = str( -# pathlib.PurePath( -# CURRENT_COMPONENT_PATH, -# "configuration/business_rules/emergency_on_business_rules.json", -# ) -# ) +DROP_POINT_BUSINESS_RULES_PATH = str( + pathlib.PurePath( + CURRENT_COMPONENT_PATH, + "configuration/business_rules/drop_point_business_rules.json", + ) +) BASE_OBJECT_NAME = "Event" - -# EMERGENCY_OFF = "emergency_delete" - -# EMERGENCY_ALERT = "emergency_alert" diff --git a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini index e69de29b..0dc46366 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini +++ b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini @@ -0,0 +1,29 @@ +[actionmapping] +XMLCoTController??Unkown = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received +XMLCoTController??Neutral = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received +XMLCoTController??Friendly = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received +XMLCoTController??Hostile = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received + +??BroadcastDropPoint = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.drop_point_broadcast + +?Unkown?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent +?Neutral?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent +?Friendly?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent +?Hostile?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent + +?ParseDropPoint?CreateNode = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.create_node + +[DropPoint] +__class = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint + +[Request] +__class = digitalpy.routing.impl.default_request.DefaultRequest + +[ActionMapper] +__class = digitalpy.routing.impl.default_action_mapper.DefaultActionMapper + +[event_manager] +__class = digitalpy.core.impl.default_event_manager.DefaultEventManager + +[Response] +__class = digitalpy.routing.impl.default_response.DefaultResponse \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini index e69de29b..98889fff 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini +++ b/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini @@ -0,0 +1,21 @@ +[actionmapping] +DropPoint??Unkown = FreeTAKServer.components.extended.drop_point.controllers.drop_point_controller.DropPointController.evaluate_request +DropPoint??Neutral = FreeTAKServer.components.extended.drop_point.controllers.drop_point_controller.DropPointController.evaluate_request +DropPoint??Friendly = FreeTAKServer.components.extended.drop_point.controllers.drop_point_controller.DropPointController.evaluate_request +DropPoint??Hostile = FreeTAKServer.components.extended.drop_point.controllers.drop_point_controller.DropPointController.evaluate_request + +??BroadcastDropPoint = FreeTAKServer.components.extended.drop_point.controllers.drop_point_sender_controller.DropPointSenderController.broadcast_drop_point + +??ParseDropPoint = FreeTAKServer.components.extended.drop_point.controllers.drop_point_controller.DropPointController.parse_drop_point + +[Request] +__class = digitalpy.routing.impl.default_request.DefaultRequest + +[ActionMapper] +__class = digitalpy.routing.impl.default_action_mapper.DefaultActionMapper + +[event_manager] +__class = digitalpy.core.impl.default_event_manager.DefaultEventManager + +[Response] +__class = digitalpy.routing.impl.default_response.DefaultResponse \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/configuration/logging.conf b/FreeTAKServer/components/extended/drop_point/configuration/logging.conf index e69de29b..7d523cf0 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/logging.conf +++ b/FreeTAKServer/components/extended/drop_point/configuration/logging.conf @@ -0,0 +1,33 @@ +[loggers] +keys=root,drop_point # TODO, A) or dropPoint, what is key here? + +[handlers] +keys=stream_handler,fileHandler + +[formatters] +keys=formatter + +[logger_root] +level=DEBUG +handlers=fileHandler + +[logger_emergency] +level=DEBUG +qualname=emergency +handlers=fileHandler + +[handler_stream_handler] +class=StreamHandler +level=DEBUG +formatter=formatter +args=(sys.stderr,) + +[handler_fileHandler] +class=FileHandler +level=DEBUG +formatter=formatter +args=('%(logfilename)s',) + +[formatter_formatter] +format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s + diff --git a/FreeTAKServer/components/extended/drop_point/configuration/type_mapping.json b/FreeTAKServer/components/extended/drop_point/configuration/type_mapping.json index e69de29b..92c43d06 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/type_mapping.json +++ b/FreeTAKServer/components/extended/drop_point/configuration/type_mapping.json @@ -0,0 +1,6 @@ +{ + "a-u-G": "Unknown", + "a-n-G": "Neutral", + "a-f-G": "Friendly", + "a-h-G": "Hostile" +} \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/configuration/business_rules.json b/FreeTAKServer/components/extended/drop_point/controllers/__init__.py similarity index 100% rename from FreeTAKServer/components/extended/drop_point/configuration/business_rules.json rename to FreeTAKServer/components/extended/drop_point/controllers/__init__.py diff --git a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py new file mode 100644 index 00000000..4fec61f2 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py @@ -0,0 +1,63 @@ +from digitalpy.logic.impl.default_business_rule_controller import ( + DefaultBusinessRuleController, +) + + +from ..configuration.drop_point_constants import ( + DROP_POINT_BUSINESS_RULES_PATH, + BASE_OBJECT_NAME +) + + +class DropPointController(DefaultBusinessRuleController): + + def __init__( + self, request, response, action_mapper, configuration, drop_point_action_mapper + ): + + super().__init__( + # the path to the business rules used by this controller + business_rules_path=DROP_POINT_BUSINESS_RULES_PATH, + # the request object (passed by constructor) + request=request, + # the response object (passed by constructor) + response=response, + # the configuration object (passed by constructor) + configuration=configuration, + # the general action mapper (passed by constructor) + action_mapper=action_mapper, + # the component action mapper (passed by constructor). + # the component or internal action mapper is configured + # to use the internal action mapping configuration. + # it is this internal action mapper that is used by + # the DefaultBusinessRuleController evaluate_request + internal_action_mapper=drop_point_action_mapper, + ) + + def execute(self, method=None): + getattr(self, method)(**self.request.get_values()) + return self.response + + def parse_drop_point(self, **kwargs): + """Creates the model object outline and + """ + self.request.get_value("logger").debug("parsing drop point") + + self.response.set_values(kwargs) + + # TODO + # self.request.set_value("message_type", EMERGENCY_ALERT) + self.request.set_value("object_class_name", BASE_OBJECT_NAME) + + self.request.set_context(self.request.get_action()) + + response = self.execute_sub_action("CreateNode") + + self.request.set_value("model_object", response.get_value("model_object")) + + self.request.set_value("message", self.request.get_value("message").xmlString) + + sub_response = self.execute_sub_action("ParseCoT") + + for key, value in sub_response.get_values().items(): + self.response.set_value(key, value) \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py new file mode 100644 index 00000000..ef76c10d --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py @@ -0,0 +1,27 @@ + +from digitalpy.routing.controller import Controller +from ..domain import Event + + +class DropPointSenderController(Controller): + """this class is responsible for transmitting drop points""" + + def execute(self, method=None): + getattr(self, method)(**self.request.get_values()) + return self.response + + def broadcast_drop_point(self, model_object: Event, **kwargs): + """this method will broadcast a drop point + """ + try: + self.request.get_value("logger").debug( + f"broadcasting emergency {model_object.uid}" + ) + + self.response.set_values(kwargs) + self.request.set_value("model_objects", [model_object]) + self.execute_sub_action("Broadcast") + except Exception as error: + self.request.get_value("logger").error( + f"error broadcasting emergency {error}" + ) diff --git a/FreeTAKServer/components/extended/drop_point/drop_point.py b/FreeTAKServer/components/extended/drop_point/drop_point.py deleted file mode 100644 index 716a20e3..00000000 --- a/FreeTAKServer/components/extended/drop_point/drop_point.py +++ /dev/null @@ -1,39 +0,0 @@ -from digitalpy.routing.controller import Controller - - -class DropPoint(Controller): - - """ - Facade - Domain - - - """ - def accept_visitor(self, visitor): - pass - - def initialize(self, request: Request, response: Response): - self.request = request - self.response = response - - def execute(self, method=None): - getattr(self, method)(**self.request.get_values()) - - - def drop_point_broadcast(self, message, **kwargs): - self.response.set_values(kwargs) - - domain = _DropPointDomain() - request = ObjectFactory.get_new_instance('request') - request.set_action('ParseCoT') - request.set_value('message', message) - request.set_value('domain', domain) - - actionmapper = ObjectFactory.get_instance('actionMapper') - response = ObjectFactory.get_new_instance('response') - - model_object = domain.create_node(DROP_POINT, BASE_OBJECT_NAME) - - def drop_point_recieve(self, **kwargs): - self.response.set_values(kwargs) - self.response.set_action("point_broadcast") \ No newline at end of file From 37161a326a76d73fc1f5ac77808a8e8ee39e5fbe Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Tue, 4 Oct 2022 20:08:58 -0400 Subject: [PATCH 3/9] Implement drop point component --- .../drop_point_business_rules.json | 16 ++++++-- .../configuration/drop_point_constants.py | 2 + .../configuration/external_action_mapping.ini | 2 - .../drop_point/configuration/logging.conf | 2 +- .../controllers/drop_point_controller.py | 4 +- .../drop_point_sender_controller.py | 6 +-- .../configuration/routing/action_mapping.ini | 2 - .../test_drop_point.py | 40 +++++++++++++++++++ 8 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 tests/test_components/test_external_components/test_drop_point.py diff --git a/FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json b/FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json index 4047cc73..7bc9f9e4 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json +++ b/FreeTAKServer/components/extended/drop_point/configuration/business_rules/drop_point_business_rules.json @@ -5,16 +5,24 @@ "matchable": "model_object", "rules": { "type == 'Unknown'": { - "actions": [] + "actions": [ + "BroadcastDropPoint" + ] }, "type == 'Neutral'": { - "actions": [] + "actions": [ + "BroadcastDropPoint" + ] }, "type == 'Friendly'": { - "actions": [] + "actions": [ + "BroadcastDropPoint" + ] }, "type == 'Hostile'": { - "actions": [] + "actions": [ + "BroadcastDropPoint" + ] } } } \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py index 9b52bdb9..481e6b03 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py +++ b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py @@ -56,3 +56,5 @@ ) BASE_OBJECT_NAME = "Event" + +DROP_POINT = "drop_point" \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini index 0dc46366..429523bf 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini +++ b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini @@ -4,8 +4,6 @@ XMLCoTController??Neutral = FreeTAKServer.components.extended.drop_point.drop_po XMLCoTController??Friendly = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received XMLCoTController??Hostile = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received -??BroadcastDropPoint = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.drop_point_broadcast - ?Unkown?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent ?Neutral?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent ?Friendly?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent diff --git a/FreeTAKServer/components/extended/drop_point/configuration/logging.conf b/FreeTAKServer/components/extended/drop_point/configuration/logging.conf index 7d523cf0..1dcab650 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/logging.conf +++ b/FreeTAKServer/components/extended/drop_point/configuration/logging.conf @@ -1,5 +1,5 @@ [loggers] -keys=root,drop_point # TODO, A) or dropPoint, what is key here? +keys=root,drop_point [handlers] keys=stream_handler,fileHandler diff --git a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py index 4fec61f2..314d5f00 100644 --- a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py +++ b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py @@ -5,6 +5,7 @@ from ..configuration.drop_point_constants import ( DROP_POINT_BUSINESS_RULES_PATH, + DROP_POINT, BASE_OBJECT_NAME ) @@ -45,8 +46,7 @@ def parse_drop_point(self, **kwargs): self.response.set_values(kwargs) - # TODO - # self.request.set_value("message_type", EMERGENCY_ALERT) + self.request.set_value("message_type", DROP_POINT) self.request.set_value("object_class_name", BASE_OBJECT_NAME) self.request.set_context(self.request.get_action()) diff --git a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py index ef76c10d..530d41bd 100644 --- a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py +++ b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py @@ -4,7 +4,7 @@ class DropPointSenderController(Controller): - """this class is responsible for transmitting drop points""" + """this class is responsible for transmitting points""" def execute(self, method=None): getattr(self, method)(**self.request.get_values()) @@ -15,7 +15,7 @@ def broadcast_drop_point(self, model_object: Event, **kwargs): """ try: self.request.get_value("logger").debug( - f"broadcasting emergency {model_object.uid}" + f"broadcasting point {model_object.uid}" ) self.response.set_values(kwargs) @@ -23,5 +23,5 @@ def broadcast_drop_point(self, model_object: Event, **kwargs): self.execute_sub_action("Broadcast") except Exception as error: self.request.get_value("logger").error( - f"error broadcasting emergency {error}" + f"error broadcasting point {error}" ) diff --git a/FreeTAKServer/configuration/routing/action_mapping.ini b/FreeTAKServer/configuration/routing/action_mapping.ini index d8b20fbc..6e3a112a 100644 --- a/FreeTAKServer/configuration/routing/action_mapping.ini +++ b/FreeTAKServer/configuration/routing/action_mapping.ini @@ -2,8 +2,6 @@ ??Broadcast = FreeTAKServer.components.core.message_sender.main_message_sender.MessageSender.broadcast ??ParseCoT = FreeTAKServer.components.core.cot_parser.main_cot_parser.COTParser.parse_cot_to_object ??ParseModelObjectToXML = FreeTAKServer.components.core.cot_parser.main_cot_parser.COTParser.parse_objects_to_cots -??BroadcastDropPoint = FreeTAKServer.components.extended.drop_point.drop_point_broadcast -??DropPoint = FreeTAKServer.components.extended.drop_point.DropPoint diff --git a/tests/test_components/test_external_components/test_drop_point.py b/tests/test_components/test_external_components/test_drop_point.py new file mode 100644 index 00000000..e0d68584 --- /dev/null +++ b/tests/test_components/test_external_components/test_drop_point.py @@ -0,0 +1,40 @@ +import pathlib +from unittest.mock import MagicMock + +from digitalpy.config.impl.inifile_configuration import InifileConfiguration +from digitalpy.core.impl.default_factory import DefaultFactory +from digitalpy.core.object_factory import ObjectFactory +from FreeTAKServer.components.core.type.type_facade import Type +from FreeTAKServer.components.extended.drop_point.drop_point_facade import DropPoint +from FreeTAKServer.controllers.XMLCoTController import XMLCoTController +from lxml import etree + + +def setup_module(): + config = InifileConfiguration("") + config.add_configuration( + str(pathlib.PurePath(pathlib.Path(__file__).parent.parent.parent.parent.absolute(), "FreeTAKServer/configuration/external_action_mapping.ini")) + ) + + ObjectFactory.configure(DefaultFactory(config)) + ObjectFactory.register_instance("configuration", config) + + Type(None, None, None, None).register(config) + + DropPoint(None, None, None, None).register(config) + +def test_drop_point(): + test_data = 'DATA' + mock_message = MagicMock() + mock_message.xmlString = test_data + mock_message.clientInformation = "test" + + mock_client = MagicMock() + + XMLCoTController(MagicMock()).determineCoTGeneral( + mock_message, {"test": [mock_client, MagicMock()]} + ) + + assert len(mock_client.send.call_args[0][0].decode()) == len( + etree.tostring(etree.fromstring(test_data)) + ) From bae2c4ca32a7d9bf6ba3ababf7cc84e370aa6bfd Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Wed, 5 Oct 2022 08:59:07 -0400 Subject: [PATCH 4/9] WIP update domain --- .../drop_point/configuration/logging.conf | 4 +- .../extended/drop_point/domain/__init__.py | 11 + .../extended/drop_point/domain/_detail.py | 64 +++++ .../extended/drop_point/domain/_link.py | 106 +++++++++ .../extended/drop_point/domain/_point.py | 64 +++++ .../drop_point/domain/_precisionlocation.py | 42 ++++ .../extended/drop_point/domain/_usericon.py | 27 +++ .../model_constants/ContactVariables.py | 101 ++++++++ .../domain/model_constants/DetailVariables.py | 4 + .../domain/model_constants/EventVariables.py | 221 ++++++++++++++++++ .../domain/model_constants/LinkVariables.py | 79 +++++++ .../domain/model_constants/PointVariables.py | 7 + .../PrecisionlocationVariables.py | 27 +++ .../model_constants/UsericonVariables.py | 8 + .../__init__.py} | 0 .../test_external_components/__init__.py | 0 .../test_drop_point.py | 14 +- .../test_emergency.py | 6 +- 18 files changed, 778 insertions(+), 7 deletions(-) create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/_usericon.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/model_constants/ContactVariables.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/model_constants/DetailVariables.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/model_constants/EventVariables.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/model_constants/LinkVariables.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/model_constants/PointVariables.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/model_constants/PrecisionlocationVariables.py create mode 100644 FreeTAKServer/components/extended/drop_point/domain/model_constants/UsericonVariables.py rename FreeTAKServer/components/extended/drop_point/domain/{_precision_location.py => model_constants/__init__.py} (100%) rename FreeTAKServer/components/extended/drop_point/domain/_user_icon.py => tests/test_components/test_external_components/__init__.py (100%) diff --git a/FreeTAKServer/components/extended/drop_point/configuration/logging.conf b/FreeTAKServer/components/extended/drop_point/configuration/logging.conf index 1dcab650..02f1848b 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/logging.conf +++ b/FreeTAKServer/components/extended/drop_point/configuration/logging.conf @@ -11,9 +11,9 @@ keys=formatter level=DEBUG handlers=fileHandler -[logger_emergency] +[logger_drop_point] level=DEBUG -qualname=emergency +qualname=drop_point handlers=fileHandler [handler_stream_handler] diff --git a/FreeTAKServer/components/extended/drop_point/domain/__init__.py b/FreeTAKServer/components/extended/drop_point/domain/__init__.py index e69de29b..22d696bd 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/__init__.py +++ b/FreeTAKServer/components/extended/drop_point/domain/__init__.py @@ -0,0 +1,11 @@ +"""this package contains all the model objects, every model object class +should be defined as follows, _name.py containing a class Name with the class +exported here as Name. The class must be exported here as it is used by the +domain controller class to get classes based on the object configurations""" +from ._contact import contact as contact +from ._detail import detail as detail +from ._event import Event as Event +from ._link import link as link +from ._point import point as point +from ._precisionlocation import Precisionlocation as Precisionlocation +from ._usericon import usericon as usericon \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_detail.py b/FreeTAKServer/components/extended/drop_point/domain/_detail.py index e69de29b..011d35b1 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_detail.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_detail.py @@ -0,0 +1,64 @@ +####################################################### +# +# detail.py +# Python implementation of the Class detail +# Generated by Enterprise Architect +# Created on(FTSProtocolObject): 11-Feb-2020 11:08:07 AM +# Original author: Corvo +# +####################################################### + +from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode +from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty + + +class detail(CoTNode): + """An optional element used to hold CoT sub-schema. empty element""" + + __index = -1 + + def __init__(self, configuration, model): + super().__init__(self.__class__.__name__, configuration, model) + + @CoTProperty + def link(self): + return self.cot_attributes.get("link", None) + + @link.setter + def link(self, link): + self.cot_attributes["link"] = link + + @CoTProperty + def contact(self): + return self.cot_attributes.get("contact", None) + + @contact.setter + def contact(self, contact): + self.cot_attributes["contact"] = contact + + @CoTProperty + def usericon(self): + return self.cot_attributes.get("usericon", None) + + @usericon.setter + def usericon(self, usericon): + self.cot_attributes["usericon"] = usericon + + @CoTProperty + def Precisionlocation(self): + return self.cot_attributes.get("Precisionlocation", None) + + @Precisionlocation.setter + def Precisionlocation(self, precisionlocation): + self.cot_attributes["Precisionlocation"] = precisionlocation + + @CoTProperty + def remarks(self): + return self.cot_attributes.get("remarks", None) + + @remarks.setter + def remarks(self, remarks): + self.cot_attributes["remarks"] = remarks + + + diff --git a/FreeTAKServer/components/extended/drop_point/domain/_link.py b/FreeTAKServer/components/extended/drop_point/domain/_link.py index e69de29b..5dee3a7d 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_link.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_link.py @@ -0,0 +1,106 @@ +from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode +from datetime import datetime as dt +from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty + + +class link(CoTNode): + def __init__(self, configuration, model): + super().__init__(self.__class__.__name__, configuration, model) + self.cot_attributes["uid"] = None + self.cot_attributes["relation"] = None + self.cot_attributes["production_time"] = None + self.cot_attributes["type"] = None + self.cot_attributes["parent_callsign"] = None + + @CoTProperty + def remarks(self): + return self.cot_attributes.get("remarks", None) + + @remarks.setter + def remarks(self, remarks): + self.__modified = True + self.cot_attributes["remarks"] = remarks + + @CoTProperty + def callsign(self): + return self.cot_attributes.get("callsign", None) + + @callsign.setter + def callsign(self, callsign): + self.cot_attributes["callsign"] = callsign + + @CoTProperty + def point(self): + return self.cot_attributes.get("point", None) + + @point.setter + def point(self, point): + self.cot_attributes["point"] = point + + @CoTProperty + def uid(self): + import uuid + + if "uid" in self.cot_attributes: + return self.cot_attributes.get("uid", None) + else: + self.cot_attributes["uid"] = uuid.uuid1() + return self.cot_attributes.get("uid", None) + + @uid.setter + def uid(self, uid=0): + self.__modified = True + self.cot_attributes["uid"] = uid + + @CoTProperty + def production_time(self): + return self.cot_attributes.get("production_time", None) + + @production_time.setter + def production_time(self, production_time=0): + self.__modified = True + DATETIME_FMT = "%Y-%m-%dT%H:%M:%SZ" + if production_time == None: + timer = dt.datetime + now = timer.utcnow() + zulu = now.strftime(DATETIME_FMT) + add = dt.timedelta(minutes=1) + production_time_part = dt.datetime.strptime(zulu, DATETIME_FMT) + add + self.production_time = production_time_part.strftime(DATETIME_FMT) + else: + self.production_time = production_time + + @CoTProperty + def relation(self): + return self.cot_attributes.get("relation", None) + + @relation.setter + def relation(self, relation=0): + self.__modified = True + self.cot_attributes["relation"] = relation + + @CoTProperty + def type(self): + return self.cot_attributes.get("type", None) + + @type.setter + def type(self, type=0): + self.__modified = True + self.cot_attributes["type"] = type + + @CoTProperty + def parent_callsign(self): + return self.cot_attributes.get("parent_callsign", None) + + @parent_callsign.setter + def parent_callsign(self, parent_callsign=0): + self.__modified = True + self.cot_attributes["parent_callsign"] = parent_callsign + + @CoTProperty + def relationship(self): + return self.cot_attributes.get("relationship", None) + + @relationship.setter + def relationship(self, relationship): + self.cot_attributes["relationship"] = relationship diff --git a/FreeTAKServer/components/extended/drop_point/domain/_point.py b/FreeTAKServer/components/extended/drop_point/domain/_point.py index e69de29b..5f13b85e 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_point.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_point.py @@ -0,0 +1,64 @@ +####################################################### +# +# point.py +# Python implementation of the CoT point +# Generated by Enterprise Architect +# Created on(FTSProtocolObject): 11-Feb-2020 11(FTSProtocolObject):08(FTSProtocolObject):07 AM +# Original author: Corvo +# +####################################################### +# Latitude referred to the WGS 84 ellipsoid in degrees +from .model_constants.PointVariables import PointVariables as vars +from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode +from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty + + +class point(CoTNode): + + def __init__(self, configuration, model, le=vars().LE, ce=vars().CE, hae=vars().HAE, lon=vars().LON, lat=vars().LAT): + super().__init__(self.__class__.__name__, configuration, model) + self.cot_attributes["le"] = le + self.cot_attributes["ce"] = ce + self.cot_attributes["hae"] = hae + self.cot_attributes["lon"] = lon + self.cot_attributes["lat"] = lat + + @CoTProperty + def ce(self): + return self.cot_attributes.get("ce", None) + + @ce.setter + def ce(self, ce): + self.cot_attributes["ce"]=ce + + @CoTProperty + def le(self): + return self.cot_attributes.get("le", None) + + @le.setter + def le(self,le): + self.cot_attributes["le"]=le + + @CoTProperty + def lat(self): + return self.cot_attributes.get("lat", None) + + @lat.setter + def lat(self, lat): + self.cot_attributes["lat"]=lat + + @CoTProperty + def lon(self): + return self.cot_attributes.get("lon", None) + + @lon.setter + def lon(self,lon): + self.cot_attributes["lon"]=lon + + @CoTProperty + def hae(self): + return self.cot_attributes.get("hae", None) + + @hae.setter + def hae(self,hae): + self.cot_attributes["hae"] = hae \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py b/FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py new file mode 100644 index 00000000..bc33f6b1 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py @@ -0,0 +1,42 @@ +from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode +from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty +from FreeTAKServer.model.FTSModel.fts_protocol_object import FTSProtocolObject +####################################################### +# +# Precisionlocation.py +# Python implementation of the Class Precisionlocation +# Generated by Enterprise Architect +# Created on(FTSProtocolObject): 11-Feb-2020 11(FTSProtocolObject):08(FTSProtocolObject):10 AM +# Original author: Corvo +# +####################################################### +from FreeTAKServer.model.FTSModelVariables.PrecisionlocationVariables import PrecisionlocationVariables as vars + +class Precisionlocation(CoTNode): + """some type of location? + """ + +# TDB can be DTED0 or ??? + + + def __init__(self, configuration, model, altsrc=vars().ALTSRC, geopointsrc=vars().GEOPOINTSRC): + super().__init__(self.__class__.__name__, configuration, model) + self.cot_attributes['geopointsrc'] = geopointsrc + self.cot_attributes['altsrc'] = altsrc + + @CoTProperty + def geopointsrc(self): + return self.cot_attributes.get('geopointsrc', None) + + @geopointsrc.setter + def geopointsrc(self, geopointsrc=0): + self.cot_attributes['geopointsrc'] = geopointsrc + + @CoTProperty + def altsrc(self): + return self.cot_attributes.get('altsrc', None) + + @altsrc.setter + def setaltsrc(self, altsrc=0): + self.cot_attributes['altsrc'] = altsrc + \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_usericon.py b/FreeTAKServer/components/extended/drop_point/domain/_usericon.py new file mode 100644 index 00000000..7e184206 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/_usericon.py @@ -0,0 +1,27 @@ +from FreeTAKServer.model.FTSModel.fts_protocol_object import FTSProtocolObject +####################################################### +# +# usericon.py +# Python implementation of the Class usericon +# Generated by Enterprise Architect +# Created on(FTSProtocolObject): 11-Feb-2020 11(FTSProtocolObject):08(FTSProtocolObject):08 AM +# Original author: Corvo +# +####################################################### +from FreeTAKServer.model.FTSModelVariables.UsericonVariables import UsericonVariables as vars +from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty +from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode + +class usericon(CoTNode): + def __init__(self, configuration, model, iconsetpath=vars().ICONSETPATH): + super().__init__(self.__class__.__name__, configuration, model) + self.cot_attributes["iconsetpath"] = iconsetpath + + @CoTProperty + def iconsetpath(self): + return self.iconsetpath + + @iconsetpath.setter + def iconsetpath(self, iconsetpath=0): + self.iconsetpath=iconsetpath + diff --git a/FreeTAKServer/components/extended/drop_point/domain/model_constants/ContactVariables.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/ContactVariables.py new file mode 100644 index 00000000..782024fa --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/model_constants/ContactVariables.py @@ -0,0 +1,101 @@ +class ContactVariables: + def __init__(self): + self.CALLSIGN = None + self.ENDPOINT = None + self.ICONSETPATH = None + self.UID = None + self.NAME = None + + @classmethod + def connection(cls): + cls.CALLSIGN = None + cls.ENDPOINT = None + cls.ICONSETPATH = None + cls.UID = None + cls.NAME = None + cls.PHONE = None + cls.EMAILADDRESS = None + cls.XMPPUSERNAME = None + cls.SIPADDRESS = None + return cls + + @classmethod + def drop_point(cls): + cls.CALLSIGN = "DEFAULT" + cls.ENDPOINT = None + cls.ICONSETPATH = None + cls.UID = None + cls.NAME = None + cls.EMAILADDRESS = None + cls.XMPPUSERNAME = None + cls.SIPADDRESS = None + return cls + + @classmethod + def geochat(cls): + cls.CALLSIGN = "DEFAULT" + cls.ENDPOINT = None + cls.ICONSETPATH = None + cls.UID = None + cls.NAME = None + cls.EMAILADDRESS = None + cls.XMPPUSERNAME = None + cls.SIPADDRESS = None + return cls + + @classmethod + def emergency_on(cls): + cls.CALLSIGN = None + cls.ENDPOINT = None + cls.ICONSETPATH = None + cls.UID = None + cls.NAME = None + cls.EMAILADDRESS = None + cls.XMPPUSERNAME = None + cls.SIPADDRESS = None + return cls + + @classmethod + def UserUpdate(cls): + cls.ENDPOINT = None + cls.PHONE = None + cls.CALLSIGN = None + cls.EMAILADDRESS = None + cls.XMPPUSERNAME = None + cls.SIPADDRESS = None + return cls + + @classmethod + def SimpleCoT(cls): + cls.callsign = None + return cls + + @classmethod + def Presence(cls): + cls.callsign = None + return cls + + @classmethod + def Route(cls): + cls.callsign = None + return cls + + @classmethod + def VideoStream(cls): + cls.callsign = None + return cls + + @classmethod + def DroneSensor(cls): + cls.callsign = None + return cls + + @classmethod + def SPISensor(cls): + cls.callsign = None + return cls + + @classmethod + def BitsImageryVideo(cls): + cls.callsign = None + return cls \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/model_constants/DetailVariables.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/DetailVariables.py new file mode 100644 index 00000000..ebdfd981 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/model_constants/DetailVariables.py @@ -0,0 +1,4 @@ +@classmethod +def ExcheckUpdate(cls): + return cls + diff --git a/FreeTAKServer/components/extended/drop_point/domain/model_constants/EventVariables.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/EventVariables.py new file mode 100644 index 00000000..15bdd674 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/model_constants/EventVariables.py @@ -0,0 +1,221 @@ +class EventVariables: + + @classmethod + def drop_point(cls): + cls.VERSIONNUM = '2.0' + cls.UID = 'RANDOM' + cls.TYPE = "DEFAULT" + cls.HOW = "h-g-i-g-o" + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def geochat(cls): + cls.VERSIONNUM = '2.0' + cls.UID = None + cls.TYPE = "b-t-f" + cls.HOW = 'h-g-i-g-o' + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def other(cls): + cls.VERSIONNUM = '2.0' + cls.UID = 'RANDOM' + cls.TYPE = "DEFAULT" + cls.HOW = None + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def FederatedCoT(cls): + cls.VERSIONNUM = '2.0' + cls.UID = 'RANDOM' + cls.TYPE = "DEFAULT" + cls.HOW = None + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def emergency_on(cls): + cls.VERSIONNUM = '2.0' + cls.UID = None + cls.TYPE = "b-a-o-tbl" + cls.HOW = 'm-g' + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def emergency_off(cls): + cls.VERSIONNUM = '2.0' + cls.UID = 'RANDOM' + cls.TYPE = "DEFAULT" + cls.HOW = 'h-e' + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def connection(cls): + cls.VERSIONNUM = '2.0' + cls.UID = 'RANDOM' + cls.TYPE = "DEFAULT" + cls.HOW = None + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def ping(cls): + cls.VERSIONNUM = '2.0' + cls.UID = 'RANDOM' + cls.TYPE = "DEFAULT" + cls.HOW = None + cls.TIME = None + cls.START = None + cls.STALE = None + return cls + + @classmethod + def disconnect(cls): + cls.uid = None + cls.version = '2.0' + cls.type = 't-x-d-d' + cls.time = None + cls.start = None + cls.stale = None + cls.how = 'h-g-i-g-o' + return cls + + @classmethod + def DeleteVideo(cls): + cls.uid = None + cls.version = '2.0' + cls.type = 't-x-d-d' + cls.time = None + cls.start = None + cls.stale = None + cls.how = 'h-g-i-g-o' + return cls + + @classmethod + def takPong(cls): + cls.version = '2.0' + cls.uid = 'takPong' + cls.type = 't-x-c-t-r' + cls.how = 'h-g-i-g-o' + cls.time = None + cls.start = None + cls.stale = None + return cls + + @classmethod + def UserUpdate(cls): + cls.version = None + cls.uid = None + cls.type = None + cls.how = None + cls.time = None + cls.start = None + cls.stale = None + return cls + + @classmethod + def SimpleCoT(cls): + cls.version = "2.0" + cls.uid = None + cls.type = None + cls.time = None + cls.start = None + cls.stale = None + cls.how = None + return cls + + @classmethod + def Presence(cls): + cls.version = "2.0" + cls.uid = None + cls.type = None + cls.time = None + cls.start = None + cls.stale = None + cls.how = None + return cls + + @classmethod + def ExcheckUpdate(cls): + cls.version = None + cls.uid = None + cls.type = "t-x-m-c" + cls.time = None + cls.start = None + cls.stale = None + cls.how = "h-g-i-g-o" + return cls + + @classmethod + def Route(cls): + cls.version = None + cls.uid = None + cls.type = "b-m-r" + cls.time = None + cls.start = None + cls.stale = None + cls.how = "h-e" + return cls + + @classmethod + def VideoStream(cls): + cls.version = None + cls.uid = None + cls.type = "b-i-v" + cls.time = None + cls.start = None + cls.stale = None + cls.how = "m-g" + return cls + + @classmethod + def DroneSensor(cls): + cls.version = None + cls.uid = None + cls.type = "a-f-A-M-H-Q" + cls.time = None + cls.start = None + cls.stale = None + cls.how = "m-g" + return cls + + @classmethod + def BitsImageryVideo(cls): + cls.version = None + cls.uid = None + cls.type = "b-i-v" + cls.time = None + cls.start = None + cls.stale = None + cls.how = "m-g" + return cls + + @classmethod + def SPISensor(cls): + cls.version = None + cls.uid = None + cls.type = "b-m-p-s-p-i" + cls.time = None + cls.start = None + cls.stale = None + cls.how = "m-g" + return cls \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/model_constants/LinkVariables.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/LinkVariables.py new file mode 100644 index 00000000..8d274f6c --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/model_constants/LinkVariables.py @@ -0,0 +1,79 @@ +class LinkVariables: + def __init__(self): + self.UID = None + self.RELATION = None + self.PRODUCTIONTIME = None + self.TYPE = None + self.PARENTCALLSIGN = None + self.POINT = None + + @classmethod + def VideoStream(cls): + cls.UID = None + cls.PRODUCTIONTIME = None + cls.RELATIONSHIP = None + cls.PARENTCALLSIGN = None + return cls + + @classmethod + def drop_point(cls): + cls.UID = "DEFAULT" + cls.TYPE = "a-f-G-U-C" + cls.PARENTCALLSIGN = "DEFAULT" + cls.RELATION = "p-p" + cls.PRODUCTIONTIME = None + return cls + + @classmethod + def geochat(cls): + cls.UID = "SERVER-UID" + cls.TYPE = "a-f-G-U-C-I" + cls.PARENTCALLSIGN = None + cls.RELATION = "p-p" + return cls + + @classmethod + def emergency_on(cls): + cls.UID = "SERVER" + cls.TYPE = "a-f-G-U-C" + cls.PARENTCALLSIGN = None + cls.RELATION = "p-p" + cls.PRODUCTIONTIME = None + return cls + + @classmethod + def disconnect(cls): + cls.UID = None + cls.TYPE = "a-f-G-U-C" + cls.RELATION = "p-p" + return cls + + @classmethod + def DeleteVideo(cls): + cls.UID = None + cls.TYPE = "b-i-v" + cls.RELATION = "p-p" + return cls + + @classmethod + def Route(cls): + cls.UID = None + cls.TYPE = "b-m-p-w" + cls.REMARKS = "" + cls.POINT = "0, 0" + cls.CALLSIGN = "" + cls.RELATION = "c" + return cls + + @classmethod + def SPISensor(cls): + cls.UID = None + cls.TYPE = "a-f-A-M-H-Q" + cls.RELATION = "p-p" + return cls + + @classmethod + def BitsImageryVideo(cls): + cls.UID = None + cls.PRODUCTIONTIME = None + return cls \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/model_constants/PointVariables.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/PointVariables.py new file mode 100644 index 00000000..952a8a1d --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/model_constants/PointVariables.py @@ -0,0 +1,7 @@ +class PointVariables: + def __init__(self): + self.LE = "9999999.0" + self.CE = "9999999.0" + self.HAE = "9999999.0" + self.LON = "0" + self.LAT = "0" \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/model_constants/PrecisionlocationVariables.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/PrecisionlocationVariables.py new file mode 100644 index 00000000..4afee87d --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/model_constants/PrecisionlocationVariables.py @@ -0,0 +1,27 @@ +class PrecisionlocationVariables: + def __init__(self): + self.ALTSRC = None + self.GEOPOINTSRC = None + + @classmethod + def drop_point(cls): + cls.ALTSRC = '???' + cls.GEOPOINTSRC = None + return cls + + @classmethod + def connection(cls): + cls.ALTSRC = None + cls.GEOPOINTSRC = None + return cls + + @classmethod + def UserUpdate(cls): + cls.altsrc = None + cls.geopointsrc = None + return cls + + @classmethod + def SPISensor(cls): + cls.ALTSRC = "GPS" + return cls \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/model_constants/UsericonVariables.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/UsericonVariables.py new file mode 100644 index 00000000..7ca2baa0 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/domain/model_constants/UsericonVariables.py @@ -0,0 +1,8 @@ +class UsericonVariables: + def __init__(self): + self.ICONSETPATH = "DEFAULT" + + @classmethod + def drop_point(cls): + cls.ICONSETPATH = "DEFAULT" + return cls \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_precision_location.py b/FreeTAKServer/components/extended/drop_point/domain/model_constants/__init__.py similarity index 100% rename from FreeTAKServer/components/extended/drop_point/domain/_precision_location.py rename to FreeTAKServer/components/extended/drop_point/domain/model_constants/__init__.py diff --git a/FreeTAKServer/components/extended/drop_point/domain/_user_icon.py b/tests/test_components/test_external_components/__init__.py similarity index 100% rename from FreeTAKServer/components/extended/drop_point/domain/_user_icon.py rename to tests/test_components/test_external_components/__init__.py diff --git a/tests/test_components/test_external_components/test_drop_point.py b/tests/test_components/test_external_components/test_drop_point.py index e0d68584..672f8d25 100644 --- a/tests/test_components/test_external_components/test_drop_point.py +++ b/tests/test_components/test_external_components/test_drop_point.py @@ -13,7 +13,7 @@ def setup_module(): config = InifileConfiguration("") config.add_configuration( - str(pathlib.PurePath(pathlib.Path(__file__).parent.parent.parent.parent.absolute(), "FreeTAKServer/configuration/external_action_mapping.ini")) + str(pathlib.PurePath(pathlib.Path(__file__).parent.parent.parent.parent.absolute(), "FreeTAKServer/configuration/routing/action_mapping.ini")) ) ObjectFactory.configure(DefaultFactory(config)) @@ -24,7 +24,17 @@ def setup_module(): DropPoint(None, None, None, None).register(config) def test_drop_point(): - test_data = 'DATA' + test_data = """ + + + + + + + + + + """ mock_message = MagicMock() mock_message.xmlString = test_data mock_message.clientInformation = "test" diff --git a/tests/test_components/test_external_components/test_emergency.py b/tests/test_components/test_external_components/test_emergency.py index 14349b28..b7b6ca03 100644 --- a/tests/test_components/test_external_components/test_emergency.py +++ b/tests/test_components/test_external_components/test_emergency.py @@ -9,12 +9,14 @@ from FreeTAKServer.components.core.type.type_facade import Type from FreeTAKServer.controllers.XMLCoTController import XMLCoTController from lxml import etree +import pathlib def setup_module(module): config = InifileConfiguration("") config.add_configuration( - r"C:\Users\natha\PycharmProjects\FreeTakServer\FreeTAKServer\configuration\routing\action_mapping.ini" + str(pathlib.PurePath(pathlib.Path(__file__).parent.parent.parent.parent.absolute(), "FreeTAKServer/configuration/routing/action_mapping.ini")) + # r"C:\Users\natha\PycharmProjects\FreeTakServer\FreeTAKServer\configuration\routing\action_mapping.ini" ) ObjectFactory.configure(DefaultFactory(config)) @@ -51,8 +53,6 @@ def test_emergency_broadcast(): mock_client = MagicMock() - mock_client = MagicMock() - XMLCoTController(MagicMock()).determineCoTGeneral( mock_message, {"test": [mock_client, MagicMock()]} ) From 8d51b0c4299cec55e55a6b1e45c1ae98bb517813 Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Wed, 5 Oct 2022 12:50:28 -0400 Subject: [PATCH 5/9] Wrap up drop point test --- .../model_definitions/drop_point.json | Bin 42828 -> 42988 bytes .../extended/drop_point/domain/__init__.py | 2 +- .../extended/drop_point/domain/_contact.py | 6 +++--- .../extended/drop_point/domain/_detail.py | 10 ++++----- .../extended/drop_point/domain/_link.py | 8 ++++++-- .../drop_point/domain/_precisionlocation.py | 4 ++-- .../extended/drop_point/domain/_usericon.py | 4 ++-- .../test_drop_point.py | 19 +++++------------- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/FreeTAKServer/components/extended/drop_point/configuration/model_definitions/drop_point.json b/FreeTAKServer/components/extended/drop_point/configuration/model_definitions/drop_point.json index 5c1125b81adb85eceed3e83ca77daf7836544694..dd6b4a9ced896d17b0910942dde72e0e3e604e2c 100644 GIT binary patch delta 122 zcmX?ej_J*LrVXzcCpUR2uvRnhGH^{!3{aoU#B9J=Fxfv*nHeO~=&3mQ5u?-Q9;Q8U s!U_ziP>BJoaB^HB*W?hEsLi($)5JigF(V{ICMN}`AP0KxMlg8%>k delta 77 zcmaEJp6SdvrVXzcC&w^bF$PTDpQt=Jh}mWH2c|u7?3@go3`z_TL6?~so86Mq#3s$+ Z0xCOSVLtgmKF{QHJbDmKn;R-~^Z=Kh9nk;) diff --git a/FreeTAKServer/components/extended/drop_point/domain/__init__.py b/FreeTAKServer/components/extended/drop_point/domain/__init__.py index 22d696bd..54804d56 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/__init__.py +++ b/FreeTAKServer/components/extended/drop_point/domain/__init__.py @@ -7,5 +7,5 @@ from ._event import Event as Event from ._link import link as link from ._point import point as point -from ._precisionlocation import Precisionlocation as Precisionlocation +from ._precisionlocation import precisionlocation as precisionlocation from ._usericon import usericon as usericon \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_contact.py b/FreeTAKServer/components/extended/drop_point/domain/_contact.py index e876c74b..97c9d896 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_contact.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_contact.py @@ -70,7 +70,7 @@ def uid(self): # uid setter @uid.setter def uid(self, uid=None): - self.uid = uid + self.cot_attributes["uid"] = uid @CoTProperty def name(self): @@ -78,7 +78,7 @@ def name(self): @name.setter def name(self, name=None): - self.name = name + self.cot_attributes["name"] = name @CoTProperty def phone(self): @@ -86,4 +86,4 @@ def phone(self): @phone.setter def phone(self, phone=None): - self.phone = phone \ No newline at end of file + self.cot_attributes["phone"] = phone \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_detail.py b/FreeTAKServer/components/extended/drop_point/domain/_detail.py index 011d35b1..938d93ad 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_detail.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_detail.py @@ -45,12 +45,12 @@ def usericon(self, usericon): self.cot_attributes["usericon"] = usericon @CoTProperty - def Precisionlocation(self): - return self.cot_attributes.get("Precisionlocation", None) + def precisionlocation(self): + return self.cot_attributes.get("precisionlocation", None) - @Precisionlocation.setter - def Precisionlocation(self, precisionlocation): - self.cot_attributes["Precisionlocation"] = precisionlocation + @precisionlocation.setter + def precisionlocation(self, precisionlocation): + self.cot_attributes["precisionlocation"] = precisionlocation @CoTProperty def remarks(self): diff --git a/FreeTAKServer/components/extended/drop_point/domain/_link.py b/FreeTAKServer/components/extended/drop_point/domain/_link.py index 5dee3a7d..838513fa 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_link.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_link.py @@ -8,8 +8,12 @@ def __init__(self, configuration, model): super().__init__(self.__class__.__name__, configuration, model) self.cot_attributes["uid"] = None self.cot_attributes["relation"] = None + self.cot_attributes["relationship"] = None + self.cot_attributes["remarks"] = None self.cot_attributes["production_time"] = None self.cot_attributes["type"] = None + self.cot_attributes["callsign"] = None + self.cot_attributes["point"] = None self.cot_attributes["parent_callsign"] = None @CoTProperty @@ -66,9 +70,9 @@ def production_time(self, production_time=0): zulu = now.strftime(DATETIME_FMT) add = dt.timedelta(minutes=1) production_time_part = dt.datetime.strptime(zulu, DATETIME_FMT) + add - self.production_time = production_time_part.strftime(DATETIME_FMT) + self.cot_attributes["production_time"] = production_time_part.strftime(DATETIME_FMT) else: - self.production_time = production_time + self.cot_attributes["production_time"] = production_time @CoTProperty def relation(self): diff --git a/FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py b/FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py index bc33f6b1..cb253feb 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_precisionlocation.py @@ -12,7 +12,7 @@ ####################################################### from FreeTAKServer.model.FTSModelVariables.PrecisionlocationVariables import PrecisionlocationVariables as vars -class Precisionlocation(CoTNode): +class precisionlocation(CoTNode): """some type of location? """ @@ -37,6 +37,6 @@ def altsrc(self): return self.cot_attributes.get('altsrc', None) @altsrc.setter - def setaltsrc(self, altsrc=0): + def altsrc(self, altsrc=0): self.cot_attributes['altsrc'] = altsrc \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/domain/_usericon.py b/FreeTAKServer/components/extended/drop_point/domain/_usericon.py index 7e184206..46b9d15f 100644 --- a/FreeTAKServer/components/extended/drop_point/domain/_usericon.py +++ b/FreeTAKServer/components/extended/drop_point/domain/_usericon.py @@ -19,9 +19,9 @@ def __init__(self, configuration, model, iconsetpath=vars().ICONSETPATH): @CoTProperty def iconsetpath(self): - return self.iconsetpath + return self.cot_attributes.get("iconsetpath", None) @iconsetpath.setter def iconsetpath(self, iconsetpath=0): - self.iconsetpath=iconsetpath + self.cot_attributes["iconsetpath"]=iconsetpath diff --git a/tests/test_components/test_external_components/test_drop_point.py b/tests/test_components/test_external_components/test_drop_point.py index 672f8d25..7fb9ee71 100644 --- a/tests/test_components/test_external_components/test_drop_point.py +++ b/tests/test_components/test_external_components/test_drop_point.py @@ -24,17 +24,7 @@ def setup_module(): DropPoint(None, None, None, None).register(config) def test_drop_point(): - test_data = """ - - - - - - - - - - """ + test_data = '' mock_message = MagicMock() mock_message.xmlString = test_data mock_message.clientInformation = "test" @@ -45,6 +35,7 @@ def test_drop_point(): mock_message, {"test": [mock_client, MagicMock()]} ) - assert len(mock_client.send.call_args[0][0].decode()) == len( - etree.tostring(etree.fromstring(test_data)) - ) + test_case_len = len(''.join(mock_client.send.call_args[0][0].decode().split())) + test_data_len = len(''.join(etree.tostring(etree.fromstring(test_data)).decode().split())) + + assert test_case_len == test_data_len \ No newline at end of file From ee99c4e7df001999d856a775a51f8573729ffb64 Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Wed, 5 Oct 2022 12:55:47 -0400 Subject: [PATCH 6/9] Address issues with emergency alert test, remove redundant test --- .../test_emergency.py | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tests/test_components/test_external_components/test_emergency.py b/tests/test_components/test_external_components/test_emergency.py index b7b6ca03..d19c52e4 100644 --- a/tests/test_components/test_external_components/test_emergency.py +++ b/tests/test_components/test_external_components/test_emergency.py @@ -29,7 +29,7 @@ def setup_module(module): def test_emergency_alert(): - test_data = 'DATA' + test_data = 'CALL 911 NOWDATA' mock_message = MagicMock() mock_message.xmlString = test_data mock_message.clientInformation = "test" @@ -40,23 +40,7 @@ def test_emergency_alert(): mock_message, {"test": [mock_client, MagicMock()]} ) - assert len(mock_client.send.call_args[0][0].decode()) == len( - etree.tostring(etree.fromstring(test_data)) - ) - + test_case_len = len(''.join(mock_client.send.call_args[0][0].decode().split())) + test_data_len = len(''.join(etree.tostring(etree.fromstring(test_data)).decode().split())) -def test_emergency_broadcast(): - test_data = 'DATA' - mock_message = MagicMock() - mock_message.xmlString = test_data - mock_message.clientInformation = "test" - - mock_client = MagicMock() - - XMLCoTController(MagicMock()).determineCoTGeneral( - mock_message, {"test": [mock_client, MagicMock()]} - ) - - assert len(mock_client.send.call_args[0][0].decode()) == len( - etree.tostring(etree.fromstring(test_data)) - ) + assert test_case_len == test_data_len \ No newline at end of file From da2ac1ca5be70a0809d630d8a926a9c88428cde3 Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Tue, 18 Oct 2022 15:50:03 -0400 Subject: [PATCH 7/9] Update drop point component for async changes --- .../configuration/drop_point_constants.py | 3 +- .../configuration/external_action_mapping.ini | 11 +++--- .../configuration/internal_action_mapping.ini | 2 ++ .../model_definitions/__init__.py | 0 .../controllers/drop_point_controller.py | 4 ++- .../drop_point_general_controller.py | 36 +++++++++++++++++++ .../drop_point_sender_controller.py | 17 +++++++-- 7 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 FreeTAKServer/components/extended/drop_point/configuration/model_definitions/__init__.py create mode 100644 FreeTAKServer/components/extended/drop_point/controllers/drop_point_general_controller.py diff --git a/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py index 481e6b03..7117d83b 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py +++ b/FreeTAKServer/components/extended/drop_point/configuration/drop_point_constants.py @@ -43,7 +43,8 @@ ) ) -# TODO not needed? + +# TODO delete this? BUSINESS_RULES_PATH = str( pathlib.PurePath(CURRENT_COMPONENT_PATH, "configuration/business_rules.json") ) diff --git a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini index 429523bf..ee117538 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini +++ b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini @@ -1,8 +1,11 @@ [actionmapping] -XMLCoTController??Unkown = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received -XMLCoTController??Neutral = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received -XMLCoTController??Friendly = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received -XMLCoTController??Hostile = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received +??Unkown = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received +??Neutral = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received +??Friendly = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received +??Hostile = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received + +# TODO verify +??BroadcastDropPoint = FreeTAKServer.components.extended.controllers.drop_point.drop_point_controller.DropPointController.broadcast_drop_point ?Unkown?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent ?Neutral?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent diff --git a/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini index 98889fff..f9521e4b 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini +++ b/FreeTAKServer/components/extended/drop_point/configuration/internal_action_mapping.ini @@ -8,6 +8,8 @@ DropPoint??Hostile = FreeTAKServer.components.extended.drop_point.controllers.dr ??ParseDropPoint = FreeTAKServer.components.extended.drop_point.controllers.drop_point_controller.DropPointController.parse_drop_point +??SerializeDropPoint = FreeTAKServer.components.extended.drop_point.controllers.drop_point_general_controller.DropPointGeneralController.serialize_drop_point + [Request] __class = digitalpy.routing.impl.default_request.DefaultRequest diff --git a/FreeTAKServer/components/extended/drop_point/configuration/model_definitions/__init__.py b/FreeTAKServer/components/extended/drop_point/configuration/model_definitions/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py index 314d5f00..fe13d712 100644 --- a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py +++ b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_controller.py @@ -60,4 +60,6 @@ def parse_drop_point(self, **kwargs): sub_response = self.execute_sub_action("ParseCoT") for key, value in sub_response.get_values().items(): - self.response.set_value(key, value) \ No newline at end of file + self.response.set_value(key, value) + + self.request.get_value("logger").debug("drop point parsed") \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_general_controller.py b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_general_controller.py new file mode 100644 index 00000000..7a282951 --- /dev/null +++ b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_general_controller.py @@ -0,0 +1,36 @@ + +from digitalpy.routing.controller import Controller +from digitalpy.routing.request import Request +from digitalpy.routing.response import Response +from digitalpy.routing.action_mapper import ActionMapper +from digitalpy.config.configuration import Configuration + +class DropPointGeneralController(Controller): + def __init__( + self, + request: Request, + response: Response, + sync_action_mapper: ActionMapper, + configuration: Configuration, + ) -> None: + super().__init__(request, response, sync_action_mapper, configuration) + + def execute(self, method=None): + getattr(self, method)(**self.request.get_values()) + return self.response + + def serialize_drop_point(self, **kwargs): + """method used to serialize the drop point to a given format""" + # serialize the drop point model object in a sub-action + response = self.execute_sub_action( + self.request.get_value("model_object_parser") + ) + # add the serialized model object to the controller response as a value + self.response.set_value( + "serialized_message", response.get_value("serialized_message") + ) + self.request.get_value("logger").debug( + "serialized drop point message to format " + + self.request.get_value("model_object_parser") + ) + \ No newline at end of file diff --git a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py index 530d41bd..5d54d0f8 100644 --- a/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py +++ b/FreeTAKServer/components/extended/drop_point/controllers/drop_point_sender_controller.py @@ -1,11 +1,24 @@ from digitalpy.routing.controller import Controller from ..domain import Event +from digitalpy.routing.request import Request +from digitalpy.routing.response import Response +from digitalpy.routing.action_mapper import ActionMapper +from digitalpy.config.configuration import Configuration class DropPointSenderController(Controller): """this class is responsible for transmitting points""" + def __init__( + self, + request: Request, + response: Response, + drop_point_action_mapper: ActionMapper, + configuration: Configuration, + ) -> None: + super().__init__(request, response, drop_point_action_mapper, configuration) + def execute(self, method=None): getattr(self, method)(**self.request.get_values()) return self.response @@ -20,8 +33,8 @@ def broadcast_drop_point(self, model_object: Event, **kwargs): self.response.set_values(kwargs) self.request.set_value("model_objects", [model_object]) - self.execute_sub_action("Broadcast") + self.execute_sub_action(self.request.get_value("model_object_parser")) except Exception as error: self.request.get_value("logger").error( - f"error broadcasting point {error}" + f"error broadcasting drop point {error}" ) From a7d90092208b5c94c2e9907c2790de098a2cf0f2 Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Wed, 19 Oct 2022 15:48:04 -0400 Subject: [PATCH 8/9] Remove comment from action mapping --- .../drop_point/configuration/external_action_mapping.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini index ee117538..a5a5ead7 100644 --- a/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini +++ b/FreeTAKServer/components/extended/drop_point/configuration/external_action_mapping.ini @@ -4,7 +4,6 @@ ??Friendly = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received ??Hostile = FreeTAKServer.components.extended.drop_point.drop_point_facade.DropPoint.Received -# TODO verify ??BroadcastDropPoint = FreeTAKServer.components.extended.controllers.drop_point.drop_point_controller.DropPointController.broadcast_drop_point ?Unkown?GetNodeParent = FreeTAKServer.components.extended.drop_point.base.drop_point_domain.DropPointDomain.get_parent From 3abd275438df95ecfcbfe69125e0d1cc9e43748f Mon Sep 17 00:00:00 2001 From: Ariel De La Cruz Date: Tue, 25 Oct 2022 08:59:45 -0400 Subject: [PATCH 9/9] Update version --- FreeTAKServer/controllers/configuration/MainConfig.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FreeTAKServer/controllers/configuration/MainConfig.py b/FreeTAKServer/controllers/configuration/MainConfig.py index d1ac257f..26a393c8 100644 --- a/FreeTAKServer/controllers/configuration/MainConfig.py +++ b/FreeTAKServer/controllers/configuration/MainConfig.py @@ -12,7 +12,7 @@ class MainConfig: """ # the version information of the server (recommended to leave as default) - version = "FreeTAKServer-1.9.9.22 Public" + version = "FreeTAKServer-1.9.9.23 Public" # yaml_path = str(os.environ.get("FTS_CONFIG_PATH", "/opt/FTSConfig.yaml")) diff --git a/setup.py b/setup.py index 1108e792..e5b894f4 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ packages=find_packages( include=["FreeTAKServer", "FreeTAKServer.*", "*.json", "*.ini", "*.conf"] ), - version="1.9.9.22", + version="1.9.9.23", license="EPL-2.0", description="An open source server for the TAK family of applications.", long_description=long_description,