Internal Structure

1. Class Representation

class microesb.microesb.JSONTransformer[source]

Bases: object

JSON transformer class.

Provides JSON transformation functionality for class hierarchies.

__init__()[source]
Variables:

_json_dict (dict) – recursive internal properties processing dict

json_transform()[source]

json_transform() method.

Recursively generate _json_dict for complete object hierarchy.

Iterates through all elements in the hierarchy and calls set_json_dict() on each to populate their json_dict representation.

property json

json() method.

Returns:

json.dumps(self._json_dict)

Return type:

str (json dump)

Decorated with @property so direct property access possible

property json_dict

json_dict() method.

Returns:

self._json_dict

Return type:

dict

Decorated with @property so direct property access possible

class microesb.microesb.BaseHandler[source]

Bases: JSONTransformer

Abstract Base Class (ABC) Meta Class.

__init__()[source]
Variables:
  • logger (classref) – logging logger reference

  • _SYSProperties (dict[SYSProperties]) – internal properties processing dict

  • _SYSParentObject (classref) – internal (hierarchical) class instance ref

  • _SYSClassNames (list[classname]) – internal class names dict

abstract _add_class()[source]

Abstract _add_class() method.

abstract set_properties()[source]

Abstract set_properties() method.

iterate()[source]

Recursive iterate through hierarchical class instances.

Returns:

generator yielding class instances in hierarchy

Return type:

generator

add_properties(properties, parent_instance)[source]

add_properties() method.

Parameters:
  • properties (dict) – system properties dictionary

  • parent_instance (classref) – parent class instance reference

The ClassMapper recursively adds instance properties by calling add_properties() method on initialization for each existing class instance.

_add_sys_default_properties(properties)[source]

_add_sys_default_properties() method.

Parameters:

properties (dict) – system properties dictionary

Enhance (add) system default properties dictionary by properties dict defined inside this method.

Currently ‘SYSServiceMethod’ is the only system property added.

Returns:

properties

Return type:

dict

_register_property(property_id, property_item)[source]

_register_property() method.

Parameters:
  • property_id (str) – property id (internal class attribute name)

  • property_item (dict) – property item to be registered for internal processing only

Modifying data internally (inside a Service-Implementation) requires setting additional properties not defined in Service-Properties, e.g. generated data, time-stamps or similar.

Use this private method for this purpose.

_set_property(property_id, value)[source]

_set_property() method.

Parameters:
  • property_id (str) – property dict key

  • value (str) – property value

property parent_object

parent_object() method.

Returns:

self._SYSParentObject

Return type:

classref

Decorated with @property so direct property access possible

property properties

properties() method.

Returns:

self._SYSProperties

Return type:

dict

Decorated with @property so direct property access possible

property property_dict

property_dict() method.

Return all classes self._SYSProperties property_id, value dictionary.

Returns:

dictionary of all properties excluding ‘SYSServiceMethod’

Return type:

dict

Decorated with @property so direct property access possible

property class_count

class_count() method.

Returns:

len(self._SYSClassNames)

Return type:

int

Decorated with @property so direct property access possible

property class_name

class_name() method.

Returns:

self.__class__.__name__

Return type:

str

Decorated with @property so direct property access possible

get_value_by_property_id(property_id)[source]

get_value_by_property_id() method.

Parameters:

property_id (str) – property identifier

Returns:

attribute value for given property_id

Return type:

dynamic

class microesb.microesb.ClassHandler[source]

Bases: BaseHandler

ClassHandler class. Inherits BaseHandler class.

__init__()[source]
Variables:
  • _SYSType (str) – const internal system type to differentiate handler types

  • _ServiceRouter (classref) – ServiceRouter instance reference

__add__(args)[source]

overloaded internal __add__() method (+ operator).

Parameters:

args (dict) – class setup dictionary

_add_class() “wrapper” primary used for ClassMapper.

>>> args = {
>>>     'class_name': class_name,
>>>     'class_ref': class_ref
>>> }
>>> class_instance + args
__iter__()[source]

overloaded internal __iter__() method.

Overloaded for using iter() on class references.

Returns:

generator yielding class instances from _SYSClassNames

Return type:

generator

_add_class(*, class_name, class_ref)[source]

_add_class() method.

Parameters:
  • * (dict) – used for passing params as **args dictionary

  • class_name (str) – class name

  • class_ref (classref) – class instance reference name

Append class_name to self._SYSClassNames. Setup new class instance in global namespace.

Primary called by overloaded __add__() method.

set_properties(item_dict)[source]

set_properties() method.

Parameters:

item_dict (dict) – properties dictionary

Iterates over item_dict and calls self._set_property(property_id, value) foreach item.

set_json_dict()[source]

set_json_dict() method.

Propagate self.json_dict with current class instance attribute values (self._SYSProperties) and with empty (None) class instance references (processed from JSONTransformer).

Removes ‘SYSServiceMethod’ from json_dict and initializes child class references to None.

class microesb.microesb.MultiClassHandler[source]

Bases: BaseHandler

MultiObject handler class.

__init__()[source]
Variables:
  • _SYSType (str) – const internal system type to differentiate handler types

  • _object_container (list[object]) – object instance container

__iter__()[source]

overloaded internal __iter__() method.

Overloaded for using iter() on class references.

Returns:

generator yielding class instances from _object_container

Return type:

generator

_add_class()[source]

_add_class() method.

Returns:

instance

Return type:

object instance

Setup class instance and append it to self._object_container.

set_properties(property_list)[source]

set_properties() method.

Parameters:

property_list (list) – properties dictionary

Setup class instance and append it to self._object_container.

set_json_dict()[source]

set_json_dict() method.

Prepare self.json_dict from self._object_container.

Iterates through all instances in _object_container and appends their json_dict to create a list. Removes empty entries.

set_instance_json_dict()[source]

set_instance_json_dict() method.

Prepare self.json_dict from self._SYSProperties (used by JSONTransformer).

Extracts all property values and populates json_dict, ignoring any errors from missing or inaccessible attributes.

class microesb.microesb.ClassMapper(*, class_references, class_mappings, class_properties)[source]

Bases: ClassHandler

Class Mapper class.

__init__(*, class_references, class_mappings, class_properties)[source]
Parameters:
  • * (dict) – used for passing params as **args dictionary

  • class_references (dict) – class references dictionary

  • class_mappings (dict) – class mappings dictionary

  • class_properties (dict) – class properties dictionary

Variables:
  • _class_mappings (dict) – set from class_mappings param

  • _class_properties (dict) – set from class_properties param

  • _class_references (dict) – set from class_references param

  • _class_hierarchy (dict) – internally used to map parent instances

_get_mapping(class_name)[source]

_get_mapping() method.

Parameters:

class_name (str) – mapping class_name

Returns:

self._class_mappings[class_name]

Return type:

str

Get class name from class_mappings dictionary by class_name.

get_references()[source]

get_references() method.

Returns:

self._class_references

Return type:

dict

Get class references dictionary.

get_class_hierarchy()[source]

get_class_hierarchy() method.

Returns:

self._class_hierarchy

Return type:

dict

Get class hierarchy dictionary.

_map(*, class_name, property_ref, parent_instance, children={})[source]

_map() method.

Parameters:
  • * (dict) – used for passing params as **args dictionary

  • class_name (str) – (root) class name

  • property_ref (dict) – property reference dictionary

  • parent_instance (classref) – object reference

  • children (dict) – children definition dictionary

Recursive map class hierarchy / class instances.

class microesb.microesb.ServiceMapper(*, class_mapper, service_call_data)[source]

Bases: ClassHandler

Service Mapper class.

__init__(*, class_mapper, service_call_data)[source]
Parameters:
  • * (dict) – used for passing params as **args dictionary

  • class_mapper (classref) – class mapper instance reference

  • service_call_data (dict) – service call metadata dictionary

Variables:

_class_mapper (classref) – set from class_mapper param

_map(*, class_name, parent_instance, hierarchy, children={}, property_ref=None)[source]

_map() method.

Parameters:
  • * (dict) – used for passing params as **args dictionary

  • class_name (str) – (root) class name

  • parent_instance (classref) – property reference dictionary

  • hierarchy (dict) – (root) class setup item

  • children (dict) – children definition dictionary

  • property_ref (dict) – property reference dictionary

Recursive process class hierarchy / service properties mapping.

class microesb.microesb.ServiceExecuter[source]

Bases: object

Service Executer class.

__init__()[source]
Variables:
  • logger (classref) – logging logger reference

  • _cm_ref (classref) – class mapper reference

  • _con_ref_dict (dict) – connection reference dictionary

  • _class_hierarchy (dict) – class hierarchy dictionary

  • _class_hierarchy_list (list) – list of class hierarchy items

  • _hierarchy_level (int) – current hierarchy level counter

  • _map_hierarchy_level (int) – mapping hierarchy level counter

  • _class_hierarchy_comp (dict) – class hierarchy comparison dictionary

  • _hierarchy_level_comp (int) – hierarchy level comparison counter

execute(class_mapper, service_data)[source]

execute() method.

Execute service calls by creating ServiceMapper instances for each data item.

Parameters:
  • class_mapper (classref) – class mapper instance reference

  • service_data (dict) – data dictionary with ‘data’ key containing list of items

Returns:

list of ServiceMapper instances

Return type:

list

execute_get_hierarchy(class_mapper, service_data)[source]

execute_get_hierarchy() method.

Execute service calls and return connected class hierarchies with json_dicts.

Parameters:
  • class_mapper (classref) – class mapper instance reference

  • service_data (dict) – data dictionary with ‘data’ key containing list of items

Returns:

list of connected class hierarchy dictionaries

Return type:

list

_connect_hierarchy(class_mapper_ref)[source]

_connect_hierarchy() method.

Init method for connecting all generated json_dicts.

Parameters:

class_mapper_ref (classref) – class mapper instance reference

Returns:

connected class hierarchy reference dictionary

Return type:

dict

_map_object_instances(ref_dict)[source]

_map_object_instances() method.

Recursively map object instances to reference dictionary and perform JSON transform on root.

Parameters:

ref_dict (dict) – reference dictionary to process

_connect_hierarchy_recursive(reference_dict, parent_class=None, parent_dict=None)[source]

_connect_hierarchy_recursive() method.

Recursively connect all generated json_dicts to their parents.

Parameters:
  • reference_dict (dict) – reference dictionary to process

  • parent_class (str) – parent class name (optional)

  • parent_dict (dict) – parent dictionary reference (optional)

_rename_dict_key(rename_dict, parent_dict=None, parent_class=None)[source]

_rename_dict_key() method.

Recursively rename ‘children’ keys to ‘children_processed’ when hierarchy matches.

Parameters:
  • rename_dict (dict) – dictionary to process

  • parent_dict (dict) – parent dictionary reference (optional)

  • parent_class (str) – parent class name (optional)