Change the constructor to detect whether there are compositions (by checking the…
- User
Change the constructor to detect whether there are compositions (by checking the it_source table) and generate relations.
Code: CLASS zbc_uml_class DEFINITION INHERITING FROM zbc_uml_element PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
"! This is the constructor of the class "! @parameter io_renderer | The renderer object "! @parameter is_class | The class to render METHODS constructor IMPORTING io_renderer TYPE REF TO zbc_uml_renderer is_class TYPE cl_uml_class_scanner=>uml_line it_source TYPE string_t. METHODS render REDEFINITION. METHODS get_attributes RETURNING VALUE(rt_attributes) TYPE zbc_uml_attribute_t. METHODS get_methods RETURNING VALUE(rt_methods) TYPE zbc_uml_method_t. METHODS get_relations RETURNING VALUE(rt_relations) TYPE zbc_uml_relation_t.PROTECTED SECTION. DATA gt_attributes TYPE zbc_uml_attribute_t.
DATA gt_methods TYPE zbc_uml_method_t. DATA gt_relations TYPE zbc_uml_relation_t.PRIVATE SECTION. ENDCLASS.
CLASS zbc_uml_class IMPLEMENTATION.
METHOD constructor.
super->constructor( iv_kind = zbc_uml_entity=>cs_kinds-class io_renderer = io_renderer iv_name = '' && is_class-name iv_type = '' iv_visibility = '' && is_class-visibility iv_is_static = '' iv_is_abstract = is_class-is_abstract iv_description = '' && is_class-description ). LOOP AT is_class-t_attributes INTO DATA(ls_attribute) WHERE type_kind <> 'v'. IF ls_attribute-is_aggregation = abap_true OR ls_attribute-is_association = abap_true. DATA(lv_relation_type) = COND #( WHEN ls_attribute-is_aggregation = abap_true THEN zbc_uml_relation=>cs_types-aggregation ELSE zbc_uml_relation=>cs_types-association ). APPEND NEW zbc_uml_relation( io_renderer = io_renderer iv_from = '' && ls_attribute-type iv_to = '' && is_class-name iv_type = lv_relation_type iv_description = '' ) TO gt_relations. ENDIF. APPEND NEW zbc_uml_attribute( io_renderer = io_renderer is_attribute = ls_attribute ) TO gt_attributes. ENDLOOP. LOOP AT is_class-t_methods INTO DATA(ls_method). APPEND NEW zbc_uml_method( io_renderer = io_renderer is_method = ls_method ) TO gt_methods. ENDLOOP. IF is_class-supertype IS NOT INITIAL. APPEND NEW zbc_uml_relation( io_renderer = io_renderer iv_from = '' && is_class-name iv_to = '' && is_class-supertype iv_type = zbc_uml_relation=>cs_types-inheritance iv_description = '' ) TO gt_relations. ENDIF.ENDMETHOD.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.