How To Work With Generic Entity Action Path Using Mapper Yml

Stored procedure mapper yml allows modifying the entity action path and DB types without changing it in the entity class every time it requires.
A common example of a use case: when the entity was generated for a test environment, but going to be used inside production.

Prerequisite:

An OpenLegacy sp sdk.

Step 1: generate mapper yml

  1. Right-click on the project → OpenLegacy → import stored procedures.

  2. Check Generate mapper info check box.

3. ${orchestration-key}.yml will appear in {orchestration-key}/src/main/resources/mapper

Step 2: modifying the mapper yml and the entity class

 

  1. The auto-generated ${orchestration-key}.yml will look like this:

entries: "DEMO.BANK_EXAMPLE.GET_ACCOUNT_BY_ID": "DEMO.BANK_EXAMPLE.GET_ACCOUNT_BY_ID": "DEMO.BANK_EXAMPLE.GET_ACCOUNT_BY_ID" "DEMO.ACCOUNT_OBJ": "DEMO.ACCOUNT_OBJ"

The file structure:

entries: "${ENTITY_action_path_KEY}": "${ACTION_PATH_KEY}": "${ACTION_pATH_VALUE}"

The file contains the entity key ${ENTITY_action_path_KEY}" eg: e.g: DEMO.BANK_EXAMPLE.GET_ACCOUNT_BY_ID,
the entity key contains the entity action path as the value "${ACTION_pATH_VALUE}" e.g: DEMO.BANK_EXAMPLE.GET_ACCOUNT_BY_ID, and its key ${ACTION_PATH_KEY} e.g: DEMO.BANK_EXAMPLE.GET_ACCOUNT_BY_ID


To avoid run-time reflection exception we must not use the entity name as a key.

Instead of the entity name, change the ${ENTITY_action_path_KEY} and the ${ACTION_PATH_KEY} to a generic name e.g: PROCEDURE_PATH for the SP action path.

entries: "PROCEDURE_PATH": "PROCEDURE_PATH": "DEMO.BANK_EXAMPLE.GET_ACCOUNT_BY_ID" "DEMO.ACCOUNT_OBJ": "DEMO.ACCOUNT_OBJ"

 

2. Go to the entity change the action path to the action path key from the mapper yml.

For example:

 

 

Conclusion:

Now you can change the ${ACTION_PATH_KEY} value in the mapper yml every time you want to use a different environment, without update the entity.