Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp committed Jul 23, 2024
1 parent 167cabf commit 524c69a
Show file tree
Hide file tree
Showing 115 changed files with 6,297 additions and 421 deletions.
5 changes: 4 additions & 1 deletion cloud/zcl_abapgit_aff_registry.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ENDCLASS.



CLASS zcl_abapgit_aff_registry IMPLEMENTATION.
CLASS ZCL_ABAPGIT_AFF_REGISTRY IMPLEMENTATION.


METHOD constructor.
Expand All @@ -46,6 +46,8 @@ CLASS zcl_abapgit_aff_registry IMPLEMENTATION.


METHOD initialize_registry_table.
register( 'BGQC' ).
register( 'CDBO' ).
register( 'CHKC' ).
register( 'CHKO' ).
register( 'CHKV' ).
Expand All @@ -59,6 +61,7 @@ CLASS zcl_abapgit_aff_registry IMPLEMENTATION.
register( 'SMBC' ).
register( 'NONT' ).
register( 'RONT' ).
register( 'UIAD' ).
register( 'UIPG' ).
register( 'UIST' ).
ENDMETHOD.
Expand Down
9 changes: 8 additions & 1 deletion cloud/zcl_abapgit_ajson.clas.locals_imp.abap
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
IF is_parent_type-tab_item_buf IS NOT BOUND. " Indirect hint that table was srt/hsh, see get_node_type
APPEND INITIAL LINE TO <parent_stdtab> REFERENCE INTO lr_target_field.
ASSERT sy-subrc = 0.
ELSE.
CLEAR <tab_item>.
ENDIF.

WHEN lif_kind=>struct_flat OR lif_kind=>struct_deep.
Expand Down Expand Up @@ -1809,8 +1811,13 @@ CLASS lcl_filter_runner IMPLEMENTATION.
METHOD walk.

DATA ls_node TYPE zif_abapgit_ajson_types=>ty_node.
DATA lv_tab_key TYPE string.

IF cs_parent-type = zif_abapgit_ajson_types=>node_type-array.
lv_tab_key = 'array_index'. " path + index
ENDIF.

LOOP AT mr_source_tree->* INTO ls_node WHERE path = iv_path.
LOOP AT mr_source_tree->* INTO ls_node USING KEY (lv_tab_key) WHERE path = iv_path.
CASE ls_node-type.
WHEN zif_abapgit_ajson_types=>node_type-boolean OR zif_abapgit_ajson_types=>node_type-null
OR zif_abapgit_ajson_types=>node_type-number OR zif_abapgit_ajson_types=>node_type-string.
Expand Down
214 changes: 213 additions & 1 deletion cloud/zcl_abapgit_ajson.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,21 @@ CLASS ltcl_json_to_abap DEFINITION
METHODS to_abap_str_to_packed
FOR TESTING
RAISING cx_static_check.
METHODS to_abap_compressed_stdrd
FOR TESTING
RAISING cx_static_check.
METHODS to_abap_compressed_stdrd_key
FOR TESTING
RAISING cx_static_check.
METHODS to_abap_compressed_sort
FOR TESTING
RAISING cx_static_check.
METHODS to_abap_compressed_sort_unique
FOR TESTING
RAISING cx_static_check.
METHODS to_abap_compressed_hash
FOR TESTING
RAISING cx_static_check.
ENDCLASS.

CLASS zcl_abapgit_ajson DEFINITION LOCAL FRIENDS ltcl_json_to_abap.
Expand Down Expand Up @@ -2189,6 +2204,171 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.

ENDMETHOD.

METHOD to_abap_compressed_stdrd.

TYPES: BEGIN OF ty_foo_bar,
foo TYPE string,
bar TYPE string,
END OF ty_foo_bar.

DATA lt_foo_bar TYPE STANDARD TABLE OF ty_foo_bar.
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
DATA lo_ajson TYPE REF TO zcl_abapgit_ajson.
DATA lv_json TYPE string.

lv_json =
'[' &&
' {' &&
' "foo": "abc",' &&
' "bar": "123"' &&
' },' &&
' {' &&
' "foo": "cde"' &&
' }' &&
']'.

lo_ajson = zcl_abapgit_ajson=>parse( lv_json ).

lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).

READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.

cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).

ENDMETHOD.

METHOD to_abap_compressed_stdrd_key.

TYPES: BEGIN OF ty_foo_bar,
foo TYPE string,
bar TYPE string,
END OF ty_foo_bar.

DATA lt_foo_bar TYPE STANDARD TABLE OF ty_foo_bar WITH NON-UNIQUE KEY foo.
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
DATA lo_ajson TYPE REF TO zcl_abapgit_ajson.
DATA lv_json TYPE string.

lv_json =
'[' &&
' {' &&
' "foo": "abc",' &&
' "bar": "123"' &&
' },' &&
' {' &&
' "foo": "cde"' &&
' }' &&
']'.

lo_ajson = zcl_abapgit_ajson=>parse( lv_json ).

lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).

READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.

cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).

ENDMETHOD.

METHOD to_abap_compressed_sort.

TYPES: BEGIN OF ty_foo_bar,
foo TYPE string,
bar TYPE string,
END OF ty_foo_bar.

DATA lt_foo_bar TYPE SORTED TABLE OF ty_foo_bar WITH NON-UNIQUE KEY foo.
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
DATA lo_ajson TYPE REF TO zcl_abapgit_ajson.
DATA lv_json TYPE string.

lv_json =
'[' &&
' {' &&
' "foo": "abc",' &&
' "bar": "123"' &&
' },' &&
' {' &&
' "foo": "cde"' &&
' }' &&
']'.

lo_ajson = zcl_abapgit_ajson=>parse( lv_json ).

lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).

READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.

cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).

ENDMETHOD.

METHOD to_abap_compressed_sort_unique.

TYPES: BEGIN OF ty_foo_bar,
foo TYPE string,
bar TYPE string,
END OF ty_foo_bar.

DATA lt_foo_bar TYPE SORTED TABLE OF ty_foo_bar WITH UNIQUE KEY foo.
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
DATA lo_ajson TYPE REF TO zcl_abapgit_ajson.
DATA lv_json TYPE string.

lv_json =
'[' &&
' {' &&
' "foo": "abc",' &&
' "bar": "123"' &&
' },' &&
' {' &&
' "foo": "cde"' &&
' }' &&
']'.

lo_ajson = zcl_abapgit_ajson=>parse( lv_json ).

lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).

READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.

cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).

ENDMETHOD.

METHOD to_abap_compressed_hash.

TYPES: BEGIN OF ty_foo_bar,
foo TYPE string,
bar TYPE string,
END OF ty_foo_bar.

DATA lt_foo_bar TYPE HASHED TABLE OF ty_foo_bar WITH UNIQUE KEY foo.
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
DATA lo_ajson TYPE REF TO zcl_abapgit_ajson.
DATA lv_json TYPE string.

lv_json =
'[' &&
' {' &&
' "foo": "abc",' &&
' "bar": "123"' &&
' },' &&
' {' &&
' "foo": "cde"' &&
' }' &&
']'.

lo_ajson = zcl_abapgit_ajson=>parse( lv_json ).

lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).

READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.

cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).

ENDMETHOD.

ENDCLASS.

**********************************************************************
Expand Down Expand Up @@ -4408,15 +4588,47 @@ CLASS ltcl_filter_test IMPLEMENTATION.
lo_json->push(
iv_path = '/'
iv_val = 'b' ).
lo_json->push(
iv_path = '/'
iv_val = 'c' ).
lo_json->push(
iv_path = '/'
iv_val = 'd' ).
lo_json->push(
iv_path = '/'
iv_val = 'e' ).
lo_json->push(
iv_path = '/'
iv_val = 'f' ).
lo_json->push(
iv_path = '/'
iv_val = 'g' ).
lo_json->push(
iv_path = '/'
iv_val = 'h' ).
lo_json->push(
iv_path = '/'
iv_val = 'i' ).
lo_json->push(
iv_path = '/'
iv_val = 'j' ).

lo_json_filtered = zcl_abapgit_ajson=>create_from(
ii_source_json = lo_json
ii_filter = me ).

CREATE OBJECT lo_nodes_exp.
lo_nodes_exp->add( ' | |array | | |2' ).
lo_nodes_exp->add( ' | |array | | |10' ).
lo_nodes_exp->add( '/ |1 |str |a |1|0' ).
lo_nodes_exp->add( '/ |2 |str |b |2|0' ).
lo_nodes_exp->add( '/ |3 |str |c |3|0' ).
lo_nodes_exp->add( '/ |4 |str |d |4|0' ).
lo_nodes_exp->add( '/ |5 |str |e |5|0' ).
lo_nodes_exp->add( '/ |6 |str |f |6|0' ).
lo_nodes_exp->add( '/ |7 |str |g |7|0' ).
lo_nodes_exp->add( '/ |8 |str |h |8|0' ).
lo_nodes_exp->add( '/ |9 |str |i |9|0' ).
lo_nodes_exp->add( '/ |10 |str |j |10|0' ).

cl_abap_unit_assert=>assert_equals(
act = lo_json_filtered->mt_json_tree
Expand Down
Loading

0 comments on commit 524c69a

Please sign in to comment.