Posts

ADF BC REST service - defaulting with CREATE method

Image
JDev: 12.2.1.3.0

This is more like an update on my previous article - ADF BC REST - NULL and DEFAULT, where I spoke about the various ways null data can be defaulted via a REST API. However, there was one use case which I had missed - the CREATE method of EntityImpl.

There is an interesting behaviour which may be observed when, instead of  setting a default value declaratively on the entity attribute, we override the CREATE method of the EntityImpl subclass.

When a value is set in the create method, this value takes precedence, irrespective of whether we pass null, some value or don't pass the attribute in the payload at all.

To demonstrate this, I will set a value of 25000 for Salary attribute in the create method.


And I will pass the below payloads:


For all the three payloads, the data gets saved with salary 25000, the value with which it was initialized in the create method, irrespective of the fact that I also have a declarative default value for the Salary entity attribute.


ADF BC REST service - NULL and DEFAULT

Image
JDev: 12.2.1.3.0 Source: GitHub
This article talks about an interesting difference between passing null and no value for a column in the payload of an ADF BC REST end-point. Now this might seem a bit obvious in the end, but nonetheless, it can be confusing at times.
To demonstrate this problem, I have the following use-case: Set a default value for employee "Salary" during insert or update!
Now your GUI might have some required validation set on this field, and it does not allow the end-user to save the form without a non-zero salary. That is all good. But your QA might have an automation running to check the REST APIs with their own payload. And this is something which needs to be in sync with the UI logic.
To get started, I have my Employee entity object with a default value of 5500 for Salary field.

Case # 1: Payload does not contain Salary attribute

When I submit this payload, I get back an Employee object with the default Salary of 5500, as declaratively set up on the e…

Querying ADF BC REST service - RowFinders and REST Shape

Image
JDev: 12.2.1.3.0 Source: GitHub
This article talks about querying ADF BC REST services using a RowFinder, and displaying different data sets based on our needs, using REST Shaping.
REST Shaping This is a powerful tool provided by ADF BC to determine the kind of data you can expose to the end user.
Imagine this use-case where we need to display certain attributes of an employee on the front-end application depending on whether we have an anonymous or an authenticated user, while we retain all the features of the view object (View criteria, custom SQL etc). Creating multiple copies of the same VO is certainly not an option.
REST shaping allows you to create metadata on the view object, identified by a unique name, where you can specify which columns may displayed and which all may be hidden.
See examples below, which show two shapes created - AuthView and NoAuthView, each showing different data sets.



Important Note: Each REST instance supports a single REST shape. I did not find any way …

XML generation with Oracle ADF

Image
JDev: 12.2.1.3.0
Source: GitHub

XML generation is something we use quite extensively in ADF products - be it for PDF generation, or for printing labels on a Zebra printer or for sending data to an external system. And ADF BC does have an out-of-the-box support for generating XML documents straight out of its view objects, via its writeXML API.
However, there are times when we need to stretch the XML documents - maybe create a custom XML, or import a custom node inside a ADF BC generated XML. This article intends to provide a working solution for these extra bits, along with a few tweaks for the standard process.
This article will cover 3 use-cases: 1. Generate a standard XML from ADF BC, with node names of our choice. 2. Generate a custom XML from an XSD schema. 3. Combine the above two XMLs into a composite XML document.
The sample application uses Departments and Employees tables from HR schema. To keep the size of the XMLs small, the VOs have been tuned to return only 5 records.
T…

Oracle ADF with Google Cloud Storage

Image
JDev: 12.2.1.3.0
Source: 1) GoogleLib 2) Application

This would be the third, final and the shortest article on the topic of integrating ADF Faces with Google's NoSQL Firebase database. In my previous two articles - Oracle ADF with Google Firebase and Oracle ADF with Google Firebase (Part II - Secure CRUD) - I have spoken about setting up Firebase database reference and performing secure CRUD operations. I have used Firebase Admin setup for Java for all of my activities.
This article explores another great feature in this package - Google Cloud Storage. Unfortunately, the Admin SDK is quite limited when it comes to storage. Almost all the great features have been exposed to the Android SDK or the web/JavaScript SDK libraries. But nonetheless, with whatever is available, we can store documents on the Firebase cloud storage and access them via a secured protocol.
To set up cloud storage, we need to extend our Firebase initialization to include the default cloud storage bucket - gs:…

Oracle ADF with Google Firebase (Part II - Secure CRUD)

Image
JDev: 12.2.1.3.0
Source: GitHub

In my previous blog - Oracle ADF with Google Firebase - I wrote about integrating ADF Faces with a NoSQL database like Google Firebase. Till now I only discussed about fetching data from an insecure connection. But in a real world scenario, we would want the REST APIs to be secured so that only an authenticated user should be able to access the database.
This article will extend the previous application further by securing the REST APIs with a web token, and will ensure that a Bearer token is required in order to access the data. This article will also showcase generic crud operations.
Google Firebase also allows provides it's own authentication system, however, we will not be using that, since our application will be hosted on WebLogic server, which is supposed to take care of authentication and authorization. What we would do is to generate a secure token once WebLogic authenticates and authorizes the user, and use this token to access the databa…

Oracle ADF with Google Firebase

Image
JDev: 12.2.1.3.0 Source: GitHub
This article talks about an interesting integration of Oracle ADF with Google's Firebase database. For those of you who are not aware of this, Firebase is a NoSQL cloud database service, provided free of cost (well, it's free for most of the way) by Google.
Reference: Google Firebase
We also had our eye on MongoDB cloud , but Firebase won the race for one simple reason - it provides out-of-the-box REST API connectors for it's entire data structure, and wrappers for query purposes. You do not need to write or manage a single line of code. Additionally, it provided access for firestore - an online storage space to upload documents.
The data-structure of firebase is quite unique - it stores data as a JSON tree. Every node of that tree is exposed as a REST URL, and all you need is to use the URL in your application.
To show an example, here's what Department and Employee structures look like in Firebase:

To access the desired node, appropri…