From 335759f7417a046ebc0611c26e6c0aa0edf1bfa6 Mon Sep 17 00:00:00 2001 From: Christian Guenter Date: Tue, 24 Jul 2018 15:36:49 +0000 Subject: [PATCH] Store user and time for last deserialize With this commit after every deserialize operation the user, date and time are stored in repo xml. The information is shown in repo overview. --- .../zcl_abapgit_persistence_repo.clas.abap | 42 +++++++++++++- src/persist/zif_abapgit_persistence.intf.abap | 2 + .../zcl_abapgit_gui_page_repo_over.clas.abap | 57 +++++++++++++------ src/zcl_abapgit_repo.clas.abap | 49 +++++++++++++--- 4 files changed, 123 insertions(+), 27 deletions(-) diff --git a/src/persist/zcl_abapgit_persistence_repo.clas.abap b/src/persist/zcl_abapgit_persistence_repo.clas.abap index 3dc93b216..1fc729152 100644 --- a/src/persist/zcl_abapgit_persistence_repo.clas.abap +++ b/src/persist/zcl_abapgit_persistence_repo.clas.abap @@ -79,10 +79,18 @@ CLASS zcl_abapgit_persistence_repo DEFINITION zcx_abapgit_exception . METHODS update_local_settings IMPORTING - !iv_key TYPE zif_abapgit_persistence=>ty_repo-key - !is_settings TYPE zif_abapgit_persistence=>ty_repo_xml-local_settings + iv_key TYPE zif_abapgit_persistence=>ty_repo-key + is_settings TYPE zif_abapgit_persistence=>ty_repo_xml-local_settings RAISING zcx_abapgit_exception . + METHODS update_deserialized + IMPORTING + iv_key TYPE zif_abapgit_persistence=>ty_value + iv_deserialized_at TYPE timestampl + iv_deserialized_by TYPE xubname + RAISING + zcx_abapgit_exception. + PRIVATE SECTION. DATA mo_db TYPE REF TO zcl_abapgit_persistence_db . @@ -444,4 +452,34 @@ CLASS zcl_abapgit_persistence_repo IMPLEMENTATION. iv_data = ls_content-data_str ). ENDMETHOD. + + METHOD update_deserialized. + + DATA: lt_content TYPE zif_abapgit_persistence=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE zif_abapgit_persistence=>ty_repo. + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + IF iv_deserialized_at IS NOT INITIAL. + ls_repo-deserialized_at = iv_deserialized_at. + ENDIF. + + IF iv_deserialized_by IS NOT INITIAL. + ls_repo-deserialized_by = iv_deserialized_by. + ENDIF. + + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + ENDMETHOD. + ENDCLASS. diff --git a/src/persist/zif_abapgit_persistence.intf.abap b/src/persist/zif_abapgit_persistence.intf.abap index dcba036e3..b4ea9ee70 100644 --- a/src/persist/zif_abapgit_persistence.intf.abap +++ b/src/persist/zif_abapgit_persistence.intf.abap @@ -35,6 +35,8 @@ INTERFACE zif_abapgit_persistence PUBLIC. package TYPE devclass, created_by TYPE xubname, created_at TYPE timestampl, + deserialized_by TYPE xubname, + deserialized_at TYPE timestampl, offline TYPE sap_bool, local_checksums TYPE ty_local_checksum_tt, dot_abapgit TYPE zif_abapgit_dot_abapgit=>ty_dot_abapgit, diff --git a/src/ui/zcl_abapgit_gui_page_repo_over.clas.abap b/src/ui/zcl_abapgit_gui_page_repo_over.clas.abap index c3a8551a2..d1586b42f 100644 --- a/src/ui/zcl_abapgit_gui_page_repo_over.clas.abap +++ b/src/ui/zcl_abapgit_gui_page_repo_over.clas.abap @@ -19,15 +19,17 @@ CLASS zcl_abapgit_gui_page_repo_over DEFINITION PRIVATE SECTION. TYPES: BEGIN OF ty_overview, - favorite TYPE string, - type TYPE string, - key TYPE string, - name TYPE string, - url TYPE string, - package TYPE string, - branch TYPE string, - created_by TYPE string, - created_at TYPE string, + favorite TYPE string, + type TYPE string, + key TYPE string, + name TYPE string, + url TYPE string, + package TYPE string, + branch TYPE string, + created_by TYPE string, + created_at TYPE string, + deserialized_by TYPE string, + deserialized_at TYPE string, END OF ty_overview, tty_overview TYPE STANDARD TABLE OF ty_overview WITH NON-UNIQUE DEFAULT KEY. @@ -158,13 +160,15 @@ CLASS zcl_abapgit_gui_page_repo_over IMPLEMENTATION. IF mv_filter IS NOT INITIAL. - DELETE ct_overview WHERE key NS mv_filter - AND name NS mv_filter - AND url NS mv_filter - AND package NS mv_filter - AND branch NS mv_filter - AND created_by NS mv_filter - AND created_at NS mv_filter. + DELETE ct_overview WHERE key NS mv_filter + AND name NS mv_filter + AND url NS mv_filter + AND package NS mv_filter + AND branch NS mv_filter + AND created_by NS mv_filter + AND created_at NS mv_filter + AND deserialized_by NS mv_filter + AND deserialized_at NS mv_filter. ENDIF. @@ -242,6 +246,17 @@ CLASS zcl_abapgit_gui_page_repo_over IMPLEMENTATION. ls_overview-created_at = |{ lv_date DATE = USER } { lv_time TIME = USER }|. ENDIF. + ls_overview-deserialized_by = -deserialized_by. + + IF -deserialized_at IS NOT INITIAL. + CONVERT TIME STAMP -deserialized_at + TIME ZONE mv_time_zone + INTO DATE lv_date + TIME lv_time. + + ls_overview-deserialized_at = |{ lv_date DATE = USER } { lv_time TIME = USER }|. + ENDIF. + INSERT ls_overview INTO TABLE rt_overview. ENDLOOP. @@ -406,6 +421,8 @@ CLASS zcl_abapgit_gui_page_repo_over IMPLEMENTATION. io_html->add( |Branch name| ). io_html->add( |Creator| ). io_html->add( |Created at [{ mv_time_zone }]| ). + io_html->add( |Deserialized by| ). + io_html->add( |Deserialized at [{ mv_time_zone }]| ). io_html->add( || ). io_html->add( '' ). io_html->add( '' ). @@ -473,6 +490,8 @@ CLASS zcl_abapgit_gui_page_repo_over IMPLEMENTATION. io_html->add( |{ -branch }| ). io_html->add( |{ -created_by }| ). io_html->add( |{ -created_at }| ). + io_html->add( |{ -deserialized_by }| ). + io_html->add( |{ -deserialized_at }| ). io_html->add( || ). io_html->add( || ). io_html->add( || ). @@ -510,6 +529,12 @@ CLASS zcl_abapgit_gui_page_repo_over IMPLEMENTATION. add_order_by_option( iv_option = |CREATED_AT| io_html = io_html ). + add_order_by_option( iv_option = |DESERIALIZED_BY| + io_html = io_html ). + + add_order_by_option( iv_option = |DESERIALIZED_AT| + io_html = io_html ). + io_html->add( || ). ENDMETHOD. diff --git a/src/zcl_abapgit_repo.clas.abap b/src/zcl_abapgit_repo.clas.abap index 2cfbfe4f9..aa1d3a025 100644 --- a/src/zcl_abapgit_repo.clas.abap +++ b/src/zcl_abapgit_repo.clas.abap @@ -110,7 +110,6 @@ CLASS zcl_abapgit_repo DEFINITION PROTECTED SECTION. - DATA mt_local TYPE zif_abapgit_definitions=>ty_files_item_tt . DATA mt_remote TYPE zif_abapgit_definitions=>ty_files_tt . DATA mv_do_local_refresh TYPE abap_bool . @@ -120,16 +119,24 @@ CLASS zcl_abapgit_repo DEFINITION METHODS set IMPORTING - !it_checksums TYPE zif_abapgit_persistence=>ty_local_checksum_tt OPTIONAL - !iv_url TYPE zif_abapgit_persistence=>ty_repo-url OPTIONAL - !iv_branch_name TYPE zif_abapgit_persistence=>ty_repo-branch_name OPTIONAL - !iv_head_branch TYPE zif_abapgit_persistence=>ty_repo-head_branch OPTIONAL - !iv_offline TYPE zif_abapgit_persistence=>ty_repo-offline OPTIONAL - !is_dot_abapgit TYPE zif_abapgit_persistence=>ty_repo-dot_abapgit OPTIONAL - !is_local_settings TYPE zif_abapgit_persistence=>ty_repo-local_settings OPTIONAL + !it_checksums TYPE zif_abapgit_persistence=>ty_local_checksum_tt OPTIONAL + !iv_url TYPE zif_abapgit_persistence=>ty_repo-url OPTIONAL + !iv_branch_name TYPE zif_abapgit_persistence=>ty_repo-branch_name OPTIONAL + !iv_head_branch TYPE zif_abapgit_persistence=>ty_repo-head_branch OPTIONAL + !iv_offline TYPE zif_abapgit_persistence=>ty_repo-offline OPTIONAL + !is_dot_abapgit TYPE zif_abapgit_persistence=>ty_repo-dot_abapgit OPTIONAL + !is_local_settings TYPE zif_abapgit_persistence=>ty_repo-local_settings OPTIONAL + !iv_deserialized_at TYPE zif_abapgit_persistence=>ty_repo-deserialized_at OPTIONAL + !iv_deserialized_by TYPE zif_abapgit_persistence=>ty_repo-deserialized_by OPTIONAL RAISING zcx_abapgit_exception . + PRIVATE SECTION. + METHODS: + update_last_deserialize + RAISING + zcx_abapgit_exception. + ENDCLASS. @@ -215,6 +222,7 @@ CLASS zcl_abapgit_repo IMPLEMENTATION. CLEAR: mt_local, mv_last_serialization. update_local_checksums( lt_updated_files ). + update_last_deserialize( ). ENDMETHOD. @@ -494,7 +502,9 @@ CLASS zcl_abapgit_repo IMPLEMENTATION. OR iv_head_branch IS SUPPLIED OR iv_offline IS SUPPLIED OR is_dot_abapgit IS SUPPLIED - OR is_local_settings IS SUPPLIED. + OR is_local_settings IS SUPPLIED + OR iv_deserialized_by IS SUPPLIED + OR iv_deserialized_at IS SUPPLIED. CREATE OBJECT lo_persistence. @@ -547,6 +557,15 @@ CLASS zcl_abapgit_repo IMPLEMENTATION. ms_data-local_settings = is_local_settings. ENDIF. + IF iv_deserialized_at IS SUPPLIED + OR iv_deserialized_by IS SUPPLIED. + lo_persistence->update_deserialized( + iv_key = ms_data-key + iv_deserialized_at = iv_deserialized_at + iv_deserialized_by = iv_deserialized_by ). + ms_data-deserialized_at = iv_deserialized_at. + ENDIF. + ENDMETHOD. @@ -648,5 +667,17 @@ CLASS zcl_abapgit_repo IMPLEMENTATION. ENDMETHOD. " update_local_checksums + METHOD update_last_deserialize. + + DATA: lv_deserialized_at TYPE zif_abapgit_persistence=>ty_repo-deserialized_at, + lv_deserialized_by TYPE zif_abapgit_persistence=>ty_repo-deserialized_by. + + GET TIME STAMP FIELD lv_deserialized_at. + lv_deserialized_by = sy-uname. + + set( iv_deserialized_at = lv_deserialized_at + iv_deserialized_by = lv_deserialized_by ). + + ENDMETHOD. ENDCLASS.