Commit 5c437417 authored by Michael Thies's avatar Michael Thies
Browse files

Merge branch fix/data_type_iec6360_concept_description with refs/heads/master...

Merge branch fix/data_type_iec6360_concept_description with refs/heads/master into refs/merge-requests/56/train
parents 90d2f167 b4c49715
Pipeline #340047 passed with stage
in 49 seconds
...@@ -414,8 +414,9 @@ class AASFromJsonDecoder(json.JSONDecoder): ...@@ -414,8 +414,9 @@ class AASFromJsonDecoder(json.JSONDecoder):
object_class=model.concept.IEC61360ConceptDescription)\ object_class=model.concept.IEC61360ConceptDescription)\
-> model.concept.IEC61360ConceptDescription: -> model.concept.IEC61360ConceptDescription:
ret = object_class(identification=cls._construct_identifier(_get_ts(dct, 'identification', dict)), ret = object_class(identification=cls._construct_identifier(_get_ts(dct, 'identification', dict)),
preferred_name=cls._construct_lang_string_set(_get_ts(data_spec, 'preferredName', list)), preferred_name=cls._construct_lang_string_set(_get_ts(data_spec, 'preferredName', list)))
data_type=IEC61360_DATA_TYPES_INVERSE[_get_ts(data_spec, 'dataType', str)]) if 'dataType' in data_spec:
ret.data_type = IEC61360_DATA_TYPES_INVERSE[_get_ts(data_spec, 'dataType', str)]
if 'definition' in data_spec: if 'definition' in data_spec:
ret.definition = cls._construct_lang_string_set(_get_ts(data_spec, 'definition', list)) ret.definition = cls._construct_lang_string_set(_get_ts(data_spec, 'definition', list))
if 'shortName' in data_spec: if 'shortName' in data_spec:
......
...@@ -275,10 +275,11 @@ def append_iec61360_concept_description_attrs(obj: model.concept.IEC61360Concept ...@@ -275,10 +275,11 @@ def append_iec61360_concept_description_attrs(obj: model.concept.IEC61360Concept
ConceptDescription, but we want to generate compliant JSON documents. So, we fake the JSON structure of an object ConceptDescription, but we want to generate compliant JSON documents. So, we fake the JSON structure of an object
with dataSpecifications. with dataSpecifications.
""" """
data_spec = { data_spec: Dict[str, object] = {
'preferredName': lang_string_set_to_json(obj.preferred_name), 'preferredName': lang_string_set_to_json(obj.preferred_name)
'dataType': _generic.IEC61360_DATA_TYPES[obj.data_type],
} }
if obj.data_type is not None:
data_spec['dataType'] = _generic.IEC61360_DATA_TYPES[obj.data_type]
if obj.definition is not None: if obj.definition is not None:
data_spec['definition'] = lang_string_set_to_json(obj.definition) data_spec['definition'] = lang_string_set_to_json(obj.definition)
if obj.short_name is not None: if obj.short_name is not None:
......
...@@ -929,8 +929,10 @@ def _construct_iec61360_concept_description(element: etree.Element, failsafe: bo ...@@ -929,8 +929,10 @@ def _construct_iec61360_concept_description(element: etree.Element, failsafe: bo
cd = model.IEC61360ConceptDescription( cd = model.IEC61360ConceptDescription(
identifier, identifier,
_child_construct_mandatory(element, NS_IEC + "preferredName", _construct_lang_string_set, namespace=NS_IEC), _child_construct_mandatory(element, NS_IEC + "preferredName", _construct_lang_string_set, namespace=NS_IEC),
_child_text_mandatory_mapped(element, NS_IEC + "dataType", IEC61360_DATA_TYPES_INVERSE)
) )
data_type = _get_text_mapped_or_none(element.find(NS_IEC + "dataType"), IEC61360_DATA_TYPES_INVERSE)
if data_type is not None:
cd.data_type = data_type
definition = _failsafe_construct(element.find(NS_IEC + "definition"), _construct_lang_string_set, failsafe, definition = _failsafe_construct(element.find(NS_IEC + "definition"), _construct_lang_string_set, failsafe,
namespace=NS_IEC) namespace=NS_IEC)
if definition is not None: if definition is not None:
......
...@@ -140,7 +140,7 @@ class IEC61360ConceptDescription(ConceptDescription): ...@@ -140,7 +140,7 @@ class IEC61360ConceptDescription(ConceptDescription):
def __init__(self, def __init__(self,
identification: base.Identifier, identification: base.Identifier,
preferred_name: base.LangStringSet, preferred_name: base.LangStringSet,
data_type: IEC61360DataType, data_type: Optional[IEC61360DataType] = None,
definition: Optional[base.LangStringSet] = None, definition: Optional[base.LangStringSet] = None,
short_name: Optional[base.LangStringSet] = None, short_name: Optional[base.LangStringSet] = None,
is_case_of: Optional[Set[base.Reference]] = None, is_case_of: Optional[Set[base.Reference]] = None,
...@@ -190,7 +190,7 @@ class IEC61360ConceptDescription(ConceptDescription): ...@@ -190,7 +190,7 @@ class IEC61360ConceptDescription(ConceptDescription):
super().__init__(identification, is_case_of, id_short, category, description, parent, administration) super().__init__(identification, is_case_of, id_short, category, description, parent, administration)
self.preferred_name: base.LangStringSet = preferred_name self.preferred_name: base.LangStringSet = preferred_name
self.short_name: Optional[base.LangStringSet] = short_name self.short_name: Optional[base.LangStringSet] = short_name
self.data_type: IEC61360DataType = data_type self.data_type: Optional[IEC61360DataType] = data_type
self.definition: Optional[base.LangStringSet] = definition self.definition: Optional[base.LangStringSet] = definition
self.unit: Optional[str] = unit self.unit: Optional[str] = unit
self.unit_id: Optional[base.Reference] = unit_id self.unit_id: Optional[base.Reference] = unit_id
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment