mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
#310 persistence and page-commit logic
This commit is contained in:
parent
a4413dfae7
commit
b096124be9
|
@ -80,7 +80,7 @@ CLASS lcl_gui_page_commit IMPLEMENTATION.
|
||||||
|
|
||||||
DATA: lo_user TYPE REF TO lcl_persistence_user,
|
DATA: lo_user TYPE REF TO lcl_persistence_user,
|
||||||
lv_user TYPE string,
|
lv_user TYPE string,
|
||||||
lv_key TYPE string,
|
lv_key TYPE lcl_persistence_db=>ty_value,
|
||||||
lv_email TYPE string.
|
lv_email TYPE string.
|
||||||
|
|
||||||
* see https://git-scm.com/book/ch5-2.html
|
* see https://git-scm.com/book/ch5-2.html
|
||||||
|
@ -88,10 +88,18 @@ CLASS lcl_gui_page_commit IMPLEMENTATION.
|
||||||
* body should wrap at 72 characters
|
* body should wrap at 72 characters
|
||||||
|
|
||||||
lo_user = lcl_app=>user( ).
|
lo_user = lcl_app=>user( ).
|
||||||
lv_user = lo_user->get_username( ).
|
|
||||||
lv_email = lo_user->get_email( ).
|
|
||||||
lv_key = mo_repo->get_key( ).
|
lv_key = mo_repo->get_key( ).
|
||||||
|
|
||||||
|
lv_user = lo_user->get_repo_username( lv_key ).
|
||||||
|
IF lv_user IS INITIAL.
|
||||||
|
lv_user = lo_user->get_username( ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
lv_email = lo_user->get_repo_email( lv_key ).
|
||||||
|
IF lv_email IS INITIAL.
|
||||||
|
lv_email = lo_user->get_email( ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
CREATE OBJECT ro_html.
|
CREATE OBJECT ro_html.
|
||||||
|
|
||||||
ro_html->add( '<div class="form_div">' ).
|
ro_html->add( '<div class="form_div">' ).
|
||||||
|
@ -245,8 +253,8 @@ CLASS lcl_gui_page_commit IMPLEMENTATION.
|
||||||
ls_fields = lcl_html_action_utils=>parse_commit_request( it_postdata ).
|
ls_fields = lcl_html_action_utils=>parse_commit_request( it_postdata ).
|
||||||
|
|
||||||
lo_user = lcl_app=>user( ).
|
lo_user = lcl_app=>user( ).
|
||||||
lo_user->set_username( ls_fields-username ).
|
lo_user->set_repo_username( iv_key = mo_repo->get_key( ) iv_username = ls_fields-username ).
|
||||||
lo_user->set_email( ls_fields-email ).
|
lo_user->set_repo_email( iv_key = mo_repo->get_key( ) iv_email = ls_fields-email ).
|
||||||
|
|
||||||
IF ls_fields-username IS INITIAL.
|
IF ls_fields-username IS INITIAL.
|
||||||
lcx_exception=>raise( 'empty username' ).
|
lcx_exception=>raise( 'empty username' ).
|
||||||
|
|
|
@ -706,6 +706,26 @@ CLASS lcl_persistence_user DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_app.
|
||||||
RETURNING VALUE(rv_key) TYPE lcl_persistence_repo=>ty_repo-key
|
RETURNING VALUE(rv_key) TYPE lcl_persistence_repo=>ty_repo-key
|
||||||
RAISING lcx_exception.
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
METHODS set_repo_username
|
||||||
|
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||||
|
iv_username TYPE string
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
METHODS get_repo_username
|
||||||
|
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||||
|
RETURNING VALUE(rv_username) TYPE string
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
METHODS set_repo_email
|
||||||
|
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||||
|
iv_email TYPE string
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
METHODS get_repo_email
|
||||||
|
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||||
|
RETURNING VALUE(rv_email) TYPE string
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
CONSTANTS c_type_user TYPE lcl_persistence_db=>ty_type VALUE 'USER'.
|
CONSTANTS c_type_user TYPE lcl_persistence_db=>ty_type VALUE 'USER'.
|
||||||
|
|
||||||
|
@ -716,10 +736,18 @@ CLASS lcl_persistence_user DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_app.
|
||||||
TYPE STANDARD TABLE OF lcl_persistence_repo=>ty_repo-key
|
TYPE STANDARD TABLE OF lcl_persistence_repo=>ty_repo-key
|
||||||
WITH DEFAULT KEY.
|
WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_repo_config,
|
||||||
|
key TYPE lcl_persistence_repo=>ty_repo-key,
|
||||||
|
username TYPE string,
|
||||||
|
email TYPE string,
|
||||||
|
END OF ty_repo_config.
|
||||||
|
TYPES: ty_repo_config_tt TYPE STANDARD TABLE OF ty_repo_config WITH DEFAULT KEY.
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_user,
|
TYPES: BEGIN OF ty_user,
|
||||||
username TYPE string,
|
username TYPE string,
|
||||||
email TYPE string,
|
email TYPE string,
|
||||||
repo_show TYPE lcl_persistence_repo=>ty_repo-key,
|
repo_show TYPE lcl_persistence_repo=>ty_repo-key,
|
||||||
|
repo_config TYPE ty_repo_config_tt,
|
||||||
END OF ty_user.
|
END OF ty_user.
|
||||||
|
|
||||||
METHODS constructor
|
METHODS constructor
|
||||||
|
@ -742,6 +770,16 @@ CLASS lcl_persistence_user DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_app.
|
||||||
IMPORTING is_user TYPE ty_user
|
IMPORTING is_user TYPE ty_user
|
||||||
RAISING lcx_exception.
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
METHODS read_repo_config
|
||||||
|
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||||
|
RETURNING VALUE(rs_repo_config) TYPE ty_repo_config
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
METHODS update_repo_config
|
||||||
|
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||||
|
is_repo_config TYPE ty_repo_config
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
ENDCLASS. "lcl_persistence_user DEFINITION
|
ENDCLASS. "lcl_persistence_user DEFINITION
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
|
@ -1059,6 +1097,63 @@ CLASS lcl_persistence_user IMPLEMENTATION.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD read_repo_config.
|
||||||
|
DATA lt_repo_config TYPE ty_repo_config_tt.
|
||||||
|
|
||||||
|
lt_repo_config = read( )-repo_config.
|
||||||
|
READ TABLE lt_repo_config INTO rs_repo_config WITH KEY key = iv_key.
|
||||||
|
|
||||||
|
ENDMETHOD. "read_repo_config
|
||||||
|
|
||||||
|
METHOD update_repo_config.
|
||||||
|
DATA ls_user TYPE ty_user.
|
||||||
|
FIELD-SYMBOLS <repo_config> TYPE ty_repo_config.
|
||||||
|
|
||||||
|
ls_user = read( ).
|
||||||
|
|
||||||
|
READ TABLE ls_user-repo_config ASSIGNING <repo_config> WITH KEY key = iv_key.
|
||||||
|
IF sy-subrc IS NOT INITIAL.
|
||||||
|
APPEND INITIAL LINE TO ls_user-repo_config ASSIGNING <repo_config>.
|
||||||
|
ENDIF.
|
||||||
|
<repo_config> = is_repo_config.
|
||||||
|
<repo_config>-key = iv_key.
|
||||||
|
|
||||||
|
update( ls_user ).
|
||||||
|
|
||||||
|
ENDMETHOD. "update_repo_config
|
||||||
|
|
||||||
|
METHOD set_repo_username.
|
||||||
|
|
||||||
|
DATA: ls_repo_config TYPE ty_repo_config.
|
||||||
|
|
||||||
|
ls_repo_config = read_repo_config( iv_key ).
|
||||||
|
ls_repo_config-username = iv_username.
|
||||||
|
update_repo_config( iv_key = iv_key is_repo_config = ls_repo_config ).
|
||||||
|
|
||||||
|
ENDMETHOD. "set_repo_username
|
||||||
|
|
||||||
|
METHOD get_repo_username.
|
||||||
|
|
||||||
|
rv_username = read_repo_config( iv_key )-username.
|
||||||
|
|
||||||
|
ENDMETHOD. "get_repo_username
|
||||||
|
|
||||||
|
METHOD set_repo_email.
|
||||||
|
|
||||||
|
DATA: ls_repo_config TYPE ty_repo_config.
|
||||||
|
|
||||||
|
ls_repo_config = read_repo_config( iv_key ).
|
||||||
|
ls_repo_config-email = iv_email.
|
||||||
|
update_repo_config( iv_key = iv_key is_repo_config = ls_repo_config ).
|
||||||
|
|
||||||
|
ENDMETHOD. "set_repo_email
|
||||||
|
|
||||||
|
METHOD get_repo_email.
|
||||||
|
|
||||||
|
rv_email = read_repo_config( iv_key )-email.
|
||||||
|
|
||||||
|
ENDMETHOD. "get_repo_email
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS lcl_persistence_db IMPLEMENTATION.
|
CLASS lcl_persistence_db IMPLEMENTATION.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user