-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implmented mission change support and fixed enterprise sync bugs
- Loading branch information
Showing
25 changed files
with
505 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
FreeTAKServer/components/core/domain/domain/_mission_change_record.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode | ||
from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty | ||
|
||
class MissionChangeRecord(CoTNode): | ||
|
||
def __init__(self, configuration, model, oid=None): | ||
super().__init__(self.__class__.__name__, configuration, model, oid) | ||
self.cot_attributes["type"] = None | ||
self.cot_attributes["contentUid"] = None | ||
self.cot_attributes["missionName"] = None | ||
self.cot_attributes["timestamp"] = None | ||
self.cot_attributes["creatorUid"] = None | ||
self.cot_attributes["serverTime"] = None | ||
self.cot_attributes["contentResource"] = None | ||
self.cot_attributes["detail"] = None | ||
|
||
@CoTProperty | ||
def type(self): | ||
return self.cot_attributes.get("type", None) | ||
|
||
@type.setter | ||
def type(self, type=None): | ||
self.cot_attributes["type"] = type | ||
|
||
@CoTProperty | ||
def contentUid(self): | ||
return self.cot_attributes.get("contentUid", None) | ||
|
||
@contentUid.setter | ||
def contentUid(self, contentUid=None): | ||
self.cot_attributes["contentUid"] = contentUid | ||
|
||
@CoTProperty | ||
def missionName(self): | ||
return self.cot_attributes.get("missionName", None) | ||
|
||
@missionName.setter | ||
def missionName(self, missionName=None): | ||
self.cot_attributes["missionName"] = missionName | ||
|
||
@CoTProperty | ||
def timestamp(self): | ||
return self.cot_attributes.get("timestamp", None) | ||
|
||
@timestamp.setter | ||
def timestamp(self, timestamp=None): | ||
self.cot_attributes["timestamp"] = timestamp | ||
|
||
@CoTProperty | ||
def creatorUid(self): | ||
return self.cot_attributes.get("creatorUid", None) | ||
|
||
@creatorUid.setter | ||
def creatorUid(self, creatorUid=None): | ||
self.cot_attributes["creatorUid"] = creatorUid | ||
|
||
@CoTProperty | ||
def serverTime(self): | ||
return self.cot_attributes.get("serverTime", None) | ||
|
||
@serverTime.setter | ||
def serverTime(self, serverTime=None): | ||
self.cot_attributes["serverTime"] = serverTime | ||
|
||
@CoTProperty | ||
def contentResource(self): | ||
return self.cot_attributes.get("contentResource", None) | ||
|
||
@contentResource.setter | ||
def contentResource(self, contentResource=None): | ||
self.cot_attributes["contentResource"] = contentResource | ||
|
||
@CoTProperty | ||
def detail(self): | ||
return self.cot_attributes.get("detail", None) | ||
|
||
@detail.setter | ||
def detail(self, detail=None): | ||
self.cot_attributes["detail"] = detail |
24 changes: 24 additions & 0 deletions
24
FreeTAKServer/components/core/domain/domain/_mission_cot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from FreeTAKServer.components.core.abstract_component.cot_node import CoTNode | ||
from FreeTAKServer.components.core.abstract_component.cot_property import CoTProperty | ||
|
||
class MissionCOT(CoTNode): | ||
def __init__(self, configuration, model, oid=None): | ||
super().__init__(self.__class__.__name__, configuration, model, oid) | ||
self.cot_attributes["type"] = None | ||
self.cot_attributes["callsign"] = None | ||
|
||
@CoTProperty | ||
def type(self): | ||
return self.cot_attributes.get("type", None) | ||
|
||
@type.setter | ||
def type(self, type=None): | ||
self.cot_attributes["type"] = type | ||
|
||
@CoTProperty | ||
def callsign(self): | ||
return self.cot_attributes.get("callsign", None) | ||
|
||
@callsign.setter | ||
def callsign(self, callsign=None): | ||
self.cot_attributes["callsign"] = callsign |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...er/components/extended/mission/configuration/model_definitions/mission_change_record.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"id": "http://iec.ch/TC57/mission_collection#", | ||
"type": "object", | ||
"properties": | ||
{ | ||
"mission_change_record": | ||
{ | ||
"type": "object", | ||
"anyOf": | ||
[ | ||
{ "$ref": "#/definitions/MissionContent" }, | ||
{ "$ref": "#/definitions/MissionChangeRecord" } | ||
] | ||
} | ||
}, | ||
"definitions": | ||
{ | ||
"MissionChangeRecord" : | ||
{ | ||
"type": "object", | ||
"description" : "", | ||
"properties": | ||
{ | ||
"contentResource": | ||
{ | ||
"$ref" : "#/definitions/MissionContentData", | ||
"minItems" : 0, | ||
"maxItems" : 1 | ||
} | ||
} | ||
}, | ||
"MissionContentData": | ||
{ | ||
"type": "object" | ||
} | ||
} | ||
} |
Binary file added
BIN
+820 Bytes
...ver/components/extended/mission/configuration/model_definitions/mission_content_data.json
Binary file not shown.
94 changes: 94 additions & 0 deletions
94
FreeTAKServer/components/extended/mission/controllers/mission_change_controller.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
from FreeTAKServer.components.extended.mission.controllers.mission_domain_controller import MissionDomainController | ||
from FreeTAKServer.components.extended.mission.controllers.mission_persistence_controller import MissionPersistenceController | ||
from FreeTAKServer.core.configuration.MainConfig import MainConfig | ||
from FreeTAKServer.core.util.serialization_utils import serialize_to_json | ||
from FreeTAKServer.core.util.time_utils import get_dtg | ||
|
||
from digitalpy.core.main.controller import Controller | ||
from digitalpy.core.zmanager.request import Request | ||
from digitalpy.core.zmanager.response import Response | ||
from digitalpy.core.zmanager.action_mapper import ActionMapper | ||
from digitalpy.core.digipy_configuration.configuration import Configuration | ||
from digitalpy.core.parsing.load_configuration import LoadConfiguration | ||
|
||
config = MainConfig.instance() | ||
|
||
class MissionChangeController(Controller): | ||
"""manage mission change requests""" | ||
|
||
def __init__(self, request: Request, response: Response, sync_action_mapper: ActionMapper, configuration: Configuration): | ||
super().__init__(request, response, sync_action_mapper, configuration) | ||
self.domain_controller = MissionDomainController(request, response, sync_action_mapper, configuration) | ||
self.persistence_controller = MissionPersistenceController(request, response, sync_action_mapper, configuration) | ||
|
||
def initialize(self, request, response): | ||
"""initialize the controller""" | ||
super().initialize(request, response) | ||
self.domain_controller.initialize(request, response) | ||
self.persistence_controller.initialize(request, response) | ||
|
||
def execute(self, method=None): | ||
getattr(self, method)(**self.request.get_values()) | ||
return self.response | ||
|
||
def create_mission_record(self, mission_uid, creator_uid): | ||
self.persistence_controller.create_mission_change( | ||
type = "CREATE_MISSION", | ||
mission_uid=mission_uid, | ||
creator_uid=creator_uid, | ||
content_uid=None, | ||
cot_detail_uid=None, | ||
content_resource_uid=None | ||
) | ||
|
||
def create_mission_content_upload_record(self, mission_content_uid, creator_uid, content_uid): | ||
self.persistence_controller.create_mission_change( | ||
type = "ADD_CONTENT", | ||
mission_uid=mission_content_uid, | ||
creator_uid=creator_uid, | ||
content_uid=None, | ||
cot_detail_uid=None, | ||
content_resource_uid=content_uid | ||
) | ||
|
||
def create_mission_cot_record(self, mission_cot_uid, creator_uid, cot_uid): | ||
self.persistence_controller.create_mission_change( | ||
type = "ADD_CONTENT", | ||
mission_uid=mission_cot_uid, | ||
creator_uid=creator_uid, | ||
content_uid=cot_uid, | ||
cot_detail_uid=None, | ||
content_resource_uid=None | ||
) | ||
|
||
def get_mission_changes(self, mission_id, config_loader, *args, **kwargs): | ||
change_collection = self.domain_controller.create_mission_collection(config_loader) | ||
change_collection.type = "MissionChange" | ||
change_collection.version = "3" | ||
change_collection.nodeId = config.nodeID | ||
|
||
mission_changes = self.persistence_controller.get_mission(mission_id).changes | ||
|
||
for change in mission_changes: | ||
change_record = self.domain_controller.create_mission_change_record(config_loader) | ||
change_record.type = change.type | ||
change_record.creatorUid = change.creator_uid | ||
change_record.missionName = change.mission_uid | ||
change_record.serverTime = get_dtg(change.server_time) | ||
change_record.timestamp = get_dtg(change.timestamp) | ||
change_record.contentUid = change.content_uid | ||
|
||
if change.content_resource_uid != None: | ||
mission_content = self.domain_controller.create_mission_content_data(config_loader) | ||
self.request.set_value("objectuid", change.content_resource_uid) | ||
self.request.set_value("objecthash", change.content_resource_uid) | ||
enterprise_sync_db: 'EnterpriseSyncDataObject' = self.execute_sub_action("GetEnterpriseSyncMetaData").get_value("objectmetadata") | ||
|
||
change_record.contentResource = self.domain_controller.complete_mission_content_data(mission_content, enterprise_sync_db) | ||
|
||
change_collection.data = change_record | ||
|
||
serialized_change_collections = serialize_to_json(change_collection, self.request, self.execute_sub_action) | ||
|
||
self.response.set_value("mission_changes", serialized_change_collections) | ||
return serialized_change_collections |
Oops, something went wrong.