Recordset Sorting Utility
The Recordset Sorting utility is a Java function that allows you to sort elements of a recordset by one or more field values in ascending or descending order. For instance, you can sort the recordset data according to the date when this data was picked up as in the example below:
Copy
Unsorted recordset example
{Claim1, 2023-10-06, P, ICD10 }, {Claim2, 2023-08-26, I, ICD9 }, {Claim3, 2023-09-28, P, ICD9 }, {Claim4, 2023-09-01, H, ICD10 }
Copy
Example of a recordset sorted by the second field in descending order
{Claim1, 2023-10-06, P, ICD10}, {Claim3, 2023-09-28, P, ICD9}, {Claim4, 2023-09-01, H, ICD10}, {Claim2, 2023-08-26, I, ICD9}
Note The Recordset Sorting utility is not to be used with large and complex recordsets.
Location
Edifecs Library / Tools / XEngine / RecordSet Utils
Prerequisites
Configuration
Follow the instructions below to add and configure the recordset sorting function in your map.
- Download and unpack the RecordSet Utils.zip archive from the Edifecs Library on your local drive.
- Copy the recordsetutils.jar archive from the unpacked RecordSet Utils folder to %ECRootPath%\Common\JAExtension
- Open your map file in SpecBuilder.
- Register a new Java class. To do this:
- In SpecBuilder, on the Home tab of the ribbon, in Tools, click Java Classes Declaration.
- In Java Classes Declaration Editor window, click New.
- In Java Class Declaration window, do the following:
- Java Class Name: Click
to navigate to the class file and select the RecordSetUtils class from the recordsetutils.jar.
- Variable Name: Provide arbitrary name, for example rsUtil.
- Click OK.
- The new Java class is registered:
- Click Close.
- Add a Java function to your map. To do this:
- Right-click the map area and select Insert Function > Programming Category > Java.
- Connect the Java function to the guideline element where the recordset sorting is required. Observe the functions order in the example below:
- Configure the Java function you added. To do this:
- Right-click the function in the map area, and then click Properties
- In the Function Properties window, go to the Settings tab.
- Under Java Function, in Class, select the RecordSetUtils class you declared from the drop-down list.
- In Method, select sort(XEMapperContext, Properties) from the drop-down list.
- In the table that appears, add the following properties:
- name: (Mandatory) The name of your recordset to be sorted (for example, DTM). If the name is not provided, an exception is thrown.
- fields: (Mandatory) The indexes of the recordset fields to be used as keys for sorting, starting from 0. If indexes are not provided or have a value greater than the number of recordset fields, an exception is thrown.
For example, there is a DTM recordset with the following entries:
DTM,002,20210217
DTM,003,20210417
DTM,004,20210117
In order to sort this recordset by date, add the property value 2 (the index of the third field) in the fields property. To sort the recordset by date and the second field, add the property value 2,1.
- ascending: (Optional) The direction of sorting. Enter true (default) to set the ascending order or false to set the descending order of sorting.
- Click OK and save your map.
|
|