All files / src/repo zcl_abapgit_repo_pull.clas.abap

95.8% Statements 137/143
100% Branches 13/13
80% Functions 4/5
95.8% Lines 137/143

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 1441x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 1x 1x 1x             1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
CLASS zcl_abapgit_repo_pull DEFINITION
  PUBLIC
  CREATE PRIVATE
  GLOBAL FRIENDS zcl_abapgit_repo_factory .
 
  PUBLIC SECTION.
 
    INTERFACES zif_abapgit_repo_pull .
 
    METHODS constructor
      IMPORTING
        !ii_repo TYPE REF TO zif_abapgit_repo .
  PROTECTED SECTION.
 
    " Allows testing the pull sequence without deleting SAP objects
    METHODS delete_tadir
      IMPORTING
        !it_tadir  TYPE zif_abapgit_definitions=>ty_tadir_tt
        !is_checks TYPE zif_abapgit_definitions=>ty_delete_checks
        !ii_log    TYPE REF TO zif_abapgit_log
      RAISING
        zcx_abapgit_exception .
  PRIVATE SECTION.
 
    DATA mi_repo TYPE REF TO zif_abapgit_repo .
 
    METHODS delete_objects
      IMPORTING
        !is_checks TYPE zif_abapgit_definitions=>ty_deserialize_checks
        !ii_log    TYPE REF TO zif_abapgit_log
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS get_objects_to_delete
      IMPORTING
        !is_checks      TYPE zif_abapgit_definitions=>ty_deserialize_checks
      RETURNING
        VALUE(rt_tadir) TYPE zif_abapgit_definitions=>ty_tadir_tt .
ENDCLASS.
 
 
 
CLASS zcl_abapgit_repo_pull IMPLEMENTATION.
 
 
  METHOD constructor.
 
    mi_repo = ii_repo.
 
  ENDMETHOD.
 
 
  METHOD delete_objects.
 
    DATA:
      ls_checks TYPE zif_abapgit_definitions=>ty_delete_checks,
      lt_tadir  TYPE zif_abapgit_definitions=>ty_tadir_tt.
 
    lt_tadir = get_objects_to_delete( is_checks ).
 
    " todo, check if object type supports deletion of parts to avoid deleting complete object
 
    IF lines( lt_tadir ) > 0.
      ls_checks-transport = is_checks-transport.
 
      delete_tadir( it_tadir  = lt_tadir
                    is_checks = ls_checks
                    ii_log    = ii_log ).
 
      mi_repo->refresh( iv_drop_log = abap_false ).
    ENDIF.
 
  ENDMETHOD.
 
 
  METHOD delete_tadir.

    zcl_abapgit_objects=>delete( it_tadir  = it_tadir
                                 is_checks = is_checks
                                 ii_log    = ii_log ).

  ENDMETHOD.
 
 
  METHOD get_objects_to_delete.
 
    DATA ls_tadir TYPE zif_abapgit_definitions=>ty_tadir.
 
    FIELD-SYMBOLS <ls_overwrite> LIKE LINE OF is_checks-overwrite.
    FIELD-SYMBOLS <ls_tabl_data> LIKE LINE OF is_checks-delete_tabl_with_data.
 
    " get confirmed deletions
    LOOP AT is_checks-overwrite ASSIGNING <ls_overwrite>
      WHERE ( action = zif_abapgit_objects=>c_deserialize_action-delete
      OR action = zif_abapgit_objects=>c_deserialize_action-delete_add )
      AND decision = zif_abapgit_definitions=>c_yes.
 
      " a table that contains data needs its own confirmation
      READ TABLE is_checks-delete_tabl_with_data ASSIGNING <ls_tabl_data>
        WITH KEY object_type_and_name COMPONENTS
          obj_type = <ls_overwrite>-obj_type
          obj_name = <ls_overwrite>-obj_name.
      IF sy-subrc = 0 AND <ls_tabl_data>-decision = zif_abapgit_definitions=>c_no.
        CONTINUE.
      ENDIF.
 
      ls_tadir-pgmid    = 'R3TR'.
      ls_tadir-object   = <ls_overwrite>-obj_type.
      ls_tadir-obj_name = <ls_overwrite>-obj_name.
      ls_tadir-devclass = <ls_overwrite>-devclass.
      INSERT ls_tadir INTO TABLE rt_tadir.
 
    ENDLOOP.
 
  ENDMETHOD.
 
 
  METHOD zif_abapgit_repo_pull~checks.
 
    rs_checks = mi_repo->deserialize_checks( ).
 
  ENDMETHOD.
 
 
  METHOD zif_abapgit_repo_pull~pull.
 
    IF ii_log IS BOUND.
      ri_log = ii_log.
    ELSE.
      ri_log = mi_repo->create_new_log( 'Pull Log' ).
    ENDIF.
 
    " pass decisions to delete
    delete_objects(
      is_checks = is_checks
      ii_log    = ri_log ).
 
    " pass decisions to deserialize
    mi_repo->deserialize(
      is_checks = is_checks
      ii_log    = ri_log ).
 
  ENDMETHOD.
ENDCLASS.