lib/impl/dataSources/index.js
function get(connections, params, cb) {
  //validateParams
  //LookUpDataSource
  //CheckFormsThatAre Using The Data Source
  //Return Result.

  async.waterfall([
    function validateParams(cb) {
      validate(params).has(CONSTANTS.DATA_SOURCE_ID, function(err) {
        if (err) {
          return cb(buildErrorResponse({error: new Error("An ID Parameter Is Required To Get A Data Source"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
        }

        return cb(undefined, params[CONSTANTS.DATA_SOURCE_ID]);
      });
    },
    function findDataSources(id, cb) {
      var query = {

      };

      //Searching By ID.
      query[CONSTANTS.DATA_SOURCE_ID] = id;

      lookUpDataSources(connections, {
        query: query,
        lean: true,
        includeAuditLog: params.includeAuditLog,
        includeAuditLogData: params.includeAuditLogData
      }, function(err, dataSources) {
        if (err) {
          return cb(buildErrorResponse({
            error: err,
            userDetail: "Unexpected Error When Searching For A Data Source",
            code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
          }));
        }

        //Checking if the data source exists. Should be only one
        if (dataSources.length !== 1) {
          return cb(buildErrorResponse({
            error: new Error("Data Source Not Found"),
            systemDetail: "Requested ID: "  + params[CONSTANTS.DATA_SOURCE_ID],
            code: ERROR_CODES.FH_FORMS_NOT_FOUND
          }));
        }

        var dataSourceJSON = dataSources[0];
        dataSourceJSON = processDataSourceResponse(dataSourceJSON, {
          includeAuditLog: params.includeAuditLog
        });

        return cb(undefined, dataSourceJSON);
      });
    },
    function checkForms(dataSourceJSON, cb) {
      //Checking For Any Forms Associated With The Data Source
      checkFormsUsingDataSource(connections, dataSourceJSON, cb);
    }
  ], cb);
}
function get(connections, params, cb) {
  //validateParams
  //LookUpDataSource
  //CheckFormsThatAre Using The Data Source
  //Return Result.

  async.waterfall([
    function validateParams(cb) {
      validate(params).has(CONSTANTS.DATA_SOURCE_ID, function(err) {
        if (err) {
          return cb(buildErrorResponse({error: new Error("An ID Parameter Is Required To Get A Data Source"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
        }

        return cb(undefined, params[CONSTANTS.DATA_SOURCE_ID]);
      });
    },
    function findDataSources(id, cb) {
      var query = {

      };

      //Searching By ID.
      query[CONSTANTS.DATA_SOURCE_ID] = id;

      lookUpDataSources(connections, {
        query: query,
        lean: true,
        includeAuditLog: params.includeAuditLog,
        includeAuditLogData: params.includeAuditLogData
      }, function(err, dataSources) {
        if (err) {
          return cb(buildErrorResponse({
            error: err,
            userDetail: "Unexpected Error When Searching For A Data Source",
            code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
          }));
        }

        //Checking if the data source exists. Should be only one
        if (dataSources.length !== 1) {
          return cb(buildErrorResponse({
            error: new Error("Data Source Not Found"),
            systemDetail: "Requested ID: "  + params[CONSTANTS.DATA_SOURCE_ID],
            code: ERROR_CODES.FH_FORMS_NOT_FOUND
          }));
        }

        var dataSourceJSON = dataSources[0];
        dataSourceJSON = processDataSourceResponse(dataSourceJSON, {
          includeAuditLog: params.includeAuditLog
        });

        return cb(undefined, dataSourceJSON);
      });
    },
    function checkForms(dataSourceJSON, cb) {
      //Checking For Any Forms Associated With The Data Source
      checkFormsUsingDataSource(connections, dataSourceJSON, cb);
    }
  ], cb);
}
function get ( connections , params , cb ) { //validateParams //LookUpDataSource //CheckFormsThatAre Using The Data Source //Return Result. async . waterfall ( [ function validateParams ( cb ) { validate ( params ) . has ( CONSTANTS . DATA_SOURCE_ID , function ( err ) { if ( err ) { return cb ( buildErrorResponse ( { error : new Error ( "An ID Parameter Is Required To Get A Data Source" ) , code : ERROR_CODES . FH_FORMS_INVALID_PARAMETERS } ) ) ; } return cb ( undefined , params [ CONSTANTS . DATA_SOURCE_ID ] ) ; } ) ; } , function findDataSources ( id , cb ) { var query = { } ; //Searching By ID. query [ CONSTANTS . DATA_SOURCE_ID ] = id ; lookUpDataSources ( connections , { query : query , lean : true , includeAuditLog : params . includeAuditLog , includeAuditLogData : params . includeAuditLogData } , function ( err , dataSources ) { if ( err ) { return cb ( buildErrorResponse ( { error : err , userDetail : "Unexpected Error When Searching For A Data Source" , code : ERROR_CODES . FH_FORMS_UNEXPECTED_ERROR } ) ) ; } //Checking if the data source exists. Should be only one if ( dataSources . length !== 1 ) { return cb ( buildErrorResponse ( { error : new Error ( "Data Source Not Found" ) , systemDetail : "Requested ID: " + params [ CONSTANTS . DATA_SOURCE_ID ] , code : ERROR_CODES . FH_FORMS_NOT_FOUND } ) ) ; } var dataSourceJSON = dataSources [ 0 ] ; dataSourceJSON = processDataSourceResponse ( dataSourceJSON , { includeAuditLog : params . includeAuditLog } ) ; return cb ( undefined , dataSourceJSON ) ; } ) ; } , function checkForms ( dataSourceJSON , cb ) { //Checking For Any Forms Associated With The Data Source checkFormsUsingDataSource ( connections , dataSourceJSON , cb ) ; } ] , cb ) ; }
Get A Specific Data Source Definition
@param connections
@param params
@param params._id: Data Source Id
@param params.includeAuditLog: flag to include a data source audit log or not.
@param params.includeAuditLogData: flag for including the data set with the audit log list.
@param cb
Get A Specific Data Source Definition