From 8283f76a0cebf2f96e919a8941441aadf43f18b5 Mon Sep 17 00:00:00 2001 From: oblomov <102328295+oblomov-dev@users.noreply.github.com> Date: Wed, 22 Mar 2023 18:26:56 +0100 Subject: [PATCH] refactoring (#119) * refactoring && to || * refactoring * refactoring * renaming * refactoring --- src/z2ui5_cl_http_handler.clas.abap | 7 +- ...z2ui5_cl_http_handler.clas.locals_imp.abap | 92 +++++++------------ 2 files changed, 36 insertions(+), 63 deletions(-) diff --git a/src/z2ui5_cl_http_handler.clas.abap b/src/z2ui5_cl_http_handler.clas.abap index 0a05f493..0f25f495 100644 --- a/src/z2ui5_cl_http_handler.clas.abap +++ b/src/z2ui5_cl_http_handler.clas.abap @@ -43,7 +43,7 @@ ENDCLASS. -CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION. +CLASS z2ui5_cl_http_handler IMPLEMENTATION. METHOD main_roundtrip. @@ -52,7 +52,6 @@ CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION. DO. TRY. - DATA(li_client) = lo_runtime->app_before_event( ). ROLLBACK WORK. CAST z2ui5_if_app( lo_runtime->ms_db-o_app )->controller( li_client ). @@ -63,7 +62,6 @@ CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION. CONTINUE. ENDTRY. - IF lo_runtime->ms_next-s_nav_app_call_new IS NOT INITIAL. lo_runtime = lo_runtime->set_app_call_new( ). CONTINUE. @@ -74,14 +72,11 @@ CLASS Z2UI5_CL_HTTP_HANDLER IMPLEMENTATION. CONTINUE. ENDIF. - TRY. - li_client = lo_runtime->app_before_rendering( ). ROLLBACK WORK. CAST z2ui5_if_app( lo_runtime->ms_db-o_app )->controller( li_client ). ROLLBACK WORK. - result = lo_runtime->request_end( ). CATCH cx_root INTO x. diff --git a/src/z2ui5_cl_http_handler.clas.locals_imp.abap b/src/z2ui5_cl_http_handler.clas.locals_imp.abap index c55e0e23..74c36d9a 100644 --- a/src/z2ui5_cl_http_handler.clas.locals_imp.abap +++ b/src/z2ui5_cl_http_handler.clas.locals_imp.abap @@ -164,8 +164,10 @@ CLASS z2ui5_lcl_utility DEFINITION INHERITING FROM cx_no_check. VALUE(result) TYPE string. CLASS-METHODS trans_ref_tab_2_tab - IMPORTING ir_tab_from TYPE REF TO data - CHANGING ct_to TYPE STANDARD TABLE. + IMPORTING + ir_tab_from TYPE REF TO data + CHANGING + ct_to TYPE STANDARD TABLE. CLASS-METHODS get_trim_upper IMPORTING @@ -809,9 +811,8 @@ CLASS z2ui5_lcl_utility_tree_json IMPLEMENTATION. FIELD-SYMBOLS TYPE any. DATA(lv_name) = c_prefix && replace( val = name sub = `-` with = `_` occ = 0 ). ASSIGN (lv_name) TO . - IF sy-subrc <> 0. - RETURN. - ENDIF. + _=>raise( when = xsdbool( sy-subrc <> 0 ) ). + lo_attri->mr_actual = . lo_attri->mo_parent = me. @@ -2316,7 +2317,7 @@ CLASS z2ui5_lcl_system_app IMPLEMENTATION. result = NEW #( ). result->ms_error-x_error = error. - result->ms_error-app = cast #( app ). + result->ms_error-app = CAST #( app ). ENDMETHOD. @@ -2620,7 +2621,7 @@ CLASS z2ui5_lcl_system_runtime IMPLEMENTATION. DATA(lo_system) = lo_ui5_model->add_attribute_object( `oSystem` ). lo_system->add_attribute( n = `ID` v = ms_db-id ). - lo_system->add_attribute( n = `CHECK_DEBUG_ACTIVE` v = _=>get_abap_2_json( z2ui5_cl_http_handler=>cs_config-check_debug_mode ) apos_active = abap_false ). + lo_system->add_attribute( n = `CHECK_DEBUG_ACTIVE` v = _=>get_abap_2_json( z2ui5_cl_http_handler=>cs_config-check_debug_mode ) apos_active = abap_false ). IF ms_next-t_after IS NOT INITIAL. DATA(lo_list) = lo_ui5_model->add_attribute_list( `oAfter` ). @@ -2670,56 +2671,33 @@ CLASS z2ui5_lcl_system_runtime IMPLEMENTATION. result->ms_db-id_prev = id_prev. TRY. - DATA(lo_popup_model) = ss_client-o_body->get_attribute( `OPOPUP` ). - - LOOP AT result->ms_db-t_attri REFERENCE INTO DATA(lr_attri) - WHERE bind_type = z2ui5_if_view=>cs-bind_type-two_way. - - FIELD-SYMBOLS TYPE any. - DATA(lv_name) = c_prefix && to_upper( lr_attri->name ). - ASSIGN (lv_name) TO . - _=>raise( when = xsdbool( sy-subrc <> 0 ) ). - - CASE lr_attri->type_kind. - - WHEN `g` OR `I` OR `C`. - DATA(lv_value) = lo_popup_model->get_attribute( lr_attri->name )->get_val( ). - = lv_value. - - WHEN `h`. - _=>trans_ref_tab_2_tab( - EXPORTING ir_tab_from = lo_popup_model->get_attribute( lr_attri->name )->mr_actual - CHANGING ct_to = ). - - ENDCASE. - ENDLOOP. - + DATA(lo_model) = ss_client-o_body->get_attribute( `OPOPUP` ). CATCH cx_root. - - LOOP AT result->ms_db-t_attri REFERENCE INTO lr_attri - WHERE bind_type = z2ui5_if_view=>cs-bind_type-two_way. - - lv_name = c_prefix && to_upper( lr_attri->name ). - ASSIGN (lv_name) TO . - _=>raise( when = xsdbool( sy-subrc <> 0 ) ). - - CASE lr_attri->type_kind. - - WHEN `g` OR `I` OR `C`. - lv_value = ss_client-o_body->get_attribute( lr_attri->name )->get_val( ). - = lv_value. - - WHEN `h`. - _=>trans_ref_tab_2_tab( - EXPORTING - ir_tab_from = ss_client-o_body->get_attribute( lr_attri->name )->mr_actual - CHANGING - ct_to = ). - - ENDCASE. - ENDLOOP. + lo_model = ss_client-o_body. ENDTRY. + LOOP AT result->ms_db-t_attri REFERENCE INTO DATA(lr_attri) + WHERE bind_type = z2ui5_if_view=>cs-bind_type-two_way. + + FIELD-SYMBOLS TYPE any. + DATA(lv_name) = c_prefix && to_upper( lr_attri->name ). + ASSIGN (lv_name) TO . + _=>raise( when = xsdbool( sy-subrc <> 0 ) ). + + CASE lr_attri->type_kind. + + WHEN `g` OR `I` OR `C`. + DATA(lv_value) = lo_model->get_attribute( lr_attri->name )->get_val( ). + = lv_value. + + WHEN `h`. + _=>trans_ref_tab_2_tab( + EXPORTING ir_tab_from = lo_model->get_attribute( lr_attri->name )->mr_actual + CHANGING ct_to = ). + + ENDCASE. + ENDLOOP. + TRY. result->ms_next-event = ss_client-o_body->get_attribute( `OEVENT` )->get_attribute( `EVENT` )->get_val( ). @@ -3002,13 +2980,13 @@ CLASS z2ui5_lcl_if_client IMPLEMENTATION. METHOD z2ui5_if_client~_bind. - result = `{` && mo_runtime->_create_binding( value = val type = z2ui5_if_view=>cs-bind_type-two_way ) && `}`. + result = `{` && mo_runtime->_create_binding( value = val type = z2ui5_if_view=>cs-bind_type-two_way ) && `}`. ENDMETHOD. METHOD z2ui5_if_client~_bind_one_way. - result = `{` && mo_runtime->_create_binding( value = val type = z2ui5_if_view=>cs-bind_type-one_way ) && `}`. + result = `{` && mo_runtime->_create_binding( value = val type = z2ui5_if_view=>cs-bind_type-one_way ) && `}`. ENDMETHOD. @@ -3026,7 +3004,7 @@ CLASS z2ui5_lcl_if_client IMPLEMENTATION. METHOD z2ui5_if_client~nav_app_leave. - _=>raise( when = xsdbool( id = `` ) v = `app not found, please check if calling app exists, pervious_app_id is empty` ). + _=>raise( when = xsdbool( id = `` ) v = `app not found, please check if calling app exists, pervious app_id is empty` ). mo_runtime->ms_next-nav_app_leave_to_id = id. ENDMETHOD.