Generate Data API
Endpoint
Endpoint: /data/_generate
Method: POST
Request Structure
RequestInfo: Object containing request information.
Query Parameters:
type: Type of the resource for which data needs to be generated.
tenantId: Tenant identifier.
hierarchyType: Type of hierarchy.
forceUpdate: (Optional) Boolean indicating whether to force update existing data.
Response Structure
ResponseInfo: Object containing response information.
GeneratedResource: Array containing the details object of the generated resource.
Flow
Client Request: The client sends a POST request to /v1/data/_generate.
Request Validation: After receiving the request, the server validates the request structure and parameters.
Generate Data Process:
Validation: The server validates the generated request.
Data Processing:
Fetch Data: Fetches existing data from the database.
Modify Data: Modify the retrieved data as necessary.
Generate New ID: Generates a new random ID and sets the file store ID to null.
Expire Old Data: Marks existing data status as expired.
Generate New Data: Generates new data based on the request parameters.
Update and Persist: Updates and persists the generated request along with the new data.
Force Update Logic:
If the forceUpdate parameter is set to true:
Search and Update: Searches for existing data of the specified type and updates the existing data information.
If the forceUpdate parameter is not provided or set to false:
Fetch Existing Data: Retrieves already persisted data from the database of the specified type.
Response Creation: After processing the request, the server creates a response containing the details of the generated resource.
Response Dispatch: The server sends the generated response back to the client.
Error Handling: If errors occur, generate an error response and send it.
Flow Diagram
Data to Sheet Parsing Logic
Fetch Required Columns from MDMS:
Use
callMdmsData
to get type schema columns in the correct order.
Define Headers:
MDMS schema required columns are headers and ensures column orders.
Localise Headers:
Use
getLocalizedHeaders
withlocalizationMap
.
Localise Sheet Name:
Use
getLocalizedName
withlocalizationMap
and generate a sheet.
Adding a New Column to the Generated Sheet
To add a new column to the Generated sheet, follow these steps:
Search Schema Details
Locate the type schema from the
HCM-ADMIN-CONSOLE.adminSchema
schema in the workbench.
Identify Column Type
Determine the column type based on the properties defined in the schema:
stringProperties
for string-based columns.numberProperties
for numeric-based columns.enumProperties
for enumerated columns.
Define New Column
Add the new column to the schema under the appropriate properties section:
String Column: Include attributes such as
name
,type
,maxLength
,minLength
,isUnique
,isRequired
,description
, andorderNumber
.Number Column: Include attributes such as
name
,type
,maximum
,minimum
,isRequired
,description
,orderNumber
, anderrorMessage
.Enum Column: Include attributes such as
name
,enum
,isRequired
,description
, andorderNumber
.
Ensure Column Uniqueness
Ensure that the
isUnique
property is correctly set for string columns to enforce uniqueness.
Column Visibility (Future Implementation)
Note that
hideColumn
andfreezeColumn
features will be implemented in the next version.
Sheet Data Validation:
This process is sufficient for validating the new column in the generated sheet.
Column Change Reflection in APIs
If there's a need to reflect the column in APIs, follow these additional steps:
Update
createAndSearch.ts
FileModify the
createAndSearch.ts
file under the defined typeparseLogic
object.Integrate the new column into the appropriate data structures used for API operations.
Example :
sheetColumn: A
sheetColumnName: HCM_ADMIN_CONSOLE_FACILITY_CODE
resultantPath: id
type: string
Mapping: Data from column A (HCM_ADMIN_CONSOLE_FACILITY_CODE) in the sheet will be mapped to
id
in the API data.
By following these steps, you can successfully add and validate a new column in the generated sheet and ensure its reflection in the associated APIs.
Template Properties
General Rules
Locked Headers: The headers in the templates for each data type (user, facility, target) are locked and cannot be changed.
Sheet Protection: Certain sheets within the templates will have specific locked areas to ensure data integrity.
README Sheet: Each type of template includes a README sheet which is read-only and locked.
Target Template
Editable Columns: You can only modify the 'Target' column. All other columns are locked and cannot be edited.
Facility Template
Adding Rows: You are allowed to add new rows to create new facilities.
Editable Columns: You can modify the "Boundary Code" and 'Usage' columns.
Locked Sheets: The boundary data sheet within the facility template is locked and cannot be modified.
Dropdown Columns: The following columns are dropdowns:
Facility Type
Facility Status
Facility Usage
Facility Usage: Facility usage can be 'Active' or 'Inactive'. Active facilities are used in the campaign and require a boundary code to map.
User Template
Adding Rows: You are allowed to add new rows.
Locked Sheets: The boundary data sheet within the user template is locked and cannot be modified.
Dropdown Columns: The following columns are dropdowns:
Role
Employment Type
Data for Dropdowns
The data for the dropdown columns comes from the
mdms
(Master Data Management System) under theadminSchema
master.
Last updated
Was this helpful?