Last active
April 27, 2017 04:19
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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