Skip to content

Instantly share code, notes, and snippets.

@rickx1
Last active April 27, 2017 04:19
Show Gist options
  • Save rickx1/e8949ff3bad374b2846b307429530b01 to your computer and use it in GitHub Desktop.
Save rickx1/e8949ff3bad374b2846b307429530b01 to your computer and use it in GitHub Desktop.
This is an example of an External Data Service Implementation for IBM Content Navigator using Node.js
var genders = choicelist.create("Genders");
choicelist.addChoice(genders, "Female");
choicelist.addChoice(genders, "Male");
var otherGenders = choicelist.addCategory(genders, "Other");
choicelist.addChoices(otherGenders, ["Polygender", "Cisgender", "Pangender", "Gender neutral"] ); // I know there are more...
property.choiceList = genders;
var express = require('express')
, bodyParser = require('body-parser')
, _= require("underscore")
, http = require('http')
, morgan = require('morgan');
var jsonParser = bodyParser.json();
var app = express();
app.use(morgan("dev")); // Change this for production code
app.set('port', process.env.PORT || 3000);
app.post('/type/:objectType', jsonParser, function(req, res) {
console.log(req.body); // Remove this for production code
var dataResponse = {
"externalDataIdentifier": "Node EDS",
"properties" : [ ]
};
// Add your implementation code here
console.log(dataResponse); // Remove this for production code
res.json(dataResponse);
});
function getProperty(req, name) {
return _.findWhere(req.body.properties, {"symbolicName" : name} );
}
// This function is specific for Content Navigator, the rest of the file is the same as Case Manager.
app.get('/types', function(req, res) {
var types = ["TST_testDocType", "Email"];
res.json(types.map( value => { return {symbolicName: value} } ) );
});
http.createServer(app).listen(app.get('port'), function(){
console.log('Node EDS server listening on port ' + app.get('port'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment