DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

49
How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application Frank van der Linden, elstar IT Full stack Java Developer DEV-1129 IBM Connect 2017 Conference

Transcript of DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Page 1: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

How Watson, Bluemix, Cloudant, and XPages Can Work Together In

A Real World ApplicationFrank van der Linden, elstar IT

Full stack Java DeveloperDEV-1129

IBM Connect 2017 Conference

Page 2: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Me• Freelance Full stack Java developer

• Owner of elstar IT

• Curious of new technology

• IBM Champion 2013, 2014 and 2017

• Run (mountain) marathons

Page 3: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

How do we proceed• HR Assistant

• Running it on IBM BlueMix

• Store it in Cloudant

• Analyse it with IBM Watson

• Show it with Charts

• Lessons learned

Page 4: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

HR Assistant

Page 5: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Demo time

Page 6: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application
Page 7: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Frédéric Dehédin• At the time of the project: Senior Application

developer at Belsoft Collaboration AG

• @fdehedin

• http://www.fdehedin.ch/

Page 8: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Facts• Winner of the ICS Developer Competition 2016

• Runs on the XSP runtime on IBM BlueMix

• Store all the data in Cloudant

• Analyse jobs and job applications with IBM Watson

• Backend is pure Java, no Java Notes objects

Page 9: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Add ons• Cloudant connector OSGi plugin

• Take out the security issue

• Storing in and retrieving from Cloudant. JSON <—> POJO

• Can be accessed from Java backend.

• Do the heavy lifting. Don't reinvent the wheel.

Page 10: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Add ons• Jackson Mapper OSGi plugin

• Take out the security issue

• Used with the IBM Watson services

• Conversion of JSON to POJO

• Makes @Annotations available in Java back end

Page 11: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Roadmap

Page 12: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Running it on IBM BlueMix

Page 13: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Overview• BlueMix is IBM PaaS, with various services

• We picked a few services

Page 14: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Credentials

Page 15: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Deploy to IBM BlueMix• Fill the BlueMix Manifest file under

Application Configuration

• Will result in a yaml file

Page 16: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Deploy to IBM BlueMix• Set location of deployment

• Add shared-plugin folder

• Add the OSGi plugins

Page 17: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Deploy to IBM BlueMix• Deploy Application

Page 18: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Store it in Cloudant

Page 19: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

What is Cloudant• It is the cloud version of CouchDb

• It is document based

• CouchDb is created by Damien Katz

• Cloudant is bought by IBM

• Is like MongoDb or NSF a NoSQL datastore

Page 20: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

What is Cloudant• Data stored as JSON

• View and Search ‘formula’ defined in javascript

• Replication

• Tasks

• Build in API

• No annoying limitations

Page 21: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Cloudant database

Page 22: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Design document• Special type of document

• Holds javascript for View and FT Search definition.

Page 23: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

• It is JSON everywhere.

• _rev and _id are reserved parameters.

• doc{}, is the actual data from application

Document

Page 24: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Attachment @ Cloudant• Stored as base64 encoded String

• Can be as standalone

• Or as part of Document (we choose this way)

• Store id as attachmentId, so it can be retrieved when needed

Page 25: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Attachment @ Cloudant• AttachmentDAO

Page 26: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Attachment @ Cloudant

• AttachmentController

• Convert upload to Attachment object

Page 27: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Attachment @ Cloudant

• ControllerBase

• All controllers can use these methods

Page 28: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Attachment @ Cloudant

• Servlet is called in application for download

• base64 data for the image tag

Page 29: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Analyse it with IBM Watson

Page 30: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Watson API explorer• Very useful to test input and see what is returned

Page 31: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Services we used• Tone analyser, to get the tone of the text

• Personality Insight, to determine the personality of the job applicant

• AlchemyLanguage, to get the keywords from the Job and Job application

Page 32: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

tone analyser schema

Page 33: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Tone analyser• The same structure to call the Watson services

Page 34: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Tone analyser• ToneAnalyzerRequest contain the text to analyse

• ToneAnalyzerInjector gets text from model class

Page 35: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Tone analyser• Post the data to IBM Watson service (1)

• Convert the response back to Java class (2)

12

Page 36: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Tone analyser• ToneAnalyzerResponse holds the

results

• Use @annotations from Jackson to map JSON to properties

• Result is the source of the charts

Page 37: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Show it with charts

Page 38: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

ChartJS• Open source HTML5 javascript based

• Responsive

• DataSets = Array of Objects

Page 39: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

ChartJS• Factory to produce the chart data, accepts objects

• Factory set default Chart Type, like Radar or Bar

Page 40: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

ChartJS

Page 41: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

ChartJS• Custom control to display data

Page 42: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

ChartJS• Custom control to display data.

Page 43: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Lessons learned

Page 44: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Lessons learned• No Single Sign On service on all datacenters

• Manifest yaml file and GIT are not an happy couple

• API’s are not consistent across Watson services

• Cloudant is a very reliable, flexible and fast NoSQL datastore

• IBM Watson services are really powerful.

Page 45: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Lessons learned• There is no RichText on the web, it is HTML

• Handling attachments on Cloudant was a challenge. Took some time get a robust solution.

• BTW the way, we won the competition ;-)

Page 46: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Questions

Page 47: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Resources• HR Assistant on BlueMix

https://hrassistant.eu-gb.mybluemix.net/

• HR Assistant code on GitHub•

https://github.com/flinden68/HR-Assistant

• IBM Watson services• https://www.ibm.com/watson/developercloud/services-catalog.html

• IBM Cloudant documentation•

https://docs.cloudant.com/

• HR Assistant Demo•

https://youtu.be/yM5Foxn9Fvg

Page 48: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Resources• OSGi Cloudant connector

https://bitbucket.org/flinden68/cloudant-connector

• OSGi Jackson JSON Wrapper•

https://bitbucket.org/flinden68/jackson-json-mapper-plugin

• ChartJS• http://www.chartjs.org/

• Watson API Explorer• https://watson-api-explorer.mybluemix.net/

Page 49: DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real World Application

Reach out to me• @flinden68

• http://www.elstarit.nl

[email protected]

• https://nl.linkedin.com/in/flinden68