In this exercise, you will build on the Red Light Violation application used in the Interoperability QuickStart. This exercise assumes you have completed the Interoperability QuickStart, as it builds on the code used in that exercise. Here, you will add another route to identify at-risk intersections based on data from Chicago traffic system. This involves:
cd /home/project/shared git clone https://github.com/intersystems/Samples-Integration-SmartTicketing
/home/project/shared/Samples-Integration-SmartTicketing/Setup/CustomCensusComponents.xml
as the file to import and then click Import again.You will first create the simplest interface that includes consuming data from a file (using a record map and business service) and storing it in another file (using a business operation). We will make this more complex as we go through the exercise, but for now, notice how easy it is to consume and map data from a file to a structure you prefer within InterSystems IRIS® data platform. No coding is required for simple tasks like this, which leverage the many built-in components within InterSystems IRIS.
/home/project/shared/Samples-Integration-SmartTicketing/SampleFiles/Red_Light_Camera_Violations_Test.csv
with the following fields set:Field | Value |
---|---|
Sample File | /home/project/shared/Samples-Integration-SmartTicketing/SampleFiles/Red_Light_Camera_Violations_Test.csv |
RecordMap name | Demo.CameraViolationsMap |
Record Terminator | LF |
Samples has header row | Checked |
EnsLib.RecordMap.Service.FileService
, a prebuilt file record mapper business service, and the Service Name as From_RedLightArchive
. Specify no other fields and click OK.Field | Value |
---|---|
Enabled | checked |
File Path | /home/project/shared/Samples-Integration-RedLights/data/In/ |
File Spec | Red_Light_Camera_Violations*.csv |
Archive Path | /home/project/shared/Samples-Integration-RedLights/data/SampleFiles/ |
RecordMap | Demo.CameraViolationsMap |
EnsLib.RecordMap.Operation.FileOperation
and call it To_HighRiskArchive. You can ignore the rest of the fields for now. Specify the following fields in the Settings tab:Field | Value |
---|---|
Enabled | Checked |
File Path | /home/project/shared/Samples-Integration-RedLights/data/Out/ |
File Name | %Q_HighRisk.txt |
RecordMap | Demo.HighRiskArchiveMap |
Red_Light_Camera_Violations_Test.csv
file to the In
folder in the provided IDE. The integration will consume this file from the folder and delete it.If all worked successfully, you will receive the same message in the Out folder and the Visual Trace will show no errors. If you have any items that are marked with a red diamond: , please see the Troubleshooting Guide at the bottom of the page.
Now you will add business orchestration and a ruleset that will determine which intersections are high risk and only output that data to the file. You will use what is known as the Business Process Designer to easily apply logic — such as checking a condition, or applying a ruleset — and forward the appropriate data to the previous business operation to write to the file.
Field | Value |
---|---|
Request Class | Demo.CameraViolationsMap.Record |
Response Class | Ens.Response |
Context properties | IntersectionRisk with type %String(MAXLEN=50) VIOLATIONS with type %Integer |
Demo.IntersectionRiskRule
and Result Location to context.IntersectionRisk
.(context.IntersectionRisk = "high") || (context.IntersectionRisk = "very high")
true
line, add a Call activity, and supply the following values:Field | Value |
---|---|
Name | Call High Risk Operation |
Target | Select Operations > To_HighRiskOperation |
Request Message Class | Demo.HighRiskArchiveMap.Record |
Response Message Class | Ens.Response (the default) |
Red_Light_Camera_Violations_Test.csv
file to the In folder again. Notice in the Message Viewer that some messages stop at the business process since they are not high-risk intersections:Now we will add more routing. Data coming in can easily be routed to multiple locations with the Business Process Designer using low- to no-code.
In this section, you will update the Demo.HighRiskIntersectionsBPL to retrieve information about population density for each intersection. This information will be added to the file so that better decisions can be made on how to handle dangerous intersections. To do this, the business process will orchestrate calling a service provided by the US Census using REST to get a GeoJSON code for the intersection’s latitude and longitude, a format used throughout other datasets to indicate location. It will then make another call to get population information from a different service provided by the US Census. This population information will then be added, for each high risk intersection, to the high-risk archive file.
Field | Value |
---|---|
Enabled | Checked |
HTTP server | tigerweb.geo.census.gov |
URL | /arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer/5/ |
SSL Configuration | RESTSSL |
-87.70807749
for longitude and 41.95402905
for latitude. Click Invoke Business Service to test.Field | Value |
---|---|
Enabled | Checked |
HTTP server | api.census.gov |
URL | /data/2014/acs/acs5 |
SSL Configuration | RESTSSL |
Field | Value |
---|---|
Name | Check if has geo info |
Condition | $length(request.LATITUDE)>0 |
Field | Value |
---|---|
Name | Get Geo Info |
Target | Demo.ToCensusGeoServiceBO |
Asynchronous | Uncheck this to wait for the response before proceeding |
Request Message Class | Demo.GeoRequest (select Persistent Classes on the left to find this) |
Request Actions | ![]() |
Response Message Class | Demo.GeoResponse |
Response Actions |
Call #2:
Field | Value |
---|---|
Name | Get Population Info |
Target | Demo.ToCensusDS |
Asynchronous | Uncheck this to wait for the response before proceeding |
Request Message Class | Demo.PopulationRequest |
Request Actions | ![]() |
Response Message Class | Demo.PopulationResponse |
Response Actions | ![]() |
Demo.HighRiskArchiveMap
is open.Red_Light_Camera_Violations_Test.csv
file to the In folder. View the messages again in the Message Viewer to see that data was sent, in many of the traces, to these two REST services and successfully retrieved data (notice the Body contents).InterSystems IRIS provides many out-of-the-box components that require little to no coding. However, custom components can be coded to do just about anything you need them to do. The custom Demo.ToCensusGeoServiceBO and Demo.ToCensusDS business operations were previously created in this exercise. In the next several steps, you will explore this code, which is written in InterSystems ObjectScript.
Navigate to shared/Samples-Integration-SmartTicketing/Setup/src/cls
and open the Demo.ToCensusDS
class. In this class, you will notice the code calls a REST endpoint with a query, retrieves information, and sends data back to the calling business process.
/// Retrieves GeoJSON data from the USCensus using longitude and latitude. Method GetGeoInfo(pRequest As Demo.GeoRequest, Output pResponse As Demo.GeoResponse) As %Status { try { // Prepare and log the call // Append the city to the URL configured for adapter set tURL= ..Adapter.URL _ "query?geometry=" _ pRequest.Longitude _ "," _ pRequest.Latitude _ "&geometryType=esriGeometryPoint&outfields=*" _ "&returnGeometry=true&returnIdsOnly=false&inSR=4326&f=geojson" // Execute the call $$$TRACE("Executing call") set tSC=..Adapter.GetURL(tURL,.tHttpResponse) // Return the response if $$$ISERR(tSC)&&$IsObject(tHttpResponse)&&$IsObject(tHttpResponse.Data) &&tHttpResponse.Data.Size { set tSC= $$$ERROR($$$EnsErrGeneral,$$$StatusDisplayString(tSC)_":"_tHttpResponse.Data.Read()) } quit:$$$ISERR(tSC) if $IsObject(tHttpResponse) { // Instantiate the response object set pResponse = ##class(Demo.GeoResponse).%New() // Convert JSON into a Proxy Object set tSC = ..JSONStreamToObject(tHttpResponse.Data, .tProxy) if (tSC){ // Set response properties from the Proxy Object set pResponse.State = tProxy.features.GetAt(1).properties.STATE set pResponse.County = tProxy.features.GetAt(1).properties.COUNTY set pResponse.Tract = tProxy.features.GetAt(1).properties.TRACT set pResponse.BlockGroup = tProxy.features.GetAt(1).properties.BLKGRP $$$TRACE("Object created with " _ pResponse.State) } } }catch{ set tSC=$$$SystemError } quit tSC }
Problem | What to do |
---|---|
My lab environment won’t start or the pages won’t render. | On the launcher, click Delete and Reset Your Lab and try again. If that does not fix it, contact OnlineTraining@intersystems.com. |
I do not see a message in the visual trace. | Select From_RedLightArchive and verify the setting Target Config Names is set to To_HighRiskOperation or, for later in the exercise, to Demo.HighRiskIntersectionsBPL. |
I get a cross-origin error. | Change the Management Portal from https:// to http:// (with no s). Based on the way this lab environment is set up to share content between containers, this is required to successfully access files in the shared folder. |
Testing of Demo.ToCensusGeoServiceBO causes an error. | Verify you supplied longitude before latitude in the tester. |
The Test button is disabled so I can’t test. | Verify you have selected Production Settings > Development and Debugging and checked Testing Enabled. |
The visual trace looks different than expected and uses Ens.Scheduler. | Select the next message down. This message is related to a background process and can be ignored. |
To give you the best possible experience, this site uses cookies and by continuing to use the site you agree that we can save them on your device.