How many times did you encounter these little things?
QR Codes? What for?
They are QR codes. Using a dedicated application, you can scan them with your smartphone to display data, go to a specific URL and so on. So, what use could you have of them in your Nuxeo application? Well, a QR code can easily be generated with any document metadata. Here are a few use cases that come to mind:
- As a sales executive: Scan a QR code displayed in a customer document type to get a vCard imported into your phone contacts.
- As any company representative: Build a QR code from your Nuxeo profile information, to use on your business card.
- As any company member: Generate QR codes from a document's metadata. For example, include the Nuxeo permanent link to the file itself. Great for documents that get printed.
Many possibilities exist for QR codes.
Integrating QR Codes - the Need for a Pluggable Architecture
Okay, but what if everyone comes asking for something different? Will you spend hours maintaining each implementation, feeling as if you've opened Pandora's box? Not at all: that's when the Nuxeo platform's pluggability comes in handy.
The Nuxeo platform contains many services. Every service implements business logic around a specific Nuxeo functionality. And almost all of them include one or more extension points. These extension points are sort of interfaces. You can feed them with XML files to:
- Change the service behavior,
- Add new entries,
- Deactivate functionality you do not need.
That's exactly what you do when developing in Nuxeo Studio: build XML in a graphical interface.
In some specific cases though, the default platform features do not cover your needs. The QR codes generation is a perfect example of such a situation. But even then, it's no big deal, because you can plug your own service and extension points into the platform. This allows further configurability to your business logic.
An Extension Point for QR Codes Generation
Back to QR codes. By implementing a service along with its extension point, you can contribute simple XML files. One for each usage. If your implementation needs to evolve, you can refactor your code as much as you like. The generic logic is in the service, and your business use cases described in the XML contributions. Doesn't that sound nice and clean?
Look at the XML below. This is an XML contribution using my personal implementation:
<extension target="org.nuxeo.sample.MyQRCodeService" point="qrcontent">
<separator value="||" />
<xpath value="dc:title" />
<xpath value="uid:major_version" />
<xpath value="uid:minor_version" />
- An id for my configuration,
- The metadata to include in my QR code (on top of the document id), and
- A character (or chain) to separate each metadata.
And here is the resulting QR code on a random document:
Want to Learn More about QR Codes Generation?
During our integration training, we already cover the Nuxeo development basics. The QR codes generation example is now added to it for developers willing to go further. It's a fun and useful way to learn some advanced Nuxeo theory by practicing, at least in our opinion.
Do you want to know more, or try it out?
- Feel free to clone the Nuxeo training slides GitHub project,
- And contact us if you want to setup a training session or take part in one!
Also, make sure to have a look at the zxing and QRGen libraries that I used for this example, they truly make QR codes generation a breeze.
I look forward to discussing this with you during a training session!