Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Label Designer & Repository Transfer #6

Merged
merged 9 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .abapgit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DATA>
<NAME>abapgit-ext-tools</NAME>
<MASTER_LANGUAGE>E</MASTER_LANGUAGE>
<STARTING_FOLDER>/src/</STARTING_FOLDER>
<FOLDER_LOGIC>PREFIX</FOLDER_LOGIC>
Expand All @@ -11,6 +12,7 @@
<MIN_RELEASE>702</MIN_RELEASE>
</item>
</REQUIREMENTS>
<VERSION_CONSTANT>ZIF_ABAPGIT_EXT_TOOLS=&gt;C_VERSION</VERSION_CONSTANT>
</DATA>
</asx:values>
</asx:abap>
63 changes: 63 additions & 0 deletions src/zabapgit_label_designer.prog.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
REPORT zabapgit_label_designer.

********************************************************************************
* abapGit Label Designer
*
* A tool for designing labels for your personal abapGit settings
* Colors are based on the standard CSS colors supported by browsers
* https://www.w3schools.com/cssref/css_colors.php
*
* https://github.com/Marc-Bernard-Tools/ABAP-Tools-for-abapGit
*
* Copyright 2023 Marc Bernard <https://marcbernardtools.com/>
* SPDX-License-Identifier: MIT
********************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2023 Marc Bernard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
********************************************************************************

CONSTANTS c_version TYPE string VALUE '1.0.0' ##NEEDED.

SELECTION-SCREEN BEGIN OF SCREEN 1001.
* dummy for triggering screen
SELECTION-SCREEN END OF SCREEN 1001.

DATA go_gui TYPE REF TO zcl_abapgit_label_designer.

AT SELECTION-SCREEN ON EXIT-COMMAND.

CASE sy-ucomm.
WHEN 'CBAC' OR 'CCAN'. "Back & Escape
IF go_gui->back( ) = abap_true.
go_gui->free( ).
ELSE.
LEAVE TO SCREEN 1001.
ENDIF.
ENDCASE.

START-OF-SELECTION.

CREATE OBJECT go_gui.

go_gui->startup( '' )->render( ).

CALL SELECTION-SCREEN 1001.
21 changes: 21 additions & 0 deletions src/zabapgit_label_designer.prog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZABAPGIT_LABEL_DESIGNER</NAME>
<SUBC>1</SUBC>
<RLOAD>E</RLOAD>
<FIXPT>X</FIXPT>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>abapGit Label Designer</ENTRY>
<LENGTH>25</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>
4 changes: 3 additions & 1 deletion src/zabapgit_repo_labels.prog.abap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ REPORT zabapgit_repo_labels.
* or remove labels based on free selection of repository name, package, or URL.
*
* https://github.com/Marc-Bernard-Tools/ABAP-Tools-for-abapGit
* https://marcbernardtools.com/
*
* Copyright 2023 Marc Bernard <https://marcbernardtools.com/>
* SPDX-License-Identifier: MIT
********************************************************************************
* The MIT License (MIT)
*
Expand Down
256 changes: 256 additions & 0 deletions src/zabapgit_repo_transfer.prog.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
REPORT zabapgit_repo_transfer.

********************************************************************************
* abapGit Repository Transfer
*
* A tool for doing a mass-transfer of abapGit repositories and settings from
* one system to another based on a free selection of existing repositories and
* user settings.
*
* https://github.com/Marc-Bernard-Tools/ABAP-Tools-for-abapGit
*
* Copyright 2023 Marc Bernard <https://marcbernardtools.com/>
* SPDX-License-Identifier: MIT
********************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2023 Marc Bernard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
********************************************************************************

CONSTANTS c_version TYPE string VALUE '1.0.0' ##NEEDED.

TABLES: tdevc, tdevct, usr02.

SELECTION-SCREEN BEGIN OF BLOCK sc_header WITH FRAME TITLE sc_titl0.
SELECTION-SCREEN:
SKIP,
COMMENT /1(77) sc_txt1,
COMMENT /1(77) sc_txt2,
COMMENT /1(77) sc_txt3.
SELECTION-SCREEN END OF BLOCK sc_header.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK sc_repo WITH FRAME TITLE sc_titl1.
SELECT-OPTIONS:
s_name FOR tdevct-ctext LOWER CASE,
s_pack FOR tdevc-devclass,
s_url FOR tdevct-ctext LOWER CASE.
PARAMETERS:
p_online AS CHECKBOX DEFAULT 'X',

Check failure on line 58 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "p_online" not used

https://rules.abaplint.org/unused_variables
p_offlin AS CHECKBOX DEFAULT 'X',

Check failure on line 59 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "p_offlin" not used

https://rules.abaplint.org/unused_variables
p_favor AS CHECKBOX.

Check failure on line 60 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "p_favor" not used

https://rules.abaplint.org/unused_variables
SELECTION-SCREEN END OF BLOCK sc_repo.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK sc_user WITH FRAME TITLE sc_titl2.
SELECT-OPTIONS:
s_user FOR usr02-bname.

Check failure on line 67 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "s_user" not used

https://rules.abaplint.org/unused_variables
SELECTION-SCREEN END OF BLOCK sc_user.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK sc_act WITH FRAME TITLE sc_titl3.
PARAMETERS:
p_backup RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND lar,
p_restor RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK sc_act.

SELECTION-SCREEN BEGIN OF BLOCK sc_opt WITH FRAME TITLE sc_titl4.
PARAMETERS:
p_pull AS CHECKBOX MODIF ID res,

Check failure on line 80 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "p_pull" not used

https://rules.abaplint.org/unused_variables
p_chksum AS CHECKBOX MODIF ID res,

Check failure on line 81 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "p_chksum" not used

https://rules.abaplint.org/unused_variables
p_global AS CHECKBOX MODIF ID res,

Check failure on line 82 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "p_global" not used

https://rules.abaplint.org/unused_variables
p_user AS CHECKBOX MODIF ID res.

Check failure on line 83 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "p_user" not used

https://rules.abaplint.org/unused_variables
SELECTION-SCREEN END OF BLOCK sc_opt.

DATA gt_repos TYPE zif_abapgit_repo_srv=>ty_repo_list.

FORM get.

DATA:
lo_online TYPE REF TO zcl_abapgit_repo_online,
lv_name TYPE string,
lv_package TYPE devclass,
lv_url TYPE string,
lx_error TYPE REF TO zcx_abapgit_exception.

FIELD-SYMBOLS <li_repo> TYPE REF TO zif_abapgit_repo.

TRY.
gt_repos = zcl_abapgit_repo_srv=>get_instance( )->list( ).

LOOP AT gt_repos ASSIGNING <li_repo>.
lv_name = <li_repo>->get_name( ).
lv_package = <li_repo>->get_package( ).

IF <li_repo>->is_offline( ) = abap_false.
lo_online ?= <li_repo>.
lv_url = lo_online->get_url( ).
ELSE.
lv_url = ''.
ENDIF.

IF NOT ( lv_name IN s_name AND lv_package IN s_pack AND lv_url IN s_url ).
DELETE gt_repos.
ENDIF.
ENDLOOP.
CATCH zcx_abapgit_exception INTO lx_error.
MESSAGE lx_error TYPE 'E'.
ENDTRY.
ENDFORM.

FORM list.

TYPES:
BEGIN OF ty_alv,
name TYPE string,
package TYPE devclass,
url TYPE string,
labels TYPE string,
END OF ty_alv.

DATA:
lo_online TYPE REF TO zcl_abapgit_repo_online,
ls_settings TYPE zif_abapgit_persistence=>ty_repo-local_settings,
ls_alv TYPE ty_alv,
lt_alv TYPE STANDARD TABLE OF ty_alv WITH DEFAULT KEY.

FIELD-SYMBOLS <li_repo> TYPE REF TO zif_abapgit_repo.

LOOP AT gt_repos ASSIGNING <li_repo>.
ls_settings = <li_repo>->get_local_settings( ).

CLEAR ls_alv.
ls_alv-name = <li_repo>->get_name( ).
ls_alv-package = <li_repo>->get_package( ).
IF <li_repo>->is_offline( ) = abap_false.
lo_online ?= <li_repo>.
ls_alv-url = lo_online->get_url( ).
ENDIF.
ls_alv-labels = ls_settings-labels.
INSERT ls_alv INTO TABLE lt_alv.
ENDLOOP.

SORT lt_alv.

CALL FUNCTION 'RSDU_CALL_ALV_TABLE'
EXPORTING
i_title = 'Repository Labels'
i_ta_data = lt_alv.

ENDFORM.

FORM add_remove.

DATA:
li_repo TYPE REF TO zcl_abapgit_repo,
ls_settings TYPE zif_abapgit_persistence=>ty_repo-local_settings,
lx_error TYPE REF TO zcx_abapgit_exception.

Check failure on line 168 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Variable "lx_error" not used

https://rules.abaplint.org/unused_variables

FIELD-SYMBOLS:
<li_repo> TYPE REF TO zif_abapgit_repo.

LOOP AT gt_repos ASSIGNING <li_repo>.
li_repo ?= <li_repo>.

ls_settings = li_repo->get_local_settings( ).

* SPLIT ls_settings-labels AT ',' INTO TABLE lt_labels.
*
* LOOP AT s_label ASSIGNING <lv_label>.
* lv_label = condense( <lv_label>-low ).
* READ TABLE lt_labels TRANSPORTING NO FIELDS WITH KEY table_line = lv_label.
* IF sy-subrc <> 0 AND p_add = abap_true.
* INSERT lv_label INTO TABLE lt_labels.
* ELSEIF sy-subrc = 0 AND p_remove = abap_true.
* DELETE lt_labels WHERE table_line = lv_label.
* ENDIF.
* ENDLOOP.
*
* CONCATENATE LINES OF lt_labels INTO lv_label SEPARATED BY ','.
*
* ls_settings-labels = zcl_abapgit_repo_labels=>normalize( lv_label ).
*
* TRY.
* li_repo->set_local_settings( ls_settings ).
* COMMIT WORK AND WAIT.
* CATCH zcx_abapgit_exception INTO lx_error.
* MESSAGE lx_error TYPE 'I'.
* ENDTRY.

Check warning on line 199 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Commented code

https://rules.abaplint.org/commented_code
Comment on lines +178 to +199
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code

Suggest following fix,

Suggested change
* SPLIT ls_settings-labels AT ',' INTO TABLE lt_labels.
*
* LOOP AT s_label ASSIGNING <lv_label>.
* lv_label = condense( <lv_label>-low ).
* READ TABLE lt_labels TRANSPORTING NO FIELDS WITH KEY table_line = lv_label.
* IF sy-subrc <> 0 AND p_add = abap_true.
* INSERT lv_label INTO TABLE lt_labels.
* ELSEIF sy-subrc = 0 AND p_remove = abap_true.
* DELETE lt_labels WHERE table_line = lv_label.
* ENDIF.
* ENDLOOP.
*
* CONCATENATE LINES OF lt_labels INTO lv_label SEPARATED BY ','.
*
* ls_settings-labels = zcl_abapgit_repo_labels=>normalize( lv_label ).
*
* TRY.
* li_repo->set_local_settings( ls_settings ).
* COMMIT WORK AND WAIT.
* CATCH zcx_abapgit_exception INTO lx_error.
* MESSAGE lx_error TYPE 'I'.
* ENDTRY.

ENDLOOP.

ENDFORM.

FORM screen.

DATA lv_input TYPE abap_bool.

LOOP AT SCREEN.
IF screen-group1 = 'RES'.
lv_input = boolc( p_restor = abap_true ).
ELSE.
lv_input = abap_true.
ENDIF.

IF lv_input = abap_true.
screen-input = '1'.
ELSE.
screen-input = '0'.
ENDIF.

MODIFY SCREEN.
ENDLOOP.

ENDFORM.

INITIALIZATION.

sc_titl0 = 'Description'.
sc_txt1 = 'This is a tool for doing a mass-transfer of repositories and'.
sc_txt2 = 'settings from one system to another based on a free selection of'.
sc_txt3 = 'existing repositories and user settings.'.
sc_titl1 = 'Repository Selection'.
sc_titl2 = 'User Selection'.
sc_titl3 = 'Action'.
sc_titl4 = 'Restore Options'.

AT SELECTION-SCREEN.

PERFORM screen.

AT SELECTION-SCREEN OUTPUT.

PERFORM screen.

START-OF-SELECTION.

PERFORM get.

CASE abap_true.
WHEN p_backup.

Check failure on line 250 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Empty block, add code: When

https://rules.abaplint.org/empty_structure
* PERFORM add_remove.
* PERFORM list.

Check warning on line 252 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Commented code

https://rules.abaplint.org/commented_code
WHEN p_restor.

Check failure on line 253 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Empty block, add code: When

https://rules.abaplint.org/empty_structure
* PERFORM add_remove.
* PERFORM list.

Check warning on line 255 in src/zabapgit_repo_transfer.prog.abap

View check run for this annotation

abaplint / abaplint

Commented code

https://rules.abaplint.org/commented_code
ENDCASE.
Loading