From 96cd546c7ee129fb63180107f8623aab3dfe0923 Mon Sep 17 00:00:00 2001 From: Albert Mink Date: Tue, 5 Jul 2022 08:54:47 +0200 Subject: [PATCH] [AFF] Get data for serialization from the DB (#5670) * [AFF] Get data for serialization from the DB This is definitely not 7.02 syntax. Contributes to #5658 * is this 7.02 syntax? * WIP: inlide data declaration * declare locale variable FIELD-SYMBOL * multiple statements -> line break; local variable * one more FIELD0-SYMBOL * fix redundant `this` * WIP: streamline data types * WIP: streamline data types and typos * add const to abaplint config * rm commended code line * add const to abaplint config * WIP: SELECT follows 7.02 syntax * space before dot * WIP: SELECT 7.02 * linter constants * WIP: finish SELECT 7.02 * Update src/objects/zcl_abapgit_object_intf.clas.locals_imp.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * add ci/abaplint CONST * more CONST to ci/abaplint Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> --- abaplint.json | 7 + ci/abaplint.json | 7 + ...l_abapgit_object_intf.clas.locals_imp.abap | 441 +++++++++++++++++- 3 files changed, 450 insertions(+), 5 deletions(-) diff --git a/abaplint.json b/abaplint.json index 35937afba..1087eb0ca 100644 --- a/abaplint.json +++ b/abaplint.json @@ -34,6 +34,10 @@ "seok_access_free", "seok_access_modify", "seok_pgmid_r3tr", + "seoo_cmptype_type", + "seoo_cmptype_event", + "seoo_cmptype_method", + "seoo_cmptype_attribute", "seop_ext_class_locals_def", "seop_ext_class_locals_imp", "seop_ext_class_macros", @@ -42,6 +46,9 @@ "seop_incextapp_implementation", "seop_incextapp_macros", "seop_incextapp_testclasses", + "seos_scotype_exception", + "seos_scotype_parameter", + "seox_true", "sews_c_vif_version", "skwfc_obtype_folder", "skwfc_obtype_loio", diff --git a/ci/abaplint.json b/ci/abaplint.json index e073c7bfd..a221b2e91 100644 --- a/ci/abaplint.json +++ b/ci/abaplint.json @@ -47,6 +47,10 @@ "seok_access_free", "seok_access_modify", "seok_pgmid_r3tr", + "seoo_cmptype_type", + "seoo_cmptype_event", + "seoo_cmptype_method", + "seoo_cmptype_attribute", "seop_ext_class_locals_def", "seop_ext_class_locals_imp", "seop_ext_class_macros", @@ -55,6 +59,9 @@ "seop_incextapp_implementation", "seop_incextapp_macros", "seop_incextapp_testclasses", + "seos_scotype_exception", + "seos_scotype_parameter", + "seox_true", "sews_c_vif_version", "skwfc_obtype_folder", "skwfc_obtype_loio", diff --git a/src/objects/zcl_abapgit_object_intf.clas.locals_imp.abap b/src/objects/zcl_abapgit_object_intf.clas.locals_imp.abap index 5b9868059..65d10a694 100644 --- a/src/objects/zcl_abapgit_object_intf.clas.locals_imp.abap +++ b/src/objects/zcl_abapgit_object_intf.clas.locals_imp.abap @@ -1,6 +1,421 @@ -*"* use this source file for the definition and implementation of -*"* local helper classes, interface definitions and type -*"* declarations +CLASS lcl_aff_helper DEFINITION. + PUBLIC SECTION. + CLASS-METHODS: create_empty_interface + IMPORTING iv_intf_name TYPE seoclsname + io_lock_handle TYPE REF TO if_adt_lock_handle + RAISING zcx_abapgit_exception, + generate_class_pool + IMPORTING iv_class_name TYPE seoclsname, + get_descriptions_compo_subco + IMPORTING iv_language TYPE sy-langu + iv_clif_name TYPE seoclsname + RETURNING VALUE(rs_properties) TYPE zif_abapgit_aff_oo_types_v1=>ty_descriptions , + get_descr_comp_subc_w_exposure + IMPORTING iv_language TYPE sy-langu + iv_clif_name TYPE seoclsname + iv_exposure TYPE seoexpose DEFAULT seoc_exposure_public + RETURNING VALUE(rs_properties) TYPE zif_abapgit_aff_oo_types_v1=>ty_descriptions , + set_descriptions_compo_subco + IMPORTING iv_clif_name TYPE seoclsname + iv_language TYPE langu + is_properties TYPE zif_abapgit_aff_oo_types_v1=>ty_descriptions . + PRIVATE SECTION. + TYPES: + BEGIN OF ty_component, + visibility TYPE seoexpose, + cmpname TYPE seocmpname, + descript TYPE seodescr, + cmptype TYPE seocmptype, + END OF ty_component, + BEGIN OF ty_sub_component, + cmpname TYPE seocmpname, + sconame TYPE seosconame, + descript TYPE seodescr, + scotype TYPE seoscotype, + END OF ty_sub_component, + ty_compontents TYPE STANDARD TABLE OF ty_component, + ty_sub_compontents TYPE STANDARD TABLE OF ty_sub_component. + + CLASS-METHODS: + get_attributes + IMPORTING is_components TYPE ty_compontents + RETURNING VALUE(rs_result) TYPE zif_abapgit_aff_oo_types_v1=>ty_component_descriptions, + get_methods + IMPORTING is_components TYPE ty_compontents + is_sub_components TYPE ty_sub_compontents + RETURNING VALUE(rs_result) TYPE zif_abapgit_aff_oo_types_v1=>ty_methods, + get_types + IMPORTING is_components TYPE ty_compontents + RETURNING VALUE(rs_result) TYPE zif_abapgit_aff_oo_types_v1=>ty_component_descriptions, + get_events + IMPORTING is_components TYPE ty_compontents + is_sub_components TYPE ty_sub_compontents + RETURNING VALUE(rs_result) TYPE zif_abapgit_aff_oo_types_v1=>ty_events, + set_methods + IMPORTING iv_clif_name TYPE seoclsname + iv_language TYPE langu + is_properties TYPE zif_abapgit_aff_oo_types_v1=>ty_descriptions, + set_attributes + IMPORTING iv_clif_name TYPE seoclsname + iv_language TYPE langu + is_properties TYPE zif_abapgit_aff_oo_types_v1=>ty_descriptions, + set_events + IMPORTING iv_clif_name TYPE seoclsname + iv_language TYPE langu + is_properties TYPE zif_abapgit_aff_oo_types_v1=>ty_descriptions, + set_types + IMPORTING iv_clif_name TYPE seoclsname + iv_language TYPE langu + is_properties TYPE zif_abapgit_aff_oo_types_v1=>ty_descriptions . +ENDCLASS. + + +CLASS lcl_aff_helper IMPLEMENTATION. + + + METHOD create_empty_interface. + DATA: + lo_interface_error TYPE string, + ls_empty_interface TYPE vseointerf. + + ls_empty_interface-clsname = iv_intf_name. + ls_empty_interface-version = seoc_version_active. + ls_empty_interface-langu = sy-langu. + ls_empty_interface-descript = space. + ls_empty_interface-state = seoc_state_implemented. + ls_empty_interface-exposure = seoc_exposure_public. + + CALL FUNCTION 'SEO_INTERFACE_CREATE_COMPLETE' + EXPORTING + version = seoc_version_active + suppress_corr = abap_true + lock_handle = io_lock_handle + CHANGING + interface = ls_empty_interface + EXCEPTIONS + OTHERS = 1. + IF sy-subrc <> 0. + IF sy-msgid IS NOT INITIAL. + MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lo_interface_error. + ELSE. + lo_interface_error = 'Internal error'. + ENDIF. + " todo: raise exception here + ENDIF. + ENDMETHOD. + + + METHOD generate_class_pool. + DATA: + lo_cifkey TYPE seoclskey. + + lo_cifkey-clsname = iv_class_name. + PERFORM set_wbinactive IN PROGRAM saplseok USING ' '. + CALL FUNCTION 'SEO_WBINACTIVE_BROADCAST' + EXPORTING + wbia = ' '. + CALL FUNCTION 'SEO_CLIF_SET_WBINACTIVE' + EXPORTING + wbia = ' '. + + CALL FUNCTION 'SEO_BUFFER_REFRESH' + EXPORTING + cifkey = lo_cifkey + version = seoc_version_active. + + CALL FUNCTION 'SEO_BUFFER_REFRESH' + EXPORTING + cifkey = lo_cifkey + version = seoc_version_inactive. + + CALL FUNCTION 'SEO_CLASS_GENERATE_CLASSPOOL' + EXPORTING + clskey = lo_cifkey + suppress_corr = seox_true + EXCEPTIONS + OTHERS = 1 ##FM_SUBRC_OK. + ENDMETHOD. + + + METHOD get_descr_comp_subc_w_exposure. + DATA: + lt_components TYPE ty_compontents, + lt_sub_components TYPE ty_sub_compontents. + + + SELECT df~exposure AS visibility component~cmpname component_text~descript component~cmptype + INTO TABLE lt_components + FROM seocompo AS component + LEFT OUTER JOIN seocompotx AS component_text + ON component~cmpname = component_text~cmpname AND component~clsname = component_text~clsname AND + component_text~langu = iv_language + INNER JOIN seocompodf AS df + ON component~clsname = df~clsname AND + component~cmpname = df~cmpname + WHERE component~clsname = iv_clif_name AND + df~exposure = iv_exposure. "#EC CI_BUFFJOIN + + SELECT sub_component~cmpname sub_component~sconame sub_component_text~descript sub_component~scotype + INTO TABLE lt_sub_components + FROM seosubco AS sub_component JOIN seosubcotx AS sub_component_text + ON sub_component~clsname = sub_component_text~clsname + AND sub_component~cmpname = sub_component_text~cmpname + AND sub_component~sconame = sub_component_text~sconame + INNER JOIN seocompodf AS df + ON sub_component~clsname = df~clsname AND + sub_component~cmpname = df~cmpname + WHERE sub_component~clsname = iv_clif_name + AND df~exposure = iv_exposure + AND sub_component_text~langu = iv_language + AND sub_component_text~descript <> space. "#EC CI_BUFFJOIN + + + + rs_properties-attributes = get_attributes( lt_components ). + rs_properties-methods = get_methods( is_components = lt_components + is_sub_components = lt_sub_components ). + rs_properties-events = get_events( is_components = lt_components + is_sub_components = lt_sub_components ). + rs_properties-types = get_types( lt_components ). + ENDMETHOD. + + + METHOD get_descriptions_compo_subco. + TYPES: + BEGIN OF ty_helper_type, + cmpname TYPE seocmpname, + descript TYPE seodescr, + cmptype TYPE seocmptype, + END OF ty_helper_type. + DATA: + lt_components TYPE STANDARD TABLE OF ty_helper_type, + lt_sub_components TYPE ty_sub_compontents, + lt_components_exp TYPE ty_compontents. + + + SELECT component~cmpname component_text~descript component~cmptype + INTO TABLE lt_components + FROM seocompo AS component + LEFT OUTER JOIN seocompotx AS component_text + ON component~cmpname = component_text~cmpname AND component~clsname = component_text~clsname + AND component_text~langu = iv_language + WHERE component~clsname = iv_clif_name. "#EC CI_BUFFJOIN + + SELECT sub_component~cmpname sub_component~sconame sub_component_text~descript sub_component~scotype + INTO TABLE lt_sub_components + FROM seosubco AS sub_component JOIN seosubcotx AS sub_component_text + ON sub_component~clsname = sub_component_text~clsname + AND sub_component~cmpname = sub_component_text~cmpname + AND sub_component~sconame = sub_component_text~sconame + WHERE sub_component~clsname = iv_clif_name + AND sub_component_text~langu = iv_language + AND sub_component_text~descript <> space. "#EC CI_BUFFJOIN + + MOVE-CORRESPONDING lt_components TO lt_components_exp. + + rs_properties-attributes = get_attributes( lt_components_exp ). + rs_properties-methods = get_methods( is_components = lt_components_exp + is_sub_components = lt_sub_components ). + rs_properties-events = get_events( is_components = lt_components_exp + is_sub_components = lt_sub_components ). + rs_properties-types = get_types( lt_components_exp ). + + ENDMETHOD. + + + METHOD get_attributes. + DATA: + lo_component TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description. + FIELD-SYMBOLS TYPE ty_component. + + LOOP AT is_components ASSIGNING WHERE cmptype = seoo_cmptype_attribute AND descript IS NOT INITIAL. + lo_component-name = -cmpname. + lo_component-description = -descript. + INSERT lo_component INTO TABLE rs_result. + ENDLOOP. + ENDMETHOD. + + METHOD get_methods. + DATA: + lo_method TYPE zif_abapgit_aff_oo_types_v1=>ty_method, + lo_exception TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description, + lo_parameter TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description. + + FIELD-SYMBOLS TYPE ty_sub_component. + FIELD-SYMBOLS TYPE ty_component. + + LOOP AT is_components ASSIGNING WHERE cmptype = seoo_cmptype_method. + lo_method-name = -cmpname. + lo_method-description = -descript. + + LOOP AT is_sub_components ASSIGNING WHERE cmpname = -cmpname. + CASE -scotype. + WHEN seos_scotype_parameter. + lo_parameter-name = -sconame. + lo_parameter-description = -descript. + INSERT lo_parameter INTO TABLE lo_method-parameters. + WHEN seos_scotype_exception. + lo_exception-name = -sconame. + lo_exception-description = -descript. + INSERT lo_exception INTO TABLE lo_method-exceptions. + ENDCASE. + ENDLOOP. + + IF lo_method-description IS NOT INITIAL + OR lo_method-exceptions IS NOT INITIAL + OR lo_method-parameters IS NOT INITIAL. + INSERT lo_method INTO TABLE rs_result. + ENDIF. + ENDLOOP. + ENDMETHOD. + + METHOD get_types. + DATA: + lo_type TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description. + FIELD-SYMBOLS: TYPE ty_component. + + LOOP AT is_components ASSIGNING + WHERE cmptype = seoo_cmptype_type AND descript IS NOT INITIAL. + lo_type-name = -cmpname. + lo_type-description = -descript. + INSERT lo_type INTO TABLE rs_result. + ENDLOOP. + ENDMETHOD. + + METHOD get_events. + DATA: + lo_parameter TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description, + lo_event TYPE zif_abapgit_aff_oo_types_v1=>ty_event. + FIELD-SYMBOLS TYPE ty_component. + FIELD-SYMBOLS TYPE ty_sub_component. + + LOOP AT is_components ASSIGNING WHERE cmptype = seoo_cmptype_event. + lo_event-name = -cmpname. + lo_event-description = -descript. + + LOOP AT is_sub_components ASSIGNING WHERE cmpname = -cmpname. + lo_parameter-name = -sconame. + lo_parameter-description = -descript. + INSERT lo_parameter INTO TABLE lo_event-parameters. + ENDLOOP. + + IF lo_event-description IS NOT INITIAL OR lo_event-parameters IS NOT INITIAL. + INSERT lo_event INTO TABLE rs_result. + ENDIF. + ENDLOOP. + ENDMETHOD. + + + METHOD set_attributes. + DATA: + lo_attribute TYPE seocompotx. + FIELD-SYMBOLS: TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description. + + LOOP AT is_properties-attributes ASSIGNING . + lo_attribute-clsname = iv_clif_name. + lo_attribute-cmpname = -name. + lo_attribute-langu = iv_language. + lo_attribute-descript = -description. + MODIFY seocompotx FROM lo_attribute. + ENDLOOP. + ENDMETHOD. + + + METHOD set_methods. + DATA: + lo_method TYPE seocompotx, + lo_method_exception TYPE seosubcotx, + lo_method_parameter TYPE seosubcotx. + FIELD-SYMBOLS: TYPE zif_abapgit_aff_oo_types_v1=>ty_method, + TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description, + TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description. + + LOOP AT is_properties-methods ASSIGNING . + lo_method-clsname = iv_clif_name. + lo_method-cmpname = -name. + lo_method-langu = iv_language. + lo_method-descript = -description. + MODIFY seocompotx FROM lo_method. + + LOOP AT -parameters ASSIGNING . + lo_method_parameter-clsname = iv_clif_name. + lo_method_parameter-cmpname = -name. + lo_method_parameter-sconame = -name. + lo_method_parameter-langu = iv_language. + lo_method_parameter-descript = -description. + MODIFY seosubcotx FROM lo_method_parameter. + ENDLOOP. + + LOOP AT -exceptions ASSIGNING . + lo_method_exception-clsname = iv_clif_name. + lo_method_exception-cmpname = -name. + lo_method_exception-sconame = -name. + lo_method_exception-langu = iv_language. + lo_method_exception-descript = -description. + MODIFY seosubcotx FROM lo_method_exception. + ENDLOOP. + ENDLOOP. + ENDMETHOD. + + + METHOD set_events. + DATA: + lo_event_parameter TYPE seosubcotx, + lo_event TYPE seocompotx. + FIELD-SYMBOLS: TYPE zif_abapgit_aff_oo_types_v1=>ty_event, + TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description. + + LOOP AT is_properties-events ASSIGNING . + lo_event-clsname = iv_clif_name. + lo_event-cmpname = -name. + lo_event-langu = iv_language. + lo_event-descript = -description. + MODIFY seocompotx FROM lo_event. + + LOOP AT -parameters ASSIGNING . + lo_event_parameter-clsname = iv_clif_name. + lo_event_parameter-cmpname = -name. + lo_event_parameter-sconame = -name. + lo_event_parameter-langu = iv_language. + lo_event_parameter-descript = -description. + MODIFY seosubcotx FROM lo_event_parameter. + ENDLOOP. + ENDLOOP. + ENDMETHOD. + + + METHOD set_types. + DATA: + lo_type TYPE seocompotx. + FIELD-SYMBOLS: TYPE zif_abapgit_aff_oo_types_v1=>ty_component_description. + + LOOP AT is_properties-types ASSIGNING . + lo_type-clsname = iv_clif_name. + lo_type-cmpname = -name. + lo_type-langu = iv_language. + lo_type-descript = -description. + MODIFY seocompotx FROM lo_type. + ENDLOOP. + ENDMETHOD. + + + METHOD set_descriptions_compo_subco. + set_attributes( is_properties = is_properties + iv_clif_name = iv_clif_name + iv_language = iv_language ). + set_methods( is_properties = is_properties + iv_clif_name = iv_clif_name + iv_language = iv_language ). + set_events( is_properties = is_properties + iv_clif_name = iv_clif_name + iv_language = iv_language ). + set_types( is_properties = is_properties + iv_clif_name = iv_clif_name + iv_language = iv_language ). + ENDMETHOD. + +ENDCLASS. + CLASS lcl_aff_type_mapping DEFINITION. PUBLIC SECTION. INTERFACES zif_abapgit_aff_type_mapping. @@ -15,8 +430,24 @@ CLASS lcl_aff_type_mapping IMPLEMENTATION. ls_data_abapgit = iv_data. - " todo: to convert the data - ls_data_aff-format_version = '42'. + ls_data_aff-format_version = '1'. + + " get header + ls_data_aff-header-description = ls_data_abapgit-vseointerf-descript. + ls_data_aff-header-abap_language_version = ls_data_abapgit-vseointerf-unicode. + ls_data_aff-header-original_language = ls_data_abapgit-vseointerf-langu. + + " get category and proxy + SELECT SINGLE category clsproxy AS proxy + FROM vseointerf + INTO (ls_data_aff-category, ls_data_aff-proxy) + WHERE clsname = ls_data_abapgit-vseointerf-clsname AND version = '1' AND + langu = ls_data_aff-header-original_language. + + " get descriptions + ls_data_aff-descriptions = lcl_aff_helper=>get_descriptions_compo_subco( + iv_language = ls_data_aff-header-original_language + iv_clif_name = ls_data_abapgit-vseointerf-clsname ). es_data = ls_data_aff. ENDMETHOD.