OData and InterSystems IRIS
Tags: database
Published: 2020-08-12 14:37:41

<h2 style="margin-bottom: 11px;"><span style="font-size:16px;"><strong><span style="line-height:107%;"><span style="font-family:&quot;Calibri&quot;,sans-serif;">What is the OData</span></span></strong></span></h2>
<p><span style="font-size:11.0pt" lang="EN-US"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">OData (Open Data Protocol) is an </span></span></span><span style="font-size:11.0pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif"><a href="https://www.oasis-open.org/news/pr/iso-iec-jtc-1-approves-oasis-odata-standard-for-open-data-exchange" style="color:blue; text-decoration:underline">ISO/IEC approved</a></span></span></span><span style="font-size:11.0pt" lang="EN-US"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">, </span></span></span><span style="font-size:11.0pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif"><a href="https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=odata" style="color:blue; text-decoration:underline">OASIS standard</a></span></span></span><span style="font-size:11.0pt" lang="EN-US"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif"> that defines a set of best practices for building and consuming RESTful APIs. OData helps you focus on your business logic while building RESTful APIs without having to worry about the various approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats, query options, etc. OData also provides guidance for tracking changes, defining functions/actions for reusable procedures, and sending asynchronous/batch requests (source: OData.org).</span></span></span></p>
<h2 style="margin-bottom: 11px;"><span style="font-size:16px;"><strong><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">The OData use cases</span></span></strong></span></h2>
<ul>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Deploy data as REST Services with an interoperable format without development effort;</span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Allows BI, data visualization, ERP, CRM, ESB, Workflow tools and engines consume data using REST without development effort;</span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Virtualize corporate data in API Management tools;</span></span></span></li>
<li style="margin-bottom:11px; margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">OData advocates a standard way of implementing REST APIs that allows for SQL-like querying capabilities using these RESTful APIs. OData is essentially SQL for the web built n top of standard protocols – HTTP, JSON &amp; ATOM – while leveraging the REST architecture style (progress.com);</span></span></span></li>
<li style="margin-bottom:11px; margin-left:8px"><span style="font-size:11.0pt" lang="EN-US"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">OData has a broad adoption, see: </span></span></span></li>
</ul>
<p style="margin-bottom:11px; margin-left:8px"><img horiginal="317" src="https://dev-to-uploads.s3.amazonaws.com/i/1ewp3wnn43bw7nuwibil.png" woriginal="567"></p>

<ul>
<li style="margin-bottom:11px; margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">OData helps to implement FHIR: FHIR, or Fast Healthcare Interoperability Resources Specification, is a standard for exchanging healthcare information electronically. In order to make FHIR truly interoperable, it is <a href="http://hl7.org/fhir/search.html" style="color:blue; text-decoration:underline">recommended that systems use the rules specified by OData specification </a>for the $search parameter. Further, FHIR also uses OAuth in order to establish a trusted relationship with the client for an extra layer of security (progress.com);</span></span></span></li>
<li style="margin-bottom:11px; margin-left:8px"><span style="font-size:11.0pt" lang="EN-US"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">OData supports pagination, batch requests and different formats like JSON, ATOM, XML, etc.</span></span></span></li>
</ul>
<h2 style="margin-bottom: 11px;"><span style="font-size:16px;"><strong><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">OData and InterSystems IRIS</span></span></strong></span></h2>
<p style="margin-bottom:11px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">The InterSystems IRIS does not support OData but is possible use the OData Server for InterSystems IRIS to allows expose Persistent classes as REST. </span></span></span></p>

<p><span style="font-size:11.0pt" lang="EN-US"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Follow these instructions:</span></span></span></p>
<ol>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Clone the source code of the IRIS OData Server: git clone <a href="https://github.com/yurimarx/isc-iris-odata.git" style="color:blue; text-decoration:underline">https://github.com/yurimarx/isc-iris-odata.git</a></span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Go to: isc-iris-odata folder</span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Execute: mvnw install (MS Windows) or ./mvnw install (linux or mac)</span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Execute: docker build -t odata:1.0.0 .</span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Execute: docker run -p 8080:8080 odata:1.0.0. Your OData Server started:</span></span></span></li>
</ol>
<p style="margin-left:48px"><img horiginal="639" src="https://dev-to-uploads.s3.amazonaws.com/i/yidexai1nxhqd7mfe0es.png" woriginal="1655" width="747" height="288"></p>

<ol start="6">
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Start your InterSystems IRIS instance with any persistent class, in my ca</span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">In your browser access: &nbsp;&nbsp;<a href="http://localhost:8080/" style="color:blue; text-decoration:underline">http://localhost:8080/</a>. Set parameters on the screen:</span></span></span></li>
</ol>
<p style="margin-left:48px"><img horiginal="299" src="https://dev-to-uploads.s3.amazonaws.com/i/ylak0pil3z6hsdm7ye3w.png" woriginal="1574" width="774" height="147"></p>

<ol start="8">
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">This is parameters to my instance. Set the parameters to your IRIS instance. In namespace set your iris namespace, in the schema, the SQL Table schema, and in the port, the port to your JDBC database connection. </span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Press submit and RELOAD YOUR ODATA SERVER DOCKER INSTANCE TO APPLY PARAMETERS.</span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Access <a href="http://localhost:8080/odata.svc/" style="color:blue; text-decoration:underline">http://localhost:8080/odata.svc/</a> to see all persistent classes to your IRIS schema. In my case is:</span></span></span></li>
</ol>
<p style="margin-left:48px"><img horiginal="457" src="https://dev-to-uploads.s3.amazonaws.com/i/gob48pkdrga7367syq8q.png" woriginal="700" width="408" height="266"></p>

<ol start="11">
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">To navigate to a persistent class browse: <a href="http://localhost:8080/odata.svc/%3cPersistent_Class%3e" style="color:blue; text-decoration:underline">http://localhost:8080/odata.svc/&lt;Persistent_Class&gt;</a> e.g.: <a href="http://localhost:8080/odata.svc/Animal" style="color:blue; text-decoration:underline">http://localhost:8080/odata.svc/Animal</a> </span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">The OData server list Animal data, see:</span></span></span></li>
</ol>
<p style="margin-left:48px"><img horiginal="704" src="https://dev-to-uploads.s3.amazonaws.com/i/u0swfoi81qae4bk87cuv.png" woriginal="898" width="555" height="434"></p>

<ol start="13">
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">To see in JSON format browse: <a href="http://localhost:8080/odata.svc/Animal?$format=application/json" style="color:blue; text-decoration:underline">http://localhost:8080/odata.svc/Animal?$format=application/json</a>. See:</span></span></span></li>
</ol>
<p style="margin-left:48px"><img horiginal="587" src="https://dev-to-uploads.s3.amazonaws.com/i/7cjdqk0g1cqzm6hw2yi5.png" woriginal="808" width="415" height="301"></p>

<ol start="14">
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">&nbsp;To see details about a row browse: <a href="http://localhost:8080/odata.svc/Animal(8)?$format=application/json" style="color:blue; text-decoration:underline">http://localhost:8080/odata.svc/Animal(8)?$format=application/json</a></span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">To delete send a DELETE in your postman with <a href="http://localhost:8080/odata.svc/Animal(8)" style="color:blue; text-decoration:underline">http://localhost:8080/odata.svc/Animal(8)</a></span></span></span></li>
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">To insert send a POST in your postman with <a href="http://localhost:8080/odata.svc/Animal" style="color:blue; text-decoration:underline">http://localhost:8080/odata.svc/Animal</a> and a JSON body with property name and value pairs, like:</span></span></span></li>
</ol>
<p style="margin-left:48px"><img horiginal="589" src="https://dev-to-uploads.s3.amazonaws.com/i/ogzvq9np2dz26aw6twad.png" woriginal="807" width="452" height="329"></p>

<ol start="17">
<li style="margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">So you can do all CRUD operations with your persistent classes.</span></span></span></li>
<li style="margin-bottom:11px; margin-left:8px"><span style="font-size:11pt"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Many other features will be released in the future, if IRIS OData Server get the community adoption.</span></span></span></li>
</ol>
<p><span style="font-size:11.0pt" lang="EN-US"><span style="line-height:107%"><span style="font-family:&quot;Calibri&quot;,sans-serif">Thanks! </span></span></span></p>
<p style="margin-bottom:11px; margin-left:8px">&nbsp;</p>