abapgit-agent 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +3 -1
- package/CLAUDE.md +248 -0
- package/README.md +16 -2
- package/RELEASE_NOTES.md +80 -8
- package/abap/CLAUDE.md +72 -6
- package/abap/copilot-instructions.md +51 -0
- package/abap/zcl_abgagt_cmd_factory.clas.abap +2 -0
- package/abap/zcl_abgagt_command_tree.clas.abap +237 -0
- package/abap/zcl_abgagt_command_tree.clas.xml +15 -0
- package/abap/zcl_abgagt_command_view.clas.abap +238 -0
- package/abap/zcl_abgagt_command_view.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_tree.clas.abap +70 -0
- package/abap/zcl_abgagt_resource_tree.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_view.clas.abap +68 -0
- package/abap/zcl_abgagt_resource_view.clas.xml +15 -0
- package/abap/zcl_abgagt_rest_handler.clas.abap +2 -0
- package/abap/zcl_abgagt_viewer_clas.clas.abap +58 -0
- package/abap/zcl_abgagt_viewer_clas.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_dtel.clas.abap +98 -0
- package/abap/zcl_abgagt_viewer_dtel.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_factory.clas.abap +41 -0
- package/abap/zcl_abgagt_viewer_factory.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_intf.clas.abap +58 -0
- package/abap/zcl_abgagt_viewer_intf.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_stru.clas.abap +59 -0
- package/abap/zcl_abgagt_viewer_stru.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_tabl.clas.abap +59 -0
- package/abap/zcl_abgagt_viewer_tabl.clas.xml +15 -0
- package/abap/zif_abgagt_command.intf.abap +3 -1
- package/abap/zif_abgagt_viewer.intf.abap +11 -0
- package/abap/zif_abgagt_viewer.intf.xml +15 -0
- package/bin/abapgit-agent +397 -0
- package/docs/commands.md +27 -8
- package/docs/tree-command.md +303 -0
- package/docs/view-command.md +409 -0
- package/package.json +1 -1
- package/src/abap-client.js +22 -0
- package/src/agent.js +27 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
" TREE command implementation - displays package hierarchy tree
|
|
5
|
+
CLASS zcl_abgagt_command_tree DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
6
|
+
PUBLIC SECTION.
|
|
7
|
+
INTERFACES zif_abgagt_command.
|
|
8
|
+
|
|
9
|
+
TYPES: BEGIN OF ty_tree_params,
|
|
10
|
+
package TYPE tdevc-devclass,
|
|
11
|
+
depth TYPE i,
|
|
12
|
+
include_objects TYPE abap_bool,
|
|
13
|
+
END OF ty_tree_params.
|
|
14
|
+
|
|
15
|
+
TYPES: BEGIN OF ty_object_count,
|
|
16
|
+
object TYPE tadir-object,
|
|
17
|
+
count TYPE i,
|
|
18
|
+
END OF ty_object_count.
|
|
19
|
+
|
|
20
|
+
TYPES ty_object_counts TYPE TABLE OF ty_object_count WITH NON-UNIQUE DEFAULT KEY.
|
|
21
|
+
|
|
22
|
+
TYPES: BEGIN OF ty_package_node,
|
|
23
|
+
package TYPE tdevc-devclass,
|
|
24
|
+
parent TYPE tdevc-devclass,
|
|
25
|
+
description TYPE string,
|
|
26
|
+
depth TYPE i,
|
|
27
|
+
object_count TYPE i,
|
|
28
|
+
END OF ty_package_node.
|
|
29
|
+
|
|
30
|
+
TYPES ty_package_nodes TYPE TABLE OF ty_package_node WITH NON-UNIQUE DEFAULT KEY.
|
|
31
|
+
|
|
32
|
+
TYPES: BEGIN OF ty_tree_result,
|
|
33
|
+
success TYPE abap_bool,
|
|
34
|
+
command TYPE string,
|
|
35
|
+
package TYPE tdevc-devclass,
|
|
36
|
+
message TYPE string,
|
|
37
|
+
parent_package TYPE tdevc-devclass,
|
|
38
|
+
nodes TYPE ty_package_nodes,
|
|
39
|
+
total_packages TYPE i,
|
|
40
|
+
total_objects TYPE i,
|
|
41
|
+
objects TYPE ty_object_counts,
|
|
42
|
+
error TYPE string,
|
|
43
|
+
END OF ty_tree_result.
|
|
44
|
+
|
|
45
|
+
METHODS build_tree
|
|
46
|
+
IMPORTING is_params TYPE ty_tree_params
|
|
47
|
+
RETURNING VALUE(rs_result) TYPE ty_tree_result.
|
|
48
|
+
|
|
49
|
+
METHODS get_object_count
|
|
50
|
+
IMPORTING iv_package TYPE tdevc-devclass
|
|
51
|
+
RETURNING VALUE(rv_count) TYPE i.
|
|
52
|
+
|
|
53
|
+
METHODS get_object_counts_by_type
|
|
54
|
+
IMPORTING iv_package TYPE tdevc-devclass
|
|
55
|
+
CHANGING ct_counts TYPE ty_object_counts.
|
|
56
|
+
|
|
57
|
+
METHODS collect_subpackages
|
|
58
|
+
IMPORTING iv_parent TYPE tdevc-devclass
|
|
59
|
+
iv_current_depth TYPE i
|
|
60
|
+
iv_max_depth TYPE i
|
|
61
|
+
iv_include_objects TYPE abap_bool
|
|
62
|
+
CHANGING ct_nodes TYPE ty_package_nodes
|
|
63
|
+
cv_total_objects TYPE i
|
|
64
|
+
ct_types TYPE ty_object_counts.
|
|
65
|
+
|
|
66
|
+
ENDCLASS.
|
|
67
|
+
|
|
68
|
+
CLASS zcl_abgagt_command_tree IMPLEMENTATION.
|
|
69
|
+
|
|
70
|
+
METHOD zif_abgagt_command~get_name.
|
|
71
|
+
rv_name = zif_abgagt_command=>gc_tree.
|
|
72
|
+
ENDMETHOD.
|
|
73
|
+
|
|
74
|
+
METHOD zif_abgagt_command~execute.
|
|
75
|
+
DATA: ls_params TYPE ty_tree_params,
|
|
76
|
+
ls_result TYPE ty_tree_result.
|
|
77
|
+
|
|
78
|
+
ls_result-command = zif_abgagt_command=>gc_tree.
|
|
79
|
+
|
|
80
|
+
IF is_param IS SUPPLIED.
|
|
81
|
+
ls_params = CORRESPONDING #( is_param ).
|
|
82
|
+
ENDIF.
|
|
83
|
+
|
|
84
|
+
IF ls_params-package IS INITIAL.
|
|
85
|
+
ls_result-success = abap_false.
|
|
86
|
+
ls_result-error = 'Package is required'.
|
|
87
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
88
|
+
RETURN.
|
|
89
|
+
ENDIF.
|
|
90
|
+
|
|
91
|
+
IF ls_params-depth IS INITIAL OR ls_params-depth <= 0.
|
|
92
|
+
ls_params-depth = 3.
|
|
93
|
+
ENDIF.
|
|
94
|
+
|
|
95
|
+
IF ls_params-depth > 10.
|
|
96
|
+
ls_params-depth = 10.
|
|
97
|
+
ENDIF.
|
|
98
|
+
|
|
99
|
+
ls_result = build_tree( ls_params ).
|
|
100
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
101
|
+
ENDMETHOD.
|
|
102
|
+
|
|
103
|
+
METHOD build_tree.
|
|
104
|
+
DATA: lv_package TYPE tdevc-devclass,
|
|
105
|
+
lv_max_depth TYPE i,
|
|
106
|
+
lv_total_objects TYPE i,
|
|
107
|
+
lt_all_types TYPE ty_object_counts,
|
|
108
|
+
lt_nodes TYPE ty_package_nodes,
|
|
109
|
+
ls_package TYPE tdevc.
|
|
110
|
+
|
|
111
|
+
lv_package = is_params-package.
|
|
112
|
+
lv_max_depth = is_params-depth.
|
|
113
|
+
|
|
114
|
+
SELECT SINGLE devclass parentcl FROM tdevc
|
|
115
|
+
INTO ls_package
|
|
116
|
+
WHERE devclass = lv_package.
|
|
117
|
+
|
|
118
|
+
IF sy-subrc <> 0.
|
|
119
|
+
rs_result-success = abap_false.
|
|
120
|
+
rs_result-package = lv_package.
|
|
121
|
+
rs_result-error = |Package { lv_package } does not exist|.
|
|
122
|
+
RETURN.
|
|
123
|
+
ENDIF.
|
|
124
|
+
|
|
125
|
+
rs_result-success = abap_true.
|
|
126
|
+
rs_result-command = 'TREE'.
|
|
127
|
+
rs_result-package = lv_package.
|
|
128
|
+
rs_result-message = 'Tree retrieved successfully'.
|
|
129
|
+
rs_result-parent_package = ls_package-parentcl.
|
|
130
|
+
|
|
131
|
+
" Add root package
|
|
132
|
+
DATA(ls_root) = VALUE ty_package_node(
|
|
133
|
+
package = lv_package
|
|
134
|
+
parent = ls_package-parentcl
|
|
135
|
+
description = lv_package
|
|
136
|
+
depth = 0
|
|
137
|
+
object_count = get_object_count( lv_package ) ).
|
|
138
|
+
APPEND ls_root TO lt_nodes.
|
|
139
|
+
|
|
140
|
+
lv_total_objects = ls_root-object_count.
|
|
141
|
+
|
|
142
|
+
" Get object types for root
|
|
143
|
+
IF is_params-include_objects = abap_true.
|
|
144
|
+
get_object_counts_by_type(
|
|
145
|
+
EXPORTING iv_package = lv_package
|
|
146
|
+
CHANGING ct_counts = rs_result-objects ).
|
|
147
|
+
LOOP AT rs_result-objects INTO DATA(ls_obj).
|
|
148
|
+
APPEND ls_obj TO lt_all_types.
|
|
149
|
+
ENDLOOP.
|
|
150
|
+
ENDIF.
|
|
151
|
+
|
|
152
|
+
" Add all subpackages
|
|
153
|
+
collect_subpackages(
|
|
154
|
+
EXPORTING iv_parent = lv_package
|
|
155
|
+
iv_current_depth = 1
|
|
156
|
+
iv_max_depth = lv_max_depth
|
|
157
|
+
iv_include_objects = is_params-include_objects
|
|
158
|
+
CHANGING ct_nodes = lt_nodes
|
|
159
|
+
cv_total_objects = lv_total_objects
|
|
160
|
+
ct_types = lt_all_types ).
|
|
161
|
+
|
|
162
|
+
rs_result-nodes = lt_nodes.
|
|
163
|
+
rs_result-total_packages = lines( lt_nodes ).
|
|
164
|
+
rs_result-total_objects = lv_total_objects.
|
|
165
|
+
rs_result-objects = lt_all_types.
|
|
166
|
+
ENDMETHOD.
|
|
167
|
+
|
|
168
|
+
METHOD get_object_count.
|
|
169
|
+
DATA lv_count TYPE i.
|
|
170
|
+
SELECT COUNT(*) FROM tadir
|
|
171
|
+
INTO lv_count
|
|
172
|
+
WHERE devclass = iv_package
|
|
173
|
+
AND object NOT IN ('DEVC', 'PACK').
|
|
174
|
+
rv_count = lv_count.
|
|
175
|
+
ENDMETHOD.
|
|
176
|
+
|
|
177
|
+
METHOD get_object_counts_by_type.
|
|
178
|
+
DATA lt_counts TYPE ty_object_counts.
|
|
179
|
+
SELECT object COUNT(*) AS count FROM tadir
|
|
180
|
+
INTO TABLE lt_counts
|
|
181
|
+
WHERE devclass = iv_package
|
|
182
|
+
AND object NOT IN ('DEVC', 'PACK')
|
|
183
|
+
GROUP BY object.
|
|
184
|
+
ct_counts = lt_counts.
|
|
185
|
+
ENDMETHOD.
|
|
186
|
+
|
|
187
|
+
METHOD collect_subpackages.
|
|
188
|
+
DATA: lt_direct_subs TYPE TABLE OF tdevc,
|
|
189
|
+
ls_direct TYPE tdevc.
|
|
190
|
+
|
|
191
|
+
SELECT devclass parentcl FROM tdevc
|
|
192
|
+
INTO TABLE lt_direct_subs
|
|
193
|
+
WHERE parentcl = iv_parent
|
|
194
|
+
ORDER BY devclass.
|
|
195
|
+
|
|
196
|
+
LOOP AT lt_direct_subs INTO ls_direct.
|
|
197
|
+
DATA ls_node TYPE ty_package_node.
|
|
198
|
+
ls_node-package = ls_direct-devclass.
|
|
199
|
+
ls_node-parent = iv_parent.
|
|
200
|
+
ls_node-description = ls_direct-devclass.
|
|
201
|
+
ls_node-depth = iv_current_depth.
|
|
202
|
+
ls_node-object_count = get_object_count( ls_direct-devclass ).
|
|
203
|
+
|
|
204
|
+
APPEND ls_node TO ct_nodes.
|
|
205
|
+
cv_total_objects = cv_total_objects + ls_node-object_count.
|
|
206
|
+
|
|
207
|
+
" Add object types
|
|
208
|
+
IF iv_include_objects = abap_true.
|
|
209
|
+
DATA lt_types TYPE ty_object_counts.
|
|
210
|
+
get_object_counts_by_type(
|
|
211
|
+
EXPORTING iv_package = ls_direct-devclass
|
|
212
|
+
CHANGING ct_counts = lt_types ).
|
|
213
|
+
LOOP AT lt_types INTO DATA(ls_type).
|
|
214
|
+
READ TABLE ct_types WITH KEY object = ls_type-object
|
|
215
|
+
ASSIGNING FIELD-SYMBOL(<ls_existing>).
|
|
216
|
+
IF sy-subrc = 0.
|
|
217
|
+
<ls_existing>-count = <ls_existing>-count + ls_type-count.
|
|
218
|
+
ELSE.
|
|
219
|
+
APPEND ls_type TO ct_types.
|
|
220
|
+
ENDIF.
|
|
221
|
+
ENDLOOP.
|
|
222
|
+
ENDIF.
|
|
223
|
+
|
|
224
|
+
IF iv_current_depth < iv_max_depth.
|
|
225
|
+
collect_subpackages(
|
|
226
|
+
EXPORTING iv_parent = ls_direct-devclass
|
|
227
|
+
iv_current_depth = iv_current_depth + 1
|
|
228
|
+
iv_max_depth = iv_max_depth
|
|
229
|
+
iv_include_objects = iv_include_objects
|
|
230
|
+
CHANGING ct_nodes = ct_nodes
|
|
231
|
+
cv_total_objects = cv_total_objects
|
|
232
|
+
ct_types = ct_types ).
|
|
233
|
+
ENDIF.
|
|
234
|
+
ENDLOOP.
|
|
235
|
+
ENDMETHOD.
|
|
236
|
+
|
|
237
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_COMMAND_TREE</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>Tree Command for ABAP Git Agent</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
" VIEW command implementation - view ABAP object definitions
|
|
5
|
+
CLASS zcl_abgagt_command_view DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
6
|
+
|
|
7
|
+
PUBLIC SECTION.
|
|
8
|
+
INTERFACES zif_abgagt_command.
|
|
9
|
+
|
|
10
|
+
TYPES: BEGIN OF ty_view_params,
|
|
11
|
+
objects TYPE string_table,
|
|
12
|
+
type TYPE string,
|
|
13
|
+
END OF ty_view_params.
|
|
14
|
+
|
|
15
|
+
TYPES: BEGIN OF ty_component,
|
|
16
|
+
field TYPE string,
|
|
17
|
+
key TYPE abap_bool,
|
|
18
|
+
type TYPE string,
|
|
19
|
+
length TYPE int4,
|
|
20
|
+
dataelement TYPE string,
|
|
21
|
+
description TYPE string,
|
|
22
|
+
END OF ty_component.
|
|
23
|
+
|
|
24
|
+
TYPES: BEGIN OF ty_view_object,
|
|
25
|
+
name TYPE string,
|
|
26
|
+
type TYPE string,
|
|
27
|
+
type_text TYPE string,
|
|
28
|
+
description TYPE string,
|
|
29
|
+
domain TYPE string,
|
|
30
|
+
domain_type TYPE string,
|
|
31
|
+
domain_length TYPE int4,
|
|
32
|
+
domain_decimals TYPE int4,
|
|
33
|
+
source TYPE string,
|
|
34
|
+
definition TYPE string,
|
|
35
|
+
not_found TYPE abap_bool,
|
|
36
|
+
components TYPE STANDARD TABLE OF ty_component WITH DEFAULT KEY,
|
|
37
|
+
END OF ty_view_object.
|
|
38
|
+
|
|
39
|
+
TYPES ty_view_objects TYPE STANDARD TABLE OF ty_view_object WITH DEFAULT KEY.
|
|
40
|
+
|
|
41
|
+
TYPES: BEGIN OF ty_summary,
|
|
42
|
+
total TYPE i,
|
|
43
|
+
by_type TYPE string_table,
|
|
44
|
+
END OF ty_summary.
|
|
45
|
+
|
|
46
|
+
TYPES: BEGIN OF ty_view_result,
|
|
47
|
+
success TYPE abap_bool,
|
|
48
|
+
command TYPE string,
|
|
49
|
+
message TYPE string,
|
|
50
|
+
objects TYPE ty_view_objects,
|
|
51
|
+
summary TYPE ty_summary,
|
|
52
|
+
error TYPE string,
|
|
53
|
+
END OF ty_view_result.
|
|
54
|
+
|
|
55
|
+
METHODS detect_object_type
|
|
56
|
+
IMPORTING iv_name TYPE string
|
|
57
|
+
RETURNING VALUE(rv_type) TYPE string.
|
|
58
|
+
|
|
59
|
+
METHODS get_object_info
|
|
60
|
+
IMPORTING iv_name TYPE string
|
|
61
|
+
iv_type TYPE string
|
|
62
|
+
RETURNING VALUE(rs_object) TYPE ty_view_object.
|
|
63
|
+
|
|
64
|
+
METHODS build_summary
|
|
65
|
+
IMPORTING it_objects TYPE ty_view_objects
|
|
66
|
+
RETURNING VALUE(rs_summary) TYPE ty_summary.
|
|
67
|
+
|
|
68
|
+
ENDCLASS.
|
|
69
|
+
|
|
70
|
+
CLASS zcl_abgagt_command_view IMPLEMENTATION.
|
|
71
|
+
|
|
72
|
+
METHOD zif_abgagt_command~get_name.
|
|
73
|
+
rv_name = zif_abgagt_command=>gc_view.
|
|
74
|
+
ENDMETHOD.
|
|
75
|
+
|
|
76
|
+
METHOD zif_abgagt_command~execute.
|
|
77
|
+
DATA: ls_params TYPE ty_view_params,
|
|
78
|
+
ls_result TYPE ty_view_result,
|
|
79
|
+
lt_objects TYPE ty_view_objects,
|
|
80
|
+
lv_object TYPE string,
|
|
81
|
+
lo_factory TYPE REF TO zcl_abgagt_viewer_factory,
|
|
82
|
+
lo_viewer TYPE REF TO zif_abgagt_viewer,
|
|
83
|
+
ls_info TYPE ty_view_object.
|
|
84
|
+
|
|
85
|
+
ls_result-command = zif_abgagt_command=>gc_view.
|
|
86
|
+
|
|
87
|
+
IF is_param IS SUPPLIED.
|
|
88
|
+
ls_params = CORRESPONDING #( is_param ).
|
|
89
|
+
ENDIF.
|
|
90
|
+
|
|
91
|
+
IF ls_params-objects IS INITIAL.
|
|
92
|
+
ls_result-success = abap_false.
|
|
93
|
+
ls_result-error = 'Objects parameter is required'.
|
|
94
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
95
|
+
RETURN.
|
|
96
|
+
ENDIF.
|
|
97
|
+
|
|
98
|
+
lo_factory = zcl_abgagt_viewer_factory=>get_instance( ).
|
|
99
|
+
|
|
100
|
+
LOOP AT ls_params-objects INTO lv_object.
|
|
101
|
+
ls_info-name = lv_object.
|
|
102
|
+
|
|
103
|
+
DATA(lv_type) = ls_params-type.
|
|
104
|
+
IF lv_type IS INITIAL.
|
|
105
|
+
lv_type = detect_object_type( lv_object ).
|
|
106
|
+
ENDIF.
|
|
107
|
+
|
|
108
|
+
" Check if object was not found in TADIR
|
|
109
|
+
IF lv_type IS INITIAL.
|
|
110
|
+
ls_info-not_found = abap_true.
|
|
111
|
+
ls_info-type_text = 'Unknown'.
|
|
112
|
+
ELSE.
|
|
113
|
+
ls_info-type = lv_type.
|
|
114
|
+
|
|
115
|
+
" Set type text
|
|
116
|
+
CASE lv_type.
|
|
117
|
+
WHEN 'CLAS'. ls_info-type_text = 'Class'.
|
|
118
|
+
WHEN 'INTF'. ls_info-type_text = 'Interface'.
|
|
119
|
+
WHEN 'TABL'. ls_info-type_text = 'Table'.
|
|
120
|
+
WHEN 'STRU'. ls_info-type_text = 'Structure'.
|
|
121
|
+
WHEN 'DTEL'. ls_info-type_text = 'Data Element'.
|
|
122
|
+
WHEN OTHERS. ls_info-type_text = lv_type.
|
|
123
|
+
ENDCASE.
|
|
124
|
+
|
|
125
|
+
" Get viewer and retrieve info only if object was found
|
|
126
|
+
TRY.
|
|
127
|
+
lo_viewer = lo_factory->get_viewer( lv_type ).
|
|
128
|
+
IF lo_viewer IS BOUND.
|
|
129
|
+
ls_info = lo_viewer->get_info( lv_object ).
|
|
130
|
+
ELSE.
|
|
131
|
+
ls_info = get_object_info( iv_name = lv_object iv_type = lv_type ).
|
|
132
|
+
ENDIF.
|
|
133
|
+
CATCH cx_sy_create_object_error.
|
|
134
|
+
" Fallback for unknown types
|
|
135
|
+
ls_info = get_object_info( iv_name = lv_object iv_type = lv_type ).
|
|
136
|
+
ENDTRY.
|
|
137
|
+
ENDIF.
|
|
138
|
+
|
|
139
|
+
APPEND ls_info TO lt_objects.
|
|
140
|
+
ENDLOOP.
|
|
141
|
+
|
|
142
|
+
ls_result-success = abap_true.
|
|
143
|
+
ls_result-message = 'Retrieved object(s)'.
|
|
144
|
+
ls_result-objects = lt_objects.
|
|
145
|
+
ls_result-summary = build_summary( lt_objects ).
|
|
146
|
+
|
|
147
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
148
|
+
ENDMETHOD.
|
|
149
|
+
|
|
150
|
+
METHOD detect_object_type.
|
|
151
|
+
" Query TADIR to find actual object type
|
|
152
|
+
SELECT SINGLE object FROM tadir
|
|
153
|
+
INTO rv_type
|
|
154
|
+
WHERE obj_name = iv_name
|
|
155
|
+
AND object IN ('CLAS', 'INTF', 'TABL', 'DTEL', 'STRU').
|
|
156
|
+
ENDMETHOD.
|
|
157
|
+
|
|
158
|
+
METHOD get_object_info.
|
|
159
|
+
DATA lv_obj_name TYPE string.
|
|
160
|
+
DATA lv_devclass TYPE tadir-devclass.
|
|
161
|
+
|
|
162
|
+
rs_object-name = iv_name.
|
|
163
|
+
rs_object-type = iv_type.
|
|
164
|
+
|
|
165
|
+
CASE iv_type.
|
|
166
|
+
WHEN 'CLAS' OR 'INTF'.
|
|
167
|
+
IF iv_type = 'CLAS'.
|
|
168
|
+
rs_object-type_text = 'Class'.
|
|
169
|
+
ELSE.
|
|
170
|
+
rs_object-type_text = 'Interface'.
|
|
171
|
+
ENDIF.
|
|
172
|
+
|
|
173
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
174
|
+
INTO (lv_obj_name, lv_devclass)
|
|
175
|
+
WHERE obj_name = iv_name
|
|
176
|
+
AND object = iv_type.
|
|
177
|
+
IF sy-subrc = 0.
|
|
178
|
+
rs_object-description = |{ rs_object-type_text } { iv_name } in { lv_devclass }|.
|
|
179
|
+
ENDIF.
|
|
180
|
+
|
|
181
|
+
WHEN 'TABL'.
|
|
182
|
+
rs_object-type_text = 'Table'.
|
|
183
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
184
|
+
INTO (lv_obj_name, lv_devclass)
|
|
185
|
+
WHERE obj_name = iv_name
|
|
186
|
+
AND object = 'TABL'.
|
|
187
|
+
IF sy-subrc = 0.
|
|
188
|
+
rs_object-description = |Table { iv_name } in { lv_devclass }|.
|
|
189
|
+
ENDIF.
|
|
190
|
+
|
|
191
|
+
WHEN 'STRU'.
|
|
192
|
+
rs_object-type_text = 'Structure'.
|
|
193
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
194
|
+
INTO (lv_obj_name, lv_devclass)
|
|
195
|
+
WHERE obj_name = iv_name
|
|
196
|
+
AND object = 'TABL'.
|
|
197
|
+
IF sy-subrc = 0.
|
|
198
|
+
rs_object-description = |Structure { iv_name } in { lv_devclass }|.
|
|
199
|
+
ENDIF.
|
|
200
|
+
|
|
201
|
+
WHEN 'DTEL'.
|
|
202
|
+
rs_object-type_text = 'Data Element'.
|
|
203
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
204
|
+
INTO (lv_obj_name, lv_devclass)
|
|
205
|
+
WHERE obj_name = iv_name
|
|
206
|
+
AND object = 'DTEL'.
|
|
207
|
+
IF sy-subrc = 0.
|
|
208
|
+
rs_object-description = |Data Element { iv_name } in { lv_devclass }|.
|
|
209
|
+
ENDIF.
|
|
210
|
+
|
|
211
|
+
WHEN OTHERS.
|
|
212
|
+
rs_object-type_text = iv_type.
|
|
213
|
+
ENDCASE.
|
|
214
|
+
ENDMETHOD.
|
|
215
|
+
|
|
216
|
+
METHOD build_summary.
|
|
217
|
+
rs_summary-total = lines( it_objects ).
|
|
218
|
+
|
|
219
|
+
DATA lv_type TYPE string.
|
|
220
|
+
DATA lv_found.
|
|
221
|
+
DATA ls_type TYPE string.
|
|
222
|
+
|
|
223
|
+
LOOP AT it_objects INTO DATA(ls_obj).
|
|
224
|
+
lv_type = ls_obj-type.
|
|
225
|
+
lv_found = abap_false.
|
|
226
|
+
LOOP AT rs_summary-by_type INTO ls_type.
|
|
227
|
+
IF ls_type = lv_type.
|
|
228
|
+
lv_found = abap_true.
|
|
229
|
+
EXIT.
|
|
230
|
+
ENDIF.
|
|
231
|
+
ENDLOOP.
|
|
232
|
+
IF lv_found = abap_false.
|
|
233
|
+
APPEND lv_type TO rs_summary-by_type.
|
|
234
|
+
ENDIF.
|
|
235
|
+
ENDLOOP.
|
|
236
|
+
ENDMETHOD.
|
|
237
|
+
|
|
238
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_COMMAND_VIEW</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>VIEW command - view ABAP object definitions</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_tree DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~post REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_tree IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~post.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = mo_request->get_entity( )->get_string_data( ).
|
|
18
|
+
|
|
19
|
+
" Parse JSON using /ui2/cl_json
|
|
20
|
+
DATA: BEGIN OF ls_request,
|
|
21
|
+
package TYPE string,
|
|
22
|
+
depth TYPE i,
|
|
23
|
+
include_objects TYPE abap_bool,
|
|
24
|
+
END OF ls_request.
|
|
25
|
+
|
|
26
|
+
/ui2/cl_json=>deserialize(
|
|
27
|
+
EXPORTING
|
|
28
|
+
json = lv_json
|
|
29
|
+
CHANGING
|
|
30
|
+
data = ls_request ).
|
|
31
|
+
|
|
32
|
+
DATA lv_json_resp TYPE string.
|
|
33
|
+
|
|
34
|
+
IF ls_request-package IS INITIAL.
|
|
35
|
+
lv_json_resp = '{"success":"","command":"TREE","error":"Package is required"}'.
|
|
36
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
37
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
38
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
39
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
40
|
+
RETURN.
|
|
41
|
+
ENDIF.
|
|
42
|
+
|
|
43
|
+
" Get command from factory
|
|
44
|
+
DATA(lo_factory) = zcl_abgagt_cmd_factory=>get_instance( ).
|
|
45
|
+
DATA(lo_command) = lo_factory->get_command( zif_abgagt_command=>gc_tree ).
|
|
46
|
+
|
|
47
|
+
IF lo_command IS NOT BOUND.
|
|
48
|
+
lv_json_resp = '{"success":"","command":"TREE","error":"TREE command not found"}'.
|
|
49
|
+
lo_entity = mo_response->create_entity( ).
|
|
50
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
51
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
52
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
53
|
+
RETURN.
|
|
54
|
+
ENDIF.
|
|
55
|
+
|
|
56
|
+
" Execute command with is_param
|
|
57
|
+
DATA ls_params TYPE zcl_abgagt_command_tree=>ty_tree_params.
|
|
58
|
+
ls_params-package = ls_request-package.
|
|
59
|
+
ls_params-depth = ls_request-depth.
|
|
60
|
+
ls_params-include_objects = ls_request-include_objects.
|
|
61
|
+
|
|
62
|
+
DATA(lv_result) = lo_command->execute( is_param = ls_params ).
|
|
63
|
+
|
|
64
|
+
lo_entity = mo_response->create_entity( ).
|
|
65
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
66
|
+
lo_entity->set_string_data( lv_result ).
|
|
67
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
68
|
+
ENDMETHOD.
|
|
69
|
+
|
|
70
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_TREE</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - Tree Resource</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_view DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~post REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_view IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~post.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = mo_request->get_entity( )->get_string_data( ).
|
|
18
|
+
|
|
19
|
+
" Parse JSON using /ui2/cl_json
|
|
20
|
+
DATA: BEGIN OF ls_request,
|
|
21
|
+
objects TYPE string_table,
|
|
22
|
+
type TYPE string,
|
|
23
|
+
END OF ls_request.
|
|
24
|
+
|
|
25
|
+
/ui2/cl_json=>deserialize(
|
|
26
|
+
EXPORTING
|
|
27
|
+
json = lv_json
|
|
28
|
+
CHANGING
|
|
29
|
+
data = ls_request ).
|
|
30
|
+
|
|
31
|
+
DATA lv_json_resp TYPE string.
|
|
32
|
+
|
|
33
|
+
IF ls_request-objects IS INITIAL.
|
|
34
|
+
lv_json_resp = '{"success":false,"command":"VIEW","error":"Objects parameter is required"}'.
|
|
35
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
36
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
37
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
38
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
39
|
+
RETURN.
|
|
40
|
+
ENDIF.
|
|
41
|
+
|
|
42
|
+
" Get command from factory
|
|
43
|
+
DATA(lo_factory) = zcl_abgagt_cmd_factory=>get_instance( ).
|
|
44
|
+
DATA(lo_command) = lo_factory->get_command( zif_abgagt_command=>gc_view ).
|
|
45
|
+
|
|
46
|
+
IF lo_command IS NOT BOUND.
|
|
47
|
+
lv_json_resp = '{"success":false,"command":"VIEW","error":"VIEW command not found"}'.
|
|
48
|
+
lo_entity = mo_response->create_entity( ).
|
|
49
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
50
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
51
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
52
|
+
RETURN.
|
|
53
|
+
ENDIF.
|
|
54
|
+
|
|
55
|
+
" Execute command with is_param
|
|
56
|
+
DATA ls_params TYPE zcl_abgagt_command_view=>ty_view_params.
|
|
57
|
+
ls_params-objects = ls_request-objects.
|
|
58
|
+
ls_params-type = ls_request-type.
|
|
59
|
+
|
|
60
|
+
DATA(lv_result) = lo_command->execute( is_param = ls_params ).
|
|
61
|
+
|
|
62
|
+
lo_entity = mo_response->create_entity( ).
|
|
63
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
64
|
+
lo_entity->set_string_data( lv_result ).
|
|
65
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
66
|
+
ENDMETHOD.
|
|
67
|
+
|
|
68
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_VIEW</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>VIEW command REST resource handler</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -22,6 +22,8 @@ CLASS zcl_abgagt_rest_handler IMPLEMENTATION.
|
|
|
22
22
|
lo_router->attach( iv_template = '/unit' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_UNIT' ).
|
|
23
23
|
lo_router->attach( iv_template = '/create' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_CREATE' ).
|
|
24
24
|
lo_router->attach( iv_template = '/import' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_IMPORT' ).
|
|
25
|
+
lo_router->attach( iv_template = '/tree' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_TREE' ).
|
|
26
|
+
lo_router->attach( iv_template = '/view' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_VIEW' ).
|
|
25
27
|
|
|
26
28
|
ro_root_handler = lo_router.
|
|
27
29
|
ENDMETHOD.
|