Master Detail data in RAD Server using TEMSDataSetResource

Master Detail data in RAD Server

The TEMSDataSetResource is a very powerful component that enables rapid development of full document REST API’s for TDataSet using RAD Server. Using TEMSDataSetResource, along with traditional master detail relationship configurations, it is possible to expose, and automatically document data APIs via REST with no code at all.

In this article, I will cover sharing master detail data with no code, but also how to roll your own REST endpoint to cover more advanced detail with detail embedded calls.

In my previous article, I updated advise on getting started with Swagger UI, using the new WebFiles feature of RAD Server (from 10.3.2) as a way to view your documentation as you build your backend services API. This article will build upon the sample application created in that post.

Continue reading Master Detail data in RAD Server using TEMSDataSetResource

Embedding Swagger UI into RAD Server

This post is an update to the original post written previously showing Swagger UI being used with RAD Server, covering new features of RAD Server.

Why Embed Swagger UI into RAD Server?

Swagger UI (as previously discussed) is a great option for checking your documentation and working with the REST API. One of the challenges has always been CORS (Cross Origin Resource Sharing) that makes execution of the code a challenge when developing.

There are a few options now however. You can either work around this with browser plug-ins, (as seen before), enable CORS in the emsserver.ini under [Server.APICrossDomain], or embed swagger-ui inside your RAD Server instance.

In this video, I cover the latter option. You can watch how to get documentation up and running. The video shows how to configure your EMSServer.ini to share the external resource through RAD Server and also modify the downloaded files to automatically load up the API documentation directly from RAD Server.

WebFiles in RAD Server EMSServer.ini

The key to making this work is the WebFiles option that was added to RAD Studio in 10.3.2. This was primarily added to make it easier to serve out web content and support ExtJS for doing web client development under the Architect edition of RAD Studio, however, this also has the benefit of making other content available to share.

Continue reading Embedding Swagger UI into RAD Server

InterBase Temporary Tables

InterBase Temporary Tables

This last week, InterBase 2020 has been released bringing the awesome Tablespaces feature into play. This new feature enables splitting the database into groups of tables (a Tablespace) that can then be put onto different physical disks (to aid performance) but also enables partial backup of a database. I plan to cover this new feature, and some useful ideas about how to use them in an article in the coming weeks, but first, I want to address something a bit older in InterBase that I’ve not blogged about before. Why? Well recently, I was at a UK roadshow event, when content about InterBase 2020 was being previewed, and a developer said “This new stuff is cool, but what I really need is the ability to put data into a table temporarily in InterBase, and have it isolated from other transactions…. Other databases have it, when will InterBase get it?” Well, InterBase has had this for years!

Continue reading InterBase Temporary Tables

Opening a PDF on Android with Delphi

Intents on Android using API 26 to open PDF documents.

Recently, the Google Play store updated its requirements so the target API level of 26 was used to get new apps submitted. While this was reasonably easy to achieve through updating the AndroidManifest.Template, the change to the newer API changed the behaviour of my application.

Before the update, I would download a file to the CachePath and then share to a public folder. I would then get a URI for the public folder path file and share via Intents.  Following the update, this no longer worked. After a little research, I discovered this was due to the changes in the Android security system, that actually, make a lot of sense. Rather than sharing the file outside the application, you now provide tempory access to it via the Intent. To achieve this, you need to setup a Provider, (this is done via XML) and then programmatically provide the path as a ‘content://’ URI, set flags for allowing read / write access via the intent and share it.

The video shows how to achieve this and demo’s the working code. To help, below are some of the XML blocks you will need upon the way.

Adding Provider

Add this to the AndroidManifest.template in the source code root folder, before the </application> tag. This is then used to build all Android apps.

<provider android:name="android.support.v4.content.FileProvider"
android:authorities="%package%.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/fileprovider" />
</provider>

Provider file

Create a fileprovider.xml (or whatever file name you set in android:resource when declaring the provider).

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path name="bbresources" path="bbresources/"/>
</paths>

More flags and details for Provider Files can be found on the Android documentation

RAD Server and Enterprise Connectors

Connected Systems

Many years ago I was the lead developer for a software development company that was a market leader in the leisure industry. Back in the day, we were using Delphi 3 and then Delphi 5 to create the software. The software was a complete CRM that interfaced with access control systems, card readers, ran in multiple languages, and offered everything from reservation management to debt collection.

So why am I starting my post with this trip into the past? – In short, One thing that was true then is even truer today. The more customers the software won, the more systems we were asked to integrate with: From a finance point alone, customers wanted to consolidate their business accounts into Sage, QuickBooks and the like because they were the best at doing specific accounting jobs. While the software my team wrote managed a large percentage of the daily business, it was part of the mix that made up a customers technological capability/software systems. – No App is an Island!

Working with so many different systems and API’s can be a real handful, different API’s work in different ways which adds testing complexity,  and more skills and knowledge that needs to be learned. If it was working with text files, SOAP (needed to get to Delphi 6 (ok 7)  for that), sockets, or a growing number nowadays via JSON and HTTP, a lot was required to manage and maintain these connections (and develop the new ones each time they were needed).

Being at the heart of the connection!

While connecting to other systems was important, one thing that really establishes a product is what connects to it! One of the biggest boost sales ever received (while I don’t think they really appreciated it at the time) was the development of an external use API into the core system. This for the first time enabled customers to build their own extensions that worked with our software. Rather than limiting the potential for custom development, this added the desire for the customer to build their own applications that became reliant on our systems. Those that built on our frameworks became worth a lot more in the long term value that those that didn’t. But why is that important today?

RAD Server and Enterprise Connectors

This week has seen the launch of a brand new initiative from Embarcadero, who have partnered with CData to provide Enterprise connectivity to 80+ Enterprise applications.

So? I can program an API right…

Well, using FireDAC, these connections are easily added to any application as a database driver (just like connecting to InterBase or Oracle or any other SQL database).  It then manages the magic of converting all API’s into standards base SQL to work with!

That means,

  • live data at design time,
  • easy configuration of connections (just like any other database)
  • no need to learn multiple API’s…
  • a far simpler development process!

This also means easy access to FireDAC’s core capabilities such as LocalSQL etc.

Enterprise connectors coupled with RAD Server enable developers using RAD Studio, Delphi or C++Builder to build amazing connected middle-tier systems rapidly, that are shared using modern JSON connectivity. With the ability to easily connect to so many different data sources, and make those available via JSON and YAML documentation, you can deliver a single sign-on server with amazing connectivity very rapidly. With API usage analysis built into RAD Server, management of the heart of your customer’s software systems is easy to achieve, making your products an integral part of their future.

Get RAD Server for FREE!

Right now (Until 30th June 2017), a Site license of RAD Server is available free with Architect editions of RAD Studio, Delphi and C++Builder.  To learn more about RAD Server, I suggest checking out RAD Server home page or searching RAD Server on YouTube.

Enterprise Connectors – Beta

The Enterprise connectors beta is now available to those on the latest version of RAD Studio, Delphi or C++Builder. Visit the link here to find out more about the 80+ Enterprise systems included, such as Salesforce.com, SugarCRM, Google Analytics, MailChimp, Microsoft SharePoint, Paypal and Oracle Eloqua spanning Accounting, CRM, Marketing, NoSQL, eCommerce, Social Networking and more.

Video: Adding InterBase 2017 ToGo to RAD Studio 10.2

InterBase 2017 is now available for installation directly into RAD Studio via GetIt for use in Delphi and C++Builder applications across Windows, macOS, iOS, Android and also for Linux.

While a Linux InterBase Server Edition has been available for many years with InterBase, the introduction of the new Delphi Linux compiler in 10.2 Tokyo has ensured the addition of Linux as a new platform supported by ToGo.

Adding InterBase ToGo to the RAD Studio IDE

To install ToGo, just open GetIt in the RAD Studio IDE, (Tools > GetIt Package Manager) and search for InterBase.

 

From there you can install both the InterBase 2017 Developer Edition server and also the InterBase ToGo libraries.

InterBase Server enables multiple connections to the same database either locally or over a network. InterBase ToGo is a dynamically loaded version of the InterBase engine that runs in process for local connections and data storage or to act as a client driver for a remote conenction.

License and Video

Watch the video and see how to add InterBase ToGo into your Delphi and C++Builder applications.

Click the link here for a free trial license of InterBase ToGo.

If you are new to Database Development, then check out Cary Jensen’s latest FireDAC book that uses InterBase in a lot of the examples.

FireDAC Book – Using InterBase

New book – Delphi in Depth: FireDAC

There has been a growing stream of Delphi books in the last year covering everything from cross-platform development with FireMonkey to coding best practices around OOP. The latest book to be released is by long time Delphi Author Cary Jensen, specifically looking at database development with the cross-platform enabled FireDAC.

If you have been developing with Delphi for any amount of time, then you will probably know about Cary Jensen.  For those who don’t, Cary has written more than twenty-five books on software development, including some of the most popular works on ClientDataSets. Cary is an Embarcadero MVP and has been providing training, consultancy, and software development services since 1998.

Cary’s latest book, Delphi in Depth: FireDAC is now out and available covering 17 chapters about using FireDAC, the blazingly fast multi-platform database components from Embarcadero.

In Cary’s own words from his blog – this is the NEW goto book for database development with Delphi – and from a quick scan – I completely agree!

 I felt that this book should be more than just a FireDAC book. It should be a book that deserves to be on the shelf of every Delphi database developer. For the new Delphi database developer who is unfamiliar with the “Delphi way” of doing things, this book contains discussions of and demonstrations of the essential techniques that every Delphi database developer needs to know. This includes concepts like the TDataSet interface, the current record, and how to read to and write from TFields. (Just a note here, this book assumes you are using Delphi XE6 or later.)

Spanning over 500 pages, the book is full of examples, tips and techniques for making your database applications scream!

The book starts with an overview of the Features of FireDAC, 8 pages of high-level notes about the breadth of FireDAC – everything from Cross platform support, to ArrayDML, to DataType mapping and using LocalSQL (a very cool feature of FireDAC).

The book then helps you get started in the IDE and your applications before moving into the more advanced topics.

The other topics… see Cary’s blog. It’s well detailed. There are  17 if them, but in summary:
Chapter 1: Overview of FireDAC
Chapter 2: Connecting to Data
Chapter 3: Configuring FireDAC
Chapter 4: Basic Data Access
Chapter 5: More Data Access
Chapter 6: Navigating and Editing Data
Chapter 7: Creating Indexes
Chapter 8: Searching Data
Chapter 9: Filtering Data
Chapter 10: Creating and Using Virtual Fields
Chapter 11: Persisting Data
Chapter 12: Understanding FDMemTables
Chapter 13: More FDMemTables: Cloned Cursors and Nested DataSets
Chapter 14: The SQL Command Preprocessor
Chapter 15: Array DML
Chapter 16: Using Cached Updates
Chapter 17: Understanding Local SQL

InterBase inside

The book uses the IoT Award winning InterBase for the examples. InterBase is the cross-platform SQL database for Windows, macOS, iOS, Android and Linux.

To download the latest developer edition of InterBase for free click here.

InterBase XE7 Update 7 – now available

InterBase XE7 – Update 7

InterBase XE7 update 7 is now available for general release. This is part of the active support of previous editions, for the latest long term support version of InterBase, see InterBase 2017.

The update is available for both Windows and Linux server-based Editions of InterBase XE7 and InterBase ToGo.  For help choosing the right edition of InterBase – view InterBase Product Editions

For notes on previous InterBase XE7 updates please select the links below

What’s in InterBase XE7 – Update 7?

Update 7 is a back port of specific updates and fixes in InterBase 2017. See full list here, including

  • Update of OpenSSL.
  • Fixes to avoid database corruption in extreme case
  • Enhancements to 64bit Linux Installer
  • Backup speed improvements when a  Change Views are in place.

Downloading latest InterBase XE7

Embarcadero CodeCentral “Registered Users” can download the patch binaries (Server/Desktop/Developer/Trial) for Windows and Linux, and, ToGo Edition. You can find the downloads at http://cc.embarcadero.com/reg/interbase

For new users, the trial and developer editions are available for free at http://www.embarcadero.com/products/interbase/downloads

Programming with Delphi & InterBase