-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial health component with CreateHealth action
- Loading branch information
Showing
18 changed files
with
634 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,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 .health_action_mapper import HealthActionMapper as ActionMapper |
11 changes: 11 additions & 0 deletions
11
DigitalPyHelloWorld/components/health/base/health_action_mapper.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,11 @@ | ||
"""This is the Mission component action mapper.""" | ||
from digitalpy.core.zmanager.impl.default_action_mapper import DefaultActionMapper | ||
|
||
|
||
class HealthActionMapper(DefaultActionMapper): | ||
"""This is the Mission 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. | ||
""" |
10 changes: 10 additions & 0 deletions
10
DigitalPyHelloWorld/components/health/base/health_domain.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,10 @@ | ||
""" This file contains the Domain class for the health component. This class | ||
is to be used for all interactions with the health domain model. This class | ||
exposes and handles all domain model functions. | ||
""" | ||
|
||
|
||
class HealthDomain(): | ||
"""This class is to be used for all interactions with the health | ||
domain model. This class exposes and handles all domain model functions. | ||
""" |
Empty file.
10 changes: 10 additions & 0 deletions
10
DigitalPyHelloWorld/components/health/configuration/external_action_mapping.ini
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,10 @@ | ||
[actionmapping] | ||
?CreateHealth?post = components.health.health_facade.HealthFacade.CreateHealth_post | ||
|
||
?RetrieveHealth?get = components.health.health_facade.HealthFacade.RetrieveHealth_get | ||
|
||
?ListHealth?get = components.health.health_facade.HealthFacade.ListHealth_get | ||
|
||
?UpdateHealth?put = components.health.health_facade.HealthFacade.UpdateHealth_put | ||
|
||
?DeleteHealth?delete = components.health.health_facade.HealthFacade.DeleteHealth_delete |
30 changes: 30 additions & 0 deletions
30
DigitalPyHelloWorld/components/health/configuration/health_constants.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,30 @@ | ||
""" this file contains all the constants used in the component """ | ||
|
||
import pathlib | ||
|
||
from string import Template | ||
|
||
COMPONENT_NAME = "health" | ||
|
||
CONFIGURATION_FORMAT = "json" | ||
|
||
CURRENT_COMPONENT_PATH = pathlib.Path(__file__).absolute().parent.parent | ||
|
||
ACTION_MAPPING_PATH = CURRENT_COMPONENT_PATH / \ | ||
"configuration/external_action_mapping.ini" | ||
|
||
INTERNAL_ACTION_MAPPING_PATH = CURRENT_COMPONENT_PATH / \ | ||
"configuration/internal_action_mapping.ini" | ||
|
||
LOGGING_CONFIGURATION_PATH = CURRENT_COMPONENT_PATH / "configuration/logging.conf" | ||
|
||
LOG_FILE_PATH = CURRENT_COMPONENT_PATH / "logs" | ||
|
||
MANIFEST_PATH = CURRENT_COMPONENT_PATH / "configuration/manifest.ini" | ||
|
||
CONFIGURATION_PATH_TEMPLATE = Template( | ||
str(CURRENT_COMPONENT_PATH / "configuration/model_definitions/$message_type") + | ||
f".{CONFIGURATION_FORMAT}" | ||
) | ||
|
||
HEALTH = "health" |
21 changes: 21 additions & 0 deletions
21
DigitalPyHelloWorld/components/health/configuration/manifest.ini
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,21 @@ | ||
[healthManifest] | ||
; universally unique identifier (UUID) Version 1 | ||
UUID = h8170b8a-6675-11fd-9022-0242ac152247 | ||
; Name of this component | ||
name = health | ||
; progressive version of the component in major.minor format | ||
version = 1.0.0 | ||
; Aphrodite DigitalPy version this component is build for | ||
requiredAlfaVersion= 0.3.13.7 | ||
; short description of the component | ||
description = "Maintains a list of health records." | ||
; name of the component's author | ||
author="FreeTAKTeam" | ||
; email of the author | ||
author_email="[email protected]" | ||
; location of the project for the component | ||
url="https://github.com/FreeTAKTeam/DigtalPyHelloWorld" | ||
; Location of the release of this component | ||
repo = https://pypi.org/project/DigtalPyHelloWorld/ | ||
; software license for this component | ||
license = EPL |
Binary file added
BIN
+10.9 KB
DigitalPyHelloWorld/components/health/configuration/model_definitions/HealthClasses.json
Binary file not shown.
Empty file.
40 changes: 40 additions & 0 deletions
40
DigitalPyHelloWorld/components/health/controller/health_management_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,40 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from digitalpy.core.main.controller import Controller | ||
from ..domain.builder.health_builder import HealthBuilder | ||
|
||
if TYPE_CHECKING: | ||
from digitalpy.core.digipy_configuration.configuration import Configuration | ||
from digitalpy.core.zmanager.impl.default_action_mapper import DefaultActionMapper | ||
from digitalpy.core.zmanager.request import Request | ||
from digitalpy.core.zmanager.response import Response | ||
from digitalpy.core.domain.domain.network_client import NetworkClient | ||
|
||
|
||
class HealthManagementController(Controller): | ||
|
||
def __init__(self, request: 'Request', | ||
response: 'Response', | ||
sync_action_mapper: 'DefaultActionMapper', | ||
configuration: 'Configuration'): | ||
super().__init__(request, response, sync_action_mapper, configuration) | ||
self.health_builder = HealthBuilder(request, response, sync_action_mapper, configuration) | ||
|
||
def initialize(self, request: 'Request', response: 'Response'): | ||
"""This function is used to initialize the controller. | ||
It is intiated by the service manager.""" | ||
self.health_builder.initialize(request, response) | ||
return super().initialize(request, response) | ||
|
||
def CreateHealth_post(self, client: 'NetworkClient', data: bytes, config_loader, *args, **kwargs): # pylint: disable=unused-argument | ||
"""This function is used to handle inbound messages from a service and send a | ||
response back to the service.""" | ||
|
||
self.health_builder.build_empty_object(config_loader) | ||
self.health_builder.add_object_data(data) | ||
health_obj = self.health_builder.get_result() | ||
|
||
# list type as only lists are supported for this parameter | ||
self.response.set_value("message", [health_obj]) | ||
self.response.set_value("recipients", [str(client.get_oid())]) | ||
self.response.set_action("publish") |
Empty file.
Empty file.
31 changes: 31 additions & 0 deletions
31
DigitalPyHelloWorld/components/health/domain/builder/health_builder.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,31 @@ | ||
from digitalpy.core.domain.builder import Builder | ||
from ...configuration.health_constants import HEALTH | ||
from ...domain.model.health import Health | ||
from ...domain.model.contact import Contact | ||
|
||
|
||
class HealthBuilder(Builder): | ||
"""Builds a health object""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.result: Health = None # type: ignore | ||
|
||
def build_empty_object(self, config_loader, *args, **kwargs): # pylint: disable=unused-argument | ||
"""Builds a Health object""" | ||
self.request.set_value("object_class_name", "Health") | ||
|
||
configuration = config_loader.find_configuration(HEALTH) | ||
|
||
self.result = super()._create_model_object( | ||
configuration, extended_domain={"Health": Health, "Contact": Contact}) | ||
|
||
def add_object_data(self, mapped_object: bytes): | ||
"""adds the data from the mapped object to the Health object """ | ||
self.request.set_value("model_object", self.result) | ||
self.request.set_value("message", mapped_object) | ||
self.execute_sub_action("deserialize") | ||
|
||
def get_result(self): | ||
"""gets the result of the builder""" | ||
return self.result |
Empty file.
Oops, something went wrong.