REST Services for Downloading Input, Output, Dropped Record, Error, and Duplicate Record Files from Database
Use case Description
This use case describes the implementation of REST services to allow users to download various types of files (Input file, Output file, Dropped record file, Error file, Duplicate record file) from the database. These services will be mapped to the user interface, enabling users to perform these tasks directly from the front end.
Actors:
User
Backend Server
Database (Solution DB)
UI (Web Form)
Preconditions:
Files (Input, Output, Dropped record, Error, Duplicate record) are stored in the Solution DB.
RESTful API is set up on the backend server.
UI supports interaction with the REST services for file downloads.
Postconditions:
Users can download the specified files directly from the UI.
The requested files are retrieved from the database and provided to the user for download.
Steps:
1. Design Process flow
Overview
Backend Service for Download Input file, V3 Target File, Combined Error Report, Unsupported Product Code Report, and Account Structure Report.
Process Overview
This process flow service, supported by a structured process, retrieves all input file attachments and output and error reports.
The flow contains data formatted in JSON using ContextTarget, which the REST provider API will call. This API is consumed in the UI and functions as a backend service for the UI.
Process Flow :
Once the flow has been designed, it must be published for the REST provider.
Front-End Interface:
a. Default Flow: To Download Input File Attachment
Process Overview
The Process flow is designed to manage input file requests, allowing users to download file files from the User Interface (UI). This flow functions as a backend service for the REST provider API. When a user triggers the API, this flow is invoked to handle the request.
Process flow:
User Interface:
Process Steps
User Initiates File Download Request
Action: User interacts with the User Interface (UI) to request an input file download.
Trigger: User clicks the download button or selects the download option.
UI Sends Request to REST Provider API
Action: The UI sends an HTTP request to the REST provider API endpoint.
HTTP Method: GET
REST Provider API Calls Default Flow
Action: The REST provider API receives the request and invokes the default flow to handle the file retrieval process.
Process: The API calls the backend service associated with the default flow.
Backend Service Retrieves Input File Attachment
Action: The backend service retrieves the specified input file attachment from the server or database.
File Types: Input file V3, Target File Combined Error Report, Unsupported Product Code Report, Account Structure Report.
Backend Service Returns File to REST Provider API
Action: The backend service sends data back to the REST provider API.
REST Provider API Sends Response to UI
Action: The REST provider API sends the response containing the file data back to the UI.
UI Processes and Provides File Download to User
Action: The UI processes the response and initiates the file download for the user.
Result: User receives the requested input file.
Process flow Activity:
Source Activity - The source comprises a database. It is necessary to create DbInfo and DbLayout to be invoked in the source activity
Go to edit query and to write tables joining query.
You must utilize the EDIT Query option to efficiently retrieve attributes from multiple tables and display relevant information on the user interface. Additionally, you implement where clauses conditions to filter the data as needed.
Query Details:
Table Name: DB/file_queueFQ/
|
|
---|
Stream Selector - Use the Steam selector to specify the input stream to be consumed by the activity when there are two sources (DB).
Target Layout - The JSON schema for the source data (database) will be designed to be utilized in the RESTful API for the user interface. JSON is selected for its compatibility with RESTful APIs.
Mapping - Load the database schema and the target schema (JSON) to do one-to-one mapping.
Apply the foreach loop to fetch the data one by one.
Context Target Using ContextTarget to store data in the flow which will be carried by the REST provider.
b. Flow to Download the Output & Error Reports File:
Process Overview
The Process flow is designed to manage output & error report file requests, allowing users to download output & error report files from the User Interface (UI). This flow functions as a backend service for the REST provider API. When a user triggers the API, this flow is invoked to handle the request.
Process Flow:
FrondEnd:
Process Steps
User Initiates File Download Request
Action: User interacts with the User Interface (UI) to request an Output & Error Report file download.
Trigger: User clicks the download button or selects the download option.
UI Sends Request to REST Provider API
Action: The UI sends an HTTP request to the REST provider API endpoint.
HTTP Method: GET
REST Provider API Calls Default Flow
Action: The REST provider API receives the request and invokes the default flow to handle the file retrieval process.
Process: The API calls the backend service associated with the default flow.
Backend Service Retrieves Input File Attachment
Action: The backend service retrieves the specified input file attachment from the server or database.
File Types: v3 Output file, EBMR output file, Dropped record file, Error file, Filtered product list, Dropped record, DBQUERY_FILE
Backend Service Returns File to REST Provider API
Action: The backend service sends data back to the REST provider API.
REST Provider API Sends Response to UI
Action: The REST provider API sends the response containing the file data back to the UI.
UI Processes and Provides File Download to User
Action: The UI processes the response and initiates the file download for the user.
Result: User receives the requested input file.
Process flow Activity:
Source Activity - The source comprises a database. It is necessary to create DbInfo and DbLayout to be invoked in the source activity.
Go to edit query and to write tables joining query.
You must utilize the EDIT Query option to efficiently retrieve attributes from multiple tables and display relevant information on the user interface. Additionally, you implement where clauses conditions to filter the data as needed.
Query Details:
Table Name: DB/file_queueFQ/
|
---|
Stream Selector - Use the Steam selector to specify the input stream to be consumed by the activity when there are two sources (DB).
Target Layout - The JSON schema for the source data (database) will be designed to be utilized in the RESTful API for the user interface. JSON is selected for its compatibility with RESTful APIs.
Mapping - Load the database schema and the target schema (JSON) to do one-to-one mapping.
Apply the for each loop to fetch the data one by one.
Context Target Using ContextTarget to store data in the flow which will be carried by the REST provider.
2. Create REST Provider End-point
In this particular use case, the process flow is shared by developing a REST provider that will eventually be integrated with the user interface.
Follow the steps below to create a REST Provider:
Click Configure > WEB SERVICES > REST Provider.
Click Create REST Provider.
In the Create REST Provider window, type the name and description of the new Web Service Provider service in the Name and Description fields respectively.
Type API Version, for example, your API version can be 1
Type the resource end path URL in the Resource End Path field. The URL can be static or dynamic. Static URL example: /get/File
Select the process flow name to trigger with the web service from the Process Flow Name field. example: Pf_Attachment
Set parameterName attribute of the context source should be restRequest
fileQueueId-This process will generate a unique File ID for each file.
fileType - Type of file downloading such as Input, Output, and Report files.
Click Add Method and select GET as the method type.
Select the Response Schema (For example, we are opting for the schema that has been utilized in the process flow as the target schema)
Save it.
3. Publish the Provider (REST URL) at UI
Once the above steps have been completed, it is necessary to link the REST provider URL with the user interface (UI) to present the data on the UI