// ----------------------------------------------------------------------------- // Deletes a WOrkorder --------------------------------------------------------- // Run read_1_WO route with specific WONUM to get URI first router.get('/delete_WO', function(req, res) { var updates = { } var URI = uri; var authcookie = req.session.authcookie; var maximo = new Maximo(options); maximo.resourceobject("MXWODETAIL") .resource(URI) //Pass the URI .delete(updates,["spi:wonum","spi:description"]) .then(function(resource) { var jsondata = resource.JSON(); res.json(jsondata); }) .fail(function (error) { console.log('****** Error Code = '+error); }); });
router.get('/create_WO_2', function(req, res) { var wo = ''; var required = { "description": "Created from API", "siteid": "BEDFORD", "wonum": "a123b", "location": "BR300" } var authcookie = req.session.authcookie; var maximo = new Maximo(options,authcookie); maximo.resourceobject("MXWODETAIL") .create(required,["spi:wonum","spi:description"]) .then(function(resource) { jsondata = resource.JSON(); res.json(jsondata); }) .fail(function (error) { console.log('****** Error Code = '+error); }); });
// ----------------------------------------------------------------------------- // Updates a WOrkorder --------------------------------------------------------- // Run read_1_WO route with specific WONUM to get URI first // Add updates to WO in updates section router.get('/update_WO', function(req, res) { var updates = { "spi:description":"Updated from Node API - test crudconnector" } var URI = uri; var authcookie = req.session.authcookie; var maximo = new Maximo(options,authcookie); maximo.resourceobject("MXWODETAIL") .resource(URI) //Pass the URI .update(updates,["spi:description"]) .then(function(resource) { var jsondata = resource.JSON(); res.json(jsondata); }) .fail(function (error) { console.log('****** Error Code = '+error); }); });
// Creates a WOrkorder // In required section, fill in information about WO router.get('/create_WO', function(req, res) { var wo = ''; var required = { "description": "Created from API", "siteid": "BEDFORD", "wonum": "a123a" } var authcookie = req.session.authcookie; var maximo = new Maximo(options,authcookie); maximo.resourceobject("MXWODETAIL") .create(required,["spi:wonum","spi:description"]) .then(function(resource) { jsondata = resource.JSON(); res.json(jsondata); }) .fail(function (error) { console.log('****** Error Code = '+error); }); });
// Deletes a WOrkorder // Run read_1_WO route with specific WONUM to get URI first // Can only delete 1 WO at a time // If read_1_WO grabs multiple WOs, then delete route will delete the last WO listed router.get('/delete_WO', function(req, res) { var updates = { } var URI = uri; var authcookie = req.session.authcookie; var maximo = new Maximo(options); maximo.resourceobject("MXWODETAIL") .resource(URI) //Pass the URI .delete(updates,["spi:wonum","spi:description"]) .then(function(resource) { var jsondata = resource.JSON(); res.json(jsondata); }) .fail(function (error) { console.log('****** Error Code = '+error); }); });
// ----------------------------------------------------------------------------- // Creates a WOrkorder -------------------------------------------------------- // In required section, fill in information about WO router.get('/create_WO', function(req, res) { var wo = ''; var required = { "description": "Created from API", "siteid": "BEDFORD", "wonum": "A123A" } var authcookie = req.session.authcookie; var maximo = new Maximo(options,authcookie); maximo.resourceobject("MXWODETAIL") .create(required,["spi:wonum","spi:description"]) .then(function(resource) { jsondata = resource.JSON(); res.json(jsondata); }) .fail(function (error) { console.log('****** Error Code = '+error); }); });
// Updates a WOrkorder // Run read_1_WO with specific WONUM to get URI first // Add updates to WO in updates section // Will only update 1 WO at a time // If read_1_WO returned >1 WO, update_WO will only update the last WO listed router.get('/update_WO', function(req, res) { var updates = { "spi:description":"Updated from Node API - test crudconnector" } var URI = uri; var authcookie = req.session.authcookie; var maximo = new Maximo(options,authcookie); maximo.resourceobject("MXWODETAIL") .resource(URI) //Pass the URI .update(updates,["spi:description"]) .then(function(resource) { var jsondata = resource.JSON(); res.json(jsondata); }) .fail(function (error) { console.log('****** Error Code = '+error); }); });