Integrating an external data source
7 Tarefas
25 min
Scenario
A REST service has been created to access contact data for a customer. Your task is to access that data to replace the sample data.
Use the following credentials to log in to the exercise system:
| Role | User name | Password |
|---|---|---|
| Application Administrator | cdmadmin | password123! |
Your assignment consists of the following tasks:
Task 1: Configure a REST Connector for the external data
Run the REST integration wizard to connect to the external data source.
Task 2: Save the Data Page to your application Ruleset
Create a copy of the Contact Data Page in your application Ruleset.
Task 3: Copy the response Data Transform to your application Ruleset
Copy the Response Data Transform to your application ruleset and modify the Applies to field to reference the REST service for the external data.
Task 4: Create the request Data Transform in your application Ruleset
Create the request Data Transform in your application Ruleset and modify the Applies to field to reference the REST service for the external data.
Task 5: Update the Data Page to reference the external source
Modify the D_Contact page in your application Ruleset to reference the external REST source.
Task 6: Update the response Data Transform to map the response data
Modify the response Data Transform to map data from the external source to your application.
Task 7: View the external data
Call the REST service and process the response.
Challenge Walkthrough
Detailed Tasks
1 Configure a REST connector for the external data
Run the REST integration wizard to connect to the external data source.
- On the exercise system landing page, click Launch Pega Infinity™ , and then log in as an Administrator by entering the following credentials:
- In the User name field, enter CommonAdmin.
- In the Password field, enter password123!.
- In the header of Infinity Studio, click Configure > Integration > Connectors > Create REST Integration to run the New REST Integration wizard.
- In the System details section, enter the following connection details:
- In the Name field, enter ExternalCon.
- In the Endpoint URL field, enter: http://localhost:8080/prweb/PRRestService/test/01-01-01/getContactData/ContactId
- In the Resource path section, select the ContactId parameter.
- In the Authentication section, click Add authentication to configure the authentication service:
- Select Define New.
- In the User name field, enter serviceuser.
- Click Set password, and then enter password123!.
- Click Submit.
- Click Next to configure the resource methods.
- In the Resource Name field, enter ExternalCon, and then click Next to configure the Data Model. This is the name you use to identify the REST resource in the Contact Data Page.
- On the Data Model page, click Add a REST response.
- In the Add a REST response dialog box, click Run to query the service and get a JSON response, which is shown in the following figure:
- Click Submit to save the Data Model.
- Click Next to review the configuration.
- In the Data Layer section, select Skip (I'll do it later), and then click Create to create the REST connector.
You do not need a new data layer, as you integrate the REST Connector with an existing data layer. - Wait for the generation to complete, and then click Close.
Nota: If you receive a timeout error while creating the connector, refresh your browser page.
2 Save the Data Page to your application ruleset
Create a copy of the Contact Data Page in your application ruleset.
- In the navigation pane of Infinity Studio, click App, and then in the search field, enter Common-LDM-Entity.
- Expand Contact > Data Model > Data Page.
- In the Data Explorer, open the D_Contact Data Page.
- Click Save as, and then on the new page, maintain the default context settings:
Setting
Value
Context
GoGoRoad
Apply to
Common-LDM-Entity-Contact
Add to ruleset
GoGoRoad:01-01-01
- Click Create and open, and then click Save.
3 Copy the response Data Transform
Copy the response Data Transform to your application Ruleset and modify the Applies to field to reference the REST service for the external data.
- Open the D_Contact Data Page saved to your application ruleset (the one created in the previous task).
- Click the target icon to the right of the Response Data Transform.
- Click Save as.
- In the Label field, enter: ExternalCon_Lookup_Response.
- In the Context section, in the Apply to field, enter Common-LDM-Entity-Contact.
- Click Create and open, and then click Save.
- In the Definition tab, in Step 1, in the Action field, select Comment.
- In the Target field, enter: This is the extension response data transform to map the response of the contact
- Click Save.
4 Create the request Data Transform in your application ruleset
Create the request Data Transform in your application ruleset and set the Applies to field to reference the REST service for the external data.
- In the header of Infinity Studio, click Create > Data Model > Data Transform.
- In the Label field, enter: ExternalCon_LookupDetail_Request.
- In the Context section, in the Apply to field, enter Common-Int-External-ExternalConAPI.
- Click Create and open, and then click Save.
- Click the Pages & Classes tab:
- In the Page name field, enter ConnectorPage and in the Class field, enter Common-Int-External-ExternalConAPI.
- Add Page name Request and Class Common-LDM-Entity-Contact.
- Add Page name SettingsPg and Class Common-Admin-ApplicationSetting.
- Complete the Definition tab:
- In row 1, in the Action field, select Comment. In the Target field, add: Set the connectorPage with request details.
- In row 2, in the Action field, select Update Page. In the Target field, enter ConnectorPage.request. In the Relation field, select with values from. In the Source field, enter Request.
- In row 2.1, in the Action field, select Set. In the Target field, enter Profile. In the Relation field, select equal to. In the Source field, enter SettingsPg.
- In row 3, in the Action field, enter UpdatePage. In the Target field, enter ConnectorPage.request. In the Relation field, select with values from. In the Source field, enter Request.
- In row 3.1, in the Action field, enter Set. In the Target field, enter ConnectorPage.request.ContactId. (Use lowercase "d" in "Id" to map to the external data.) In the Relation field, select equal to. In the Source field, enter Request.ContactID.
- In row 4, in the Action field, select When. In the Target field, enter Request.ContactID=="".
- In row 4.1, in the Action field, select Set. In the Target field, enter ConnectorPage.request.Contact.ContactID to map the contact ID to the external source. In the Relation field, select equal to. In the Source field, enter Request.ContactID.
- In row 5, in the Action field, select Update Page. In the Target field, enter Primary.
- In row 5.1, in the Action field, select Set. In the Target field, enter: .request.ContactId.
- In row 5.2, in the Action field, select Set. In the Target field, enter: .request.Profile.
- Click Save.
5 Update the Data Page to reference the external data source
Modify the D_Contact Data Page in your application ruleset to reference the external REST source.
- In the App Explorer, open the D_Contact Data Page.
This Data Page is the version saved to the GoGoRoad Branch Ruleset. - In the Data Sources section, under IsLookUp, enter the external data source information:
- In the Source list, select Connector.
- In the Type list select REST.
- In the Name field, select ExternalCon.
- In the Request Data Transform field, enter ExternalCon-LookupDetail-Request.
- In the Response Data Transform field, enter ExternalCon-Lookup-Response.
- In the Endpoint URL field, enter http://localhost:8080/prweb/PRRestService/test/01-01-01/getContactData/ContactId.
- In the Method list, select GET.
- Click Save to save the D_Contact Data Page.
6 Update the response Data Transform to map the response data
Update the Response Data Transform to map data from the external source to your application.
- In the App Explorer, open the ExternalCon_Lookup_Response Data Transform.
This Data Transform is listed under the Common-LDM-Entity-Contact entity. - Click the Pages & Classes tab:
- Add Page name DataSource and Class Common-Int-External-ExternalConAPI
- Add Page name ConnectorPage and Class Common-Int-External-ExternalConAPI
- Add Page name Response and Class Common-LDM-Entity-Contact
- Add Page name SettingsPg and Class Common-Admin-ApplicationSetting
- Complete the Definition tab:
- Add row 2, in the Action field, select Update Page. In the Target field, enter Primary. In the Relation field, select with values from. In the Source field, enter DataSource.
- Add rows 2.1 through 2.8 (click Add a row) to map the Target fields to the Source fields for the following properties to map fields from the external source.
Action
Target
Source
Set
.ContactID
.response_GET.ContactId
Set
.FirstName
.response_GET.FirstName
Set
.LastName
.response_GET.LastName
Set
.PrimaryAddress.Line1
.response_GET.AddressLine1
Set
.PrimaryAddress.Line2
.response_GET.AddressLine2
Set
.City
.response_Get.City
Set
.State
.response_GET.State
Set
.PrimaryAddress.PostalCodeID
.response_GET.Zip
For example, the ExternalCon_Lookup_Response Definition tab should now look like the example in the following figure:
- To add a page for the Phone List, click Add a row (this should be row 3) and configure the following:
- In the Action field, select Append and map to.
- In the Target field, enter .PhoneList.
- In the Relation field, select a new page.
- In the second-level row (row 3.1), in the Target field, enter .PhoneNumber. In the Relation field enter equal to . In the Source field, enter Datasource.response_GET.MobilePhone.
- Right-click the second level row, and then select Add sibling below.
- Configure a Set action where .IsPrimary is equal to "true".
- To add a page for the Email List, click Add a row (row 4) and configure the following:
- In the Action field, select Append and map to.
- In the Target field, enter .EmailList.
- In the Relation field, select a new page.
- In the second-level row, in the Target field, enter .Email. In the Relation field enter equal to . In the Source field, enter DataSource.response_GET.Email.
- Right-click the second level row, and then select Add sibling below.
- Configure a set action where .IsPrimary is equal to "true".
- Click Save to save your changes to the ExternalCon_Lookup_Response Data Page.
7 View the external contact data
Now that all the components are configured, you call the REST service and process the response.
- Open the D_Contact Data Page, then click Actions > Run.
- In the Run Data dialog box, in the ContactID field, enter ContactId, and then click Run.
The dialog box shows the properties for the Pat Smith contact. - In the header of Infinity Studio, click Preview App. to display the Data Portal.
- In the navigation pane, click Contacts, then select any contact in the list.
The contact details now show the data from the external source.
Disponível na seguinte missão:
Quer nos ajudar a melhorar esse conteúdo?