mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +08:00
Refactor: Activation log (#5302)
* Refactor: Activation log - Merges the activation log into the regular pull log - Removes duplicate messages * Update Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
a828d80044
commit
ce31e33688
|
@ -19,6 +19,7 @@ CLASS zcl_abapgit_objects_activation DEFINITION
|
|||
CLASS-METHODS activate
|
||||
IMPORTING
|
||||
!iv_ddic TYPE abap_bool DEFAULT abap_false
|
||||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS clear .
|
||||
|
@ -41,26 +42,33 @@ CLASS zcl_abapgit_objects_activation DEFINITION
|
|||
CLASS-DATA:
|
||||
gt_objects TYPE TABLE OF dwinactiv .
|
||||
|
||||
CLASS-METHODS update_where_used .
|
||||
CLASS-METHODS update_where_used
|
||||
IMPORTING
|
||||
!ii_log TYPE REF TO zif_abapgit_log.
|
||||
CLASS-METHODS use_new_activation_logic
|
||||
RETURNING
|
||||
VALUE(rv_use_new_activation_logic) TYPE abap_bool .
|
||||
CLASS-METHODS activate_new
|
||||
IMPORTING
|
||||
!iv_ddic TYPE abap_bool DEFAULT abap_false
|
||||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS activate_old
|
||||
IMPORTING
|
||||
!iv_ddic TYPE abap_bool DEFAULT abap_false
|
||||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS activate_ddic
|
||||
IMPORTING
|
||||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS show_activation_errors
|
||||
CLASS-METHODS add_errors_to_log
|
||||
IMPORTING
|
||||
!iv_logname TYPE ddmass-logname
|
||||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
ENDCLASS.
|
||||
|
@ -76,12 +84,16 @@ CLASS zcl_abapgit_objects_activation IMPLEMENTATION.
|
|||
COMMIT WORK AND WAIT.
|
||||
|
||||
IF use_new_activation_logic( ) = abap_true.
|
||||
activate_new( iv_ddic ).
|
||||
activate_new(
|
||||
iv_ddic = iv_ddic
|
||||
ii_log = ii_log ).
|
||||
ELSE.
|
||||
activate_old( iv_ddic ).
|
||||
activate_old(
|
||||
iv_ddic = iv_ddic
|
||||
ii_log = ii_log ).
|
||||
ENDIF.
|
||||
|
||||
update_where_used( ).
|
||||
update_where_used( ii_log ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
@ -152,7 +164,10 @@ CLASS zcl_abapgit_objects_activation IMPLEMENTATION.
|
|||
ENDIF.
|
||||
|
||||
IF lv_rc > 0.
|
||||
show_activation_errors( lv_logname ).
|
||||
add_errors_to_log(
|
||||
iv_logname = lv_logname
|
||||
ii_log = ii_log ).
|
||||
zcx_abapgit_exception=>raise( 'Activation cancelled. Check the inactive objects.' ).
|
||||
ENDIF.
|
||||
|
||||
" Remove objects from activation queue to avoid double activation in activate_old
|
||||
|
@ -181,14 +196,14 @@ CLASS zcl_abapgit_objects_activation IMPLEMENTATION.
|
|||
li_progress->show( iv_current = 98
|
||||
iv_text = 'Activating DDIC' ).
|
||||
|
||||
activate_ddic( ).
|
||||
activate_ddic( ii_log ).
|
||||
|
||||
ELSE.
|
||||
|
||||
li_progress->show( iv_current = 98
|
||||
iv_text = 'Activating non DDIC' ).
|
||||
|
||||
activate_old( ).
|
||||
activate_old( ii_log ).
|
||||
|
||||
ENDIF.
|
||||
|
||||
|
@ -275,6 +290,43 @@ CLASS zcl_abapgit_objects_activation IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD add_errors_to_log.
|
||||
|
||||
DATA: lt_lines TYPE STANDARD TABLE OF trlog,
|
||||
lv_logname_db TYPE ddprh-protname.
|
||||
|
||||
FIELD-SYMBOLS: <ls_line> LIKE LINE OF lt_lines.
|
||||
|
||||
|
||||
lv_logname_db = iv_logname.
|
||||
|
||||
CALL FUNCTION 'TR_READ_LOG'
|
||||
EXPORTING
|
||||
iv_log_type = 'DB'
|
||||
iv_logname_db = lv_logname_db
|
||||
TABLES
|
||||
et_lines = lt_lines
|
||||
EXCEPTIONS
|
||||
invalid_input = 1
|
||||
access_error = 2
|
||||
OTHERS = 3.
|
||||
|
||||
IF sy-subrc <> 0.
|
||||
zcx_abapgit_exception=>raise_t100( ).
|
||||
ENDIF.
|
||||
|
||||
" Only error messsages
|
||||
DELETE lt_lines WHERE severity <> 'E'.
|
||||
" Remove "Return code..." message
|
||||
DELETE lt_lines WHERE class = 'D0' AND number = '319'.
|
||||
|
||||
LOOP AT lt_lines ASSIGNING <ls_line>.
|
||||
ii_log->add( <ls_line>-line ).
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD add_item.
|
||||
add( iv_type = is_item-obj_type
|
||||
iv_name = is_item-obj_name ).
|
||||
|
@ -318,52 +370,12 @@ CLASS zcl_abapgit_objects_activation IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD show_activation_errors.
|
||||
|
||||
DATA: lt_lines TYPE STANDARD TABLE OF trlog,
|
||||
lv_logname_db TYPE ddprh-protname,
|
||||
li_log TYPE REF TO zif_abapgit_log.
|
||||
|
||||
FIELD-SYMBOLS: <ls_line> LIKE LINE OF lt_lines.
|
||||
|
||||
|
||||
lv_logname_db = iv_logname.
|
||||
|
||||
CALL FUNCTION 'TR_READ_LOG'
|
||||
EXPORTING
|
||||
iv_log_type = 'DB'
|
||||
iv_logname_db = lv_logname_db
|
||||
TABLES
|
||||
et_lines = lt_lines
|
||||
EXCEPTIONS
|
||||
invalid_input = 1
|
||||
access_error = 2
|
||||
OTHERS = 3.
|
||||
|
||||
IF sy-subrc <> 0.
|
||||
zcx_abapgit_exception=>raise_t100( ).
|
||||
ENDIF.
|
||||
|
||||
DELETE lt_lines WHERE severity <> 'E'.
|
||||
|
||||
CREATE OBJECT li_log TYPE zcl_abapgit_log.
|
||||
li_log->set_title( 'Activation Errors' ).
|
||||
|
||||
LOOP AT lt_lines ASSIGNING <ls_line>.
|
||||
li_log->add( <ls_line>-line ).
|
||||
ENDLOOP.
|
||||
|
||||
IF li_log->count( ) > 0.
|
||||
zcl_abapgit_log_viewer=>show_log( li_log ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD update_where_used.
|
||||
|
||||
DATA: ls_class LIKE LINE OF gt_classes,
|
||||
lo_cross TYPE REF TO cl_wb_crossreference,
|
||||
ls_item TYPE zif_abapgit_definitions=>ty_item,
|
||||
lv_error TYPE c LENGTH 1,
|
||||
lv_include TYPE programm,
|
||||
li_progress TYPE REF TO zif_abapgit_progress.
|
||||
|
||||
|
@ -389,7 +401,15 @@ CLASS zcl_abapgit_objects_activation IMPLEMENTATION.
|
|||
p_name = lv_include
|
||||
p_include = lv_include.
|
||||
|
||||
lo_cross->index_actualize( ).
|
||||
lo_cross->index_actualize( IMPORTING p_error = lv_error ).
|
||||
|
||||
IF lv_error = abap_true.
|
||||
ls_item-obj_type = ls_class-object.
|
||||
ls_item-obj_name = ls_class-clsname.
|
||||
ii_log->add(
|
||||
iv_msg = 'Error updating where-used list'
|
||||
is_item = ls_item ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
|
|
@ -794,13 +794,21 @@ CLASS zcl_abapgit_objects IMPLEMENTATION.
|
|||
|
||||
CASE is_step-step_id.
|
||||
WHEN zif_abapgit_object=>gc_step_id-ddic.
|
||||
zcl_abapgit_objects_activation=>activate( abap_true ).
|
||||
zcl_abapgit_objects_activation=>activate(
|
||||
iv_ddic = abap_true
|
||||
ii_log = ii_log ).
|
||||
WHEN zif_abapgit_object=>gc_step_id-abap.
|
||||
zcl_abapgit_objects_activation=>activate( abap_false ).
|
||||
zcl_abapgit_objects_activation=>activate(
|
||||
iv_ddic = abap_false
|
||||
ii_log = ii_log ).
|
||||
WHEN zif_abapgit_object=>gc_step_id-late.
|
||||
" late can have both DDIC (like TABL with REF TO) and non-DDIC objects
|
||||
zcl_abapgit_objects_activation=>activate( abap_true ).
|
||||
zcl_abapgit_objects_activation=>activate( abap_false ).
|
||||
zcl_abapgit_objects_activation=>activate(
|
||||
iv_ddic = abap_true
|
||||
ii_log = ii_log ).
|
||||
zcl_abapgit_objects_activation=>activate(
|
||||
iv_ddic = abap_false
|
||||
ii_log = ii_log ).
|
||||
ENDCASE.
|
||||
|
||||
* Call postprocessing
|
||||
|
|
|
@ -39,7 +39,7 @@ ENDCLASS.
|
|||
|
||||
|
||||
|
||||
CLASS ZCL_ABAPGIT_LOG IMPLEMENTATION.
|
||||
CLASS zcl_abapgit_log IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD constructor.
|
||||
|
@ -258,6 +258,7 @@ CLASS ZCL_ABAPGIT_LOG IMPLEMENTATION.
|
|||
ls_msg-exception = <ls_log>-exception.
|
||||
APPEND ls_msg TO rt_msg.
|
||||
ENDLOOP.
|
||||
DELETE ADJACENT DUPLICATES FROM rt_msg.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user