Create Data API

Endpoint

  • Endpoint: /data/_create

  • Method: POST

Request Structure

  • Body Parameters:

    • RequestInfo: Object containing request information.

    • Resource Details: Object containing the details of the resource to be created or validated.

      • type: Type of resource (boundary, facility, user, boundaryWithTarget).

      • tenantId: Tenant identifier.

      • fileStoreId: File store identifier.

      • action: Action type (create or validate).

      • hierarchyType: Type of hierarchy.

      • campaignId: Campaign identifier.

      • additionalDetails: Additional details object (optional).

Response Structure

  • Success Response:

    - ResponseInfo: Object containing response information.

    - ResourceDetails: Array containing the detail objects of the created or validated resource.

Flow

  1. Client Initiates Request: The client sends a createData request to the Project Factory service.

  2. Validation of Request: The Project Factory service validates the request schema and the provided resource details.

  3. Processing the Request:

    • If action is 'create':

      • Enrich resource details, set status to "data-accepted", and persist in the database.

      • Further creation process happens in the background.

      • After successful creation, set the status to 'completed' and persist resource details in the database.

    • If action is 'validate':

      • Enrich resource details, set the status to "validation-started", and persist in the database.

      • Further creation process happens in the background.

      • If file data is invalid, set the status to 'invalid' and persist in the database.

      • After successful creation, set the status to 'completed' and persist resource details in the database.

    • Fail case: If validation or creation fails, set the status to 'failed' and persist in the database with the error cause in additional details.

  4. Response: The Project Factory service sends the response back to the client containing the resource details and status.

Flow Diagram

Parsing Logic from sheet

The getSheetData function retrieves and processes data from an Excel sheet, validating the structure according to the configuration provided in createAndSearchConfig. The key part of this process is the parseArrayConfig.parseLogic configuration, which specifies how to parse and validate the columns in the sheet. Here's a detailed explanation of how the function works, including the parsing logic:

Parsing Logic Using parseArrayConfig.parseLogic

The parseArrayConfig.parseLogic configuration specifies how each column in the sheet should be processed. Here's how the parsing logic works:

parseLogic: [
    {
        sheetColumn: "A",
        sheetColumnName: "HCM_ADMIN_CONSOLE_FACILITY_CODE",
        resultantPath: "id",
        type: "string"
    },
    {
        sheetColumn: "B",
        sheetColumnName: "HCM_ADMIN_CONSOLE_FACILITY_NAME",
        resultantPath: "name",
        type: "string"
    },
    {
        sheetColumn: "C",
        sheetColumnName: "HCM_ADMIN_CONSOLE_FACILITY_TYPE",
        resultantPath: "usage",
        type: "string"
    },
    {
        sheetColumn: "D",
        sheetColumnName: "HCM_ADMIN_CONSOLE_FACILITY_STATUS",
        resultantPath: "isPermanent",
        type: "boolean",
        conversionCondition: {
            "Permanent": "true",
            "Temporary": ""
        }
    },
    {
        sheetColumn: "E",
        sheetColumnName: "HCM_ADMIN_CONSOLE_FACILITY_CAPACITY",
        resultantPath: "storageCapacity",
        type: "number"
    },
    {
        sheetColumn: "F",
        sheetColumnName: "HCM_ADMIN_CONSOLE_BOUNDARY_CODE_MANDATORY"
    }
]

Column Configuration

Each column configuration specifies:

  • sheetColumn: The column letter in the sheet.

  • sheetColumnName: The expected name of the column in the sheet.

  • resultantPath: The path where the value will be stored in the resultant JSON.

  • type: The expected type of the value (e.g., string, number, or boolean).

  • conversionCondition: Optional conditions for converting values.

Validating Column Names

During the validation step, the function checks that the first-row value matches the expected column name.

Processing Rows

When mapping the rows to JSON, the function uses the resultantPath to place the values in the correct location in the JSON object. It converts values according to the specified type and conversionCondition.

Example Conversion

For a column configuration with type: "boolean" and conversionCondition, the function would convert "Permanent" to true and "Temporary" to an empty string.

{
    "sheetColumn": "D",
    "sheetColumnName": "HCM_ADMIN_CONSOLE_FACILITY_STATUS",
    "resultantPath": "isPermanent",
    "type": "boolean",
    "conversionCondition": {
        "Permanent": "true",
        "Temporary": ""
    }
}

In summary, the getSheetData function retrieves and processes data from an Excel sheet, validating the structure and content according to the createAndSearchConfig configuration. The parseArrayConfig.parseLogic configuration specifies how each column should be validated and processed into the resultant JSON format.

Last updated

Was this helpful?