A (XPages) developers
guide to Cloudant
Frank van der Linden
@flinden68
About me
• Freelance Full stack Java developer, with XPages experience
• Curious of new technology
• Owner of elstar IT
• Former IBM Champion (2013, 2014)
Roadmap
• Why Cloudant
• Introduction to Cloudant
• Inside Cloudant
• Connect to Cloudant
• Cloudant @ XPages
Why Cloudant
Why Cloudant
• For HR Assistant we wanted to use a different datastore
Introduction to Cloudant
What is Cloudant
• It is the cloud version of CouchDb
• CouchDb is created by Damien Katz
• Cloudant is bought by IBM
• It is document based
• Is like MongoDb or NSF a NoSQL datastore
What is Cloudant
• Data stored as JSON
• View and Search ‘formula’ with javascript
• Replication
• Tasks
• Build in API
• No annoying limitations
Cloudant as service
• Cloudant can be added as service in BlueMix
Cloudant standalone
• Via website cloudant.com
Inside Cloudant
Inside Cloudant
Inside Cloudant
• View mapping
• Search index
Connect to Cloudant
Connect to Cloudant
• Direct via REST
• https://someusername:secret@account.cloudant.com
• Via a OSGi Plugin, uses the HTTPConnection
• https://bitbucket.org/flinden68/cloudant-connector
Connect to Cloudant
• Credentials
• Account, necessary for the OSGi plugin
Connect to Cloudant
• It is JSON everywhere
• _rev and _id, reserved parameters
• doc{}, is the actual data from application
Cloudant connector
• Storing in and retrieving from Cloudant
• Can be accessed from Java backend.
• Will take out the security issues.
• Do the heavy lifting. Don't reinvent the wheel.
• https://bitbucket.org/flinden68/cloudant-connector
Cloudant @ XPages
Cloudant @ XPages
Cloudant @ XPages
Cloudant @ XPages
• Repeat in XPages
• Columns - values from Job class
Cloudant @ XPages
• JobController - getJobs
Cloudant @ XPages
• Job Java Class
Cloudant @ XPages
• CloudantDAO
Cloudant @ XPages
• CloudantService - connect
• Find the data in Cloudant
Cloudant @ XPages
• Job JSON in Cloudant
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
Attachment @ Cloudant
• AttachmentDAO
Attachment @ Cloudant
• AttachmentController
• Convert upload to Attachment
object
Attachment @ Cloudant
• ControllerBase
• All controllers can use these methods
Attachment @ Cloudant
• Servlet is called in application for download
• base64 data for the image tag
RichText @ Cloudant
• Stored as MultiMimePart
RichText @ Cloudant
• Which is nice converted to JSON ;-)
Search @ Cloudant
• Cloudant job ftSearch index
Search @ Cloudant
• Search example, filter the view
Search @ Cloudant
• Do the search in the Controller,
call DAO
Search @ Cloudant
• Search method calls the CloudantService
Search @ Cloudant
• CloudantService calls connector to get the data
Resources
• OSGi Cloudant connector
• https://bitbucket.org/flinden68/cloudant-connector
• Cloudant documentation
• https://docs.cloudant.com/
• HR Assistant
• hrassistant.eu-gb.mybluemix.net
• github.com/flinden68/HR-Assistant
Thank you
Cloudant e XPages

Cloudant e XPages