All files / src/persist zcl_abapgit_persist_settings.clas.abap

69.33% Statements 52/75
100% Branches 0/0
0% Functions 0/1
69.33% Lines 52/75

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 761x 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  
CLASS zcl_abapgit_persist_settings DEFINITION
  PUBLIC
  CREATE PRIVATE
  GLOBAL FRIENDS zcl_abapgit_persist_factory .
 
  PUBLIC SECTION.
 
    INTERFACES zif_abapgit_persist_settings .
  PROTECTED SECTION.
  PRIVATE SECTION.
    DATA mo_settings TYPE REF TO zcl_abapgit_settings .
 
ENDCLASS.
 
 
 
CLASS ZCL_ABAPGIT_PERSIST_SETTINGS IMPLEMENTATION.
 
 
  METHOD zif_abapgit_persist_settings~modify.

    DATA: lv_settings      TYPE string,
          ls_user_settings TYPE zif_abapgit_definitions=>ty_s_user_settings.


    lv_settings = io_settings->get_settings_xml( ).

    zcl_abapgit_persistence_db=>get_instance( )->modify(
      iv_type       = zcl_abapgit_persistence_db=>c_type_settings
      iv_value      = ''
      iv_data       = lv_settings ).

    ls_user_settings = io_settings->get_user_settings( ).

    zcl_abapgit_persistence_user=>get_instance( )->set_settings( ls_user_settings ).

    " Settings have been modified: Update Buffered Settings
    IF mo_settings IS BOUND.
      mo_settings->set_xml_settings( lv_settings ).
      mo_settings->set_user_settings( ls_user_settings ).
    ENDIF.

  ENDMETHOD.
 
 
  METHOD zif_abapgit_persist_settings~read.
 
    IF mo_settings IS BOUND.
      " Return Buffered Settings
      ro_settings = mo_settings.
      RETURN.
    ENDIF.
 
    " Settings have changed or have not yet been loaded
    CREATE OBJECT ro_settings.
 
    TRY.
 
        ro_settings->set_xml_settings(
          zcl_abapgit_persistence_db=>get_instance( )->read(
            iv_type  = zcl_abapgit_persistence_db=>c_type_settings
            iv_value = '' ) ).
 
        ro_settings->set_user_settings( zcl_abapgit_persistence_user=>get_instance( )->get_settings( ) ).
 
      CATCH zcx_abapgit_not_found zcx_abapgit_exception.
 
        ro_settings->set_defaults( ).
 
    ENDTRY.
 
    mo_settings = ro_settings.
 
  ENDMETHOD.
ENDCLASS.